diff --git a/contrib/src/ai/aiBehaviors.cxx b/contrib/src/ai/aiBehaviors.cxx index 727e7e12f4..38d32b1026 100644 --- a/contrib/src/ai/aiBehaviors.cxx +++ b/contrib/src/ai/aiBehaviors.cxx @@ -21,16 +21,16 @@ AIBehaviors::AIBehaviors() { _previous_conflict = false; _conflict = false; - _seek_obj = NULL; - _flee_obj = NULL; - _pursue_obj = NULL; - _evade_obj = NULL; - _arrival_obj = NULL; - _wander_obj = NULL; - _flock_group = NULL; - _path_follow_obj = NULL; - _path_find_obj = NULL; - _obstacle_avoidance_obj = NULL; + _seek_obj = nullptr; + _flee_obj = nullptr; + _pursue_obj = nullptr; + _evade_obj = nullptr; + _arrival_obj = nullptr; + _wander_obj = nullptr; + _flock_group = nullptr; + _path_follow_obj = nullptr; + _path_find_obj = nullptr; + _obstacle_avoidance_obj = nullptr; turn_off("seek"); turn_off("flee"); @@ -267,7 +267,7 @@ LVecBase3 AIBehaviors::calculate_prioritized() { accumulate_force("obstacle_avoidance", force); } - if(_path_follow_obj!=NULL) { + if(_path_follow_obj!=nullptr) { if(_path_follow_obj->_start) { _path_follow_obj->do_follow(); } @@ -286,13 +286,13 @@ LVecBase3 AIBehaviors::calculate_prioritized() { } if(is_on(_arrival)) { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { LVecBase3 dirn = _steering_force; dirn.normalize(); _steering_force = ((_steering_force.length() - _arrival_force.length()) * dirn); } - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { LVecBase3 dirn = _steering_force; dirn.normalize(); _steering_force = ((_steering_force.length() - _arrival_force.length()) * _arrival_obj->_arrival_direction); @@ -320,10 +320,10 @@ void AIBehaviors::remove_ai(string ai_type) { } case 1: { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { turn_off("seek"); delete _seek_obj; - _seek_obj = NULL; + _seek_obj = nullptr; } break; } @@ -338,10 +338,10 @@ void AIBehaviors::remove_ai(string ai_type) { } case 3: { - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { turn_off("pursue"); delete _pursue_obj; - _pursue_obj = NULL; + _pursue_obj = nullptr; } break; } @@ -356,59 +356,59 @@ void AIBehaviors::remove_ai(string ai_type) { } case 5: { - if(_arrival_obj != NULL) { + if(_arrival_obj != nullptr) { turn_off("arrival"); turn_off("arrival_activate"); delete _arrival_obj; - _arrival_obj = NULL; + _arrival_obj = nullptr; } break; } case 6: { - if(_flock_group != NULL) { + if(_flock_group != nullptr) { turn_off("flock"); turn_off("flock_activate"); - _flock_group = NULL; + _flock_group = nullptr; } break; } case 7: { - if(_wander_obj != NULL) { + if(_wander_obj != nullptr) { turn_off("wander"); delete _wander_obj; - _wander_obj = NULL; + _wander_obj = nullptr; } break; } case 8: { - if(_obstacle_avoidance_obj !=NULL) { + if(_obstacle_avoidance_obj !=nullptr) { turn_off("obstacle_avoidance"); delete _obstacle_avoidance_obj; - _obstacle_avoidance_obj = NULL; + _obstacle_avoidance_obj = nullptr; } break; } case 9: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); delete _pursue_obj; - _pursue_obj = NULL; + _pursue_obj = nullptr; delete _path_follow_obj; - _path_follow_obj = NULL; + _path_follow_obj = nullptr; } break; } case 16: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); delete _pursue_obj; - _pursue_obj = NULL; + _pursue_obj = nullptr; delete _path_follow_obj; - _path_follow_obj = NULL; + _path_follow_obj = nullptr; } break; } @@ -436,7 +436,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 1: { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { turn_off("seek"); } break; @@ -451,7 +451,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 3: { - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { turn_off("pursue"); } break; @@ -466,7 +466,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 5: { - if(_arrival_obj != NULL) { + if(_arrival_obj != nullptr) { turn_off("arrival"); turn_off("arrival_activate"); } @@ -474,7 +474,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 6: { - if(_flock_group != NULL) { + if(_flock_group != nullptr) { turn_off("flock"); turn_off("flock_activate"); } @@ -482,14 +482,14 @@ void AIBehaviors::pause_ai(string ai_type) { } case 7: { - if(_wander_obj != NULL) { + if(_wander_obj != nullptr) { turn_off("wander"); } break; } case 8: { - if(_obstacle_avoidance_obj != NULL) { + if(_obstacle_avoidance_obj != nullptr) { turn_off("obstacle_avoidance"); turn_off("obstacle_avoidance_activate"); } @@ -497,14 +497,14 @@ void AIBehaviors::pause_ai(string ai_type) { } case 9: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); _path_follow_obj->_start = false; } break; } case 16: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); _path_follow_obj->_start = false; } @@ -534,7 +534,7 @@ void AIBehaviors::resume_ai(string ai_type) { } case 1: { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { turn_on("seek"); } break; @@ -548,7 +548,7 @@ void AIBehaviors::resume_ai(string ai_type) { } case 3: { - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { turn_on("pursue"); } break; @@ -562,42 +562,42 @@ void AIBehaviors::resume_ai(string ai_type) { } case 5: { - if(_arrival_obj != NULL) { + if(_arrival_obj != nullptr) { turn_on("arrival"); } break; } case 6: { - if(_flock_group != NULL) { + if(_flock_group != nullptr) { turn_on("flock"); } break; } case 7: { - if(_wander_obj != NULL) { + if(_wander_obj != nullptr) { turn_on("wander"); } break; } case 8: { - if(_obstacle_avoidance_obj != NULL) { + if(_obstacle_avoidance_obj != nullptr) { turn_on("obstacle_avoidance"); } break; } case 9: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_on("pursue"); _path_follow_obj->_start = true; } break; } case 16: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); _path_follow_obj->_start = false; } diff --git a/contrib/src/ai/aiNode.cxx b/contrib/src/ai/aiNode.cxx index a37927ae63..1812cf6cc1 100644 --- a/contrib/src/ai/aiNode.cxx +++ b/contrib/src/ai/aiNode.cxx @@ -15,7 +15,7 @@ AINode::AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) { for (int i = 0; i < 8; ++i) { - _neighbours[i] = NULL; + _neighbours[i] = nullptr; } _position = pos; @@ -29,8 +29,8 @@ AINode::AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) _score = 0; _cost = 0; _heuristic = 0; - _next = NULL; - _prv_node = NULL; + _next = nullptr; + _prv_node = nullptr; } AINode::~AINode() { diff --git a/contrib/src/ai/aiPathFinder.cxx b/contrib/src/ai/aiPathFinder.cxx index 58f11bfc39..8167a6e42e 100644 --- a/contrib/src/ai/aiPathFinder.cxx +++ b/contrib/src/ai/aiPathFinder.cxx @@ -87,7 +87,7 @@ void PathFinder::identify_neighbors(Node *parent_node) { // while adding new nodes to the open list heap. remove_from_olist(); for(int i = 0; i < 8; ++i) { - if(parent_node->_neighbours[i] != NULL) { + if(parent_node->_neighbours[i] != nullptr) { if(parent_node->_neighbours[i]->_status == parent_node->_neighbours[i]->neutral && parent_node->_neighbours[i]->_type == true) { // Link the neighbor to the parent node. @@ -340,10 +340,10 @@ Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size) { for(int i = 0; i < size; ++i) { for(int j = 0; j < size; ++j) { - if(nav_mesh[i][j] != NULL && nav_mesh[i][j]->contains(x, y)) { + if(nav_mesh[i][j] != nullptr && nav_mesh[i][j]->contains(x, y)) { return(nav_mesh[i][j]); } } } - return NULL; + return nullptr; } diff --git a/contrib/src/ai/aiPathFinder.h b/contrib/src/ai/aiPathFinder.h index 1595cb2777..4b2e2c976a 100644 --- a/contrib/src/ai/aiPathFinder.h +++ b/contrib/src/ai/aiPathFinder.h @@ -18,8 +18,8 @@ #include "cmath.h" #include "lineSegs.h" -typedef vector NodeArray; -typedef vector NavMesh; +typedef std::vector NodeArray; +typedef std::vector NavMesh; Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size); @@ -32,8 +32,8 @@ class EXPCL_PANDAAI PathFinder { public: Node *_src_node; Node *_dest_node; - vector _open_list; - vector _closed_list; + std::vector _open_list; + std::vector _closed_list; NavMesh _grid; diff --git a/contrib/src/ai/aiWorld.cxx b/contrib/src/ai/aiWorld.cxx index 8210046497..bace5593ef 100644 --- a/contrib/src/ai/aiWorld.cxx +++ b/contrib/src/ai/aiWorld.cxx @@ -99,7 +99,7 @@ Flock AIWorld::get_flock(unsigned int flock_id) { return *_flock_pool[i]; } } - Flock *null_flock = NULL; + Flock *null_flock = nullptr; return *null_flock; } @@ -112,7 +112,7 @@ void AIWorld::remove_flock(unsigned int flock_id) { for(unsigned int j = 0; j < _flock_pool[i]->_ai_char_list.size(); ++j) { _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->turn_off("flock_activate"); _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->turn_off("flock"); - _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->_flock_group = NULL; + _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->_flock_group = nullptr; } _flock_pool.erase(_flock_pool.begin() + i); break; diff --git a/contrib/src/ai/aiWorld.h b/contrib/src/ai/aiWorld.h index 64cecefc2d..3848e054dc 100644 --- a/contrib/src/ai/aiWorld.h +++ b/contrib/src/ai/aiWorld.h @@ -34,7 +34,7 @@ class EXPCL_PANDAAI AIWorld { AICharPool _ai_char_pool; NodePath _render; public: - vector _obstacles; + std::vector _obstacles; typedef std::vector FlockPool; FlockPool _flock_pool; void remove_ai_char_from_flock(string name); diff --git a/contrib/src/ai/arrival.cxx b/contrib/src/ai/arrival.cxx index f9fba9438a..af7400d170 100644 --- a/contrib/src/ai/arrival.cxx +++ b/contrib/src/ai/arrival.cxx @@ -48,7 +48,7 @@ LVecBase3 Arrival::do_arrival() { _ai_char->_steering->_steering_force = LVecBase3(0.0, 0.0, 0.0); _ai_char->_steering->_arrival_force = LVecBase3(0.0, 0.0, 0.0); - if(_ai_char->_steering->_seek_obj != NULL) { + if(_ai_char->_steering->_seek_obj != nullptr) { _ai_char->_steering->turn_off("arrival"); _ai_char->_steering->turn_on("arrival_activate"); } @@ -62,11 +62,11 @@ LVecBase3 Arrival::do_arrival() { double u = _ai_char->get_velocity().length(); LVecBase3 desired_force = ((u * u) / (2 * distance)) * _ai_char->get_mass(); - if(_ai_char->_steering->_seek_obj != NULL) { + if(_ai_char->_steering->_seek_obj != nullptr) { return(desired_force); } - if(_ai_char->_steering->_pursue_obj != NULL) { + if(_ai_char->_steering->_pursue_obj != nullptr) { if(distance > _arrival_distance) { _ai_char->_steering->turn_off("arrival"); diff --git a/contrib/src/ai/meshNode.cxx b/contrib/src/ai/meshNode.cxx index 043dc5b60c..26189f6bbf 100644 --- a/contrib/src/ai/meshNode.cxx +++ b/contrib/src/ai/meshNode.cxx @@ -3,7 +3,7 @@ Node::Node(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) { for(int i = 0; i < 8; ++i) { - _neighbours[i] = NULL; + _neighbours[i] = nullptr; } _position = pos; @@ -17,8 +17,8 @@ Node::Node(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) { _score = 0; _cost = 0; _heuristic = 0; - _next = NULL; - _prv_node = NULL; + _next = nullptr; + _prv_node = nullptr; } Node::~Node() { diff --git a/contrib/src/ai/obstacleAvoidance.cxx b/contrib/src/ai/obstacleAvoidance.cxx index faf8a1ff05..87ce79026b 100644 --- a/contrib/src/ai/obstacleAvoidance.cxx +++ b/contrib/src/ai/obstacleAvoidance.cxx @@ -36,7 +36,6 @@ obstacle_detection() { double distance = 0x7fff ; double expanded_radius = 0; LVecBase3 to_obstacle; - LVecBase3 prev_avoidance; for(unsigned int i = 0; i < _ai_char->_world->_obstacles.size(); ++i) { PT(BoundingVolume) bounds = _ai_char->_world->_obstacles[i].get_bounds(); CPT(BoundingSphere) bsphere = bounds->as_bounding_sphere(); diff --git a/contrib/src/ai/pathFind.cxx b/contrib/src/ai/pathFind.cxx index 39093da197..c3f807a8e7 100644 --- a/contrib/src/ai/pathFind.cxx +++ b/contrib/src/ai/pathFind.cxx @@ -23,7 +23,7 @@ PathFind::PathFind(AICharacter *ai_ch) { _pen->set_color(1.0, 0.0, 0.0); _pen->set_thickness(2.0); - _path_finder_obj = NULL; + _path_finder_obj = nullptr; _dynamic_avoid = false; } @@ -46,7 +46,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { string fields[10]; // Open data file for reading. - ifstream nav_mesh_file (navmesh_filename); + std::ifstream nav_mesh_file (navmesh_filename); if(nav_mesh_file.is_open()) { // Capture the grid size from the file. @@ -56,9 +56,9 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { // Initialize the stage mesh with NULL nodes. for(int r = 0; r < _grid_size; ++r) { - _nav_mesh.push_back(vector()); + _nav_mesh.push_back(std::vector()); for(int c = 0; c < _grid_size; ++c) { - _nav_mesh[r].push_back(NULL); + _nav_mesh[r].push_back(nullptr); } } @@ -111,7 +111,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { * _nav_mesh. */ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){ - ifstream nav_mesh_file (navmesh_filename); + std::ifstream nav_mesh_file (navmesh_filename); // Stage variables. int gd_x, gd_y, gd_xn, gd_yn; @@ -150,7 +150,7 @@ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){ } else if(fields_n[0] == "1" && fields_n[1] == "1") { // NULL neighbor. - _nav_mesh[gd_y][gd_x]->_neighbours[i] = NULL; + _nav_mesh[gd_y][gd_x]->_neighbours[i] = nullptr; } else { cout<<"Warning: Corrupt data!"<_ai_char_np.get_pos(_ai_char->_window_render), _grid_size); - if(src == NULL) { + if(src == nullptr) { cout<<"couldnt find source"<find_path(src, dst); trace_path(src); } @@ -248,22 +248,22 @@ void PathFind::path_find(NodePath target, string type) { Node* src = find_in_mesh(_nav_mesh, _ai_char->_ai_char_np.get_pos(_ai_char->_window_render), _grid_size); - if(src == NULL) { + if(src == nullptr) { cout<<"couldnt find source"<find_path(src, dst); trace_path(src); } - if(_ai_char->_steering->_path_follow_obj!=NULL) { + if(_ai_char->_steering->_path_follow_obj!=nullptr) { if(!_ai_char->_steering->_path_follow_obj->_start) { _ai_char->_steering->start_follow("pathfind"); } @@ -277,12 +277,12 @@ void PathFind::clear_path() { // Initialize to zero for(int i = 0; i < _grid_size; ++i) { for(int j = 0; j < _grid_size; ++j) { - if(_nav_mesh[i][j] != NULL) { + if(_nav_mesh[i][j] != nullptr) { _nav_mesh[i][j]->_status = _nav_mesh[i][j]->neutral; _nav_mesh[i][j]->_cost = 0; _nav_mesh[i][j]->_heuristic = 0; _nav_mesh[i][j]->_score = 0; - _nav_mesh[i][j]->_prv_node = NULL; + _nav_mesh[i][j]->_prv_node = nullptr; } } } @@ -333,7 +333,7 @@ void PathFind::add_obstacle_to_mesh(NodePath obstacle) { Node* temp = find_in_mesh(_nav_mesh, obstacle.get_pos(), _grid_size); - if(temp != NULL) { + if(temp != nullptr) { float left = temp->_position.get_x() - np_sphere->get_radius(); float right = temp->_position.get_x() + np_sphere->get_radius(); float top = temp->_position.get_y() + np_sphere->get_radius(); @@ -341,7 +341,7 @@ void PathFind::add_obstacle_to_mesh(NodePath obstacle) { for(int i = 0; i < _grid_size; ++i) { for(int j = 0; j < _grid_size; ++j) { - if(_nav_mesh[i][j] != NULL && _nav_mesh[i][j]->_type == true) { + if(_nav_mesh[i][j] != nullptr && _nav_mesh[i][j]->_type == true) { if(_nav_mesh[i][j]->_position.get_x() >= left && _nav_mesh[i][j]->_position.get_x() <= right && _nav_mesh[i][j]->_position.get_y() >= down && _nav_mesh[i][j]->_position.get_y() <= top) { _nav_mesh[i][j]->_type = false; diff --git a/contrib/src/ai/pathFind.h b/contrib/src/ai/pathFind.h index eb82f9ff99..ffeb50abf0 100644 --- a/contrib/src/ai/pathFind.h +++ b/contrib/src/ai/pathFind.h @@ -40,9 +40,9 @@ public: LVecBase3 _prev_position; PT(GeomNode) _parent; LineSegs *_pen; - vector _previous_obstacles; + std::vector _previous_obstacles; bool _dynamic_avoid; - vector _dynamic_obstacle; + std::vector _dynamic_obstacle; PathFind(AICharacter *ai_ch); ~PathFind(); diff --git a/contrib/src/rplight/gpuCommandList.h b/contrib/src/rplight/gpuCommandList.h index f2ec280116..1551afe630 100644 --- a/contrib/src/rplight/gpuCommandList.h +++ b/contrib/src/rplight/gpuCommandList.h @@ -48,7 +48,7 @@ PUBLISHED: MAKE_PROPERTY(num_commands, get_num_commands); protected: - queue _commands; + std::queue _commands; }; #endif // GPUCOMMANDLIST_H diff --git a/contrib/src/rplight/pointerSlotStorage.h b/contrib/src/rplight/pointerSlotStorage.h index 2d908c5795..401e133b81 100644 --- a/contrib/src/rplight/pointerSlotStorage.h +++ b/contrib/src/rplight/pointerSlotStorage.h @@ -45,6 +45,7 @@ class PointerSlotStorage {}; using std::tr1::array; #else #include +using std::array; #endif /** diff --git a/contrib/src/rplight/pssmCameraRig.h b/contrib/src/rplight/pssmCameraRig.h index ce0567bbbf..33cefe6dc1 100644 --- a/contrib/src/rplight/pssmCameraRig.h +++ b/contrib/src/rplight/pssmCameraRig.h @@ -96,9 +96,9 @@ protected: inline LPoint3 get_interpolated_point(CoordinateOrigin origin, float depth); LVecBase3 get_snap_offset(const LMatrix4& mat, size_t resolution); - vector _cam_nodes; - vector _cameras; - vector _max_film_sizes; + std::vector _cam_nodes; + std::vector _cameras; + std::vector _max_film_sizes; // Current near and far points // Order: UL, UR, LL, LR (See CoordinateOrigin) diff --git a/direct/src/dcparse/dcparse.cxx b/direct/src/dcparse/dcparse.cxx index 3d02ef669c..9fbd4ef063 100644 --- a/direct/src/dcparse/dcparse.cxx +++ b/direct/src/dcparse/dcparse.cxx @@ -103,8 +103,8 @@ write_complete_field_list(const DCFile &file) { cout << field->get_class()->get_name() << "::"; } cout << field->get_name(); - if (field->as_atomic_field() != (DCAtomicField *)NULL || - field->as_molecular_field() != (DCMolecularField *)NULL) { + if (field->as_atomic_field() != nullptr || + field->as_molecular_field() != nullptr) { // It's a "method". cout << "()"; } diff --git a/direct/src/dcparser/dcArrayParameter.cxx b/direct/src/dcparser/dcArrayParameter.cxx index 7485a34a5d..b8101128bd 100644 --- a/direct/src/dcparser/dcArrayParameter.cxx +++ b/direct/src/dcparser/dcArrayParameter.cxx @@ -58,7 +58,7 @@ DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size) : _pack_type = PT_array; DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); - if (simple_type != (DCSimpleParameter *)NULL) { + if (simple_type != nullptr) { if (simple_type->get_type() == ST_char) { // We make a special case for char[] arrays: these we format as a // string. (It will still accept an array of ints packed into it.) We @@ -148,7 +148,7 @@ get_array_size() const { */ DCParameter *DCArrayParameter:: append_array_specification(const DCUnsignedIntRange &size) { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { // If this was a typedef, wrap it directly. return new DCArrayParameter(this, size); } @@ -203,7 +203,7 @@ validate_num_nested_fields(int num_nested_fields) const { void DCArrayParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { @@ -236,7 +236,7 @@ pack_string(DCPackData &pack_data, const string &value, bool &pack_error, bool &range_error) const { // We can only pack a string if the array element type is char or int8. DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); - if (simple_type == (DCSimpleParameter *)NULL) { + if (simple_type == nullptr) { pack_error = true; return; } @@ -306,7 +306,7 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const { // We can only unpack a string if the array element type is char or int8. DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); - if (simple_type == (DCSimpleParameter *)NULL) { + if (simple_type == nullptr) { pack_error = true; return; } diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index 0d2ace8f35..c3f0dc365b 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -73,7 +73,7 @@ get_num_elements() const { */ DCParameter *DCAtomicField:: get_element(int n) const { - nassertr(n >= 0 && n < (int)_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_elements.size(), nullptr); return _elements[n]; } @@ -127,7 +127,7 @@ DCSubatomicType DCAtomicField:: get_element_type(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), ST_invalid); DCSimpleParameter *simple_parameter = _elements[n]->as_simple_parameter(); - nassertr(simple_parameter != (DCSimpleParameter *)NULL, ST_invalid); + nassertr(simple_parameter != nullptr, ST_invalid); return simple_parameter->get_type(); } @@ -143,7 +143,7 @@ int DCAtomicField:: get_element_divisor(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), 1); DCSimpleParameter *simple_parameter = _elements[n]->as_simple_parameter(); - nassertr(simple_parameter != (DCSimpleParameter *)NULL, 1); + nassertr(simple_parameter != nullptr, 1); return simple_parameter->get_divisor(); } @@ -207,7 +207,7 @@ generate_hash(HashGenerator &hashgen) const { */ DCPackerInterface *DCAtomicField:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_elements.size(), nullptr); return _elements[n]; } diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index d11a116415..3d311e6506 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -80,11 +80,11 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) : _bogus_class(bogus_class) { _number = -1; - _constructor = NULL; + _constructor = nullptr; #ifdef HAVE_PYTHON - _class_def = NULL; - _owner_class_def = NULL; + _class_def = nullptr; + _owner_class_def = nullptr; #endif } @@ -93,7 +93,7 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) : */ DCClass:: ~DCClass() { - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { delete _constructor; } @@ -137,7 +137,7 @@ get_num_parents() const { */ DCClass *DCClass:: get_parent(int n) const { - nassertr(n >= 0 && n < (int)_parents.size(), NULL); + nassertr(n >= 0 && n < (int)_parents.size(), nullptr); return _parents[n]; } @@ -147,7 +147,7 @@ get_parent(int n) const { */ bool DCClass:: has_constructor() const { - return (_constructor != (DCField *)NULL); + return (_constructor != nullptr); } /** @@ -183,7 +183,7 @@ get_field(int n) const { // __asm { int 3 } } #endif //] - nassertr_always(n >= 0 && n < (int)_fields.size(), NULL); + nassertr_always(n >= 0 && n < (int)_fields.size(), nullptr); return _fields[n]; } @@ -205,13 +205,13 @@ get_field_by_name(const string &name) const { Parents::const_iterator pi; for (pi = _parents.begin(); pi != _parents.end(); ++pi) { DCField *result = (*pi)->get_field_by_name(name); - if (result != (DCField *)NULL) { + if (result != nullptr) { return result; } } // Nobody knew what this field is. - return (DCField *)NULL; + return nullptr; } /** @@ -232,7 +232,7 @@ get_field_by_index(int index_number) const { Parents::const_iterator pi; for (pi = _parents.begin(); pi != _parents.end(); ++pi) { DCField *result = (*pi)->get_field_by_index(index_number); - if (result != (DCField *)NULL) { + if (result != nullptr) { // Cache this result for future lookups. ((DCClass *)this)->_fields_by_index[index_number] = result; return result; @@ -240,7 +240,7 @@ get_field_by_index(int index_number) const { } // Nobody knew what this field is. - return (DCField *)NULL; + return nullptr; } /** @@ -250,7 +250,7 @@ get_field_by_index(int index_number) const { int DCClass:: get_num_inherited_fields() const { if (dc_multiple_inheritance && dc_virtual_inheritance && - _dc_file != (DCFile *)NULL) { + _dc_file != nullptr) { _dc_file->check_inherited_fields(); if (_inherited_fields.empty()) { ((DCClass *)this)->rebuild_inherited_fields(); @@ -283,12 +283,12 @@ get_num_inherited_fields() const { DCField *DCClass:: get_inherited_field(int n) const { if (dc_multiple_inheritance && dc_virtual_inheritance && - _dc_file != (DCFile *)NULL) { + _dc_file != nullptr) { _dc_file->check_inherited_fields(); if (_inherited_fields.empty()) { ((DCClass *)this)->rebuild_inherited_fields(); } - nassertr(n >= 0 && n < (int)_inherited_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_inherited_fields.size(), nullptr); return _inherited_fields[n]; } else { @@ -349,7 +349,7 @@ output(ostream &out) const { */ bool DCClass:: has_class_def() const { - return (_class_def != NULL); + return (_class_def != nullptr); } #endif // HAVE_PYTHON @@ -373,7 +373,7 @@ set_class_def(PyObject *class_def) { */ PyObject *DCClass:: get_class_def() const { - if (_class_def == NULL) { + if (_class_def == nullptr) { Py_INCREF(Py_None); return Py_None; } @@ -390,7 +390,7 @@ get_class_def() const { */ bool DCClass:: has_owner_class_def() const { - return (_owner_class_def != NULL); + return (_owner_class_def != nullptr); } #endif // HAVE_PYTHON @@ -414,7 +414,7 @@ set_owner_class_def(PyObject *owner_class_def) { */ PyObject *DCClass:: get_owner_class_def() const { - if (_owner_class_def == NULL) { + if (_owner_class_def == nullptr) { Py_INCREF(Py_None); return Py_None; } @@ -441,7 +441,7 @@ receive_update(PyObject *distobj, DatagramIterator &di) const { int field_id = packer.raw_unpack_uint16(); DCField *field = get_field_by_index(field_id); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "Received update for field " << field_id << ", not in class " @@ -478,7 +478,7 @@ receive_update_broadcast_required(PyObject *distobj, DatagramIterator &di) const int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) { DCField *field = get_inherited_field(i); - if (field->as_molecular_field() == (DCMolecularField *)NULL && + if (field->as_molecular_field() == nullptr && field->is_required() && field->is_broadcast()) { packer.begin_unpack(field); field->receive_update(packer, distobj); @@ -513,7 +513,7 @@ receive_update_broadcast_required_owner(PyObject *distobj, int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) { DCField *field = get_inherited_field(i); - if (field->as_molecular_field() == (DCMolecularField *)NULL && + if (field->as_molecular_field() == nullptr && field->is_required() && (field->is_ownrecv() || field->is_broadcast())) { packer.begin_unpack(field); field->receive_update(packer, distobj); @@ -546,7 +546,7 @@ receive_update_all_required(PyObject *distobj, DatagramIterator &di) const { int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) { DCField *field = get_inherited_field(i); - if (field->as_molecular_field() == (DCMolecularField *)NULL && + if (field->as_molecular_field() == nullptr && field->is_required()) { packer.begin_unpack(field); field->receive_update(packer, distobj); @@ -585,7 +585,7 @@ void DCClass:: direct_update(PyObject *distobj, const string &field_name, const string &value_blob) { DCField *field = get_field_by_name(field_name); - nassertv_always(field != NULL); + nassertv_always(field != nullptr); DCPacker packer; packer.set_unpack_data(value_blob); @@ -645,7 +645,7 @@ bool DCClass:: pack_required_field(DCPacker &packer, PyObject *distobj, const DCField *field) const { const DCParameter *parameter = field->as_parameter(); - if (parameter != (DCParameter *)NULL) { + if (parameter != nullptr) { // This is the easy case: to pack a parameter, we just look on the class // object for the data element. string field_name = field->get_name(); @@ -668,7 +668,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, } PyObject *result = PyObject_GetAttrString(distobj, (char *)field_name.c_str()); - nassertr(result != (PyObject *)NULL, false); + nassertr(result != nullptr, false); // Now pack the value into the datagram. bool pack_ok = parameter->pack_args(packer, result); @@ -677,7 +677,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, return pack_ok; } - if (field->as_molecular_field() != (DCMolecularField *)NULL) { + if (field->as_molecular_field() != nullptr) { ostringstream strm; strm << "Cannot pack molecular field " << field->get_name() << " for generate"; @@ -686,7 +686,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, } const DCAtomicField *atom = field->as_atomic_field(); - nassertr(atom != (DCAtomicField *)NULL, false); + nassertr(atom != nullptr, false); // We need to get the initial value of this field. There isn't a good, // robust way to get this; presently, we just mangle the "setFoo()" name of @@ -740,13 +740,13 @@ pack_required_field(DCPacker &packer, PyObject *distobj, } PyObject *func = PyObject_GetAttrString(distobj, (char *)getter_name.c_str()); - nassertr(func != (PyObject *)NULL, false); + nassertr(func != nullptr, false); PyObject *empty_args = PyTuple_New(0); PyObject *result = PyObject_CallObject(func, empty_args); Py_DECREF(empty_args); Py_DECREF(func); - if (result == (PyObject *)NULL) { + if (result == nullptr) { // We don't set this as an exception, since presumably the Python method // itself has already triggered a Python exception. cerr << "Error when calling " << getter_name << "\n"; @@ -789,7 +789,7 @@ Datagram DCClass:: client_format_update(const string &field_name, DOID_TYPE do_id, PyObject *args) const { DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -810,7 +810,7 @@ Datagram DCClass:: ai_format_update(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const { DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -832,7 +832,7 @@ Datagram DCClass:: ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const { DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -871,7 +871,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields; ++i) { DCField *field = get_inherited_field(i); - if (field->is_required() && field->as_molecular_field() == NULL) { + if (field->is_required() && field->as_molecular_field() == nullptr) { packer.begin_pack(field); if (!pack_required_field(packer, distobj, field)) { return Datagram(); @@ -897,7 +897,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, Py_XDECREF(py_field_name); DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -956,7 +956,7 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields; ++i) { DCField *field = get_inherited_field(i); - if (field->is_required() && field->as_molecular_field() == NULL) { + if (field->is_required() && field->as_molecular_field() == nullptr) { packer.begin_pack(field); if (!pack_required_field(packer, distobj, field)) { return Datagram(); @@ -980,7 +980,7 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, Py_XDECREF(py_field_name); DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -1042,7 +1042,7 @@ write(ostream &out, bool brief, int indent_level) const { } out << "\n"; - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { _constructor->write(out, brief, indent_level + 2); } @@ -1098,7 +1098,7 @@ output_instance(ostream &out, bool brief, const string &prename, out << " {"; - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { _constructor->output(out, brief); out << "; "; } @@ -1134,7 +1134,7 @@ generate_hash(HashGenerator &hashgen) const { hashgen.add_int((*pi)->get_number()); } - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { _constructor->generate_hash(hashgen); } @@ -1247,20 +1247,20 @@ shadow_inherited_field(const string &name) { */ bool DCClass:: add_field(DCField *field) { - nassertr(field->get_class() == this || field->get_class() == NULL, false); + nassertr(field->get_class() == this || field->get_class() == nullptr, false); field->set_class(this); - if (_dc_file != (DCFile *)NULL) { + if (_dc_file != nullptr) { _dc_file->mark_inherited_fields_stale(); } if (!field->get_name().empty()) { if (field->get_name() == _name) { // This field is a constructor. - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { // We already have a constructor. return false; } - if (field->as_atomic_field() == (DCAtomicField *)NULL) { + if (field->as_atomic_field() == nullptr) { // The constructor must be an atomic field. return false; } @@ -1278,7 +1278,7 @@ add_field(DCField *field) { } } - if (_dc_file != (DCFile *)NULL && + if (_dc_file != nullptr && ((dc_virtual_inheritance && dc_sort_inheritance_by_file) || !is_struct())) { if (dc_multiple_inheritance) { _dc_file->set_new_index_number(field); diff --git a/direct/src/dcparser/dcClassParameter.cxx b/direct/src/dcparser/dcClassParameter.cxx index be5ca00283..379dbb5961 100644 --- a/direct/src/dcparser/dcClassParameter.cxx +++ b/direct/src/dcparser/dcClassParameter.cxx @@ -119,7 +119,7 @@ get_class() const { */ DCPackerInterface *DCClassParameter:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_fields.size(), nullptr); return _nested_fields[n]; } @@ -130,7 +130,7 @@ get_nested_field(int n) const { void DCClassParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { diff --git a/direct/src/dcparser/dcDeclaration.cxx b/direct/src/dcparser/dcDeclaration.cxx index fd86238b4a..7da467a44a 100644 --- a/direct/src/dcparser/dcDeclaration.cxx +++ b/direct/src/dcparser/dcDeclaration.cxx @@ -26,7 +26,7 @@ DCDeclaration:: */ DCClass *DCDeclaration:: as_class() { - return (DCClass *)NULL; + return nullptr; } /** @@ -34,7 +34,7 @@ as_class() { */ const DCClass *DCDeclaration:: as_class() const { - return (DCClass *)NULL; + return nullptr; } /** @@ -42,7 +42,7 @@ as_class() const { */ DCSwitch *DCDeclaration:: as_switch() { - return (DCSwitch *)NULL; + return nullptr; } /** @@ -50,7 +50,7 @@ as_switch() { */ const DCSwitch *DCDeclaration:: as_switch() const { - return (DCSwitch *)NULL; + return nullptr; } /** diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index a44412638a..eeace485c6 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -31,7 +31,7 @@ */ DCField:: DCField() : - _dclass(NULL) + _dclass(nullptr) #ifdef WITHIN_PANDA , _field_update_pcollector("DCField") @@ -108,7 +108,7 @@ as_field() const { */ DCAtomicField *DCField:: as_atomic_field() { - return (DCAtomicField *)NULL; + return nullptr; } /** @@ -117,7 +117,7 @@ as_atomic_field() { */ const DCAtomicField *DCField:: as_atomic_field() const { - return (DCAtomicField *)NULL; + return nullptr; } /** @@ -126,7 +126,7 @@ as_atomic_field() const { */ DCMolecularField *DCField:: as_molecular_field() { - return (DCMolecularField *)NULL; + return nullptr; } /** @@ -135,7 +135,7 @@ as_molecular_field() { */ const DCMolecularField *DCField:: as_molecular_field() const { - return (DCMolecularField *)NULL; + return nullptr; } /** @@ -143,7 +143,7 @@ as_molecular_field() const { */ DCParameter *DCField:: as_parameter() { - return (DCParameter *)NULL; + return nullptr; } /** @@ -151,7 +151,7 @@ as_parameter() { */ const DCParameter *DCField:: as_parameter() const { - return (DCParameter *)NULL; + return nullptr; } /** @@ -235,7 +235,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { ostringstream strm; PyObject *exc_type = PyExc_Exception; - if (as_parameter() != (DCParameter *)NULL) { + if (as_parameter() != nullptr) { // If it's a parameter-type field, the value may or may not be a // sequence. if (packer.had_pack_error()) { @@ -251,7 +251,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { } else { // If it's a molecular or atomic field, the value should be a sequence. PyObject *tuple = PySequence_Tuple(sequence); - if (tuple == (PyObject *)NULL) { + if (tuple == nullptr) { strm << "Value for " << get_name() << " not a sequence: " \ << get_pystr(sequence); exc_type = PyExc_TypeError; @@ -287,8 +287,8 @@ pack_args(DCPacker &packer, PyObject *sequence) const { */ PyObject *DCField:: unpack_args(DCPacker &packer) const { - nassertr(!packer.had_error(), NULL); - nassertr(packer.get_current_field() == this, NULL); + nassertr(!packer.had_error(), nullptr); + nassertr(packer.get_current_field() == this, nullptr); size_t start_byte = packer.get_num_unpacked_bytes(); PyObject *object = packer.unpack_object(); @@ -329,7 +329,7 @@ unpack_args(DCPacker &packer) const { } Py_XDECREF(object); - return NULL; + return nullptr; } #endif // HAVE_PYTHON @@ -340,10 +340,10 @@ unpack_args(DCPacker &packer) const { */ void DCField:: receive_update(DCPacker &packer, PyObject *distobj) const { - if (as_parameter() != (DCParameter *)NULL) { + if (as_parameter() != nullptr) { // If it's a parameter-type field, just store a new value on the object. PyObject *value = unpack_args(packer); - if (value != (PyObject *)NULL) { + if (value != nullptr) { PyObject_SetAttrString(distobj, (char *)_name.c_str(), value); } Py_DECREF(value); @@ -362,9 +362,9 @@ receive_update(DCPacker &packer, PyObject *distobj) const { // method. PyObject *args = unpack_args(packer); - if (args != (PyObject *)NULL) { + if (args != nullptr) { PyObject *func = PyObject_GetAttrString(distobj, (char *)_name.c_str()); - nassertv(func != (PyObject *)NULL); + nassertv(func != nullptr); PyObject *result; { @@ -499,7 +499,7 @@ pack_default_value(DCPackData &pack_data, bool &) const { void DCField:: set_name(const string &name) { DCPackerInterface::set_name(name); - if (_dclass != (DCClass *)NULL) { + if (_dclass != nullptr) { _dclass->_dc_file->mark_inherited_fields_stale(); } } @@ -510,12 +510,12 @@ set_name(const string &name) { */ string DCField:: get_pystr(PyObject *value) { - if (value == NULL) { + if (value == nullptr) { return "(null)"; } PyObject *str = PyObject_Str(value); - if (str != NULL) { + if (str != nullptr) { #if PY_MAJOR_VERSION >= 3 string result = PyUnicode_AsUTF8(str); #else @@ -526,7 +526,7 @@ get_pystr(PyObject *value) { } PyObject *repr = PyObject_Repr(value); - if (repr != NULL) { + if (repr != nullptr) { #if PY_MAJOR_VERSION >= 3 string result = PyUnicode_AsUTF8(repr); #else @@ -536,9 +536,9 @@ get_pystr(PyObject *value) { return result; } - if (value->ob_type != NULL) { + if (value->ob_type != nullptr) { PyObject *typestr = PyObject_Str((PyObject *)(value->ob_type)); - if (typestr != NULL) { + if (typestr != nullptr) { #if PY_MAJOR_VERSION >= 3 string result = PyUnicode_AsUTF8(typestr); #else diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 9dc7009dca..43301e4615 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -123,7 +123,7 @@ read(Filename filename) { filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { cerr << "Cannot open " << filename << " for reading.\n"; return false; } @@ -247,7 +247,7 @@ get_num_classes() const { */ DCClass *DCFile:: get_class(int n) const { - nassertr(n >= 0 && n < (int)_classes.size(), NULL); + nassertr(n >= 0 && n < (int)_classes.size(), nullptr); return _classes[n]; } @@ -263,7 +263,7 @@ get_class_by_name(const string &name) const { return (*ni).second->as_class(); } - return (DCClass *)NULL; + return nullptr; } /** @@ -278,7 +278,7 @@ get_switch_by_name(const string &name) const { return (*ni).second->as_switch(); } - return (DCSwitch *)NULL; + return nullptr; } /** @@ -291,13 +291,13 @@ get_switch_by_name(const string &name) const { */ DCField *DCFile:: get_field_by_index(int index_number) const { - nassertr(dc_multiple_inheritance, NULL); + nassertr(dc_multiple_inheritance, nullptr); if (index_number >= 0 && index_number < (int)_fields_by_index.size()) { return _fields_by_index[index_number]; } - return NULL; + return nullptr; } /** @@ -352,7 +352,7 @@ get_num_typedefs() const { */ DCTypedef *DCFile:: get_typedef(int n) const { - nassertr(n >= 0 && n < (int)_typedefs.size(), NULL); + nassertr(n >= 0 && n < (int)_typedefs.size(), nullptr); return _typedefs[n]; } @@ -368,7 +368,7 @@ get_typedef_by_name(const string &name) const { return (*ni).second; } - return NULL; + return nullptr; } /** @@ -394,9 +394,9 @@ get_keyword(int n) const { const DCKeyword *DCFile:: get_keyword_by_name(const string &name) const { const DCKeyword *keyword = _keywords.get_keyword_by_name(name); - if (keyword == (const DCKeyword *)NULL) { + if (keyword == nullptr) { keyword = _default_keywords.get_keyword_by_name(name); - if (keyword != (const DCKeyword *)NULL) { + if (keyword != nullptr) { // One of the historical default keywords was used, but wasn't defined. // Define it implicitly right now. ((DCFile *)this)->_keywords.add_keyword(keyword); @@ -612,11 +612,11 @@ setup_default_keywords() { { "clrecv", 0x0040 }, { "ownsend", 0x0080 }, { "airecv", 0x0100 }, - { NULL, 0 } + { nullptr, 0 } }; _default_keywords.clear_keywords(); - for (int i = 0; default_keywords[i].name != NULL; ++i) { + for (int i = 0; default_keywords[i].name != nullptr; ++i) { DCKeyword *keyword = new DCKeyword(default_keywords[i].name, default_keywords[i].flag); diff --git a/direct/src/dcparser/dcKeywordList.cxx b/direct/src/dcparser/dcKeywordList.cxx index d3f2d0347e..c2cba110b6 100644 --- a/direct/src/dcparser/dcKeywordList.cxx +++ b/direct/src/dcparser/dcKeywordList.cxx @@ -83,7 +83,7 @@ get_num_keywords() const { */ const DCKeyword *DCKeywordList:: get_keyword(int n) const { - nassertr(n >= 0 && n < (int)_keywords.size(), NULL); + nassertr(n >= 0 && n < (int)_keywords.size(), nullptr); return _keywords[n]; } @@ -99,7 +99,7 @@ get_keyword_by_name(const string &name) const { return (*ni).second; } - return NULL; + return nullptr; } /** diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index 4dbd18299d..b2d83dad47 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -35,7 +35,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the dc file we're parsing. We keep it so we // can print it out for error messages. @@ -129,7 +129,7 @@ dcyywarning(const string &msg) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -150,7 +150,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } @@ -733,9 +733,9 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) accept(); dcyylval.str = dcyytext; - if (dc_file != (DCFile *)NULL) { + if (dc_file != nullptr) { const DCKeyword *keyword = dc_file->get_keyword_by_name(dcyylval.str); - if (keyword != (DCKeyword *)NULL) { + if (keyword != nullptr) { dcyylval.u.keyword = keyword; return KEYWORD; } diff --git a/direct/src/dcparser/dcMolecularField.cxx b/direct/src/dcparser/dcMolecularField.cxx index 4bb0c3241f..178c86ad2e 100644 --- a/direct/src/dcparser/dcMolecularField.cxx +++ b/direct/src/dcparser/dcMolecularField.cxx @@ -59,7 +59,7 @@ get_num_atomics() const { */ DCAtomicField *DCMolecularField:: get_atomic(int n) const { - nassertr(n >= 0 && n < (int)_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_fields.size(), nullptr); return _fields[n]; } @@ -161,7 +161,7 @@ generate_hash(HashGenerator &hashgen) const { */ DCPackerInterface *DCMolecularField:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_fields.size(), nullptr); return _nested_fields[n]; } diff --git a/direct/src/dcparser/dcNumericRange.I b/direct/src/dcparser/dcNumericRange.I index debc9bbcd5..8983204d48 100644 --- a/direct/src/dcparser/dcNumericRange.I +++ b/direct/src/dcparser/dcNumericRange.I @@ -58,7 +58,7 @@ is_in_range(Number num) const { return true; } - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { if (num >= (*ri)._min && num <= (*ri)._max) { return true; @@ -96,7 +96,7 @@ has_one_value() const { * by the numeric range. */ template -INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +INLINE typename DCNumericRange::Number DCNumericRange:: get_one_value() const { nassertr(has_one_value(), 0); return _ranges[0]._min; @@ -110,7 +110,7 @@ void DCNumericRange:: generate_hash(HashGenerator &hashgen) const { if (!_ranges.empty()) { hashgen.add_int(_ranges.size()); - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { // We don't account for the fractional part of floating-point ranges // here. Shouldn't be a real issue. @@ -127,7 +127,7 @@ template void DCNumericRange:: output(ostream &out, Number divisor) const { if (!_ranges.empty()) { - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; ri = _ranges.begin(); output_minmax(out, divisor, *ri); ++ri; @@ -151,7 +151,7 @@ output_char(ostream &out, Number divisor) const { } else { if (!_ranges.empty()) { - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; ri = _ranges.begin(); output_minmax_char(out, *ri); ++ri; @@ -187,7 +187,7 @@ add_range(Number min, Number max) { return false; } - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { if ((min >= (*ri)._min && min <= (*ri)._max) || (max >= (*ri)._min && max <= (*ri)._max) || @@ -227,7 +227,7 @@ get_num_ranges() const { * Returns the minimum value defined by the nth component. */ template -INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +INLINE typename DCNumericRange::Number DCNumericRange:: get_min(int n) const { nassertr(n >= 0 && n < (int)_ranges.size(), 0); return _ranges[n]._min; @@ -237,7 +237,7 @@ get_min(int n) const { * Returns the maximum value defined by the nth component. */ template -INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +INLINE typename DCNumericRange::Number DCNumericRange:: get_max(int n) const { nassertr(n >= 0 && n < (int)_ranges.size(), 0); return _ranges[n]._max; diff --git a/direct/src/dcparser/dcPackData.I b/direct/src/dcparser/dcPackData.I index 3766f64d2f..e1523f09ad 100644 --- a/direct/src/dcparser/dcPackData.I +++ b/direct/src/dcparser/dcPackData.I @@ -16,7 +16,7 @@ */ INLINE DCPackData:: DCPackData() { - _buffer = NULL; + _buffer = nullptr; _allocated_size = 0; _used_length = 0; } @@ -26,7 +26,7 @@ DCPackData() { */ INLINE DCPackData:: ~DCPackData() { - if (_buffer != (const char *)NULL) { + if (_buffer != nullptr) { delete[] _buffer; } } @@ -82,7 +82,7 @@ rewrite_data(size_t position, const char *buffer, size_t size) { */ INLINE char *DCPackData:: get_rewrite_pointer(size_t position, size_t size) { - nassertr(position + size <= _used_length, NULL); + nassertr(position + size <= _used_length, nullptr); return _buffer + position; } @@ -129,7 +129,7 @@ INLINE char *DCPackData:: take_data() { char *data = _buffer; - _buffer = NULL; + _buffer = nullptr; _allocated_size = 0; _used_length = 0; diff --git a/direct/src/dcparser/dcPackData.cxx b/direct/src/dcparser/dcPackData.cxx index 4276c735f4..2c0c19a61d 100644 --- a/direct/src/dcparser/dcPackData.cxx +++ b/direct/src/dcparser/dcPackData.cxx @@ -27,7 +27,7 @@ set_used_length(size_t size) { if (_used_length > 0) { memcpy(new_buf, _buffer, _used_length); } - if (_buffer != NULL) { + if (_buffer != nullptr) { delete[] _buffer; } _buffer = new_buf; diff --git a/direct/src/dcparser/dcPacker.I b/direct/src/dcparser/dcPacker.I index c159b0cb77..9bb4607dd6 100644 --- a/direct/src/dcparser/dcPacker.I +++ b/direct/src/dcparser/dcPacker.I @@ -24,7 +24,7 @@ clear_data() { delete[] _unpack_data; _owns_unpack_data = false; } - _unpack_data = NULL; + _unpack_data = nullptr; } /** @@ -35,7 +35,7 @@ clear_data() { */ INLINE bool DCPacker:: has_nested_fields() const { - if (_current_field == NULL) { + if (_current_field == nullptr) { return false; } else { return _current_field->has_nested_fields(); @@ -65,7 +65,7 @@ get_num_nested_fields() const { */ INLINE bool DCPacker:: more_nested_fields() const { - return (_current_field != (DCPackerInterface *)NULL && !_pack_error); + return (_current_field != nullptr && !_pack_error); } /** @@ -112,7 +112,7 @@ get_last_switch() const { */ INLINE DCPackType DCPacker:: get_pack_type() const { - if (_current_field == NULL) { + if (_current_field == nullptr) { return PT_invalid; } else { return _current_field->get_pack_type(); @@ -125,7 +125,7 @@ get_pack_type() const { */ INLINE string DCPacker:: get_current_field_name() const { - if (_current_field == NULL) { + if (_current_field == nullptr) { return string(); } else { return _current_field->get_name(); @@ -138,7 +138,7 @@ get_current_field_name() const { INLINE void DCPacker:: pack_double(double value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_double(_pack_data, value, _pack_error, _range_error); @@ -152,7 +152,7 @@ pack_double(double value) { INLINE void DCPacker:: pack_int(int value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_int(_pack_data, value, _pack_error, _range_error); @@ -166,7 +166,7 @@ pack_int(int value) { INLINE void DCPacker:: pack_uint(unsigned int value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_uint(_pack_data, value, _pack_error, _range_error); @@ -180,7 +180,7 @@ pack_uint(unsigned int value) { INLINE void DCPacker:: pack_int64(int64_t value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_int64(_pack_data, value, _pack_error, _range_error); @@ -194,7 +194,7 @@ pack_int64(int64_t value) { INLINE void DCPacker:: pack_uint64(uint64_t value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_uint64(_pack_data, value, _pack_error, _range_error); @@ -208,7 +208,7 @@ pack_uint64(uint64_t value) { INLINE void DCPacker:: pack_string(const string &value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_string(_pack_data, value, _pack_error, _range_error); @@ -223,7 +223,7 @@ pack_string(const string &value) { INLINE void DCPacker:: pack_literal_value(const string &value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _pack_data.append_data(value.data(), value.length()); @@ -238,7 +238,7 @@ INLINE double DCPacker:: unpack_double() { double value = 0.0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -257,7 +257,7 @@ INLINE int DCPacker:: unpack_int() { int value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -276,7 +276,7 @@ INLINE unsigned int DCPacker:: unpack_uint() { unsigned int value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -295,7 +295,7 @@ INLINE int64_t DCPacker:: unpack_int64() { int64_t value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -314,7 +314,7 @@ INLINE uint64_t DCPacker:: unpack_uint64() { uint64_t value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -333,7 +333,7 @@ INLINE string DCPacker:: unpack_string() { string value; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -363,7 +363,7 @@ unpack_literal_value() { INLINE void DCPacker:: unpack_double(double &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -379,7 +379,7 @@ unpack_double(double &value) { INLINE void DCPacker:: unpack_int(int &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -395,7 +395,7 @@ unpack_int(int &value) { INLINE void DCPacker:: unpack_uint(unsigned int &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -411,7 +411,7 @@ unpack_uint(unsigned int &value) { INLINE void DCPacker:: unpack_int64(int64_t &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -427,7 +427,7 @@ unpack_int64(int64_t &value) { INLINE void DCPacker:: unpack_uint64(uint64_t &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -443,7 +443,7 @@ unpack_uint64(uint64_t &value) { INLINE void DCPacker:: unpack_string(string &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -613,7 +613,7 @@ append_data(const char *buffer, size_t size) { */ INLINE char *DCPacker:: get_write_pointer(size_t size) { - nassertr(_mode == M_idle, NULL); + nassertr(_mode == M_idle, nullptr); return _pack_data.get_write_pointer(size); } @@ -773,7 +773,7 @@ raw_unpack_int64() { */ INLINE void DCPacker:: raw_unpack_int8(int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 1 > _unpack_length) { _pack_error = true; return; @@ -787,7 +787,7 @@ raw_unpack_int8(int &value) { */ INLINE void DCPacker:: raw_unpack_int16(int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 2 > _unpack_length) { _pack_error = true; return; @@ -801,7 +801,7 @@ raw_unpack_int16(int &value) { */ INLINE void DCPacker:: raw_unpack_int32(int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 4 > _unpack_length) { _pack_error = true; return; @@ -875,7 +875,7 @@ raw_unpack_string() { */ INLINE void DCPacker:: raw_unpack_int64(int64_t &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 8 > _unpack_length) { _pack_error = true; return; @@ -889,7 +889,7 @@ raw_unpack_int64(int64_t &value) { */ INLINE void DCPacker:: raw_unpack_uint8(unsigned int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 1 > _unpack_length) { _pack_error = true; return; @@ -903,7 +903,7 @@ raw_unpack_uint8(unsigned int &value) { */ INLINE void DCPacker:: raw_unpack_uint16(unsigned int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 2 > _unpack_length) { _pack_error = true; return; @@ -917,7 +917,7 @@ raw_unpack_uint16(unsigned int &value) { */ INLINE void DCPacker:: raw_unpack_uint32(unsigned int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 4 > _unpack_length) { _pack_error = true; return; @@ -931,7 +931,7 @@ raw_unpack_uint32(unsigned int &value) { */ INLINE void DCPacker:: raw_unpack_uint64(uint64_t &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 8 > _unpack_length) { _pack_error = true; return; @@ -945,7 +945,7 @@ raw_unpack_uint64(uint64_t &value) { */ INLINE void DCPacker:: raw_unpack_float64(double &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 8 > _unpack_length) { _pack_error = true; return; @@ -959,7 +959,7 @@ raw_unpack_float64(double &value) { */ INLINE void DCPacker:: raw_unpack_string(string &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); unsigned int string_length = raw_unpack_uint16(); if (_unpack_p + string_length > _unpack_length) { @@ -981,13 +981,13 @@ advance() { _current_field_index >= _num_nested_fields) { // Done with all the fields on this parent. The caller must now call // pop(). - _current_field = NULL; + _current_field = nullptr; // But if the parent is a switch record, we make a special case so we can // get the alternate fields. - if (_current_parent != (DCPackerInterface *)NULL) { + if (_current_parent != nullptr) { const DCSwitchParameter *switch_parameter = ((DCPackerInterface *)_current_parent)->as_switch_parameter(); - if (switch_parameter != (DCSwitchParameter *)NULL) { + if (switch_parameter != nullptr) { handle_switch(switch_parameter); } } @@ -995,7 +995,7 @@ advance() { } else if (_pop_marker != 0 && _unpack_p >= _pop_marker) { // Done with all the fields on this parent. The caller must now call // pop(). - _current_field = NULL; + _current_field = nullptr; } else { // We have another field to advance to. @@ -1009,7 +1009,7 @@ advance() { */ INLINE void *DCPacker::StackElement:: operator new(size_t size) { - if (_deleted_chain != (DCPacker::StackElement *)NULL) { + if (_deleted_chain != nullptr) { StackElement *obj = _deleted_chain; _deleted_chain = _deleted_chain->_next; return obj; diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index 794d5e1690..119add847e 100644 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -23,7 +23,7 @@ #include "py_panda.h" #endif -DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = NULL; +DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = nullptr; int DCPacker::StackElement::_num_ever_allocated = 0; /** @@ -32,15 +32,15 @@ int DCPacker::StackElement::_num_ever_allocated = 0; DCPacker:: DCPacker() { _mode = M_idle; - _unpack_data = NULL; + _unpack_data = nullptr; _unpack_length = 0; _owns_unpack_data = false; _unpack_p = 0; - _live_catalog = NULL; + _live_catalog = nullptr; _parse_error = false; _pack_error = false; _range_error = false; - _stack = NULL; + _stack = nullptr; clear(); } @@ -73,11 +73,11 @@ begin_pack(const DCPackerInterface *root) { _range_error = false; _root = root; - _catalog = NULL; - _live_catalog = NULL; + _catalog = nullptr; + _live_catalog = nullptr; _current_field = root; - _current_parent = NULL; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; } @@ -94,7 +94,7 @@ end_pack() { _mode = M_idle; - if (_stack != NULL || _current_field != NULL || _current_parent != NULL) { + if (_stack != nullptr || _current_field != nullptr || _current_parent != nullptr) { _pack_error = true; } @@ -146,7 +146,7 @@ set_unpack_data(const char *unpack_data, size_t unpack_length, void DCPacker:: begin_unpack(const DCPackerInterface *root) { nassertv(_mode == M_idle); - nassertv(_unpack_data != NULL); + nassertv(_unpack_data != nullptr); _mode = M_unpack; _parse_error = false; @@ -154,11 +154,11 @@ begin_unpack(const DCPackerInterface *root) { _range_error = false; _root = root; - _catalog = NULL; - _live_catalog = NULL; + _catalog = nullptr; + _live_catalog = nullptr; _current_field = root; - _current_parent = NULL; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; } @@ -175,13 +175,13 @@ end_unpack() { _mode = M_idle; - if (_stack != NULL || _current_field != NULL || _current_parent != NULL) { + if (_stack != nullptr || _current_field != nullptr || _current_parent != nullptr) { // This happens if we have not unpacked all of the fields. However, this // is not an error if we have called seek() during the unpack session (in // which case the _catalog will be non-NULL). On the other hand, if the // catalog is still NULL, then we have never called seek() and it is an // error not to unpack all values. - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { _pack_error = true; } } @@ -206,7 +206,7 @@ end_unpack() { void DCPacker:: begin_repack(const DCPackerInterface *root) { nassertv(_mode == M_idle); - nassertv(_unpack_data != NULL); + nassertv(_unpack_data != nullptr); nassertv(_unpack_p == 0); _mode = M_repack; @@ -220,14 +220,14 @@ begin_repack(const DCPackerInterface *root) { _root = root; _catalog = _root->get_catalog(); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); - if (_live_catalog == NULL) { + if (_live_catalog == nullptr) { _pack_error = true; } // We don't begin at the first field in repack mode. Instead, you must // explicitly call seek(). - _current_field = NULL; - _current_parent = NULL; + _current_field = nullptr; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; } @@ -262,12 +262,12 @@ end_repack() { */ bool DCPacker:: seek(const string &field_name) { - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { _catalog = _root->get_catalog(); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); } - nassertr(_catalog != (DCPackerCatalog *)NULL, false); - if (_live_catalog == NULL) { + nassertr(_catalog != nullptr, false); + if (_live_catalog == nullptr) { _pack_error = true; return false; } @@ -292,12 +292,12 @@ seek(const string &field_name) { */ bool DCPacker:: seek(int seek_index) { - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { _catalog = _root->get_catalog(); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); } - nassertr(_catalog != (DCPackerCatalog *)NULL, false); - if (_live_catalog == NULL) { + nassertr(_catalog != nullptr, false); + if (_live_catalog == nullptr) { _pack_error = true; return false; } @@ -324,9 +324,9 @@ seek(int seek_index) { return true; } else if (_mode == M_repack) { - nassertr(_catalog != (DCPackerCatalog *)NULL, false); + nassertr(_catalog != nullptr, false); - if (_stack != NULL || _current_field != NULL) { + if (_stack != nullptr || _current_field != nullptr) { // It is an error to reseek while the stack is nonempty--that means we // haven't finished packing the current field. _pack_error = true; @@ -334,7 +334,7 @@ seek(int seek_index) { } const DCPackerCatalog::Entry &entry = _live_catalog->get_entry(seek_index); - if (entry._parent->as_switch_parameter() != (DCSwitchParameter *)NULL) { + if (entry._parent->as_switch_parameter() != nullptr) { // If the parent is a DCSwitch, that can only mean that the seeked field // is a switch parameter. We can't support seeking to a switch // parameter and modifying it directly--what would happen to all of the @@ -357,7 +357,7 @@ seek(int seek_index) { _catalog->release_live_catalog(_live_catalog); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); - if (_live_catalog == NULL) { + if (_live_catalog == nullptr) { _pack_error = true; return false; } @@ -470,7 +470,7 @@ push() { if (_num_nested_fields >= 0 && _current_field_index >= _num_nested_fields) { - _current_field = NULL; + _current_field = nullptr; } else { _current_field = _current_parent->get_nested_field(_current_field_index); @@ -487,7 +487,7 @@ push() { */ void DCPacker:: pop() { - if (_current_field != NULL && _num_nested_fields >= 0) { + if (_current_field != nullptr && _num_nested_fields >= 0) { // Oops, didn't pack or unpack enough values. _pack_error = true; @@ -497,7 +497,7 @@ pop() { _pack_error = true; } - if (_stack == NULL) { + if (_stack == nullptr) { // Unbalanced pop(). _pack_error = true; @@ -528,7 +528,7 @@ pop() { _current_field_index = _stack->_current_field_index; _push_marker = _stack->_push_marker; _pop_marker = _stack->_pop_marker; - _num_nested_fields = (_current_parent == NULL) ? 0 : _current_parent->get_num_nested_fields(); + _num_nested_fields = (_current_parent == nullptr) ? 0 : _current_parent->get_num_nested_fields(); StackElement *next = _stack->_next; delete _stack; @@ -545,7 +545,7 @@ pop() { void DCPacker:: pack_default_value() { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { if (_current_field->pack_default_value(_pack_data, _pack_error)) { @@ -571,7 +571,7 @@ pack_default_value() { void DCPacker:: unpack_validate() { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -597,7 +597,7 @@ unpack_validate() { void DCPacker:: unpack_skip() { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -739,11 +739,11 @@ pack_object(PyObject *object) { (PyObject_HasAttrString(object, "__len__") != 0); bool is_instance = false; - const DCClass *dclass = NULL; + const DCClass *dclass = nullptr; const DCPackerInterface *current_field = get_current_field(); - if (current_field != (DCPackerInterface *)NULL) { + if (current_field != nullptr) { const DCClassParameter *class_param = get_current_field()->as_class_parameter(); - if (class_param != (DCClassParameter *)NULL) { + if (class_param != nullptr) { dclass = class_param->get_class(); if (dclass->has_class_def()) { @@ -771,7 +771,7 @@ pack_object(PyObject *object) { // (3) Otherwise, it is considered to be a class object. - if (dclass != (DCClass *)NULL && (is_instance || !is_sequence)) { + if (dclass != nullptr && (is_instance || !is_sequence)) { // The supplied object is either an instance of the expected class // object, or it is not a sequence--this is case (1) or (3). pack_class_object(dclass, object); @@ -782,7 +782,7 @@ pack_object(PyObject *object) { int size = PySequence_Size(object); for (int i = 0; i < size; ++i) { PyObject *element = PySequence_GetItem(object, i); - if (element != (PyObject *)NULL) { + if (element != nullptr) { pack_object(element); Py_DECREF(element); } else { @@ -812,7 +812,7 @@ pack_object(PyObject *object) { */ PyObject *DCPacker:: unpack_object() { - PyObject *object = NULL; + PyObject *object = nullptr; DCPackType pack_type = get_pack_type(); @@ -896,13 +896,13 @@ unpack_object() { case PT_class: { const DCClassParameter *class_param = get_current_field()->as_class_parameter(); - if (class_param != (DCClassParameter *)NULL) { + if (class_param != nullptr) { const DCClass *dclass = class_param->get_class(); if (dclass->has_class_def()) { // If we know what kind of class object this is and it has a valid // constructor, create the class object instead of just a tuple. object = unpack_class_object(dclass); - if (object == (PyObject *)NULL) { + if (object == nullptr) { cerr << "Unable to construct object of class " << dclass->get_name() << "\n"; } else { @@ -939,7 +939,7 @@ unpack_object() { break; } - nassertr(object != (PyObject *)NULL, NULL); + nassertr(object != nullptr, nullptr); return object; } #endif // HAVE_PYTHON @@ -995,10 +995,10 @@ unpack_and_format(ostream &out, bool show_field_names) { DCPackType pack_type = get_pack_type(); if (show_field_names && !get_current_field_name().empty()) { - nassertv(_current_field != (DCPackerInterface *)NULL); + nassertv(_current_field != nullptr); const DCField *field = _current_field->as_field(); - if (field != (DCField *)NULL && - field->as_parameter() != (DCParameter *)NULL) { + if (field != nullptr && + field->as_parameter() != nullptr) { out << field->get_name() << " = "; } } @@ -1135,7 +1135,7 @@ void DCPacker:: handle_switch(const DCSwitchParameter *switch_parameter) { // First, get the value from the key. This is either found in the unpack or // the pack data, depending on what mode we're in. - const DCPackerInterface *new_parent = NULL; + const DCPackerInterface *new_parent = nullptr; if (_mode == M_pack || _mode == M_repack) { const char *data = _pack_data.get_data(); @@ -1147,7 +1147,7 @@ handle_switch(const DCSwitchParameter *switch_parameter) { (_unpack_data + _push_marker, _unpack_p - _push_marker); } - if (new_parent == (DCPackerInterface *)NULL) { + if (new_parent == nullptr) { // This means an invalid value was packed for the key. _range_error = true; return; @@ -1173,20 +1173,20 @@ handle_switch(const DCSwitchParameter *switch_parameter) { void DCPacker:: clear() { clear_stack(); - _current_field = NULL; - _current_parent = NULL; + _current_field = nullptr; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; _push_marker = 0; _pop_marker = 0; - _last_switch = NULL; + _last_switch = nullptr; - if (_live_catalog != (DCPackerCatalog::LiveCatalog *)NULL) { + if (_live_catalog != nullptr) { _catalog->release_live_catalog(_live_catalog); - _live_catalog = NULL; + _live_catalog = nullptr; } - _catalog = NULL; - _root = NULL; + _catalog = nullptr; + _root = nullptr; } /** @@ -1194,7 +1194,7 @@ clear() { */ void DCPacker:: clear_stack() { - while (_stack != (StackElement *)NULL) { + while (_stack != nullptr) { StackElement *next = _stack->_next; delete _stack; _stack = next; @@ -1212,7 +1212,7 @@ pack_class_object(const DCClass *dclass, PyObject *object) { push(); while (more_nested_fields() && !_pack_error) { const DCField *field = get_current_field()->as_field(); - nassertv(field != (DCField *)NULL); + nassertv(field != nullptr); get_class_element(dclass, object, field); } pop(); @@ -1227,36 +1227,36 @@ pack_class_object(const DCClass *dclass, PyObject *object) { PyObject *DCPacker:: unpack_class_object(const DCClass *dclass) { PyObject *class_def = dclass->get_class_def(); - nassertr(class_def != (PyObject *)NULL, NULL); + nassertr(class_def != nullptr, nullptr); - PyObject *object = NULL; + PyObject *object = nullptr; if (!dclass->has_constructor()) { // If the class uses a default constructor, go ahead and create the Python // object for it now. - object = PyObject_CallObject(class_def, NULL); - if (object == (PyObject *)NULL) { - return NULL; + object = PyObject_CallObject(class_def, nullptr); + if (object == nullptr) { + return nullptr; } } push(); - if (object == (PyObject *)NULL && more_nested_fields()) { + if (object == nullptr && more_nested_fields()) { // The first nested field will be the constructor. const DCField *field = get_current_field()->as_field(); - nassertr(field != (DCField *)NULL, object); + nassertr(field != nullptr, object); nassertr(field == dclass->get_constructor(), object); set_class_element(class_def, object, field); // By now, the object should have been constructed. - if (object == (PyObject *)NULL) { - return NULL; + if (object == nullptr) { + return nullptr; } } while (more_nested_fields()) { const DCField *field = get_current_field()->as_field(); - nassertr(field != (DCField *)NULL, object); + nassertr(field != nullptr, object); set_class_element(class_def, object, field); } @@ -1287,8 +1287,8 @@ set_class_element(PyObject *class_def, PyObject *&object, push(); while (more_nested_fields()) { const DCField *field = get_current_field()->as_field(); - nassertv(field != (DCField *)NULL); - nassertv(object != (PyObject *)NULL); + nassertv(field != nullptr); + nassertv(object != nullptr); set_class_element(class_def, object, field); } pop(); @@ -1307,7 +1307,7 @@ set_class_element(PyObject *class_def, PyObject *&object, PyObject *element = unpack_object(); if (pack_type == PT_field) { - if (object == (PyObject *)NULL) { + if (object == nullptr) { // If the object hasn't been constructed yet, assume this is the // constructor. object = PyObject_CallObject(class_def, element); @@ -1315,7 +1315,7 @@ set_class_element(PyObject *class_def, PyObject *&object, } else { if (PyObject_HasAttrString(object, (char *)field_name.c_str())) { PyObject *func = PyObject_GetAttrString(object, (char *)field_name.c_str()); - if (func != (PyObject *)NULL) { + if (func != nullptr) { PyObject *result = PyObject_CallObject(func, element); Py_XDECREF(result); Py_DECREF(func); @@ -1324,7 +1324,7 @@ set_class_element(PyObject *class_def, PyObject *&object, } } else { - nassertv(object != (PyObject *)NULL); + nassertv(object != nullptr); PyObject_SetAttrString(object, (char *)field_name.c_str(), element); } @@ -1353,7 +1353,7 @@ get_class_element(const DCClass *dclass, PyObject *object, push(); while (more_nested_fields() && !_pack_error) { const DCField *field = get_current_field()->as_field(); - nassertv(field != (DCField *)NULL); + nassertv(field != nullptr); get_class_element(dclass, object, field); } pop(); diff --git a/direct/src/dcparser/dcPackerCatalog.cxx b/direct/src/dcparser/dcPackerCatalog.cxx index 0f13322009..0eda4197b6 100644 --- a/direct/src/dcparser/dcPackerCatalog.cxx +++ b/direct/src/dcparser/dcPackerCatalog.cxx @@ -21,7 +21,7 @@ */ DCPackerCatalog:: DCPackerCatalog(const DCPackerInterface *root) : _root(root) { - _live_catalog = NULL; + _live_catalog = nullptr; } /** @@ -34,7 +34,7 @@ DCPackerCatalog(const DCPackerCatalog ©) : _entries_by_name(copy._entries_by_name), _entries_by_field(copy._entries_by_field) { - _live_catalog = NULL; + _live_catalog = nullptr; } /** @@ -42,7 +42,7 @@ DCPackerCatalog(const DCPackerCatalog ©) : */ DCPackerCatalog:: ~DCPackerCatalog() { - if (_live_catalog != (LiveCatalog *)NULL) { + if (_live_catalog != nullptr) { delete _live_catalog; } @@ -92,7 +92,7 @@ find_entry_by_field(const DCPackerInterface *field) const { */ const DCPackerCatalog::LiveCatalog *DCPackerCatalog:: get_live_catalog(const char *data, size_t length) const { - if (_live_catalog != (LiveCatalog *)NULL) { + if (_live_catalog != nullptr) { // Return the previously-allocated live catalog; it will be the same as // this one since it's based on a fixed-length field. return _live_catalog; @@ -111,13 +111,13 @@ get_live_catalog(const char *data, size_t length) const { DCPacker packer; packer.set_unpack_data(data, length, false); packer.begin_unpack(_root); - const DCSwitchParameter *last_switch = NULL; + const DCSwitchParameter *last_switch = nullptr; r_fill_live_catalog(live_catalog, packer, last_switch); bool okflag = packer.end_unpack(); if (!okflag) { delete live_catalog; - return NULL; + return nullptr; } if (_root->has_fixed_structure()) { @@ -188,7 +188,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index) { string next_name_prefix = name_prefix; - if (parent != (const DCPackerInterface *)NULL && !field->get_name().empty()) { + if (parent != nullptr && !field->get_name().empty()) { // Record this entry in the catalog. next_name_prefix += field->get_name(); add_entry(next_name_prefix, field, parent, field_index); @@ -197,7 +197,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, } const DCSwitchParameter *switch_parameter = field->as_switch_parameter(); - if (switch_parameter != (DCSwitchParameter *)NULL) { + if (switch_parameter != nullptr) { // If we come upon a DCSwitch while building the catalog, save the // name_prefix at this point so we'll have it again when we later // encounter the switch while unpacking a live record (and so we can @@ -211,7 +211,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, // It's ok if num_nested is -1. for (int i = 0; i < num_nested; i++) { DCPackerInterface *nested = field->get_nested_field(i); - if (nested != (DCPackerInterface *)NULL) { + if (nested != nullptr) { r_fill_catalog(next_name_prefix, nested, field, i); } } @@ -255,10 +255,10 @@ r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer, last_switch = packer.get_last_switch(); const DCPackerInterface *switch_case = packer.get_current_parent(); - nassertv(switch_case != (DCPackerInterface *)NULL); + nassertv(switch_case != nullptr); const DCPackerCatalog *switch_catalog = live_catalog->_catalog->update_switch_fields(last_switch, switch_case); - nassertv(switch_catalog != (DCPackerCatalog *)NULL); + nassertv(switch_catalog != nullptr); live_catalog->_catalog = switch_catalog; // And we also have to expand the live catalog to hold the new entries. @@ -317,7 +317,7 @@ update_switch_fields(const DCSwitchParameter *switch_parameter, int num_nested = switch_case->get_num_nested_fields(); for (int i = 1; i < num_nested; i++) { DCPackerInterface *nested = switch_case->get_nested_field(i); - if (nested != (DCPackerInterface *)NULL) { + if (nested != nullptr) { switch_catalog->r_fill_catalog(name_prefix, nested, switch_case, i); } } diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index dc731a479a..dd6e4ae482 100644 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -32,7 +32,7 @@ DCPackerInterface(const string &name) : _has_nested_fields = false; _num_nested_fields = -1; _pack_type = PT_invalid; - _catalog = NULL; + _catalog = nullptr; } /** @@ -50,7 +50,7 @@ DCPackerInterface(const DCPackerInterface ©) : _num_nested_fields(copy._num_nested_fields), _pack_type(copy._pack_type) { - _catalog = NULL; + _catalog = nullptr; } /** @@ -58,7 +58,7 @@ DCPackerInterface(const DCPackerInterface ©) : */ DCPackerInterface:: ~DCPackerInterface() { - if (_catalog != (DCPackerCatalog *)NULL) { + if (_catalog != nullptr) { delete _catalog; } } @@ -83,7 +83,7 @@ find_seek_index(const string &name) const { */ DCField *DCPackerInterface:: as_field() { - return (DCField *)NULL; + return nullptr; } /** @@ -91,7 +91,7 @@ as_field() { */ const DCField *DCPackerInterface:: as_field() const { - return (DCField *)NULL; + return nullptr; } /** @@ -99,7 +99,7 @@ as_field() const { */ DCSwitchParameter *DCPackerInterface:: as_switch_parameter() { - return (DCSwitchParameter *)NULL; + return nullptr; } /** @@ -107,7 +107,7 @@ as_switch_parameter() { */ const DCSwitchParameter *DCPackerInterface:: as_switch_parameter() const { - return (DCSwitchParameter *)NULL; + return nullptr; } /** @@ -115,7 +115,7 @@ as_switch_parameter() const { */ DCClassParameter *DCPackerInterface:: as_class_parameter() { - return (DCClassParameter *)NULL; + return nullptr; } /** @@ -123,7 +123,7 @@ as_class_parameter() { */ const DCClassParameter *DCPackerInterface:: as_class_parameter() const { - return (DCClassParameter *)NULL; + return nullptr; } /** @@ -145,7 +145,7 @@ check_match(const string &description, DCFile *dcfile) const { dc_cleanup_parser(); DCField *field = dc_get_parameter_description(); - if (field != NULL) { + if (field != nullptr) { match = check_match(field); delete field; } @@ -184,7 +184,7 @@ calc_num_nested_fields(size_t) const { */ DCPackerInterface *DCPackerInterface:: get_nested_field(int) const { - return NULL; + return nullptr; } /** @@ -367,7 +367,7 @@ unpack_skip(const char *data, size_t length, size_t &p, */ const DCPackerCatalog *DCPackerInterface:: get_catalog() const { - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { ((DCPackerInterface *)this)->make_catalog(); } return _catalog; @@ -432,8 +432,8 @@ do_check_match_molecular_field(const DCMolecularField *) const { */ void DCPackerInterface:: make_catalog() { - nassertv(_catalog == (DCPackerCatalog *)NULL); + nassertv(_catalog == nullptr); _catalog = new DCPackerCatalog(this); - _catalog->r_fill_catalog("", this, NULL, 0); + _catalog->r_fill_catalog("", this, nullptr, 0); } diff --git a/direct/src/dcparser/dcPackerInterface.h b/direct/src/dcparser/dcPackerInterface.h index 42284ac54f..0157d3c5ce 100644 --- a/direct/src/dcparser/dcPackerInterface.h +++ b/direct/src/dcparser/dcPackerInterface.h @@ -82,7 +82,7 @@ PUBLISHED: virtual const DCClassParameter *as_class_parameter() const; INLINE bool check_match(const DCPackerInterface *other) const; - bool check_match(const string &description, DCFile *dcfile = NULL) const; + bool check_match(const string &description, DCFile *dcfile = nullptr) const; public: virtual void set_name(const string &name); diff --git a/direct/src/dcparser/dcParameter.cxx b/direct/src/dcparser/dcParameter.cxx index a1fcfecca7..ef1c50997f 100644 --- a/direct/src/dcparser/dcParameter.cxx +++ b/direct/src/dcparser/dcParameter.cxx @@ -22,7 +22,7 @@ */ DCParameter:: DCParameter() { - _typedef = NULL; + _typedef = nullptr; _has_fixed_byte_size = false; _has_fixed_structure = false; _num_nested_fields = -1; @@ -66,7 +66,7 @@ as_parameter() const { */ DCSimpleParameter *DCParameter:: as_simple_parameter() { - return NULL; + return nullptr; } /** @@ -74,7 +74,7 @@ as_simple_parameter() { */ const DCSimpleParameter *DCParameter:: as_simple_parameter() const { - return NULL; + return nullptr; } /** @@ -82,7 +82,7 @@ as_simple_parameter() const { */ DCClassParameter *DCParameter:: as_class_parameter() { - return NULL; + return nullptr; } /** @@ -90,7 +90,7 @@ as_class_parameter() { */ const DCClassParameter *DCParameter:: as_class_parameter() const { - return NULL; + return nullptr; } /** @@ -98,7 +98,7 @@ as_class_parameter() const { */ DCSwitchParameter *DCParameter:: as_switch_parameter() { - return NULL; + return nullptr; } /** @@ -106,7 +106,7 @@ as_switch_parameter() { */ const DCSwitchParameter *DCParameter:: as_switch_parameter() const { - return NULL; + return nullptr; } /** @@ -114,7 +114,7 @@ as_switch_parameter() const { */ DCArrayParameter *DCParameter:: as_array_parameter() { - return NULL; + return nullptr; } /** @@ -122,7 +122,7 @@ as_array_parameter() { */ const DCArrayParameter *DCParameter:: as_array_parameter() const { - return NULL; + return nullptr; } /** diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 5c39b398e4..8b9c7e40ad 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -29,18 +29,18 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -DCFile *dc_file = (DCFile *)NULL; -static DCClass *current_class = (DCClass *)NULL; -static DCSwitch *current_switch = (DCSwitch *)NULL; -static DCAtomicField *current_atomic = (DCAtomicField *)NULL; -static DCMolecularField *current_molecular = (DCMolecularField *)NULL; -static DCParameter *current_parameter = (DCParameter *)NULL; +DCFile *dc_file = nullptr; +static DCClass *current_class = nullptr; +static DCSwitch *current_switch = nullptr; +static DCAtomicField *current_atomic = nullptr; +static DCMolecularField *current_molecular = nullptr; +static DCParameter *current_parameter = nullptr; static DCKeywordList current_keyword_list; static DCPacker default_packer; static DCPacker *current_packer; static DCDoubleRange double_range; static DCUnsignedIntRange uint_range; -static DCField *parameter_description = (DCField *)NULL; +static DCField *parameter_description = nullptr; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -55,7 +55,7 @@ dc_init_parser(istream &in, const string &filename, DCFile &file) { void dc_init_parser_parameter_value(istream &in, const string &filename, DCPacker &packer) { - dc_file = NULL; + dc_file = nullptr; current_packer = &packer; dc_init_lexer(in, filename); dc_start_parameter_value(); @@ -66,7 +66,7 @@ dc_init_parser_parameter_description(istream &in, const string &filename, DCFile *file) { dc_file = file; dc_init_lexer(in, filename); - parameter_description = NULL; + parameter_description = nullptr; dc_start_parameter_description(); } @@ -77,7 +77,7 @@ dc_get_parameter_description() { void dc_cleanup_parser() { - dc_file = (DCFile *)NULL; + dc_file = nullptr; } %} @@ -181,7 +181,7 @@ dc: { if (!dc_file->add_class($2)) { DCClass *old_class = dc_file->get_class_by_name($2->get_name()); - if (old_class != (DCClass *)NULL && old_class->is_bogus_class()) { + if (old_class != nullptr && old_class->is_bogus_class()) { yyerror("Base class defined after its first reference: " + $2->get_name()); } else { yyerror("Duplicate class name: " + $2->get_name()); @@ -249,7 +249,7 @@ import_symbol_list: typedef_decl: KW_TYPEDEF parameter_with_default { - if ($2 != (DCParameter *)NULL) { + if ($2 != nullptr) { DCTypedef *dtypedef = new DCTypedef($2); if (!dc_file->add_typedef(dtypedef)) { @@ -304,13 +304,13 @@ dclass: dclass_name: IDENTIFIER { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("No DCFile available, so no class names are predefined."); - $$ = NULL; + $$ = nullptr; } else { DCClass *dclass = dc_file->get_class_by_name($1); - if (dclass == (DCClass *)NULL) { + if (dclass == nullptr) { // Create a bogus class as a forward reference. dclass = new DCClass(dc_file, $1, false, true); dc_file->add_class(dclass); @@ -332,7 +332,7 @@ dclass_derivation: dclass_base_list: dclass_name { - if ($1 != (DCClass *)NULL) { + if ($1 != nullptr) { current_class->add_parent($1); } } @@ -342,7 +342,7 @@ dclass_base_list: yyerror("Multiple inheritance is not supported without \"dc-multiple-inheritance 1\" in your Config.prc file."); } else { - if ($3 != (DCClass *)NULL) { + if ($3 != nullptr) { current_class->add_parent($3); } } @@ -354,7 +354,7 @@ dclass_fields: | dclass_fields ';' | dclass_fields dclass_field ';' { - if ($2 == (DCField *)NULL) { + if ($2 == nullptr) { // Pass this error up. } else if (!current_class->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); @@ -367,7 +367,7 @@ dclass_fields: dclass_field: atomic_field keyword_list { - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { if ($1->get_name().empty()) { yyerror("Field name required."); } @@ -379,14 +379,14 @@ dclass_field: | unnamed_parameter_with_default keyword_list { yyerror("Unnamed parameters are not allowed on a dclass"); - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { $1->copy_keywords(current_keyword_list); } $$ = $1; } | named_parameter_with_default keyword_list { - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { $1->copy_keywords(current_keyword_list); } $$ = $1; @@ -408,13 +408,13 @@ struct: struct_name: IDENTIFIER { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("No DCFile available, so no struct names are predefined."); - $$ = NULL; + $$ = nullptr; } else { DCClass *dstruct = dc_file->get_class_by_name($1); - if (dstruct == (DCClass *)NULL) { + if (dstruct == nullptr) { // Create a bogus class as a forward reference. dstruct = new DCClass(dc_file, $1, false, true); dc_file->add_class(dstruct); @@ -436,13 +436,13 @@ struct_derivation: struct_base_list: struct_name { - if ($1 != (DCClass *)NULL) { + if ($1 != nullptr) { current_class->add_parent($1); } } | struct_base_list ',' struct_name { - if ($3 != (DCClass *)NULL) { + if ($3 != nullptr) { current_class->add_parent($3); } } @@ -453,7 +453,7 @@ struct_fields: | struct_fields ';' | struct_fields struct_field ';' { - if ($2 == (DCField *)NULL) { + if ($2 == nullptr) { // Pass this error up. } else if (!current_class->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); @@ -483,7 +483,7 @@ struct_field: atomic_field: optional_name '(' { - if (current_class == (DCClass *)NULL) { + if (current_class == nullptr) { yyerror("Cannot define a method outside of a struct or class."); DCClass *temp_class = new DCClass(dc_file, "temp", false, false); // memory leak. current_atomic = new DCAtomicField($1, temp_class, false); @@ -511,7 +511,7 @@ nonempty_parameter_list: atomic_element: parameter_with_default { - if ($1 != (DCParameter *)NULL) { + if ($1 != nullptr) { current_atomic->add_element($1); } } @@ -538,14 +538,14 @@ named_parameter_with_default: { current_packer = &default_packer; current_packer->clear_data(); - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { current_packer->begin_pack($1); } } parameter_value { bool is_valid = false; - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { is_valid = $1->is_valid(); } if (current_packer->end_pack()) { @@ -568,14 +568,14 @@ unnamed_parameter_with_default: { current_packer = &default_packer; current_packer->clear_data(); - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { current_packer->begin_pack($1); } } parameter_value { bool is_valid = false; - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { is_valid = $1->is_valid(); } if (current_packer->end_pack()) { @@ -636,7 +636,7 @@ simple_type_name: | simple_type_name '(' double_range ')' { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + nassertr(simple_param != nullptr, 0); if (!simple_param->set_range(double_range)) { yyerror("Inappropriate range for type"); } @@ -645,7 +645,7 @@ simple_type_name: | simple_type_name '/' small_unsigned_integer { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + nassertr(simple_param != nullptr, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); @@ -661,7 +661,7 @@ simple_type_name: | simple_type_name '%' number { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + nassertr(simple_param != nullptr, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); @@ -676,22 +676,22 @@ type_name: simple_type_name | IDENTIFIER { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("Invalid type."); - $$ = NULL; + $$ = nullptr; } else { DCTypedef *dtypedef = dc_file->get_typedef_by_name($1); - if (dtypedef == (DCTypedef *)NULL) { + if (dtypedef == nullptr) { // Maybe it's a class name. DCClass *dclass = dc_file->get_class_by_name($1); - if (dclass != (DCClass *)NULL) { + if (dclass != nullptr) { // Create an implicit typedef for this. dtypedef = new DCTypedef(new DCClassParameter(dclass), true); } else { // Maybe it's a switch name. DCSwitch *dswitch = dc_file->get_switch_by_name($1); - if (dswitch != (DCSwitch *)NULL) { + if (dswitch != nullptr) { // This also gets an implicit typedef. dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true); } else { @@ -709,10 +709,10 @@ type_name: | struct { // This is an inline struct definition. - if ($1 == (DCClass *)NULL) { - $$ = NULL; + if ($1 == nullptr) { + $$ = nullptr; } else { - if (dc_file != (DCFile *)NULL) { + if (dc_file != nullptr) { dc_file->add_thing_to_delete($1); } else { // This is a memory leak--this happens when we put an anonymous @@ -725,10 +725,10 @@ type_name: | switch { // This is an inline switch definition. - if ($1 == (DCSwitch *)NULL) { - $$ = NULL; + if ($1 == nullptr) { + $$ = nullptr; } else { - if (dc_file != (DCFile *)NULL) { + if (dc_file != nullptr) { dc_file->add_thing_to_delete($1); } else { // This is a memory leak--this happens when we put an anonymous @@ -840,8 +840,8 @@ type_definition: type_name | type_definition '[' uint_range ']' { - if ($1 == (DCParameter *)NULL) { - $$ = NULL; + if ($1 == nullptr) { + $$ = nullptr; } else { $$ = $1->append_array_specification(uint_range); } @@ -857,7 +857,7 @@ parameter_definition: | parameter_definition '/' small_unsigned_integer { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { + if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { yyerror("A divisor is only allowed on a primitive type."); } else if (!simple_param->is_numeric_type()) { @@ -872,7 +872,7 @@ parameter_definition: | parameter_definition '%' number { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { + if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { yyerror("A modulus is only allowed on a primitive type."); } else if (!simple_param->is_numeric_type()) { @@ -1184,8 +1184,8 @@ atomic_name: IDENTIFIER { DCField *field = current_class->get_field_by_name($1); - $$ = (DCAtomicField *)NULL; - if (field == (DCField *)NULL) { + $$ = nullptr; + if (field == nullptr) { // Maybe the field is unknown because the class is partially // bogus. In that case, allow it for now; create a bogus field as // a placeholder. @@ -1200,7 +1200,7 @@ atomic_name: } else { $$ = field->as_atomic_field(); - if ($$ == (DCAtomicField *)NULL) { + if ($$ == nullptr) { yyerror("Not an atomic field: " + $1); } } @@ -1210,13 +1210,13 @@ atomic_name: molecular_atom_list: atomic_name { - if ($1 != (DCAtomicField *)NULL) { + if ($1 != nullptr) { current_molecular->add_atomic($1); } } | molecular_atom_list ',' atomic_name { - if ($3 != (DCAtomicField *)NULL) { + if ($3 != nullptr) { current_molecular->add_atomic($3); if (!$3->is_bogus_field() && !current_molecular->compare_keywords(*$3)) { yyerror("Mismatched keywords in molecule between " + @@ -1258,7 +1258,7 @@ switch_fields: { if (!current_switch->is_field_valid()) { yyerror("case declaration required before first element"); - } else if ($2 != (DCField *)NULL) { + } else if ($2 != nullptr) { if (!current_switch->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); } diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index bd1d6cd086..34f4e7e402 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -21,7 +21,7 @@ #include DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map; -DCClassParameter *DCSimpleParameter::_uint32uint8_type = NULL; +DCClassParameter *DCSimpleParameter::_uint32uint8_type = nullptr; /** * @@ -186,7 +186,7 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) : _nested_field = create_uint32uint8_type(); } else { - _nested_field = NULL; + _nested_field = nullptr; } } @@ -2173,7 +2173,7 @@ unpack_skip(const char *data, size_t length, size_t &p, void DCSimpleParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { @@ -2342,7 +2342,7 @@ do_check_match_array_parameter(const DCArrayParameter *other) const { // We cannot match a fixed-size array. return false; } - if (_nested_field == NULL) { + if (_nested_field == nullptr) { // Only an array-style simple parameter can match a DCArrayParameter. return false; } @@ -2374,8 +2374,8 @@ create_nested_field(DCSubatomicType type, unsigned int divisor) { */ DCPackerInterface *DCSimpleParameter:: create_uint32uint8_type() { - if (_uint32uint8_type == NULL) { - DCClass *dclass = new DCClass(NULL, "", true, false); + if (_uint32uint8_type == nullptr) { + DCClass *dclass = new DCClass(nullptr, "", true, false); dclass->add_field(new DCSimpleParameter(ST_uint32)); dclass->add_field(new DCSimpleParameter(ST_uint8)); _uint32uint8_type = new DCClassParameter(dclass); diff --git a/direct/src/dcparser/dcSwitch.cxx b/direct/src/dcparser/dcSwitch.cxx index 0215a9919c..ee3c70f7c5 100644 --- a/direct/src/dcparser/dcSwitch.cxx +++ b/direct/src/dcparser/dcSwitch.cxx @@ -27,7 +27,7 @@ DCSwitch(const string &name, DCField *key_parameter) : _name(name), _key_parameter(key_parameter) { - _default_case = NULL; + _default_case = nullptr; _fields_added = false; } @@ -36,7 +36,7 @@ DCSwitch(const string &name, DCField *key_parameter) : */ DCSwitch:: ~DCSwitch() { - nassertv(_key_parameter != (DCField *)NULL); + nassertv(_key_parameter != nullptr); delete _key_parameter; Cases::iterator ci; @@ -121,7 +121,7 @@ get_case_by_value(const string &case_value) const { */ DCPackerInterface *DCSwitch:: get_case(int n) const { - nassertr(n >= 0 && n < (int)_cases.size(), NULL); + nassertr(n >= 0 && n < (int)_cases.size(), nullptr); return _cases[n]->_fields; } @@ -157,8 +157,8 @@ get_num_fields(int case_index) const { */ DCField *DCSwitch:: get_field(int case_index, int n) const { - nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL); - nassertr(n >= 0 && n < (int)_cases[case_index]->_fields->_fields.size(), NULL); + nassertr(case_index >= 0 && case_index < (int)_cases.size(), nullptr); + nassertr(n >= 0 && n < (int)_cases[case_index]->_fields->_fields.size(), nullptr); return _cases[case_index]->_fields->_fields[n]; } @@ -168,7 +168,7 @@ get_field(int case_index, int n) const { */ DCField *DCSwitch:: get_field_by_name(int case_index, const string &name) const { - nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL); + nassertr(case_index >= 0 && case_index < (int)_cases.size(), nullptr); const FieldsByName &fields_by_name = _cases[case_index]->_fields->_fields_by_name; FieldsByName::const_iterator ni; @@ -177,7 +177,7 @@ get_field_by_name(int case_index, const string &name) const { return (*ni).second; } - return NULL; + return nullptr; } /** @@ -226,7 +226,7 @@ add_invalid_case() { */ bool DCSwitch:: add_default() { - if (_default_case != (SwitchFields *)NULL) { + if (_default_case != nullptr) { add_invalid_case(); return false; } @@ -286,12 +286,12 @@ apply_switch(const char *value_data, size_t length) const { } // Unexpected value--use the default. - if (_default_case != (SwitchFields *)NULL) { + if (_default_case != nullptr) { return _default_case; } // No default. - return NULL; + return nullptr; } /** @@ -326,26 +326,26 @@ output_instance(ostream &out, bool brief, const string &prename, _key_parameter->output(out, brief); out << ") {"; - const SwitchFields *last_fields = NULL; + const SwitchFields *last_fields = nullptr; Cases::const_iterator ci; for (ci = _cases.begin(); ci != _cases.end(); ++ci) { const SwitchCase *dcase = (*ci); - if (dcase->_fields != last_fields && last_fields != (SwitchFields *)NULL) { + if (dcase->_fields != last_fields && last_fields != nullptr) { last_fields->output(out, brief); } last_fields = dcase->_fields; out << "case " << _key_parameter->format_data(dcase->_value, false) << ": "; } - if (_default_case != (SwitchFields *)NULL) { - if (_default_case != last_fields && last_fields != (SwitchFields *)NULL) { + if (_default_case != nullptr) { + if (_default_case != last_fields && last_fields != nullptr) { last_fields->output(out, brief); } last_fields = _default_case; out << "default: "; } - if (last_fields != (SwitchFields *)NULL) { + if (last_fields != nullptr) { last_fields->output(out, brief); } @@ -372,12 +372,12 @@ write_instance(ostream &out, bool brief, int indent_level, _key_parameter->output(out, brief); out << ") {\n"; - const SwitchFields *last_fields = NULL; + const SwitchFields *last_fields = nullptr; Cases::const_iterator ci; for (ci = _cases.begin(); ci != _cases.end(); ++ci) { const SwitchCase *dcase = (*ci); - if (dcase->_fields != last_fields && last_fields != (SwitchFields *)NULL) { + if (dcase->_fields != last_fields && last_fields != nullptr) { last_fields->write(out, brief, indent_level + 2); } last_fields = dcase->_fields; @@ -385,15 +385,15 @@ write_instance(ostream &out, bool brief, int indent_level, << "case " << _key_parameter->format_data(dcase->_value, false) << ":\n"; } - if (_default_case != (SwitchFields *)NULL) { - if (_default_case != last_fields && last_fields != (SwitchFields *)NULL) { + if (_default_case != nullptr) { + if (_default_case != last_fields && last_fields != nullptr) { last_fields->write(out, brief, indent_level + 2); } last_fields = _default_case; indent(out, indent_level) << "default:\n"; } - if (last_fields != (SwitchFields *)NULL) { + if (last_fields != nullptr) { last_fields->write(out, brief, indent_level + 2); } @@ -428,7 +428,7 @@ generate_hash(HashGenerator &hashgen) const { } } - if (_default_case != (SwitchFields *)NULL) { + if (_default_case != nullptr) { const SwitchFields *fields = _default_case; hashgen.add_int(fields->_fields.size()); Fields::const_iterator fi; @@ -446,7 +446,7 @@ generate_hash(HashGenerator &hashgen) const { */ bool DCSwitch:: pack_default_value(DCPackData &pack_data, bool &pack_error) const { - SwitchFields *fields = NULL; + SwitchFields *fields = nullptr; DCPacker packer; packer.begin_pack(_key_parameter); if (!_cases.empty()) { @@ -466,7 +466,7 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { pack_error = true; } - if (fields == (SwitchFields *)NULL) { + if (fields == nullptr) { pack_error = true; } else { @@ -528,7 +528,7 @@ do_check_match_switch(const DCSwitch *other) const { */ DCSwitch::SwitchFields *DCSwitch:: start_new_case() { - SwitchFields *fields = NULL; + SwitchFields *fields = nullptr; if (_current_fields.empty() || _fields_added) { // If we have recently encountered a break (which removes all of the @@ -587,7 +587,7 @@ DCSwitch::SwitchFields:: */ DCPackerInterface *DCSwitch::SwitchFields:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_fields.size(), nullptr); return _fields[n]; } diff --git a/direct/src/dcparser/dcSwitchParameter.cxx b/direct/src/dcparser/dcSwitchParameter.cxx index 0dcc741861..8f3b7ccf00 100644 --- a/direct/src/dcparser/dcSwitchParameter.cxx +++ b/direct/src/dcparser/dcSwitchParameter.cxx @@ -66,7 +66,7 @@ DCSwitchParameter(const DCSwitch *dswitch) : // Also consider the default case, if there is one. const DCSwitch::SwitchFields *fields = (DCSwitch::SwitchFields *)_dswitch->get_default_case(); - if (fields != (DCSwitch::SwitchFields *)NULL) { + if (fields != nullptr) { if (!fields->has_fixed_byte_size() || fields->get_fixed_byte_size() != _fixed_byte_size) { _has_fixed_byte_size = false; @@ -155,7 +155,7 @@ apply_switch(const char *value_data, size_t length) const { void DCSwitchParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { @@ -171,7 +171,7 @@ void DCSwitchParameter:: write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { write_typedef_name(out, brief, indent_level, prename, name, postname); } else { diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index 6d65f16524..4f2712f148 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -60,10 +60,7 @@ #include #endif -using namespace std; - #define INLINE inline -#define TYPENAME typename // These symbols are used within the Panda environment for exporting classes // and functions to the scripting language. They're largely meaningless if @@ -82,7 +79,7 @@ using namespace std; // Panda defines a special Filename class. We'll use an ordinary string // instead. -typedef string Filename; +typedef std::string Filename; // Panda defines WORDS_BIGENDIAN on a bigendian machine; otherwise, the // machine is assumed to be littleendian. Outside of Panda, you're @@ -92,15 +89,15 @@ typedef string Filename; #include #include #include -#define pvector vector -#define pmap map -#define pset set +#define pvector std::vector +#define pmap std::map +#define pset std::set #include -typedef ifstream pifstream; -typedef ofstream pofstream; -typedef fstream pfstream; +typedef std::ifstream pifstream; +typedef std::ofstream pofstream; +typedef std::fstream pfstream; #endif // WITHIN_PANDA diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 1b4601fc41..027236579d 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -83,7 +83,7 @@ namespace { // If we can't open the process with PROCESS_TERMINATE rights, then we // give up immediately. hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, dwPID); - if(hProc == NULL) { + if(hProc == nullptr) { return TA_FAILED; } @@ -115,7 +115,7 @@ namespace { ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - if (CreateProcess(NULL, (char*)cmd.c_str(), + if (CreateProcess(nullptr, (char*)cmd.c_str(), 0, 0, 1, NORMAL_PRIORITY_CLASS, 0, 0, &si, &pi)) { pid=pi.dwProcessId; @@ -228,7 +228,7 @@ DirectD::start_app(const string& cmd) { ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - if (CreateProcess(NULL, (char*)cmd.c_str(), + if (CreateProcess(nullptr, (char*)cmd.c_str(), 0, 0, 1, NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED, 0, 0, &si, &pi)) { // The process must be created with CREATE_SUSPENDED to give us a chance diff --git a/direct/src/directdServer/directdClient.cxx b/direct/src/directdServer/directdClient.cxx index 550c3f2862..91059ed384 100644 --- a/direct/src/directdServer/directdClient.cxx +++ b/direct/src/directdServer/directdClient.cxx @@ -24,7 +24,7 @@ DirectDClient::cli_command(const string& cmd) { cerr<<"command "<> code; string host; @@ -49,7 +49,7 @@ DirectDClient::run_client(const string& host, int port) { connect_to(host, port); while (!cin.fail() && _connections.size()!=0) { - cout << "directd send: " << flush; + cout << "directd send: " << std::flush; string d; cin >> d; cli_command(d); diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index e247c2bd55..910edf7154 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -41,10 +41,10 @@ CConnectionRepository:: CConnectionRepository(bool has_owner_view, bool threaded_net) : _lock("CConnectionRepository::_lock"), #ifdef HAVE_PYTHON - _python_repository(NULL), + _python_repository(nullptr), #endif #ifdef HAVE_OPENSSL - _http_conn(NULL), + _http_conn(nullptr), #endif #ifdef HAVE_NET _cw(&_qcm, threaded_net ? 1 : 0), @@ -95,7 +95,7 @@ set_tcp_header_size(int tcp_header_size) { _tcp_header_size = tcp_header_size; #ifdef HAVE_OPENSSL - if (_http_conn != (SocketStream *)NULL) { + if (_http_conn != nullptr) { _http_conn->set_tcp_header_size(tcp_header_size); } #endif @@ -157,7 +157,7 @@ try_connect_net(const URLSpec &url) { _qcm.open_TCP_client_connection(url.get_server(), url.get_port(), game_server_timeout_ms); - if (_net_conn != (Connection *)NULL) { + if (_net_conn != nullptr) { _net_conn->set_no_delay(true); _qcr.add_connection(_net_conn); return true; @@ -209,7 +209,7 @@ start_delay(double min_delay, double max_delay) { _qcr.start_delay(min_delay, max_delay); #endif // HAVE_NET #ifdef HAVE_OPENSSL - if (_http_conn != (SocketStream *)NULL) { + if (_http_conn != nullptr) { _http_conn->start_delay(min_delay, max_delay); } #endif // HAVE_OPENSSL @@ -233,7 +233,7 @@ stop_delay() { _qcr.stop_delay(); #endif // HAVE_NET #ifdef HAVE_OPENSSL - if (_http_conn != (SocketStream *)NULL) { + if (_http_conn != nullptr) { _http_conn->stop_delay(); } #endif // HAVE_OPENSSL @@ -278,7 +278,7 @@ check_datagram() { #ifdef HAVE_PYTHON // For now, we need to stuff this field onto the Python structure, to // support legacy code that expects to find it there. - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_STATE gstate; gstate = PyGILState_Ensure(); @@ -353,7 +353,7 @@ is_connected() { _qcm.close_connection(reset_connection); if (reset_connection == _net_conn) { // Whoops, lost our connection. - _net_conn = NULL; + _net_conn = nullptr; return false; } } @@ -370,7 +370,7 @@ is_connected() { // Connection lost. delete _http_conn; - _http_conn = NULL; + _http_conn = nullptr; } #endif // HAVE_OPENSSL @@ -607,7 +607,7 @@ disconnect() { #ifdef HAVE_NET if (_net_conn) { _qcm.close_connection(_net_conn); - _net_conn = NULL; + _net_conn = nullptr; } #endif // HAVE_NET @@ -615,7 +615,7 @@ disconnect() { if (_http_conn) { _http_conn->close(); delete _http_conn; - _http_conn = NULL; + _http_conn = nullptr; } #endif // HAVE_OPENSSL @@ -684,11 +684,11 @@ handle_update_field() { PStatTimer timer(_update_pcollector); unsigned int do_id = _di.get_uint32(); - if (_python_repository != (PyObject *)NULL) + if (_python_repository != nullptr) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); - nassertr(doId2do != NULL, false); + nassertr(doId2do != nullptr, false); #ifdef USE_PYTHON_2_2_OR_EARLIER PyObject *doId = PyInt_FromLong(do_id); @@ -699,14 +699,14 @@ handle_update_field() { Py_DECREF(doId); Py_DECREF(doId2do); - if (distobj != NULL) { + if (distobj != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertr(dclass_obj != NULL, false); + nassertr(dclass_obj != nullptr, false); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertr(dclass_this != NULL, false); + nassertr(dclass_this != nullptr, false); DCClass *dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -715,7 +715,7 @@ handle_update_field() { // 'neverDisable' attribute set to non-zero if (_in_quiet_zone) { PyObject *neverDisable = PyObject_GetAttrString(distobj, "neverDisable"); - nassertr(neverDisable != NULL, false); + nassertr(neverDisable != nullptr, false); unsigned int cNeverDisable = PyLong_AsLong(neverDisable); if (!cNeverDisable) { @@ -772,14 +772,14 @@ handle_update_field_owner() { PStatTimer timer(_update_pcollector); unsigned int do_id = _di.get_uint32(); - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); - nassertr(doId2do != NULL, false); + nassertr(doId2do != nullptr, false); PyObject *doId2ownerView = PyObject_GetAttrString(_python_repository, "doId2ownerView"); - nassertr(doId2ownerView != NULL, false); + nassertr(doId2ownerView != nullptr, false); #ifdef USE_PYTHON_2_2_OR_EARLIER PyObject *doId = PyInt_FromLong(do_id); @@ -791,13 +791,13 @@ handle_update_field_owner() { PyObject *distobjOV = PyDict_GetItem(doId2ownerView, doId); Py_DECREF(doId2ownerView); - if (distobjOV != NULL) { + if (distobjOV != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobjOV, "dclass"); - nassertr(dclass_obj != NULL, false); + nassertr(dclass_obj != nullptr, false); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertr(dclass_this != NULL, false); + nassertr(dclass_this != nullptr, false); DCClass *dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -834,13 +834,13 @@ handle_update_field_owner() { Py_DECREF(doId); Py_DECREF(doId2do); - if (distobj != NULL) { + if (distobj != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertr(dclass_obj != NULL, false); + nassertr(dclass_obj != nullptr, false); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertr(dclass_this != NULL, false); + nassertr(dclass_this != nullptr, false); DCClass *dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -849,8 +849,9 @@ handle_update_field_owner() { vector_uchar data = _di.get_remaining_bytes(); DCPacker packer; packer.set_unpack_data((const char *)data.data(), data.size(), false); - int field_id = packer.raw_unpack_uint16(); - DCField *field = dclass->get_field_by_index(field_id); + + //int field_id = packer.raw_unpack_uint16(); + //DCField *field = dclass->get_field_by_index(field_id); if (true) {//field->is_broadcast()) { // It's a good idea to ensure the reference count to distobj is raised // while we call the update method--otherwise, the update method might @@ -914,19 +915,19 @@ describe_message(ostream &out, const string &prefix, string msgName; #ifdef HAVE_PYTHON - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { PyObject *msgId = PyLong_FromLong(msg_type); - nassertv(msgId != NULL); + nassertv(msgId != nullptr); #if PY_MAJOR_VERSION >= 3 PyObject *methodName = PyUnicode_FromString("_getMsgName"); #else PyObject *methodName = PyString_FromString("_getMsgName"); #endif - nassertv(methodName != NULL); + nassertv(methodName != nullptr); PyObject *result = PyObject_CallMethodObjArgs(_python_repository, methodName, - msgId, NULL); - nassertv(result != NULL); + msgId, nullptr); + nassertv(result != nullptr); #if PY_MAJOR_VERSION >= 3 msgName += string(PyUnicode_AsUTF8(result)); @@ -951,13 +952,13 @@ describe_message(ostream &out, const string &prefix, // It's an update message. Figure out what dclass the object is based on // its doId, so we can decode the rest of the message. do_id = packer.raw_unpack_uint32(); - DCClass *dclass = NULL; + DCClass *dclass = nullptr; #ifdef HAVE_PYTHON - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); - nassertv(doId2do != NULL); + nassertv(doId2do != nullptr); #ifdef USE_PYTHON_2_2_OR_EARLIER PyObject *doId = PyInt_FromLong(do_id); @@ -968,13 +969,13 @@ describe_message(ostream &out, const string &prefix, Py_DECREF(doId); Py_DECREF(doId2do); - if (distobj != NULL) { + if (distobj != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertv(dclass_obj != NULL); + nassertv(dclass_obj != nullptr); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertv(dclass_this != NULL); + nassertv(dclass_this != nullptr); dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -984,7 +985,7 @@ describe_message(ostream &out, const string &prefix, int field_id = packer.raw_unpack_uint16(); - if (dclass == (DCClass *)NULL) { + if (dclass == nullptr) { out << full_prefix << "update for unknown object " << do_id << ", field " << field_id << "\n"; @@ -992,7 +993,7 @@ describe_message(ostream &out, const string &prefix, out << full_prefix << ":" << dclass->get_name() << "(" << do_id << ")."; DCField *field = dclass->get_field_by_index(field_id); - if (field == (DCField *)NULL) { + if (field == nullptr) { out << "unknown field " << field_id << "\n"; } else { diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.cxx b/direct/src/distributed/cDistributedSmoothNodeBase.cxx index 14a665d9b9..37c69daaca 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.cxx +++ b/direct/src/distributed/cDistributedSmoothNodeBase.cxx @@ -26,12 +26,12 @@ static const double network_time_precision = 100.0; // Matches ClockDelta.py */ CDistributedSmoothNodeBase:: CDistributedSmoothNodeBase() { - _repository = NULL; + _repository = nullptr; _is_ai = false; _ai_id = 0; #ifdef HAVE_PYTHON - _clock_delta = NULL; + _clock_delta = nullptr; #endif _currL[0] = 0; @@ -270,7 +270,7 @@ broadcast_pos_hpr_xy() { void CDistributedSmoothNodeBase:: begin_send_update(DCPacker &packer, const string &field_name) { DCField *field = _dclass->get_field_by_name(field_name); - nassertv(field != (DCField *)NULL); + nassertv(field != nullptr); if (_is_ai) { @@ -298,9 +298,9 @@ begin_send_update(DCPacker &packer, const string &field_name) { void CDistributedSmoothNodeBase:: finish_send_update(DCPacker &packer) { #ifdef HAVE_PYTHON - nassertv(_clock_delta != NULL); + nassertv(_clock_delta != nullptr); PyObject *clock_delta = PyObject_GetAttrString(_clock_delta, "delta"); - nassertv(clock_delta != NULL); + nassertv(clock_delta != nullptr); double delta = PyFloat_AsDouble(clock_delta); Py_DECREF(clock_delta); #else @@ -319,7 +319,7 @@ finish_send_update(DCPacker &packer) { bool pack_ok = packer.end_pack(); if (pack_ok) { Datagram dg(packer.get_data(), packer.get_length()); - nassertv(_repository != NULL); + nassertv(_repository != nullptr); _repository->send_datagram(dg); } else { diff --git a/direct/src/interval/cIntervalManager.cxx b/direct/src/interval/cIntervalManager.cxx index bd6189b349..104c9e0953 100644 --- a/direct/src/interval/cIntervalManager.cxx +++ b/direct/src/interval/cIntervalManager.cxx @@ -125,7 +125,7 @@ CInterval *CIntervalManager:: get_c_interval(int index) const { MutexHolder holder(_lock); - nassertr(index >= 0 && index < (int)_intervals.size(), NULL); + nassertr(index >= 0 && index < (int)_intervals.size(), nullptr); return _intervals[index]._interval; } @@ -140,14 +140,14 @@ remove_c_interval(int index) { nassertv(index >= 0 && index < (int)_intervals.size()); IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); NameIndex::iterator ni = _name_index.find(def._interval->get_name()); nassertv(ni != _name_index.end()); nassertv((*ni).second == index); _name_index.erase(ni); - def._interval = (CInterval *)NULL; + def._interval = nullptr; def._next_slot = _first_slot; _first_slot = index; } @@ -171,7 +171,7 @@ interrupt() { while (ni != _name_index.end()) { int index = (*ni).second; const IntervalDef &def = _intervals[index]; - nassertr(def._interval != (CInterval *)NULL, num_paused); + nassertr(def._interval != nullptr, num_paused); if (def._interval->get_auto_pause() || def._interval->get_auto_finish()) { // This interval may be interrupted. if (def._interval->get_auto_pause()) { @@ -262,7 +262,7 @@ step() { while (ni != _name_index.end()) { int index = (*ni).second; const IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); if (!def._interval->step_play()) { // This interval is finished and wants to be removed from the active // list. @@ -299,7 +299,7 @@ get_next_event() { while (_next_event_index < (int)_intervals.size()) { IntervalDef &def = _intervals[_next_event_index]; - if (def._interval != (CInterval *)NULL) { + if (def._interval != nullptr) { if ((def._flags & F_external) != 0 && def._interval->check_t_callback()) { return _next_event_index; @@ -338,7 +338,7 @@ get_next_removal() { nassertr(index >= 0 && index < (int)_intervals.size(), -1); IntervalDef &def = _intervals[index]; - def._interval = (CInterval *)NULL; + def._interval = nullptr; def._next_slot = _first_slot; _first_slot = index; return index; @@ -373,7 +373,7 @@ write(ostream &out) const { int index = (*ni).second; nassertv(index >= 0 && index < (int)_intervals.size()); const IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); out << *def._interval << "\n"; } @@ -384,7 +384,7 @@ write(ostream &out) const { int index = (*ri); nassertv(index >= 0 && index < (int)_intervals.size()); const IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); out << "(R)" << *def._interval << "\n"; } } @@ -395,7 +395,7 @@ write(ostream &out) const { */ CIntervalManager *CIntervalManager:: get_global_ptr() { - if (_global_ptr == (CIntervalManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new CIntervalManager; } return _global_ptr; @@ -433,7 +433,7 @@ remove_index(int index) { if ((def._flags & F_external) != 0) { _removed.push_back(index); } else { - def._interval = (CInterval *)NULL; + def._interval = nullptr; def._next_slot = _first_slot; _first_slot = index; } diff --git a/direct/src/interval/cLerpNodePathInterval.cxx b/direct/src/interval/cLerpNodePathInterval.cxx index 8c9423106f..12286ce3d8 100644 --- a/direct/src/interval/cLerpNodePathInterval.cxx +++ b/direct/src/interval/cLerpNodePathInterval.cxx @@ -57,7 +57,7 @@ CLerpNodePathInterval(const string &name, double duration, _flags(0), _texture_stage(TextureStage::get_default()), _override(0), - _slerp(NULL) + _slerp(nullptr) { if (bake_in_start) { _flags |= F_bake_in_start; @@ -191,7 +191,7 @@ priv_step(double t) { _flags &= ~F_slerp_setup; } } - nassertv(_slerp != NULL); + nassertv(_slerp != nullptr); (this->*_slerp)(quat, d); } if ((_flags & F_end_scale) != 0) { @@ -404,7 +404,7 @@ priv_step(double t) { color.set(1.0f, 1.0f, 1.0f, 1.0f); const RenderAttrib *attrib = state->get_attrib(ColorAttrib::get_class_type()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attrib); if (ca->get_color_type() == ColorAttrib::T_flat) { color = ca->get_color(); @@ -428,7 +428,7 @@ priv_step(double t) { color_scale.set(1.0f, 1.0f, 1.0f, 1.0f); const RenderAttrib *attrib = state->get_attrib(ColorScaleAttrib::get_class_type()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); color_scale = csa->get_scale(); } @@ -446,7 +446,7 @@ priv_step(double t) { const RenderAttrib *attrib = state->get_attrib(TexMatrixAttrib::get_class_type()); CPT(TexMatrixAttrib) tma; - if (attrib != (const TexMatrixAttrib *)NULL) { + if (attrib != nullptr) { tma = DCAST(TexMatrixAttrib, attrib); transform = tma->get_transform(_texture_stage); } else { diff --git a/direct/src/interval/cMetaInterval.I b/direct/src/interval/cMetaInterval.I index ae30cd9792..0140e6e019 100644 --- a/direct/src/interval/cMetaInterval.I +++ b/direct/src/interval/cMetaInterval.I @@ -58,8 +58,8 @@ get_def_type(int n) const { */ INLINE CInterval *CMetaInterval:: get_c_interval(int n) const { - nassertr(n >= 0 && n < (int)_defs.size(), NULL); - nassertr(_defs[n]._type == DT_c_interval, NULL); + nassertr(n >= 0 && n < (int)_defs.size(), nullptr); + nassertr(_defs[n]._type == DT_c_interval, nullptr); return _defs[n]._c_interval; } diff --git a/direct/src/interval/cMetaInterval.cxx b/direct/src/interval/cMetaInterval.cxx index dd5f1386f2..2b764187bc 100644 --- a/direct/src/interval/cMetaInterval.cxx +++ b/direct/src/interval/cMetaInterval.cxx @@ -66,7 +66,7 @@ clear_intervals() { Defs::iterator di; for (di = _defs.begin(); di != _defs.end(); ++di) { IntervalDef &def = (*di); - if (def._c_interval != (CInterval *)NULL) { + if (def._c_interval != nullptr) { CInterval::Parents::iterator pi = find(def._c_interval->_parents.begin(), def._c_interval->_parents.end(), @@ -122,7 +122,7 @@ int CMetaInterval:: add_c_interval(CInterval *c_interval, double rel_time, RelativeStart rel_to) { nassertr(_event_queue.empty() && !_processing_events, -1); - nassertr(c_interval != (CInterval *)NULL, -1); + nassertr(c_interval != nullptr, -1); c_interval->_parents.push_back(this); c_interval->_ival_pcollector = PStatCollector(_ival_pcollector, c_interval->_pname); @@ -756,7 +756,7 @@ do_recompute() { // We do a stable_sort() to guarantee ordering of events that have the same // start time. These must be invoked in the order in which they appear. - stable_sort(_events.begin(), _events.end(), IndirectLess()); + std::stable_sort(_events.begin(), _events.end(), IndirectLess()); _duration = int_to_double_time(_end_time); } diff --git a/direct/src/motiontrail/cMotionTrail.cxx b/direct/src/motiontrail/cMotionTrail.cxx index 988a59c5dc..e578ea2f63 100644 --- a/direct/src/motiontrail/cMotionTrail.cxx +++ b/direct/src/motiontrail/cMotionTrail.cxx @@ -55,14 +55,14 @@ CMotionTrail ( ) { _resolution_distance = 0.5f; // node path states - _geom_node = 0; + _geom_node = nullptr; // real-time data _vertex_index = 0; - _vertex_data = 0; - _triangles = 0; + _vertex_data = nullptr; + _triangles = nullptr; - _vertex_array = 0; + _vertex_array = nullptr; } /** @@ -298,7 +298,7 @@ add_geometry_quad (LVector4 &v0, LVector4 &v1, LVector4 &v2, LVector4 &v3, LVect */ void CMotionTrail::end_geometry ( ) { static CPT(RenderState) state; - if (state == (RenderState *)NULL) { + if (state == nullptr) { state = RenderState::make(ColorAttrib::make_vertex()); } @@ -674,7 +674,7 @@ update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform) { } for (index = 0; index < total_vertices; index++) { - nurbs_curve_result_array [index] = 0; + nurbs_curve_result_array [index] = nullptr; } delete[] nurbs_curve_result_array; @@ -804,6 +804,6 @@ update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform) { this -> end_geometry ( ); delete[] _vertex_array; - _vertex_array = 0; + _vertex_array = nullptr; } } diff --git a/direct/src/plugin/binaryXml.cxx b/direct/src/plugin/binaryXml.cxx index 6363f12d8e..4840a2c1e2 100644 --- a/direct/src/plugin/binaryXml.cxx +++ b/direct/src/plugin/binaryXml.cxx @@ -69,11 +69,11 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { // Now write out the node type. NodeType type = NT_element; - if (xnode->ToDocument() != NULL) { + if (xnode->ToDocument() != nullptr) { type = NT_document; - } else if (xnode->ToElement() != NULL) { + } else if (xnode->ToElement() != nullptr) { type = NT_element; - } else if (xnode->ToText() != NULL) { + } else if (xnode->ToText() != nullptr) { type = NT_text; } else { type = NT_unknown; @@ -88,10 +88,10 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { if (type == NT_element) { // Write the element attributes. TiXmlElement *xelement = xnode->ToElement(); - assert(xelement != NULL); + assert(xelement != nullptr); const TiXmlAttribute *xattrib = xelement->FirstAttribute(); - while (xattrib != NULL) { + while (xattrib != nullptr) { // We have an attribute. out.put((char)true); @@ -114,7 +114,7 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { // Now write all of the children. TiXmlNode *xchild = xnode->FirstChild(); - while (xchild != NULL) { + while (xchild != nullptr) { // We have a child. out.put((char)true); write_xml_node(out, xchild); @@ -136,13 +136,13 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, xml_uint32 value_length; in.read((char *)&value_length, sizeof(value_length)); if (in.gcount() != sizeof(value_length)) { - return NULL; + return nullptr; } xml_uint32 value_proof_expect = (value_length + length_nonce1) * length_nonce2; xml_uint32 value_proof; in.read((char *)&value_proof, sizeof(value_proof)); if (in.gcount() != sizeof(value_proof)) { - return NULL; + return nullptr; } if (value_proof != value_proof_expect) { // Hey, we ran into garbage: the proof value didn't match our expected @@ -164,7 +164,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, } logfile << "\n"; logfile << "End garbage.\n"; - return NULL; + return nullptr; } if (value_length > buffer_length) { @@ -179,10 +179,10 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, // Read the node type. NodeType type = (NodeType)in.get(); if (type == NT_unknown) { - return NULL; + return nullptr; } - TiXmlNode *xnode = NULL; + TiXmlNode *xnode = nullptr; if (type == NT_element) { xnode = new TiXmlElement(value); } else if (type == NT_document) { @@ -196,7 +196,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, if (type == NT_element) { // Read the element attributes. TiXmlElement *xelement = xnode->ToElement(); - assert(xelement != NULL); + assert(xelement != nullptr); bool got_attrib = (bool)(in.get() != 0); while (got_attrib && in && !in.eof()) { @@ -205,7 +205,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, in.read((char *)&name_length, sizeof(name_length)); if (in.gcount() != sizeof(name_length)) { delete xnode; - return NULL; + return nullptr; } if (name_length > buffer_length) { @@ -221,7 +221,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, in.read((char *)&value_length, sizeof(value_length)); if (in.gcount() != sizeof(value_length)) { delete xnode; - return NULL; + return nullptr; } if (value_length > buffer_length) { @@ -245,7 +245,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, while (got_child && in && !in.eof()) { // We have a child. TiXmlNode *xchild = read_xml_node(in, buffer, buffer_length, logfile); - if (xchild != NULL) { + if (xchild != nullptr) { xnode->LinkEndChild(xchild); } @@ -317,12 +317,12 @@ read_xml(istream &in, ostream &logfile) { char *buffer = new char[buffer_length]; TiXmlNode *xnode = read_xml_node(in, buffer, buffer_length, logfile); delete[] buffer; - if (xnode == NULL) { - return NULL; + if (xnode == nullptr) { + return nullptr; } TiXmlDocument *doc = xnode->ToDocument(); - assert(doc != NULL); + assert(doc != nullptr); #else // standard ASCII read. @@ -330,7 +330,7 @@ read_xml(istream &in, ostream &logfile) { in >> *doc; if (in.fail() || in.eof()) { delete doc; - return NULL; + return nullptr; } #endif diff --git a/direct/src/plugin/fileSpec.cxx b/direct/src/plugin/fileSpec.cxx index 58194c10f2..29f22e9899 100644 --- a/direct/src/plugin/fileSpec.cxx +++ b/direct/src/plugin/fileSpec.cxx @@ -42,7 +42,7 @@ FileSpec() { _timestamp = 0; memset(_hash, 0, hash_size); _got_hash = false; - _actual_file = NULL; + _actual_file = nullptr; } /** @@ -56,7 +56,7 @@ FileSpec(const FileSpec ©) : _got_hash(copy._got_hash) { memcpy(_hash, copy._hash, hash_size); - _actual_file = NULL; + _actual_file = nullptr; } /** @@ -76,7 +76,7 @@ operator = (const FileSpec ©) { */ FileSpec:: ~FileSpec() { - if (_actual_file != NULL) { + if (_actual_file != nullptr) { delete _actual_file; } } @@ -87,25 +87,25 @@ FileSpec:: void FileSpec:: load_xml(TiXmlElement *xelement) { const char *filename = xelement->Attribute("filename"); - if (filename != NULL) { + if (filename != nullptr) { _filename = filename; } const char *size = xelement->Attribute("size"); - if (size != NULL) { + if (size != nullptr) { char *endptr; _size = strtoul(size, &endptr, 10); } const char *timestamp = xelement->Attribute("timestamp"); - if (timestamp != NULL) { + if (timestamp != nullptr) { char *endptr; _timestamp = strtoul(timestamp, &endptr, 10); } _got_hash = false; const char *hash = xelement->Attribute("hash"); - if (hash != NULL && strlen(hash) == (hash_size * 2)) { + if (hash != nullptr && strlen(hash) == (hash_size * 2)) { // Decode the hex hash string. _got_hash = decode_hex(_hash, hash, hash_size); } @@ -151,9 +151,9 @@ quick_verify(const string &package_dir) { */ bool FileSpec:: quick_verify_pathname(const string &pathname) { - if (_actual_file != NULL) { + if (_actual_file != nullptr) { delete _actual_file; - _actual_file = NULL; + _actual_file = nullptr; } int result = 1; @@ -221,9 +221,9 @@ quick_verify_pathname(const string &pathname) { */ bool FileSpec:: full_verify(const string &package_dir) { - if (_actual_file != NULL) { + if (_actual_file != nullptr) { delete _actual_file; - _actual_file = NULL; + _actual_file = nullptr; } string pathname = get_pathname(package_dir); @@ -281,7 +281,7 @@ full_verify(const string &package_dir) { */ const FileSpec *FileSpec:: force_get_actual_file(const string &pathname) { - if (_actual_file == NULL) { + if (_actual_file == nullptr) { #ifdef _WIN32 struct _stat st; wstring pathname_w; @@ -418,7 +418,7 @@ output_hash(ostream &out) const { bool FileSpec:: priv_check_hash(const string &pathname, void *stp) { const struct stat &st = *(const struct stat *)stp; - assert(_actual_file == NULL); + assert(_actual_file == nullptr); _actual_file = new FileSpec; _actual_file->_filename = pathname; _actual_file->_size = st.st_size; diff --git a/direct/src/plugin/find_root_dir.cxx b/direct/src/plugin/find_root_dir.cxx index 0cf4546a0e..d15362bfd0 100644 --- a/direct/src/plugin/find_root_dir.cxx +++ b/direct/src/plugin/find_root_dir.cxx @@ -46,7 +46,7 @@ static wstring get_csidl_dir_w(int csidl) { static const int buffer_size = MAX_PATH; wchar_t buffer[buffer_size]; - if (SHGetSpecialFolderPathW(NULL, buffer, csidl, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, csidl, true)) { wstring root = buffer; root += wstring(L"/Panda3D"); @@ -73,10 +73,10 @@ find_root_dir_default_w() { wstring root; bool is_protected = false; HMODULE ieframe = LoadLibrary("ieframe.dll"); - if (ieframe != NULL) { + if (ieframe != nullptr) { typedef HRESULT STDAPICALLTYPE IEIsProtectedModeProcess(BOOL *pbResult); IEIsProtectedModeProcess *func = (IEIsProtectedModeProcess *)GetProcAddress(ieframe, "IEIsProtectedModeProcess"); - if (func != NULL) { + if (func != nullptr) { BOOL result = false; HRESULT hr = (*func)(&result); if (hr == S_OK) { @@ -101,12 +101,12 @@ find_root_dir_default_w() { // instead of hard-linking it. HMODULE shell32 = LoadLibrary("shell32.dll"); - if (shell32 != NULL) { + if (shell32 != nullptr) { typedef HRESULT STDAPICALLTYPE SHGetKnownFolderPath(REFGUID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); SHGetKnownFolderPath *func = (SHGetKnownFolderPath *)GetProcAddress(shell32, "SHGetKnownFolderPath"); - if (func != NULL) { - LPWSTR cache_path = NULL; - HRESULT hr = (*func)(FOLDERID_LocalAppDataLow, 0, NULL, &cache_path); + if (func != nullptr) { + LPWSTR cache_path = nullptr; + HRESULT hr = (*func)(FOLDERID_LocalAppDataLow, 0, nullptr, &cache_path); if (SUCCEEDED(hr)) { root = cache_path; @@ -128,8 +128,8 @@ find_root_dir_default_w() { // cache folder. typedef HRESULT STDAPICALLTYPE IEGetWriteableFolderPath(REFGUID clsidFolderID, LPWSTR* lppwstrPath); IEGetWriteableFolderPath *func = (IEGetWriteableFolderPath *)GetProcAddress(ieframe, "IEGetWriteableFolderPath"); - if (func != NULL) { - LPWSTR cache_path = NULL; + if (func != nullptr) { + LPWSTR cache_path = nullptr; // Since we're here, we'll start by asking for LocalAppDataLow, even // though I know it doesn't work. @@ -218,9 +218,9 @@ find_root_dir_default() { string root; const passwd *pwdata = getpwuid(getuid()); - if (pwdata == NULL) { + if (pwdata == nullptr) { char *home = getenv("HOME"); - if (home == NULL) { + if (home == nullptr) { // Beh. Let's hope it never gets to this point. return "."; } else { @@ -260,13 +260,13 @@ find_root_dir_actual() { } TiXmlElement *xconfig = doc.FirstChildElement("config"); - if (xconfig == NULL) { + if (xconfig == nullptr) { // No element within config.xml. return root; } const char *new_root = xconfig->Attribute("root_dir"); - if (new_root == NULL || *new_root == '\0') { + if (new_root == nullptr || *new_root == '\0') { // No root_dir specified. return root; } @@ -295,7 +295,7 @@ find_root_dir() { wstring root_w; string_to_wstring(root_w, root); - DWORD length = GetShortPathNameW(root_w.c_str(), NULL, 0); + DWORD length = GetShortPathNameW(root_w.c_str(), nullptr, 0); wchar_t *short_name = new wchar_t[length]; GetShortPathNameW(root_w.c_str(), short_name, length); diff --git a/direct/src/plugin/handleStreamBuf.cxx b/direct/src/plugin/handleStreamBuf.cxx index c3aa4dc76f..c2adbd2f62 100644 --- a/direct/src/plugin/handleStreamBuf.cxx +++ b/direct/src/plugin/handleStreamBuf.cxx @@ -120,10 +120,10 @@ close() { void HandleStreamBuf:: close_handle() { #ifdef _WIN32 - if (_handle != NULL) { + if (_handle != nullptr) { CloseHandle(_handle); } - _handle = NULL; + _handle = nullptr; #else if (_handle != -1) { ::close(_handle); @@ -256,7 +256,7 @@ read_chars(char *start, size_t length) { #ifdef _WIN32 // Windows case. DWORD bytes_read = 0; - BOOL success = ReadFile(_handle, start, length, &bytes_read, NULL); + BOOL success = ReadFile(_handle, start, length, &bytes_read, nullptr); if (!success) { DWORD error = GetLastError(); if (error != ERROR_HANDLE_EOF && error != ERROR_BROKEN_PIPE) { @@ -304,7 +304,7 @@ write_chars(const char *start, size_t length) { #ifdef _WIN32 // Windows case. DWORD bytes_written = 0; - BOOL success = WriteFile(_handle, start, length, &bytes_written, NULL); + BOOL success = WriteFile(_handle, start, length, &bytes_written, nullptr); if (!success) { assert(bytes_written <= length); DWORD error = GetLastError(); diff --git a/direct/src/plugin/load_plugin.cxx b/direct/src/plugin/load_plugin.cxx index f5a730eacb..f46cb7355d 100644 --- a/direct/src/plugin/load_plugin.cxx +++ b/direct/src/plugin/load_plugin.cxx @@ -75,9 +75,9 @@ P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream_ptr; P3D_instance_handle_event_func *P3D_instance_handle_event_ptr; #ifdef _WIN32 -static HMODULE module = NULL; +static HMODULE module = nullptr; #else -static void *module = NULL; +static void *module = nullptr; #endif static bool plugin_loaded = false; @@ -139,11 +139,11 @@ load_plugin(const string &p3d_plugin_filename, string filename = p3d_plugin_filename; #ifdef _WIN32 - assert(module == NULL); + assert(module == nullptr); if (filename.empty()) { // If no filename is supplied, look within our existing address space. - module = GetModuleHandle(NULL); + module = GetModuleHandle(nullptr); dso_needs_unload = false; } else { @@ -168,7 +168,7 @@ load_plugin(const string &p3d_plugin_filename, dso_needs_unload = true; } - if (module == NULL) { + if (module == nullptr) { // Couldn't load the DLL. logfile << "Couldn't load " << filename << ", error = " @@ -180,16 +180,16 @@ load_plugin(const string &p3d_plugin_filename, #else // _WIN32 // Posix case. - assert(module == NULL); + assert(module == nullptr); if (filename.empty()) { - module = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); + module = dlopen(nullptr, RTLD_LAZY | RTLD_LOCAL); } else { module = dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL); } - if (module == NULL) { + if (module == nullptr) { // Couldn't load the .so. const char *message = dlerror(); - if (message == (char *)NULL) { + if (message == nullptr) { message = "No error"; } logfile << "Couldn't load " << filename << ": " << message << "\n"; @@ -276,45 +276,45 @@ init_plugin(const string &contents_filename, const string &host_url, const string &start_dir, ostream &logfile) { // Ensure that all of the function pointers have been found. - if (P3D_initialize_ptr == NULL || - P3D_finalize_ptr == NULL || - P3D_set_plugin_version_ptr == NULL || - P3D_set_super_mirror_ptr == NULL || - P3D_new_instance_ptr == NULL || - P3D_instance_start_ptr == NULL || - P3D_instance_start_stream_ptr == NULL || - P3D_instance_finish_ptr == NULL || - P3D_instance_setup_window_ptr == NULL || + if (P3D_initialize_ptr == nullptr || + P3D_finalize_ptr == nullptr || + P3D_set_plugin_version_ptr == nullptr || + P3D_set_super_mirror_ptr == nullptr || + P3D_new_instance_ptr == nullptr || + P3D_instance_start_ptr == nullptr || + P3D_instance_start_stream_ptr == nullptr || + P3D_instance_finish_ptr == nullptr || + P3D_instance_setup_window_ptr == nullptr || - P3D_object_get_type_ptr == NULL || - P3D_object_get_bool_ptr == NULL || - P3D_object_get_int_ptr == NULL || - P3D_object_get_float_ptr == NULL || - P3D_object_get_string_ptr == NULL || - P3D_object_get_repr_ptr == NULL || - P3D_object_get_property_ptr == NULL || - P3D_object_set_property_ptr == NULL || - P3D_object_has_method_ptr == NULL || - P3D_object_call_ptr == NULL || - P3D_object_eval_ptr == NULL || - P3D_object_incref_ptr == NULL || - P3D_object_decref_ptr == NULL || + P3D_object_get_type_ptr == nullptr || + P3D_object_get_bool_ptr == nullptr || + P3D_object_get_int_ptr == nullptr || + P3D_object_get_float_ptr == nullptr || + P3D_object_get_string_ptr == nullptr || + P3D_object_get_repr_ptr == nullptr || + P3D_object_get_property_ptr == nullptr || + P3D_object_set_property_ptr == nullptr || + P3D_object_has_method_ptr == nullptr || + P3D_object_call_ptr == nullptr || + P3D_object_eval_ptr == nullptr || + P3D_object_incref_ptr == nullptr || + P3D_object_decref_ptr == nullptr || - P3D_make_class_definition_ptr == NULL || - P3D_new_undefined_object_ptr == NULL || - P3D_new_none_object_ptr == NULL || - P3D_new_bool_object_ptr == NULL || - P3D_new_int_object_ptr == NULL || - P3D_new_float_object_ptr == NULL || - P3D_new_string_object_ptr == NULL || - P3D_instance_get_panda_script_object_ptr == NULL || - P3D_instance_set_browser_script_object_ptr == NULL || + P3D_make_class_definition_ptr == nullptr || + P3D_new_undefined_object_ptr == nullptr || + P3D_new_none_object_ptr == nullptr || + P3D_new_bool_object_ptr == nullptr || + P3D_new_int_object_ptr == nullptr || + P3D_new_float_object_ptr == nullptr || + P3D_new_string_object_ptr == nullptr || + P3D_instance_get_panda_script_object_ptr == nullptr || + P3D_instance_set_browser_script_object_ptr == nullptr || - P3D_instance_get_request_ptr == NULL || - P3D_check_request_ptr == NULL || - P3D_request_finish_ptr == NULL || - P3D_instance_feed_url_stream_ptr == NULL || - P3D_instance_handle_event_ptr == NULL) { + P3D_instance_get_request_ptr == nullptr || + P3D_check_request_ptr == nullptr || + P3D_request_finish_ptr == nullptr || + P3D_instance_feed_url_stream_ptr == nullptr || + P3D_instance_handle_event_ptr == nullptr) { logfile << "Some function pointers not found:" @@ -411,55 +411,55 @@ unload_plugin(ostream &logfile) { static void unload_dso() { if (dso_needs_unload) { - assert(module != NULL); + assert(module != nullptr); #ifdef _WIN32 FreeLibrary(module); #else dlclose(module); #endif - module = NULL; + module = nullptr; dso_needs_unload = false; } - P3D_initialize_ptr = NULL; - P3D_finalize_ptr = NULL; - P3D_set_plugin_version_ptr = NULL; - P3D_set_super_mirror_ptr = NULL; - P3D_new_instance_ptr = NULL; - P3D_instance_start_ptr = NULL; - P3D_instance_start_stream_ptr = NULL; - P3D_instance_finish_ptr = NULL; - P3D_instance_setup_window_ptr = NULL; + P3D_initialize_ptr = nullptr; + P3D_finalize_ptr = nullptr; + P3D_set_plugin_version_ptr = nullptr; + P3D_set_super_mirror_ptr = nullptr; + P3D_new_instance_ptr = nullptr; + P3D_instance_start_ptr = nullptr; + P3D_instance_start_stream_ptr = nullptr; + P3D_instance_finish_ptr = nullptr; + P3D_instance_setup_window_ptr = nullptr; - P3D_object_get_type_ptr = NULL; - P3D_object_get_bool_ptr = NULL; - P3D_object_get_int_ptr = NULL; - P3D_object_get_float_ptr = NULL; - P3D_object_get_string_ptr = NULL; - P3D_object_get_repr_ptr = NULL; - P3D_object_get_property_ptr = NULL; - P3D_object_set_property_ptr = NULL; - P3D_object_has_method_ptr = NULL; - P3D_object_call_ptr = NULL; - P3D_object_eval_ptr = NULL; - P3D_object_incref_ptr = NULL; - P3D_object_decref_ptr = NULL; + P3D_object_get_type_ptr = nullptr; + P3D_object_get_bool_ptr = nullptr; + P3D_object_get_int_ptr = nullptr; + P3D_object_get_float_ptr = nullptr; + P3D_object_get_string_ptr = nullptr; + P3D_object_get_repr_ptr = nullptr; + P3D_object_get_property_ptr = nullptr; + P3D_object_set_property_ptr = nullptr; + P3D_object_has_method_ptr = nullptr; + P3D_object_call_ptr = nullptr; + P3D_object_eval_ptr = nullptr; + P3D_object_incref_ptr = nullptr; + P3D_object_decref_ptr = nullptr; - P3D_make_class_definition_ptr = NULL; - P3D_new_undefined_object_ptr = NULL; - P3D_new_none_object_ptr = NULL; - P3D_new_bool_object_ptr = NULL; - P3D_new_int_object_ptr = NULL; - P3D_new_float_object_ptr = NULL; - P3D_new_string_object_ptr = NULL; - P3D_instance_get_panda_script_object_ptr = NULL; - P3D_instance_set_browser_script_object_ptr = NULL; + P3D_make_class_definition_ptr = nullptr; + P3D_new_undefined_object_ptr = nullptr; + P3D_new_none_object_ptr = nullptr; + P3D_new_bool_object_ptr = nullptr; + P3D_new_int_object_ptr = nullptr; + P3D_new_float_object_ptr = nullptr; + P3D_new_string_object_ptr = nullptr; + P3D_instance_get_panda_script_object_ptr = nullptr; + P3D_instance_set_browser_script_object_ptr = nullptr; - P3D_instance_get_request_ptr = NULL; - P3D_check_request_ptr = NULL; - P3D_request_finish_ptr = NULL; - P3D_instance_feed_url_stream_ptr = NULL; - P3D_instance_handle_event_ptr = NULL; + P3D_instance_get_request_ptr = nullptr; + P3D_check_request_ptr = nullptr; + P3D_request_finish_ptr = nullptr; + P3D_instance_feed_url_stream_ptr = nullptr; + P3D_instance_handle_event_ptr = nullptr; plugin_loaded = false; } diff --git a/direct/src/plugin/mkdir_complete.cxx b/direct/src/plugin/mkdir_complete.cxx index 9422ea2e32..8b721f1fa8 100644 --- a/direct/src/plugin/mkdir_complete.cxx +++ b/direct/src/plugin/mkdir_complete.cxx @@ -154,7 +154,7 @@ mkfile_complete(const string &filename, ostream &logfile) { */ bool mkdir_complete_w(const wstring &dirname, ostream &logfile) { - if (CreateDirectoryW(dirname.c_str(), NULL) != 0) { + if (CreateDirectoryW(dirname.c_str(), nullptr) != 0) { // Success! return true; } @@ -171,7 +171,7 @@ mkdir_complete_w(const wstring &dirname, ostream &logfile) { wstring parent = get_dirname_w(dirname); if (!parent.empty() && mkdir_complete_w(parent, logfile)) { // Parent successfully created. Try again to make the child. - if (CreateDirectoryW(dirname.c_str(), NULL) != 0) { + if (CreateDirectoryW(dirname.c_str(), nullptr) != 0) { // Got it! return true; } @@ -198,7 +198,7 @@ mkfile_complete_w(const wstring &filename, ostream &logfile) { HANDLE file = CreateFileW(filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (file == INVALID_HANDLE_VALUE) { // Try to make the parent directory first. wstring parent = get_dirname_w(filename); @@ -206,7 +206,7 @@ mkfile_complete_w(const wstring &filename, ostream &logfile) { // Parent successfully created. Try again to make the file. file = CreateFileW(filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); } if (file == INVALID_HANDLE_VALUE) { logfile diff --git a/direct/src/plugin/p3dAuthSession.cxx b/direct/src/plugin/p3dAuthSession.cxx index 46678c19ad..15363647f9 100644 --- a/direct/src/plugin/p3dAuthSession.cxx +++ b/direct/src/plugin/p3dAuthSession.cxx @@ -53,7 +53,7 @@ P3DAuthSession(P3DInstance *inst) : _cert_filename = new P3DTemporaryFile(".crt"); string filename = _cert_filename->get_filename(); FILE *fp = fopen(filename.c_str(), "w"); - if (fp == NULL) { + if (fp == nullptr) { nout << "Couldn't write temporary file\n"; return; } @@ -88,7 +88,7 @@ P3DAuthSession:: ~P3DAuthSession() { shutdown(false); - if (_cert_filename != NULL) { + if (_cert_filename != nullptr) { delete _cert_filename; } } @@ -101,7 +101,7 @@ shutdown(bool send_message) { if (!send_message) { // If we're not to send the instance the shutdown message as a result of // this, then clear the _inst pointer now. - _inst = NULL; + _inst = nullptr; } if (_p3dcert_running) { @@ -119,7 +119,7 @@ shutdown(bool send_message) { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 100000; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); int status; waitpid(_p3dcert_pid, &status, WNOHANG); #endif // _WIN32 @@ -133,7 +133,7 @@ shutdown(bool send_message) { join_wait_thread(); // We're no longer bound to any particular instance. - _inst = NULL; + _inst = nullptr; } /** @@ -146,7 +146,7 @@ start_p3dcert() { return; } - if (_inst->_p3dcert_package == NULL) { + if (_inst->_p3dcert_package == nullptr) { nout << "Couldn't start Python: no p3dcert package.\n"; return; } @@ -175,14 +175,14 @@ start_p3dcert() { const wchar_t *keep[] = { L"TMP", L"TEMP", L"HOME", L"USER", L"SYSTEMROOT", L"USERPROFILE", L"COMSPEC", - NULL + nullptr }; wstring env_w; - for (int ki = 0; keep[ki] != NULL; ++ki) { + for (int ki = 0; keep[ki] != nullptr; ++ki) { wchar_t *value = _wgetenv(keep[ki]); - if (value != NULL) { + if (value != nullptr) { env_w += keep[ki]; env_w += L"="; env_w += value; @@ -204,11 +204,11 @@ start_p3dcert() { #ifdef HAVE_X11 "DISPLAY", "XAUTHORITY", #endif - NULL + nullptr }; - for (int ki = 0; keep[ki] != NULL; ++ki) { + for (int ki = 0; keep[ki] != nullptr; ++ki) { char *value = getenv(keep[ki]); - if (value != NULL) { + if (value != nullptr) { _env += keep[ki]; _env += "="; _env += value; @@ -337,7 +337,7 @@ wt_thread_run() { // Notify the instance that we're done. P3DInstance *inst = _inst; - if (inst != NULL) { + if (inst != nullptr) { inst->auth_finished_sub_thread(); } @@ -388,7 +388,7 @@ win_create_process() { // anyway. PROCESS_INFORMATION process_info; BOOL result = CreateProcess - (_p3dcert_exe.c_str(), command_line, NULL, NULL, TRUE, + (_p3dcert_exe.c_str(), command_line, nullptr, nullptr, TRUE, 0, (void *)_env.c_str(), start_dir_cstr, &startup_info, &process_info); bool started_program = (result != 0); @@ -440,7 +440,7 @@ posix_create_process() { p = zero + 1; zero = _env.find('\0', p); } - ptrs.push_back((char *)NULL); + ptrs.push_back(nullptr); execle(_p3dcert_exe.c_str(), _p3dcert_exe.c_str(), _cert_filename->get_filename().c_str(), _cert_dir.c_str(), diff --git a/direct/src/plugin/p3dCInstance.cxx b/direct/src/plugin/p3dCInstance.cxx index d6ecf259f1..0f77925b22 100644 --- a/direct/src/plugin/p3dCInstance.cxx +++ b/direct/src/plugin/p3dCInstance.cxx @@ -19,7 +19,7 @@ */ P3DCInstance:: P3DCInstance(TiXmlElement *xinstance) : - _func(NULL) + _func(nullptr) { xinstance->Attribute("instance_id", &_instance_id); } diff --git a/direct/src/plugin/p3dCert.cxx b/direct/src/plugin/p3dCert.cxx index bae39a3c76..f47723d466 100644 --- a/direct/src/plugin/p3dCert.cxx +++ b/direct/src/plugin/p3dCert.cxx @@ -55,10 +55,10 @@ static LanguageIndex detect_language() { typedef BOOL (*GUPL)(DWORD, PULONG, PZZWSTR, PULONG); GUPL pGetUserPreferredUILanguages = (GUPL)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), TEXT("GetUserPreferredUILanguages")); - if (pGetUserPreferredUILanguages != NULL) { + if (pGetUserPreferredUILanguages != nullptr) { ULONG num_langs = 0; ULONG buffer_size = 0; - pGetUserPreferredUILanguages(8, &num_langs, NULL, &buffer_size); + pGetUserPreferredUILanguages(8, &num_langs, nullptr, &buffer_size); PZZWSTR buffer = (PZZWSTR)_alloca(buffer_size); if (pGetUserPreferredUILanguages(8, &num_langs, buffer, &buffer_size)) { for (ULONG i = 0; i < num_langs; ++i) { @@ -67,7 +67,7 @@ static LanguageIndex detect_language() { // It may be a two-letter code; match it in our list. for (int j = 0; j < LI_COUNT; ++j) { const char *lang_code = language_codes[j]; - if (lang_code != NULL && lang_code[0] == buffer[0] && + if (lang_code != nullptr && lang_code[0] == buffer[0] && lang_code[1] == buffer[1]) { return (LanguageIndex)j; } @@ -120,7 +120,7 @@ static LanguageIndex detect_language() { // See if we support this language. for (int j = 0; j < LI_COUNT; ++j) { const char *lang_code = language_codes[j]; - if (lang_code != NULL && strncasecmp(buffer, lang_code, 2) == 0) { + if (lang_code != nullptr && strncasecmp(buffer, lang_code, 2) == 0) { CFRelease(langs); return (LanguageIndex)j; } @@ -136,10 +136,10 @@ static LanguageIndex detect_language() { // First consult the LANGUAGE variable, which is a GNU extension that can // contain multiple languages in order of preference. const char *lang = getenv("LANGUAGE"); - while (lang != NULL && lang[0] != 0) { + while (lang != nullptr && lang[0] != 0) { size_t len; const char *next = strchr(lang, ':'); - if (next == NULL) { + if (next == nullptr) { len = strlen(lang); } else { len = (next - lang); @@ -150,7 +150,7 @@ static LanguageIndex detect_language() { // It may be a two-letter language code; match it in our list. for (int i = 0; i < LI_COUNT; ++i) { const char *lang_code = language_codes[i]; - if (lang_code != NULL && strncasecmp(lang, lang_code, 2) == 0) { + if (lang_code != nullptr && strncasecmp(lang, lang_code, 2) == 0) { return (LanguageIndex)i; } } @@ -161,14 +161,14 @@ static LanguageIndex detect_language() { // Fall back to the C locale functions. setlocale(LC_ALL, ""); - lang = setlocale(LC_MESSAGES, NULL); + lang = setlocale(LC_MESSAGES, nullptr); - if (lang == NULL || lang[0] == 0 || strcmp(lang, "C") == 0) { + if (lang == nullptr || lang[0] == 0 || strcmp(lang, "C") == 0) { // Try the LANG variable. lang = getenv("LANG"); } - if (lang == NULL || strlen(lang) < 2 || isalnum(lang[2])) { + if (lang == nullptr || strlen(lang) < 2 || isalnum(lang[2])) { // Couldn't extract a meaningful two-letter code. return LI_default; } @@ -176,7 +176,7 @@ static LanguageIndex detect_language() { // It may be a two-letter language code; match it in our list. for (int i = 0; i < LI_COUNT; ++i) { const char *lang_code = language_codes[i]; - if (lang_code != NULL && strncasecmp(lang, lang_code, 2) == 0) { + if (lang_code != nullptr && strncasecmp(lang, lang_code, 2) == 0) { return (LanguageIndex)i; } } @@ -192,7 +192,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdS LPWSTR *argv; int argc; argv = CommandLineToArgvW(pCmdLine, &argc); - if (argv == NULL || argc != 2) { + if (argv == nullptr || argc != 2) { cerr << "usage: p3dcert cert_filename cert_dir\n"; return 1; } @@ -243,10 +243,10 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : Fl_Window(435, 242, new_application_title[li]), _cert_dir(cert_dir) { - _view_cert_dialog = NULL; + _view_cert_dialog = nullptr; - _cert = NULL; - _stack = NULL; + _cert = nullptr; + _stack = nullptr; _verify_result = -1; // Center the window on the screen. @@ -264,17 +264,17 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : */ AuthDialog:: ~AuthDialog() { - if (_view_cert_dialog != NULL) { + if (_view_cert_dialog != nullptr) { _view_cert_dialog->hide(); } - if (_cert != NULL) { + if (_cert != nullptr) { X509_free(_cert); - _cert = NULL; + _cert = nullptr; } - if (_stack != NULL) { + if (_stack != nullptr) { sk_X509_free(_stack); - _stack = NULL; + _stack = nullptr; } } @@ -294,7 +294,7 @@ void AuthDialog:: view_cert_clicked(Fl_Widget *w, void *data) { AuthDialog *dlg = (AuthDialog *) data; - if (dlg->_view_cert_dialog != NULL) { + if (dlg->_view_cert_dialog != nullptr) { dlg->_view_cert_dialog->hide(); } dlg->hide(); @@ -317,7 +317,7 @@ cancel_clicked(Fl_Widget *w, void *data) { */ void AuthDialog:: approve_cert() { - assert(_cert != NULL); + assert(_cert != nullptr); // Make sure the directory exists. #ifdef _WIN32 @@ -332,7 +332,7 @@ approve_cert() { // Sure, there's a slight race condition right now: another process might // attempt to create the same filename. So what. - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 wchar_t *buf = new wchar_t[buf_length]; @@ -366,7 +366,7 @@ approve_cert() { fp = fopen(buf, "w"); #endif // _WIN32 - if (fp != NULL) { + if (fp != nullptr) { PEM_write_X509(fp, _cert); fclose(fp); } @@ -386,14 +386,14 @@ void AuthDialog:: read_cert_file(const string &cert_filename) { #endif - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 fp = _wfopen(cert_filename.c_str(), L"r"); #else // _WIN32 fp = fopen(cert_filename.c_str(), "r"); #endif // _WIN32 - if (fp == NULL) { + if (fp == nullptr) { #ifdef _WIN32 wcerr << L"Couldn't read " << cert_filename.c_str() << L"\n"; #else @@ -401,8 +401,8 @@ read_cert_file(const string &cert_filename) { #endif return; } - _cert = PEM_read_X509(fp, NULL, NULL, (void *)""); - if (_cert == NULL) { + _cert = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + if (_cert == nullptr) { #ifdef _WIN32 wcerr << L"Could not read certificate in " << cert_filename.c_str() << L".\n"; #else @@ -413,11 +413,11 @@ read_cert_file(const string &cert_filename) { } // Build up a STACK of the remaining certificates in the file. - _stack = sk_X509_new(NULL); - X509 *c = PEM_read_X509(fp, NULL, NULL, (void *)""); - while (c != NULL) { + _stack = sk_X509_new(nullptr); + X509 *c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + while (c != nullptr) { sk_X509_push(_stack, c); - c = PEM_read_X509(fp, NULL, NULL, (void *)""); + c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); } fclose(fp); @@ -429,7 +429,7 @@ read_cert_file(const string &cert_filename) { */ void AuthDialog:: get_friendly_name() { - if (_cert == NULL) { + if (_cert == nullptr) { _friendly_name.clear(); return; } @@ -447,15 +447,15 @@ get_friendly_name() { // A complex OpenSSL interface to extract out the name in utf-8. X509_NAME *xname = X509_get_subject_name(_cert); - if (xname != NULL) { + if (xname != nullptr) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { // We just get the first common name. I guess it's possible to have // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); - if (xentry != NULL) { + if (xentry != nullptr) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); - if (data != NULL) { + if (data != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an // easier way to decode the ASN1_STRING? Curse these incomplete // docs. @@ -480,7 +480,7 @@ get_friendly_name() { */ void AuthDialog:: verify_cert() { - if (_cert == NULL) { + if (_cert == nullptr) { _verify_result = -1; return; } @@ -535,11 +535,11 @@ load_certificates_from_der_ram(X509_STORE *store, bp = (unsigned char *)data; bp_end = bp + data_size; - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (x509 != nullptr) { X509_STORE_add_cert(store, x509); ++count; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } return count; @@ -578,7 +578,7 @@ layout() { next_y += 180; short nbuttons = 1; - if (_cert != NULL) { + if (_cert != nullptr) { nbuttons++; if (_verify_result == 0) { nbuttons++; @@ -586,13 +586,13 @@ layout() { } short bx = (w() - nbuttons * BUTTON_WIDTH - (nbuttons - 1) * BUTTON_SPACE) / 2; - if (_verify_result == 0 && _cert != NULL) { + if (_verify_result == 0 && _cert != nullptr) { Fl_Return_Button *run_button = new Fl_Return_Button(bx, next_y, BUTTON_WIDTH, 25, run_title[li]); run_button->callback(this->run_clicked, this); bx += BUTTON_WIDTH + BUTTON_SPACE; } - if (_cert != NULL) { + if (_cert != nullptr) { Fl_Button *view_button = new Fl_Button(bx, next_y, BUTTON_WIDTH, 25, show_cert_title[li]); view_button->callback(this->view_cert_clicked, this); bx += BUTTON_WIDTH + BUTTON_SPACE; @@ -672,8 +672,8 @@ ViewCertDialog(AuthDialog *auth_dialog, X509 *cert) : */ ViewCertDialog:: ~ViewCertDialog() { - if (_auth_dialog != NULL) { - _auth_dialog->_view_cert_dialog = NULL; + if (_auth_dialog != nullptr) { + _auth_dialog->_view_cert_dialog = nullptr; } } @@ -683,7 +683,7 @@ ViewCertDialog:: void ViewCertDialog:: run_clicked(Fl_Widget *w, void *data) { ViewCertDialog *dlg = (ViewCertDialog *) data; - if (dlg->_auth_dialog != NULL){ + if (dlg->_auth_dialog != nullptr){ dlg->_auth_dialog->approve_cert(); } dlg->hide(); @@ -695,7 +695,7 @@ run_clicked(Fl_Widget *w, void *data) { void ViewCertDialog:: cancel_clicked(Fl_Widget *w, void *data) { ViewCertDialog *dlg = (ViewCertDialog *) data; - if (dlg->_auth_dialog != NULL){ + if (dlg->_auth_dialog != nullptr){ dlg->_auth_dialog->hide(); } dlg->hide(); @@ -707,7 +707,7 @@ cancel_clicked(Fl_Widget *w, void *data) { void ViewCertDialog:: layout() { // Format the certificate text for display in the dialog. - assert(_cert != NULL); + assert(_cert != nullptr); BIO *mbio = BIO_new(BIO_s_mem()); X509_print(mbio, _cert); diff --git a/direct/src/plugin/p3dCert_wx.cxx b/direct/src/plugin/p3dCert_wx.cxx index ae373bb5ba..d2e5a78801 100644 --- a/direct/src/plugin/p3dCert_wx.cxx +++ b/direct/src/plugin/p3dCert_wx.cxx @@ -136,14 +136,14 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : // I hate stay-on-top dialogs, but if we don't set this flag, it doesn't // come to the foreground on OSX, and might be lost behind the browser // window. - wxDialog(NULL, wxID_ANY, _T("New Panda3D Application"), wxDefaultPosition, + wxDialog(nullptr, wxID_ANY, _T("New Panda3D Application"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP), _cert_dir(cert_dir) { - _view_cert_dialog = NULL; + _view_cert_dialog = nullptr; - _cert = NULL; - _stack = NULL; + _cert = nullptr; + _stack = nullptr; _verify_result = -1; read_cert_file(cert_filename); @@ -157,17 +157,17 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : */ AuthDialog:: ~AuthDialog() { - if (_view_cert_dialog != NULL) { + if (_view_cert_dialog != nullptr) { _view_cert_dialog->Destroy(); } - if (_cert != NULL) { + if (_cert != nullptr) { X509_free(_cert); - _cert = NULL; + _cert = nullptr; } - if (_stack != NULL) { + if (_stack != nullptr) { sk_X509_free(_stack); - _stack = NULL; + _stack = nullptr; } } @@ -184,7 +184,7 @@ run_clicked(wxCommandEvent &event) { */ void AuthDialog:: view_cert_clicked(wxCommandEvent &event) { - if (_view_cert_dialog != NULL) { + if (_view_cert_dialog != nullptr) { _view_cert_dialog->Destroy(); } Hide(); @@ -206,7 +206,7 @@ cancel_clicked(wxCommandEvent &event) { */ void AuthDialog:: approve_cert() { - assert(_cert != NULL); + assert(_cert != nullptr); // Make sure the directory exists. mkdir_complete(_cert_dir, cerr); @@ -243,13 +243,13 @@ approve_cert() { // Sure, there's a slight race condition right now: another process might // attempt to create the same filename. So what. - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 fp = _wfopen(buf_w.c_str(), L"w"); #else // _WIN32 fp = fopen(buf, "w"); #endif // _WIN32 - if (fp != NULL) { + if (fp != nullptr) { PEM_write_X509(fp, _cert); fclose(fp); } @@ -263,7 +263,7 @@ approve_cert() { */ void AuthDialog:: read_cert_file(const string &cert_filename) { - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 wstring cert_filename_w; if (string_to_wstring(cert_filename_w, cert_filename)) { @@ -273,23 +273,23 @@ read_cert_file(const string &cert_filename) { fp = fopen(cert_filename.c_str(), "r"); #endif // _WIN32 - if (fp == NULL) { + if (fp == nullptr) { cerr << "Couldn't read " << cert_filename << "\n"; return; } - _cert = PEM_read_X509(fp, NULL, NULL, (void *)""); - if (_cert == NULL) { + _cert = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + if (_cert == nullptr) { cerr << "Could not read certificate in " << cert_filename << ".\n"; fclose(fp); return; } // Build up a STACK of the remaining certificates in the file. - _stack = sk_X509_new(NULL); - X509 *c = PEM_read_X509(fp, NULL, NULL, (void *)""); - while (c != NULL) { + _stack = sk_X509_new(nullptr); + X509 *c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + while (c != nullptr) { sk_X509_push(_stack, c); - c = PEM_read_X509(fp, NULL, NULL, (void *)""); + c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); } fclose(fp); @@ -301,7 +301,7 @@ read_cert_file(const string &cert_filename) { */ void AuthDialog:: get_friendly_name() { - if (_cert == NULL) { + if (_cert == nullptr) { _friendly_name.clear(); return; } @@ -319,15 +319,15 @@ get_friendly_name() { // A complex OpenSSL interface to extract out the name in utf-8. X509_NAME *xname = X509_get_subject_name(_cert); - if (xname != NULL) { + if (xname != nullptr) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { // We just get the first common name. I guess it's possible to have // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); - if (xentry != NULL) { + if (xentry != nullptr) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); - if (data != NULL) { + if (data != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an // easier way to decode the ASN1_STRING? Curse these incomplete // docs. @@ -352,7 +352,7 @@ get_friendly_name() { */ void AuthDialog:: verify_cert() { - if (_cert == NULL) { + if (_cert == nullptr) { _verify_result = -1; return; } @@ -407,11 +407,11 @@ load_certificates_from_der_ram(X509_STORE *store, bp = (unsigned char *)data; bp_end = bp + data_size; - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (x509 != nullptr) { X509_STORE_add_cert(store, x509); ++count; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } return count; @@ -449,12 +449,12 @@ layout() { // Create the run cancel buttons. wxBoxSizer *bsizer = new wxBoxSizer(wxHORIZONTAL); - if (_verify_result == 0 && _cert != NULL) { + if (_verify_result == 0 && _cert != nullptr) { wxButton *run_button = new wxButton(panel, wxID_OK, _T("Run")); bsizer->Add(run_button, 0, wxALIGN_CENTER | wxALL, 5); } - if (_cert != NULL) { + if (_cert != nullptr) { wxButton *view_button = new wxButton(panel, VIEW_CERT_BUTTON, _T("View Certificate")); bsizer->Add(view_button, 0, wxALIGN_CENTER | wxALL, 5); } @@ -522,7 +522,7 @@ END_EVENT_TABLE() */ ViewCertDialog:: ViewCertDialog(AuthDialog *auth_dialog, X509 *cert) : -wxDialog(NULL, wxID_ANY, _T("View Certificate"), wxDefaultPosition, +wxDialog(nullptr, wxID_ANY, _T("View Certificate"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), _auth_dialog(auth_dialog), _cert(cert) @@ -535,8 +535,8 @@ wxDialog(NULL, wxID_ANY, _T("View Certificate"), wxDefaultPosition, */ ViewCertDialog:: ~ViewCertDialog() { - if (_auth_dialog != NULL) { - _auth_dialog->_view_cert_dialog = NULL; + if (_auth_dialog != nullptr) { + _auth_dialog->_view_cert_dialog = nullptr; } } @@ -545,7 +545,7 @@ ViewCertDialog:: */ void ViewCertDialog:: run_clicked(wxCommandEvent &event) { - if (_auth_dialog != NULL){ + if (_auth_dialog != nullptr){ _auth_dialog->approve_cert(); } Destroy(); @@ -556,7 +556,7 @@ run_clicked(wxCommandEvent &event) { */ void ViewCertDialog:: cancel_clicked(wxCommandEvent &event) { - if (_auth_dialog != NULL){ + if (_auth_dialog != nullptr){ _auth_dialog->Destroy(); } Destroy(); @@ -568,7 +568,7 @@ cancel_clicked(wxCommandEvent &event) { void ViewCertDialog:: layout() { // Format the certificate text for display in the dialog. - assert(_cert != NULL); + assert(_cert != nullptr); BIO *mbio = BIO_new(BIO_s_mem()); X509_print(mbio, _cert); diff --git a/direct/src/plugin/p3dConcreteSequence.cxx b/direct/src/plugin/p3dConcreteSequence.cxx index 946afd05cd..2dd6dbf29e 100644 --- a/direct/src/plugin/p3dConcreteSequence.cxx +++ b/direct/src/plugin/p3dConcreteSequence.cxx @@ -86,7 +86,7 @@ get_property(const string &property) { char *endptr; int index = strtoul(property.c_str(), &endptr, 10); if (*endptr != '\0') { - return NULL; + return nullptr; } return get_element(index); @@ -133,7 +133,7 @@ fill_xml(TiXmlElement *xvalue, P3DSession *session) { P3D_object **P3DConcreteSequence:: get_object_array() { if (_elements.empty()) { - return NULL; + return nullptr; } return &_elements[0]; } @@ -165,7 +165,7 @@ get_element(int n) const { return _elements[n]; } - return NULL; + return nullptr; } /** @@ -174,7 +174,7 @@ get_element(int n) const { */ bool P3DConcreteSequence:: set_element(int n, P3D_object *value) { - if (value == NULL) { + if (value == nullptr) { // Delete an element. if (n < 0 || n >= (int)_elements.size()) { // Invalid index. diff --git a/direct/src/plugin/p3dConcreteStruct.cxx b/direct/src/plugin/p3dConcreteStruct.cxx index f85119cd2d..753bcb2b83 100644 --- a/direct/src/plugin/p3dConcreteStruct.cxx +++ b/direct/src/plugin/p3dConcreteStruct.cxx @@ -82,7 +82,7 @@ get_property(const string &property) { return (*ei).second; } - return NULL; + return nullptr; } /** @@ -91,7 +91,7 @@ get_property(const string &property) { */ bool P3DConcreteStruct:: set_property(const string &property, P3D_object *value) { - if (value == NULL) { + if (value == nullptr) { // Delete an element. Elements::iterator ei = _elements.find(property); if (ei == _elements.end()) { @@ -139,7 +139,7 @@ has_method(const string &method_name) { P3D_object *P3DConcreteStruct:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { - P3D_object *result = NULL; + P3D_object *result = nullptr; if (method_name == "toString") { string value; @@ -147,9 +147,9 @@ call(const string &method_name, bool needs_response, result = P3D_new_string_object(value.data(), value.length()); } - if (result != NULL && !needs_response) { + if (result != nullptr && !needs_response) { P3D_OBJECT_DECREF(result); - result = NULL; + result = nullptr; } return result; diff --git a/direct/src/plugin/p3dConditionVar.cxx b/direct/src/plugin/p3dConditionVar.cxx index 341e8be905..22133c0781 100644 --- a/direct/src/plugin/p3dConditionVar.cxx +++ b/direct/src/plugin/p3dConditionVar.cxx @@ -28,7 +28,7 @@ P3DConditionVar() { InitializeCriticalSection(&_lock); // Create an auto-reset event. - _event_signal = CreateEvent(NULL, false, false, NULL); + _event_signal = CreateEvent(nullptr, false, false, nullptr); #else // _WIN32 pthread_mutexattr_t attr; @@ -38,7 +38,7 @@ P3DConditionVar() { pthread_mutexattr_destroy(&attr); assert(result == 0); - result = pthread_cond_init(&_cvar, NULL); + result = pthread_cond_init(&_cvar, nullptr); assert(result == 0); #endif // _WIN32 @@ -115,7 +115,7 @@ wait(double timeout) { #else // _WIN32 struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); // Convert from timeval to timespec struct timespec ts; diff --git a/direct/src/plugin/p3dDownload.cxx b/direct/src/plugin/p3dDownload.cxx index 9b1af6ba7d..6423b4d9a7 100644 --- a/direct/src/plugin/p3dDownload.cxx +++ b/direct/src/plugin/p3dDownload.cxx @@ -27,7 +27,7 @@ P3DDownload() { _canceled = false; _download_id = 0; - _instance = NULL; + _instance = nullptr; } /** @@ -46,7 +46,7 @@ P3DDownload(const P3DDownload ©) : _canceled = false; _download_id = 0; - _instance = NULL; + _instance = nullptr; } /** @@ -162,7 +162,7 @@ receive_data(const unsigned char *this_data, size_t this_data_size) { */ void P3DDownload:: download_progress() { - time_t now = time(NULL); + time_t now = time(nullptr); if (now - _last_reported_time > 10) { _last_reported_time = now; nout << "Downloading " << get_url() << ": "; diff --git a/direct/src/plugin/p3dFileParams.cxx b/direct/src/plugin/p3dFileParams.cxx index 128520d993..1be229e3bb 100644 --- a/direct/src/plugin/p3dFileParams.cxx +++ b/direct/src/plugin/p3dFileParams.cxx @@ -90,13 +90,13 @@ set_tokens(const P3D_token tokens[], size_t num_tokens) { void P3DFileParams:: set_token(const char *keyword, const char *value) { Token token; - if (keyword != NULL) { + if (keyword != nullptr) { // Make the token lowercase, since HTML is case-insensitive but we're not. for (const char *p = keyword; *p; ++p) { token._keyword += tolower(*p); } } - if (value != NULL) { + if (value != nullptr) { token._value = value; } _tokens.push_back(token); @@ -111,7 +111,7 @@ set_args(int argc, const char *argv[]) { for (int i = 0; i < argc; ++i) { const char *arg = argv[i]; - if (arg == NULL) { + if (arg == nullptr) { arg = ""; } _args.push_back(arg); diff --git a/direct/src/plugin/p3dHost.I b/direct/src/plugin/p3dHost.I index f7e4640b66..27f3e2a8f8 100644 --- a/direct/src/plugin/p3dHost.I +++ b/direct/src/plugin/p3dHost.I @@ -79,7 +79,7 @@ get_descriptive_name() const { */ inline bool P3DHost:: has_contents_file() const { - return (_xcontents != NULL); + return (_xcontents != nullptr); } /** diff --git a/direct/src/plugin/p3dHost.cxx b/direct/src/plugin/p3dHost.cxx index 054dbe6166..028af6bef0 100644 --- a/direct/src/plugin/p3dHost.cxx +++ b/direct/src/plugin/p3dHost.cxx @@ -42,7 +42,7 @@ P3DHost(const string &host_url, const string &host_dir) : _descriptive_name = _host_url; - _xcontents = NULL; + _xcontents = nullptr; _contents_expiration = 0; _contents_iseq = 0; } @@ -52,7 +52,7 @@ P3DHost(const string &host_url, const string &host_dir) : */ P3DHost:: ~P3DHost() { - if (_xcontents != NULL) { + if (_xcontents != nullptr) { delete _xcontents; } @@ -94,7 +94,7 @@ P3DHost:: */ P3DHost *P3DHost:: get_alt_host(const string &alt_host) { - assert(_xcontents != NULL); + assert(_xcontents != nullptr); AltHosts::iterator hi; hi = _alt_hosts.find(alt_host); @@ -118,8 +118,8 @@ has_current_contents_file(P3DInstanceManager *inst_mgr) const { return has_contents_file(); } - time_t now = time(NULL); - return now < _contents_expiration && (_xcontents != NULL); + time_t now = time(nullptr); + return now < _contents_expiration && (_xcontents != nullptr); } /** @@ -153,11 +153,11 @@ read_contents_file(const string &contents_filename, bool fresh_download) { } TiXmlElement *xcontents = doc.FirstChildElement("contents"); - if (xcontents == NULL) { + if (xcontents == nullptr) { return false; } - if (_xcontents != NULL) { + if (_xcontents != nullptr) { delete _xcontents; } _xcontents = (TiXmlElement *)xcontents->Clone(); @@ -169,7 +169,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Get the latest possible expiration time, based on the max_age indication. // Any expiration time later than this is in error. - time_t now = time(NULL); + time_t now = time(nullptr); _contents_expiration = now + (time_t)max_age; if (fresh_download) { @@ -177,7 +177,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Update the XML with the new download information. TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - while (xorig != NULL) { + while (xorig != nullptr) { xcontents->RemoveChild(xorig); xorig = xcontents->FirstChildElement("orig"); } @@ -192,7 +192,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Read the download hash and expiration time from the XML. int expiration = 0; TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - if (xorig != NULL) { + if (xorig != nullptr) { _contents_spec.load_xml(xorig); xorig->Attribute("expiration", &expiration); } @@ -208,18 +208,18 @@ read_contents_file(const string &contents_filename, bool fresh_download) { << " s\n"; TiXmlElement *xhost = _xcontents->FirstChildElement("host"); - if (xhost != NULL) { + if (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // We're the primary host. This is the normal case. read_xhost(xhost); // Build up the list of alternate hosts. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *keyword = xalthost->Attribute("keyword"); const char *url = xalthost->Attribute("url"); - if (keyword != NULL && url != NULL) { + if (keyword != nullptr && url != nullptr) { _alt_hosts[keyword] = url; } xalthost = xalthost->NextSiblingElement("alt_host"); @@ -228,9 +228,9 @@ read_contents_file(const string &contents_filename, bool fresh_download) { } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *url = xalthost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // Yep, we're this alternate host. read_xhost(xalthost); break; @@ -288,12 +288,12 @@ read_contents_file(const string &contents_filename, bool fresh_download) { void P3DHost:: read_xhost(TiXmlElement *xhost) { const char *descriptive_name = xhost->Attribute("descriptive_name"); - if (descriptive_name != NULL && _descriptive_name.empty()) { + if (descriptive_name != nullptr && _descriptive_name.empty()) { _descriptive_name = descriptive_name; } const char *host_dir_basename = xhost->Attribute("host_dir"); - if (host_dir_basename == NULL) { + if (host_dir_basename == nullptr) { host_dir_basename = ""; } if (_host_dir.empty()) { @@ -303,7 +303,7 @@ read_xhost(TiXmlElement *xhost) { // Get the "download" URL, which is the source from which we download // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); - if (download_url != NULL) { + if (download_url != nullptr) { _download_url_prefix = download_url; } if (!_download_url_prefix.empty()) { @@ -315,9 +315,9 @@ read_xhost(TiXmlElement *xhost) { } TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); - while (xmirror != NULL) { + while (xmirror != nullptr) { const char *url = xmirror->Attribute("url"); - if (url != NULL) { + if (url != nullptr) { add_mirror(url); } xmirror = xmirror->NextSiblingElement("mirror"); @@ -338,7 +338,7 @@ get_package(const string &package_name, const string &package_version, const string &package_platform, const string &package_seq, const string &alt_host) { if (!alt_host.empty()) { - if (_xcontents != NULL) { + if (_xcontents != nullptr) { // If we're asking for an alt host and we've already read our // contents.xml file, then we already know all of our hosts, and we can // start the package off with the correct host immediately. @@ -355,7 +355,7 @@ get_package(const string &package_name, const string &package_version, string key = package_name + "_" + package_version; PlatformPackages &ppackages = _packages[alt_host][key]; PlatformPackages::iterator ppi; - P3DPackage *package = NULL; + P3DPackage *package = nullptr; // First, look for an exact match of the platform. for (ppi = ppackages.begin(); ppi != ppackages.end(); ++ppi) { @@ -366,7 +366,7 @@ get_package(const string &package_name, const string &package_version, } // If an exact match isn't found, look for a generic platform. - if (package == NULL) { + if (package == nullptr) { for (ppi = ppackages.begin(); ppi != ppackages.end(); ++ppi) { if ((*ppi)->get_package_platform().empty()) { package = *ppi; @@ -375,18 +375,18 @@ get_package(const string &package_name, const string &package_version, } } - if (package != NULL) { + if (package != nullptr) { if (package->get_failed()) { // If the package has previously failed, move it aside and try again // (maybe it just failed because the user interrupted it). nout << "Package " << key << " has previously failed; trying again.\n"; _failed_packages.push_back(package); ppackages.erase(ppi); - package = NULL; + package = nullptr; } } - if (package == NULL) { + if (package == nullptr) { package = new P3DPackage(this, package_name, package_version, package_platform, alt_host); ppackages.push_back(package); @@ -428,7 +428,7 @@ choose_suitable_platform(string &selected_platform, const string &package_name, const string &package_version, const string &package_platform) { - if (_xcontents == NULL) { + if (_xcontents == nullptr) { return false; } @@ -443,17 +443,17 @@ choose_suitable_platform(string &selected_platform, for (int pi = 0; pi < num_supported_platforms; ++pi) { string supported_platform = inst_mgr->get_supported_platform(pi); xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (name != NULL && + if (name != nullptr && package_name == name && supported_platform == platform && package_version == version) { @@ -470,17 +470,17 @@ choose_suitable_platform(string &selected_platform, // Now, we look for an exact match for the expected platform. xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (name != NULL && + if (name != nullptr && package_name == name && package_platform == platform && package_version == version) { @@ -496,17 +496,17 @@ choose_suitable_platform(string &selected_platform, // Look one more time, this time looking for a non-platform-specific // version. xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (name != NULL && + if (name != nullptr && package_name == name && *platform == '\0' && package_version == version) { @@ -535,7 +535,7 @@ get_package_desc_file(FileSpec &desc_file, // out const string &package_name, // in const string &package_version, // in const string &package_platform) { // in - if (_xcontents == NULL) { + if (_xcontents == nullptr) { return false; } @@ -545,22 +545,22 @@ get_package_desc_file(FileSpec &desc_file, // out // platform precisely, because we previously called // choose_suitable_platform(). TiXmlElement *xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); const char *seq = xpackage->Attribute("seq"); const char *solo = xpackage->Attribute("solo"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } - if (name != NULL && platform != NULL && + if (name != nullptr && platform != nullptr && package_name == name && package_platform == platform && package_version == version) { @@ -568,7 +568,7 @@ get_package_desc_file(FileSpec &desc_file, // out desc_file.load_xml(xpackage); package_seq = seq; package_solo = false; - if (solo != NULL) { + if (solo != nullptr) { package_solo = (atoi(solo) != 0); } return true; diff --git a/direct/src/plugin/p3dInstance.I b/direct/src/plugin/p3dInstance.I index 4168f68ac8..13aacd8b6b 100644 --- a/direct/src/plugin/p3dInstance.I +++ b/direct/src/plugin/p3dInstance.I @@ -105,7 +105,7 @@ get_matches_script_origin() const { */ inline bool P3DInstance:: is_started() const { - return (_session != NULL); + return (_session != nullptr); } /** @@ -123,7 +123,7 @@ is_failed() const { inline P3DInstance::ImageFile:: ImageFile() { _use_standard_image = true; - _temp_filename = NULL; + _temp_filename = nullptr; _image_placement = P3DSplashWindow::IP_none; } @@ -140,8 +140,8 @@ inline P3DInstance::ImageFile:: */ inline void P3DInstance::ImageFile:: cleanup() { - if (_temp_filename != NULL) { + if (_temp_filename != nullptr) { delete _temp_filename; - _temp_filename = NULL; + _temp_filename = nullptr; } } diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index 0eabdaafd5..21e608d5a5 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -99,22 +99,22 @@ P3DInstance(P3D_request_ready_func *func, int argc, const char *argv[], void *user_data) : _func(func) { - _dom_object = NULL; + _dom_object = nullptr; _main_object = new P3DMainObject; _main_object->set_instance(this); _user_data = user_data; _request_pending = false; _total_time_reports = 0; - _temp_p3d_filename = NULL; - _image_package = NULL; + _temp_p3d_filename = nullptr; + _image_package = nullptr; _current_background_image = IT_none; _current_button_image = IT_none; _got_fparams = false; _got_wparams = false; _p3d_trusted = false; - _xpackage = NULL; - _certlist_package = NULL; - _p3dcert_package = NULL; + _xpackage = nullptr; + _certlist_package = nullptr; + _p3dcert_package = nullptr; _fparams.set_tokens(tokens, num_tokens); _fparams.set_args(argc, argv); @@ -141,10 +141,10 @@ P3DInstance(P3D_request_ready_func *func, } _auth_button_clicked = false; _failed = false; - _session = NULL; - _auth_session = NULL; - _panda3d_package = NULL; - _splash_window = NULL; + _session = nullptr; + _auth_session = nullptr; + _panda3d_package = nullptr; + _splash_window = nullptr; _instance_window_opened = false; _instance_window_attached = false; _stuff_to_download = false; @@ -163,18 +163,18 @@ P3DInstance(P3D_request_ready_func *func, #ifdef __APPLE__ _shared_fd = -1; _shared_mmap_size = 0; - _swbuffer = NULL; - _reversed_buffer = NULL; - _buffer_data = NULL; - _data_provider = NULL; - _buffer_color_space = NULL; - _buffer_image = NULL; + _swbuffer = nullptr; + _reversed_buffer = nullptr; + _buffer_data = nullptr; + _data_provider = nullptr; + _buffer_color_space = nullptr; + _buffer_image = nullptr; // We have to start with _mouse_active true; firefox doesn't send activate // events. _mouse_active = true; _modifiers = 0; - _frame_timer = NULL; + _frame_timer = nullptr; #endif // __APPLE__ // Set some initial properties. @@ -219,7 +219,7 @@ P3DInstance(P3D_request_ready_func *func, time_t timestamp = inst_mgr->get_coreapi_timestamp(); _main_object->set_int_property("coreapiTimestamp", (int)timestamp); const char *timestamp_string = ctime(×tamp); - if (timestamp_string == NULL) { + if (timestamp_string == nullptr) { timestamp_string = ""; } _main_object->set_string_property("coreapiTimestampString", timestamp_string); @@ -239,7 +239,7 @@ P3DInstance(P3D_request_ready_func *func, // contents. P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url()); _image_package = host->get_package("images", "", "", ""); - if (_image_package != NULL) { + if (_image_package != nullptr) { _image_package->add_instance(this); } @@ -261,27 +261,27 @@ P3DInstance(P3D_request_ready_func *func, */ P3DInstance:: ~P3DInstance() { - assert(_session == NULL); + assert(_session == nullptr); cleanup(); - if (_dom_object != NULL) { + if (_dom_object != nullptr) { P3D_OBJECT_DECREF(_dom_object); - _dom_object = NULL; + _dom_object = nullptr; } - if (_main_object != NULL) { + if (_main_object != nullptr) { nout << "panda_script_object ref = " << _main_object->_ref_count << "\n"; - _main_object->set_instance(NULL); + _main_object->set_instance(nullptr); P3D_OBJECT_DECREF(_main_object); - _main_object = NULL; + _main_object = nullptr; } Downloads::iterator di; for (di = _downloads.begin(); di != _downloads.end(); ++di) { P3DDownload *download = (*di).second; if (download->get_instance() == this) { - download->set_instance(NULL); + download->set_instance(nullptr); } p3d_unref_delete(download); } @@ -300,10 +300,10 @@ void P3DInstance:: cleanup() { _failed = true; - if (_auth_session != NULL) { + if (_auth_session != nullptr) { _auth_session->shutdown(false); p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } for (int i = 0; i < (int)IT_num_image_types; ++i) { @@ -316,47 +316,47 @@ cleanup() { (*pi)->remove_instance(this); } _packages.clear(); - if (_image_package != NULL) { + if (_image_package != nullptr) { _image_package->remove_instance(this); - _image_package = NULL; + _image_package = nullptr; } - if (_certlist_package != NULL) { + if (_certlist_package != nullptr) { _certlist_package->remove_instance(this); - _certlist_package = NULL; + _certlist_package = nullptr; } - if (_p3dcert_package != NULL) { + if (_p3dcert_package != nullptr) { _p3dcert_package->remove_instance(this); - _p3dcert_package = NULL; + _p3dcert_package = nullptr; } - if (_splash_window != NULL) { + if (_splash_window != nullptr) { delete _splash_window; - _splash_window = NULL; + _splash_window = nullptr; } - if (_temp_p3d_filename != NULL) { + if (_temp_p3d_filename != nullptr) { delete _temp_p3d_filename; - _temp_p3d_filename = NULL; + _temp_p3d_filename = nullptr; } - if (_xpackage != NULL) { + if (_xpackage != nullptr) { delete _xpackage; - _xpackage = NULL; + _xpackage = nullptr; } #ifdef __APPLE__ - if (_frame_timer != NULL) { + if (_frame_timer != nullptr) { CFRunLoopTimerInvalidate(_frame_timer); CFRelease(_frame_timer); - _frame_timer = NULL; + _frame_timer = nullptr; } free_swbuffer(); #endif - TiXmlDocument *doc = NULL; + TiXmlDocument *doc = nullptr; ACQUIRE_LOCK(_request_lock); RawRequests::iterator ri; for (ri = _raw_requests.begin(); ri != _raw_requests.end(); ++ri) { @@ -404,7 +404,7 @@ set_p3d_url(const string &p3d_url) { determine_p3d_basename(p3d_url); // Make a temporary file to receive the instance data. - assert(_temp_p3d_filename == NULL); + assert(_temp_p3d_filename == nullptr); _temp_p3d_filename = new P3DTemporaryFile(".p3d"); _stuff_to_download = true; @@ -416,7 +416,7 @@ set_p3d_url(const string &p3d_url) { #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else - gettimeofday(&_start_dl_timeval, NULL); + gettimeofday(&_start_dl_timeval, nullptr); #endif _show_dl_instance_progress = false; @@ -445,7 +445,7 @@ make_p3d_stream(const string &p3d_url) { determine_p3d_basename(p3d_url); // Make a temporary file to receive the instance data. - assert(_temp_p3d_filename == NULL); + assert(_temp_p3d_filename == nullptr); _temp_p3d_filename = new P3DTemporaryFile(".p3d"); _stuff_to_download = true; @@ -457,7 +457,7 @@ make_p3d_stream(const string &p3d_url) { #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else - gettimeofday(&_start_dl_timeval, NULL); + gettimeofday(&_start_dl_timeval, nullptr); #endif _show_dl_instance_progress = false; @@ -505,7 +505,7 @@ set_wparams(const P3DWindowParams &wparams) { if (_wparams.get_window_type() != P3D_WT_hidden) { // Update or create the splash window. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_wparams(_wparams); } else { make_splash_window(); @@ -526,13 +526,13 @@ set_wparams(const P3DWindowParams &wparams) { int x_size = _wparams.get_win_width(); int y_size = _wparams.get_win_height(); if (x_size != 0 && y_size != 0) { - if (_swbuffer == NULL || _swbuffer->get_x_size() != x_size || + if (_swbuffer == nullptr || _swbuffer->get_x_size() != x_size || _swbuffer->get_y_size() != y_size) { // We need to open a new shared buffer. alloc_swbuffer(); } - if (_swbuffer == NULL) { + if (_swbuffer == nullptr) { nout << "Could not open swbuffer\n"; } } @@ -540,7 +540,7 @@ set_wparams(const P3DWindowParams &wparams) { } // Update the instance in the sub-process. - if (_session != NULL) { + if (_session != nullptr) { TiXmlDocument *doc = new TiXmlDocument; TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "setup_window"); @@ -582,11 +582,11 @@ set_browser_script_object(P3D_object *browser_script_object) { if (browser_script_object != _dom_object) { P3D_OBJECT_XDECREF(_dom_object); _dom_object = browser_script_object; - if (_dom_object != NULL) { + if (_dom_object != nullptr) { P3D_OBJECT_INCREF(_dom_object); } - if (_session != NULL) { + if (_session != nullptr) { send_browser_script_object(); } } @@ -596,12 +596,12 @@ set_browser_script_object(P3D_object *browser_script_object) { _origin_protocol.clear(); _origin_hostname.clear(); _origin_port.clear(); - if (_dom_object != NULL) { + if (_dom_object != nullptr) { P3D_object *location = P3D_OBJECT_GET_PROPERTY(_dom_object, "location"); - if (location != NULL) { + if (location != nullptr) { P3D_object *protocol = P3D_OBJECT_GET_PROPERTY(location, "protocol"); - if (protocol != NULL) { - int size = P3D_OBJECT_GET_STRING(protocol, NULL, 0); + if (protocol != nullptr) { + int size = P3D_OBJECT_GET_STRING(protocol, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(protocol, buffer, size); _origin_protocol = string(buffer, size); @@ -610,8 +610,8 @@ set_browser_script_object(P3D_object *browser_script_object) { } P3D_object *hostname = P3D_OBJECT_GET_PROPERTY(location, "hostname"); - if (hostname != NULL) { - int size = P3D_OBJECT_GET_STRING(hostname, NULL, 0); + if (hostname != nullptr) { + int size = P3D_OBJECT_GET_STRING(hostname, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(hostname, buffer, size); _origin_hostname = string(buffer, size); @@ -620,8 +620,8 @@ set_browser_script_object(P3D_object *browser_script_object) { } P3D_object *port = P3D_OBJECT_GET_PROPERTY(location, "port"); - if (port != NULL) { - int size = P3D_OBJECT_GET_STRING(port, NULL, 0); + if (port != nullptr) { + int size = P3D_OBJECT_GET_STRING(port, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(port, buffer, size); _origin_port = string(buffer, size); @@ -676,14 +676,14 @@ get_request() { if (_baked_requests.empty()) { // No requests ready. _request_pending = false; - return NULL; + return nullptr; } P3D_request *request = _baked_requests.front(); _baked_requests.pop_front(); _request_pending = !_baked_requests.empty(); - if (request != NULL) { + if (request != nullptr) { switch (request->_request_type) { case P3D_RT_notify: { @@ -691,7 +691,7 @@ get_request() { string message = request->_request._notify._message; string expression = _fparams.lookup_token(message); nout << "notify: " << message << " " << expression << "\n"; - if (!expression.empty() && _dom_object != NULL) { + if (!expression.empty() && _dom_object != nullptr) { P3D_object *result = P3D_OBJECT_EVAL(_dom_object, expression.c_str()); P3D_OBJECT_XDECREF(result); } @@ -702,13 +702,13 @@ get_request() { { // We also send an implicit message when Python requests itself to // shutdown. - _main_object->set_pyobj(NULL); + _main_object->set_pyobj(nullptr); _main_object->set_string_property("status", "stopped"); string message = "onpythonstop"; string expression = _fparams.lookup_token(message); nout << "notify: " << message << " " << expression << "\n"; - if (!expression.empty() && _dom_object != NULL) { + if (!expression.empty() && _dom_object != nullptr) { P3D_object *result = P3D_OBJECT_EVAL(_dom_object, expression.c_str()); P3D_OBJECT_XDECREF(result); } @@ -730,13 +730,13 @@ get_request() { const char *host_url = request->_request._forget_package._host_url; const char *package_name = request->_request._forget_package._package_name; const char *package_version = request->_request._forget_package._package_version; - if (package_version == NULL) { + if (package_version == nullptr) { package_version = ""; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DHost *host = inst_mgr->get_host(host_url); - if (package_name != NULL) { + if (package_name != nullptr) { P3DPackage *package = host->get_package(package_name, package_version, _session_platform, ""); host->forget_package(package); } else { @@ -769,7 +769,7 @@ void P3DInstance:: bake_requests() { while (true) { // Get the latest request from the read thread. - TiXmlDocument *doc = NULL; + TiXmlDocument *doc = nullptr; ACQUIRE_LOCK(_request_lock); if (!_raw_requests.empty()) { doc = _raw_requests.front(); @@ -777,18 +777,18 @@ bake_requests() { } RELEASE_LOCK(_request_lock); - if (doc == NULL) { + if (doc == nullptr) { // No more requests to process right now. return; } // Now we've got a request in XML form; convert it to P3D_request form. TiXmlElement *xrequest = doc->FirstChildElement("request"); - assert(xrequest != (TiXmlElement *)NULL); + assert(xrequest != nullptr); P3D_request *request = make_p3d_request(xrequest); delete doc; - if (request != NULL) { + if (request != nullptr) { _baked_requests.push_back(request); } } @@ -812,7 +812,7 @@ add_raw_request(TiXmlDocument *doc) { // Tell the world we've got a new request. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); inst_mgr->signal_request_ready(this); - if (_session != NULL) { + if (_session != nullptr) { _session->signal_request_ready(this); } } @@ -824,7 +824,7 @@ add_raw_request(TiXmlDocument *doc) { */ void P3DInstance:: add_baked_request(P3D_request *request) { - assert(request->_instance == NULL); + assert(request->_instance == nullptr); request->_instance = this; ref(); @@ -843,14 +843,14 @@ add_baked_request(P3D_request *request) { */ void P3DInstance:: finish_request(P3D_request *request, bool handled) { - assert(request != NULL); - if (request->_instance == NULL) { + assert(request != nullptr); + if (request->_instance == nullptr) { nout << "Ignoring empty request " << request << "\n"; return; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - if (inst_mgr->validate_instance(request->_instance) == NULL) { + if (inst_mgr->validate_instance(request->_instance) == nullptr) { // nout << "Ignoring unknown request " << request << "\n"; return; } @@ -860,31 +860,31 @@ finish_request(P3D_request *request, bool handled) { break; case P3D_RT_get_url: - if (request->_request._get_url._url != NULL) { + if (request->_request._get_url._url != nullptr) { free((char *)request->_request._get_url._url); - request->_request._get_url._url = NULL; + request->_request._get_url._url = nullptr; } break; case P3D_RT_notify: - if (request->_request._notify._message != NULL) { + if (request->_request._notify._message != nullptr) { free((char *)request->_request._notify._message); - request->_request._notify._message = NULL; + request->_request._notify._message = nullptr; } break; case P3D_RT_forget_package: - if (request->_request._forget_package._host_url != NULL) { + if (request->_request._forget_package._host_url != nullptr) { free((char *)request->_request._forget_package._host_url); - request->_request._forget_package._host_url = NULL; + request->_request._forget_package._host_url = nullptr; } - if (request->_request._forget_package._package_name != NULL) { + if (request->_request._forget_package._package_name != nullptr) { free((char *)request->_request._forget_package._package_name); - request->_request._forget_package._package_name = NULL; + request->_request._forget_package._package_name = nullptr; } - if (request->_request._forget_package._package_version != NULL) { + if (request->_request._forget_package._package_version != nullptr) { free((char *)request->_request._forget_package._package_version); - request->_request._forget_package._package_version = NULL; + request->_request._forget_package._package_version = nullptr; } break; @@ -893,7 +893,7 @@ finish_request(P3D_request *request, bool handled) { } p3d_unref_delete(((P3DInstance *)request->_instance)); - request->_instance = NULL; + request->_instance = nullptr; delete request; } @@ -925,7 +925,7 @@ feed_url_stream(int unique_id, if (!download_ok || download->get_download_finished()) { // All done. if (download->get_instance() == this) { - download->set_instance(NULL); + download->set_instance(nullptr); } _downloads.erase(di); p3d_unref_delete(download); @@ -941,7 +941,7 @@ feed_url_stream(int unique_id, bool P3DInstance:: handle_event(const P3D_event_data &event) { bool retval = false; - if (_splash_window != NULL) { + if (_splash_window != nullptr) { if (_splash_window->handle_event(event)) { retval = true; } @@ -970,7 +970,7 @@ handle_event(const P3D_event_data &event) { */ const string &P3DInstance:: get_log_pathname() const { - if (_session != NULL) { + if (_session != nullptr) { return _session->_log_pathname; } return _log_pathname; @@ -1053,16 +1053,16 @@ remove_package(P3DPackage *package) { _downloading_packages.erase(pi); } if (package == _image_package) { - _image_package = NULL; + _image_package = nullptr; } if (package == _certlist_package) { - _certlist_package = NULL; + _certlist_package = nullptr; } if (package == _p3dcert_package) { - _p3dcert_package = NULL; + _p3dcert_package = nullptr; } if (package == _panda3d_package) { - _panda3d_package = NULL; + _panda3d_package = nullptr; } set_failed(); @@ -1170,7 +1170,7 @@ start_download(P3DDownload *download, bool add_request) { // is true in order to ask the plugin for the stream. if (add_request) { P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_get_url; request->_request._get_url._url = strdup(download->get_url().c_str()); request->_request._get_url._unique_id = download_id; @@ -1227,7 +1227,7 @@ request_stop_main_thread() { if (add_request) { _requested_stop = true; P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_stop; add_baked_request(request); } @@ -1240,7 +1240,7 @@ request_stop_main_thread() { void P3DInstance:: request_refresh() { P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_refresh; add_baked_request(request); } @@ -1251,7 +1251,7 @@ request_refresh() { void P3DInstance:: request_callback(P3D_callback_func *func, void *data) { P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_callback; request->_request._callback._func = func; request->_request._callback._data = data; @@ -1335,7 +1335,7 @@ splash_button_clicked_main_thread() { if (!_p3d_trusted) { auth_button_clicked(); - } else if (_session == NULL) { + } else if (_session == nullptr) { play_button_clicked(); } else { nout << "Ignoring click for already-started instance\n"; @@ -1349,10 +1349,10 @@ splash_button_clicked_main_thread() { void P3DInstance:: auth_button_clicked() { // Delete the previous session and create a new one. - if (_auth_session != NULL) { + if (_auth_session != nullptr) { _auth_session->shutdown(false); p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -1366,7 +1366,7 @@ auth_button_clicked() { */ void P3DInstance:: play_button_clicked() { - if (_session == NULL && _p3d_trusted) { + if (_session == nullptr && _p3d_trusted) { set_button_image(IT_none); if (!_download_started) { // Now we initiate the download. @@ -1754,12 +1754,12 @@ check_p3d_signature() { } // Check the list of pre-approved certificates. - if (_certlist_package == NULL) { + if (_certlist_package == nullptr) { // We have to go download this package. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url()); _certlist_package = host->get_package("certlist", "", "", ""); - if (_certlist_package != NULL) { + if (_certlist_package != nullptr) { _certlist_package->add_instance(this); } @@ -1791,12 +1791,12 @@ mark_p3d_untrusted() { return; } - if (_p3dcert_package == NULL) { + if (_p3dcert_package == nullptr) { // We have to go download this package. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url()); _p3dcert_package = host->get_package("p3dcert", "", "", ""); - if (_p3dcert_package != NULL) { + if (_p3dcert_package != nullptr) { _p3dcert_package->add_instance(this); } @@ -1883,14 +1883,14 @@ scan_app_desc_file(TiXmlDocument *doc) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); TiXmlElement *xpackage = doc->FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { return; } - assert(_xpackage == NULL); + assert(_xpackage == nullptr); _xpackage = (TiXmlElement *)xpackage->Clone(); TiXmlElement *xconfig = _xpackage->FirstChildElement("config"); - if (xconfig != NULL) { + if (xconfig != nullptr) { int hidden = 0; if (xconfig->QueryIntAttribute("hidden", &hidden) == TIXML_SUCCESS) { if (hidden != 0) { @@ -1899,27 +1899,27 @@ scan_app_desc_file(TiXmlDocument *doc) { } const char *log_basename = xconfig->Attribute("log_basename"); - if (log_basename != NULL) { + if (log_basename != nullptr) { _log_basename = log_basename; } const char *prc_name = xconfig->Attribute("prc_name"); - if (prc_name != NULL) { + if (prc_name != nullptr) { _prc_name = prc_name; } const char *start_dir = xconfig->Attribute("start_dir"); - if (start_dir != NULL) { + if (start_dir != nullptr) { _start_dir = start_dir; } const char *run_origin = xconfig->Attribute("run_origin"); - if (run_origin != NULL) { + if (run_origin != nullptr) { _matches_run_origin = check_matches_origin(run_origin); } const char *script_origin = xconfig->Attribute("script_origin"); - if (script_origin != NULL) { + if (script_origin != nullptr) { _matches_script_origin = check_matches_origin(script_origin); } @@ -1987,24 +1987,24 @@ scan_app_desc_file(TiXmlDocument *doc) { void P3DInstance:: add_panda3d_package() { assert(!_packages_specified); - assert(_panda3d_package == NULL); - if (_xpackage == NULL) { + assert(_panda3d_package == nullptr); + if (_xpackage == nullptr) { return; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); TiXmlElement *xrequires = _xpackage->FirstChildElement("requires"); - while (xrequires != NULL) { + while (xrequires != nullptr) { const char *name = xrequires->Attribute("name"); const char *host_url = xrequires->Attribute("host"); - if (name != NULL && host_url != NULL && strcmp(name, "panda3d") == 0) { + if (name != nullptr && host_url != nullptr && strcmp(name, "panda3d") == 0) { const char *version = xrequires->Attribute("version"); - if (version == NULL) { + if (version == nullptr) { version = ""; } const char *seq = xrequires->Attribute("seq"); - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } P3DHost *host = inst_mgr->get_host(host_url); @@ -2026,23 +2026,23 @@ add_panda3d_package() { void P3DInstance:: add_packages() { assert(!_packages_specified); - if (_xpackage == NULL) { + if (_xpackage == nullptr) { return; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); TiXmlElement *xrequires = _xpackage->FirstChildElement("requires"); - while (xrequires != NULL) { + while (xrequires != nullptr) { const char *name = xrequires->Attribute("name"); const char *host_url = xrequires->Attribute("host"); - if (name != NULL && host_url != NULL) { + if (name != nullptr && host_url != nullptr) { const char *version = xrequires->Attribute("version"); - if (version == NULL) { + if (version == nullptr) { version = ""; } const char *seq = xrequires->Attribute("seq"); - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } P3DHost *host = inst_mgr->get_host(host_url); @@ -2074,17 +2074,17 @@ add_packages() { string P3DInstance:: find_alt_host_url(const string &host_url, const string &alt_host) { TiXmlElement *xhost = _xpackage->FirstChildElement("host"); - while (xhost != NULL) { + while (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && host_url == url) { + if (url != nullptr && host_url == url) { // This matches the host. Now do we have a matching alt_host keyword // for this host? TiXmlElement *xalt_host = xhost->FirstChildElement("alt_host"); - while (xalt_host != NULL) { + while (xalt_host != nullptr) { const char *keyword = xalt_host->Attribute("keyword"); - if (keyword != NULL && alt_host == keyword) { + if (keyword != nullptr && alt_host == keyword) { const char *alt_host_url = xalt_host->Attribute("url"); - if (alt_host_url != NULL) { + if (alt_host_url != nullptr) { return alt_host_url; } } @@ -2110,9 +2110,9 @@ get_host_info(P3DHost *host) { assert(!host->has_contents_file()); TiXmlElement *xhost = _xpackage->FirstChildElement("host"); - while (xhost != NULL) { + while (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && host->get_host_url() == url) { + if (url != nullptr && host->get_host_url() == url) { // Found the entry for this particular host. host->read_xhost(xhost); return; @@ -2168,7 +2168,7 @@ send_browser_script_object() { TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "pyobj"); xcommand->SetAttribute("op", "set_browser_script_object"); - if (_dom_object != NULL) { + if (_dom_object != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(_dom_object)); } @@ -2184,16 +2184,16 @@ send_browser_script_object() { P3D_request *P3DInstance:: make_p3d_request(TiXmlElement *xrequest) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - P3D_request *request = NULL; + P3D_request *request = nullptr; const char *rtype = xrequest->Attribute("rtype"); - if (rtype != NULL) { + if (rtype != nullptr) { if (strcmp(rtype, "notify") == 0) { const char *message = xrequest->Attribute("message"); - if (message != NULL) { + if (message != nullptr) { // A notify message from Python code. request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_notify; request->_request._notify._message = strdup(message); handle_notify_request(message); @@ -2210,19 +2210,19 @@ make_p3d_request(TiXmlElement *xrequest) { int unique_id = 0; xrequest->Attribute("unique_id", &unique_id); - P3D_object *value = NULL; + P3D_object *value = nullptr; TiXmlElement *xvalue = xrequest->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { value = _session->xml_to_p3dobj(xvalue); } - if (value == NULL) { + if (value == nullptr) { value = inst_mgr->new_none_object(); } - if (operation != NULL && xobject != NULL) { + if (operation != nullptr && xobject != nullptr) { P3D_object *object = _session->xml_to_p3dobj(xobject); - if (property_name == NULL) { + if (property_name == nullptr) { property_name = ""; } @@ -2242,25 +2242,25 @@ make_p3d_request(TiXmlElement *xrequest) { } else if (strcmp(rtype, "stop") == 0) { // A stop request from Python code. This is kind of weird, but OK. request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_stop; } else if (strcmp(rtype, "forget_package") == 0) { const char *host_url = xrequest->Attribute("host_url"); - if (host_url != NULL) { + if (host_url != nullptr) { // A Python-level request to remove a package from the cache. request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_forget_package; request->_request._forget_package._host_url = strdup(host_url); - request->_request._forget_package._package_name = NULL; - request->_request._forget_package._package_version = NULL; + request->_request._forget_package._package_name = nullptr; + request->_request._forget_package._package_version = nullptr; const char *package_name = xrequest->Attribute("package_name"); const char *package_version = xrequest->Attribute("package_version"); - if (package_name != NULL) { + if (package_name != nullptr) { request->_request._forget_package._package_name = strdup(package_name); - if (package_version != NULL) { + if (package_version != nullptr) { request->_request._forget_package._package_version = strdup(package_version); } } @@ -2271,8 +2271,8 @@ make_p3d_request(TiXmlElement *xrequest) { } } - if (request != NULL) { - assert(request->_instance == NULL); + if (request != nullptr) { + assert(request->_instance == nullptr); request->_instance = this; ref(); } @@ -2298,19 +2298,19 @@ handle_notify_request(const string &message) { doc->LinkEndChild(xcommand); TiXmlDocument *response = _session->command_and_response(doc); - P3D_object *result = NULL; - if (response != NULL) { + P3D_object *result = nullptr; + if (response != nullptr) { TiXmlElement *xresponse = response->FirstChildElement("response"); - if (xresponse != NULL) { + if (xresponse != nullptr) { TiXmlElement *xvalue = xresponse->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { result = _session->xml_to_p3dobj(xvalue); } } delete response; } - if (result != NULL) { + if (result != nullptr) { if (_matches_script_origin) { // We only actually merge the objects if this web page is allowed to // call our scripting functions. @@ -2329,7 +2329,7 @@ handle_notify_request(const string &message) { // The process told us that it just successfully opened its window, for // the first time. Hide the splash window. _instance_window_opened = true; - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_visible(false); } @@ -2352,7 +2352,7 @@ handle_notify_request(const string &message) { // window opening and the first frame being drawn. _instance_window_attached = true; #ifndef __APPLE__ - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_visible(false); } #endif // __APPLE__ @@ -2360,12 +2360,12 @@ handle_notify_request(const string &message) { #ifdef __APPLE__ // Start a timer to update the frame repeatedly. This seems to be // steadier than waiting for nullEvent. - if (_frame_timer == NULL) { + if (_frame_timer == nullptr) { CFRunLoopTimerContext timer_context; memset(&timer_context, 0, sizeof(timer_context)); timer_context.info = this; _frame_timer = CFRunLoopTimerCreate - (NULL, 0, 1.0 / 60.0, 0, 0, timer_callback, &timer_context); + (nullptr, 0, 1.0 / 60.0, 0, 0, timer_callback, &timer_context); CFRunLoopRef run_loop = CFRunLoopGetCurrent(); CFRunLoopAddTimer(run_loop, _frame_timer, kCFRunLoopCommonModes); } @@ -2377,16 +2377,16 @@ handle_notify_request(const string &message) { _instance_window_opened = true; _instance_window_attached = false; set_background_image(IT_active); - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_visible(true); } #ifdef __APPLE__ // Stop the frame timer; we don't need it any more. - if (_frame_timer != NULL) { + if (_frame_timer != nullptr) { CFRunLoopTimerInvalidate(_frame_timer); CFRelease(_frame_timer); - _frame_timer = NULL; + _frame_timer = nullptr; } #endif // __APPLE__ @@ -2403,7 +2403,7 @@ handle_notify_request(const string &message) { auth_finished_main_thread(); } else if (message == "keyboardfocus") { - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->request_keyboard_focus(); } } @@ -2430,7 +2430,7 @@ handle_script_request(const string &operation, P3D_object *object, // We've got the property value; feed it back down to the subprocess. - if (result != NULL) { + if (result != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); } @@ -2445,7 +2445,7 @@ handle_script_request(const string &operation, P3D_object *object, xcommand->LinkEndChild(xvalue); } else if (operation == "del_property") { - bool result = P3D_OBJECT_SET_PROPERTY(object, property_name.c_str(), true, NULL); + bool result = P3D_OBJECT_SET_PROPERTY(object, property_name.c_str(), true, nullptr); TiXmlElement *xvalue = new TiXmlElement("value"); xvalue->SetAttribute("type", "bool"); @@ -2476,20 +2476,20 @@ handle_script_request(const string &operation, P3D_object *object, P3D_OBJECT_CALL(object, property_name.c_str(), needs_response, values, num_values); - if (result != NULL) { + if (result != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); } } else if (operation == "eval") { P3D_object *result; - int size = P3D_OBJECT_GET_STRING(value, NULL, 0); + int size = P3D_OBJECT_GET_STRING(value, nullptr, 0); char *buffer = new char[size + 1]; P3D_OBJECT_GET_STRING(value, buffer, size + 1); result = P3D_OBJECT_EVAL(object, buffer); delete[] buffer; - if (result != NULL) { + if (result != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); } @@ -2544,7 +2544,7 @@ make_splash_window() { make_visible = true; } - if (_splash_window != NULL) { + if (_splash_window != nullptr) { // Already got one. _splash_window->set_visible(make_visible); return; @@ -2704,7 +2704,7 @@ make_splash_window() { _image_files[i]._filename.clear(); // Make a temporary file to receive the splash image. - assert(_image_files[i]._temp_filename == NULL); + assert(_image_files[i]._temp_filename == nullptr); _image_files[i]._temp_filename = new P3DTemporaryFile(".jpg"); // Start downloading the requested image. @@ -2753,7 +2753,7 @@ set_background_image(ImageType image_type) { } // Update the splash window. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_image_filename(_image_files[_current_background_image]._filename, P3DSplashWindow::IP_background); } } @@ -2790,7 +2790,7 @@ set_button_image(ImageType image_type) { } // Update the splash window. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { if (_current_button_image != IT_none) { _splash_window->set_image_filename(_image_files[_current_button_image]._filename, P3DSplashWindow::IP_button_ready); _splash_window->set_image_filename(_image_files[_current_button_image + 1]._filename, P3DSplashWindow::IP_button_rollover); @@ -2804,7 +2804,7 @@ set_button_image(ImageType image_type) { } else { // We're not changing the button graphic, but we might be re-activating // it. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { if (_current_button_image != IT_none) { _splash_window->set_button_active(true); } else { @@ -2829,7 +2829,7 @@ report_package_info_ready(P3DPackage *package) { // If we're downloading one of the two cert packages, though, put up a // progress bar. make_splash_window(); - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } if (package == _certlist_package) { @@ -2926,7 +2926,7 @@ ready_to_install() { #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else - gettimeofday(&_start_dl_timeval, NULL); + gettimeofday(&_start_dl_timeval, nullptr); #endif nout << "Beginning install of " << _downloading_packages.size() @@ -2956,7 +2956,7 @@ ready_to_install() { _main_object->set_float_property("downloadProgress", progress); } - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(progress, true, 0); } @@ -3030,7 +3030,7 @@ mark_download_complete() { } // Take down the download progress bar. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } set_install_label(""); @@ -3090,7 +3090,7 @@ report_instance_progress(double progress, bool is_progress_known, double elapsed = (double)(now - _start_dl_tick) * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); double elapsed = (double)(now.tv_sec - _start_dl_timeval.tv_sec) + (double)(now.tv_usec - _start_dl_timeval.tv_usec) / 1000000.0; #endif @@ -3108,7 +3108,7 @@ report_instance_progress(double progress, bool is_progress_known, } } - if (_splash_window != NULL && _show_dl_instance_progress) { + if (_splash_window != nullptr && _show_dl_instance_progress) { _splash_window->set_install_progress(progress, is_progress_known, received_data); } _main_object->set_float_property("instanceDownloadProgress", progress); @@ -3125,7 +3125,7 @@ report_package_progress(P3DPackage *package, double progress) { } if (package == _certlist_package || package == _p3dcert_package) { // This gets its own progress bar. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(progress, true, 0); } return; @@ -3141,7 +3141,7 @@ report_package_progress(P3DPackage *package, double progress) { progress = (progress * package->get_download_size() + _total_downloaded + _prev_downloaded) / (_total_download_size + _prev_downloaded); progress = min(progress, 1.0); - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(progress, true, 0); } _main_object->set_float_property("downloadProgress", progress); @@ -3155,7 +3155,7 @@ report_package_progress(P3DPackage *package, double progress) { double elapsed = (double)(now - _start_dl_tick) * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); double elapsed = (double)(now.tv_sec - _start_dl_timeval.tv_sec) + (double)(now.tv_usec - _start_dl_timeval.tv_usec) / 1000000.0; #endif @@ -3213,7 +3213,7 @@ report_package_done(P3DPackage *package, bool success) { // files out of it and point them to the splash window. string package_dir = package->get_package_dir(); const TiXmlElement *xconfig = package->get_xconfig(); - if (xconfig == NULL) { + if (xconfig == nullptr) { nout << "No entry in image package\n"; return; } @@ -3225,7 +3225,7 @@ report_package_done(P3DPackage *package, bool success) { // filename. string token = string(_image_type_names[i]) + "_img"; const string *basename = xconfig->Attribute(token); - if (basename == NULL) { + if (basename == nullptr) { nout << "No entry in image package for " << token << "\n"; } else { string image_filename = package_dir + "/" + *basename; @@ -3233,7 +3233,7 @@ report_package_done(P3DPackage *package, bool success) { // If the image should be on the window now, and the window still // exists, put it up. - if (_splash_window != NULL && + if (_splash_window != nullptr && _image_files[i]._image_placement != P3DSplashWindow::IP_none) { P3DSplashWindow::ImagePlacement image_placement = _image_files[i]._image_placement; _splash_window->set_image_filename(image_filename, image_placement); @@ -3252,7 +3252,7 @@ report_package_done(P3DPackage *package, bool success) { package->mark_used(); // Take down the download progress. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } set_install_label(""); @@ -3270,7 +3270,7 @@ report_package_done(P3DPackage *package, bool success) { package->mark_used(); // Take down the download progress. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } set_install_label(""); @@ -3294,7 +3294,7 @@ report_package_done(P3DPackage *package, bool success) { void P3DInstance:: set_install_label(const string &install_label) { _install_label = install_label; - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_label(_install_label); } } @@ -3330,7 +3330,7 @@ paint_window() { */ bool P3DInstance:: get_framebuffer_osx_port() { - if (_swbuffer == NULL || !_instance_window_attached) { + if (_swbuffer == nullptr || !_instance_window_attached) { // We don't have a Panda3D window yet. return false; } @@ -3382,7 +3382,7 @@ get_framebuffer_osx_port() { _swbuffer->close_read_framebuffer(); - if (_splash_window != NULL && _splash_window->get_visible()) { + if (_splash_window != nullptr && _splash_window->get_visible()) { // If the splash window is up, time to hide it. We've just rendered a // real frame. _splash_window->set_visible(false); @@ -3404,7 +3404,7 @@ get_framebuffer_osx_port() { */ bool P3DInstance:: get_framebuffer_osx_cgcontext() { - if (_swbuffer == NULL || !_instance_window_attached) { + if (_swbuffer == nullptr || !_instance_window_attached) { // We don't have a Panda3D window yet. return false; } @@ -3420,7 +3420,7 @@ get_framebuffer_osx_cgcontext() { memcpy(_reversed_buffer, framebuffer, y_size * rowsize); _swbuffer->close_read_framebuffer(); - if (_splash_window != NULL && _splash_window->get_visible()) { + if (_splash_window != nullptr && _splash_window->get_visible()) { // If the splash window is up, time to hide it. We've just rendered a // real frame. _splash_window->set_visible(false); @@ -3466,7 +3466,7 @@ paint_window_osx_port() { const P3D_window_handle &handle = _wparams.get_parent_window(); assert(handle._window_handle_type == P3D_WHT_osx_port); GrafPtr out_port = handle._handle._osx_port._port; - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(out_port, &port_save); // Make sure the clipping rectangle isn't in the way. Is there a better way @@ -3479,7 +3479,7 @@ paint_window_osx_port() { &src_rect, &ddrc_rect, srcCopy, 0); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } DisposeGWorld(pGWorld); @@ -3501,7 +3501,7 @@ paint_window_osx_cgcontext(CGContextRef context) { int x_size = min(_wparams.get_win_width(), _swbuffer->get_x_size()); int y_size = min(_wparams.get_win_height(), _swbuffer->get_y_size()); - if (_buffer_image != NULL) { + if (_buffer_image != nullptr) { CGRect region = { { 0, 0 }, { (CGFloat)x_size, (CGFloat)y_size } }; CGContextDrawImage(context, region, _buffer_image); } @@ -3526,20 +3526,20 @@ handle_event_osx_event_record(const P3D_event_data &event) { const P3D_window_handle &handle = _wparams.get_parent_window(); if (handle._window_handle_type == P3D_WHT_osx_port) { GrafPtr out_port = handle._handle._osx_port._port; - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(out_port, &port_save); GlobalToLocal(&pt); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } } else { // First, convert the coordinates from screen coordinates to browser // window coordinates. WindowRef window = handle._handle._osx_cgcontext._window; CGPoint cgpt = { (CGFloat)pt.h, (CGFloat)pt.v }; - HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL, + HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, nullptr, kHICoordSpaceWindow, window); // Then convert to plugin coordinates. @@ -3572,7 +3572,7 @@ handle_event_osx_event_record(const P3D_event_data &event) { case keyDown: case keyUp: case autoKey: - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { swb_event._source = SubprocessWindowBuffer::ES_keyboard; swb_event._code = er->message; if (er->what == keyUp) { @@ -3614,7 +3614,7 @@ handle_event_osx_event_record(const P3D_event_data &event) { } } - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { _swbuffer->add_event(swb_event); } #endif // __APPLE__ @@ -3709,7 +3709,7 @@ handle_event_osx_cocoa(const P3D_event_data &event) { swb_event._flags |= SubprocessWindowBuffer::EF_has_mouse; } - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { _swbuffer->add_event(swb_event); } #endif // __APPLE__ @@ -3773,7 +3773,7 @@ void P3DInstance:: send_notify(const string &message) { nout << "send_notify(" << message << ")\n"; P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_notify; request->_request._notify._message = strdup(message.c_str()); add_baked_request(request); @@ -3793,12 +3793,12 @@ alloc_swbuffer() { _swbuffer = SubprocessWindowBuffer::new_buffer (_shared_fd, _shared_mmap_size, _shared_filename, x_size, y_size); - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { _reversed_buffer = new char[_swbuffer->get_framebuffer_size()]; memset(_reversed_buffer, 0, _swbuffer->get_row_size()); size_t rowsize = _swbuffer->get_row_size(); - _buffer_data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)_reversed_buffer, + _buffer_data = CFDataCreateWithBytesNoCopy(nullptr, (const UInt8 *)_reversed_buffer, y_size * rowsize, kCFAllocatorNull); _data_provider = CGDataProviderCreateWithCFData(_buffer_data); @@ -3806,7 +3806,7 @@ alloc_swbuffer() { _buffer_image = CGImageCreate(x_size, y_size, 8, 32, rowsize, _buffer_color_space, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, - _data_provider, NULL, false, kCGRenderingIntentDefault); + _data_provider, nullptr, false, kCGRenderingIntentDefault); } } @@ -3819,26 +3819,26 @@ alloc_swbuffer() { */ void P3DInstance:: free_swbuffer() { - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { SubprocessWindowBuffer::destroy_buffer(_shared_fd, _shared_mmap_size, _shared_filename, _swbuffer); - _swbuffer = NULL; + _swbuffer = nullptr; } - if (_reversed_buffer != NULL) { + if (_reversed_buffer != nullptr) { delete[] _reversed_buffer; - _reversed_buffer = NULL; + _reversed_buffer = nullptr; } - if (_buffer_image != NULL) { + if (_buffer_image != nullptr) { CGImageRelease(_buffer_image); CGColorSpaceRelease(_buffer_color_space); CGDataProviderRelease(_data_provider); CFRelease(_buffer_data); - _buffer_data = NULL; - _data_provider = NULL; - _buffer_color_space = NULL; - _buffer_image = NULL; + _buffer_data = nullptr; + _data_provider = nullptr; + _buffer_color_space = nullptr; + _buffer_image = nullptr; } } #endif // __APPLE__ @@ -3881,7 +3881,7 @@ download_finished(bool success) { // Put it onscreen if it's supposed to be onscreen now, and our splash // window still exists. - if (_inst->_splash_window != NULL && + if (_inst->_splash_window != nullptr && _inst->_image_files[_index]._image_placement != P3DSplashWindow::IP_none) { P3DSplashWindow::ImagePlacement image_placement = _inst->_image_files[_index]._image_placement; _inst->_splash_window->set_image_filename(get_filename(), image_placement); diff --git a/direct/src/plugin/p3dInstanceManager.cxx b/direct/src/plugin/p3dInstanceManager.cxx index 46a194e289..3b8c52ba15 100644 --- a/direct/src/plugin/p3dInstanceManager.cxx +++ b/direct/src/plugin/p3dInstanceManager.cxx @@ -86,11 +86,11 @@ P3DInstanceManager() { _true_object = new P3DBoolObject(true); _false_object = new P3DBoolObject(false); - _auth_session = NULL; + _auth_session = nullptr; // Seed the lame random number generator in rand(); we use it to select a // mirror for downloading. - srand((unsigned int)time(NULL)); + srand((unsigned int)time(nullptr)); #ifdef _WIN32 // Ensure the appropriate Windows common controls are available to this @@ -127,7 +127,7 @@ P3DInstanceManager:: #ifndef _WIN32 // Restore the original SIGPIPE handler. - sigaction(SIGPIPE, &_old_sigpipe, NULL); + sigaction(SIGPIPE, &_old_sigpipe, nullptr); #endif // _WIN32 // force-finish any remaining instances. @@ -139,9 +139,9 @@ P3DInstanceManager:: assert(_sessions.empty()); assert(_instances.empty()); - if (_auth_session != NULL) { + if (_auth_session != nullptr) { p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } Hosts::iterator hi; @@ -239,7 +239,7 @@ initialize(int api_version, const string &contents_filename, int mib[2] = { CTL_HW, HW_MACHINE }; char machine[512]; size_t len = 511; - if (sysctl(mib, 2, (void *)machine, &len, NULL, 0) == 0) { + if (sysctl(mib, 2, (void *)machine, &len, nullptr, 0) == 0) { if (strcmp(machine, "x86_64") == 0) { _supported_platforms.push_back("osx_amd64"); } @@ -400,7 +400,7 @@ set_plugin_version(int major, int minor, int sequence, nout << "Core API version: " << _coreapi_set_ver << "\n"; const char *timestamp_string = ctime(&_coreapi_timestamp); - if (timestamp_string == NULL) { + if (timestamp_string == nullptr) { timestamp_string = ""; } nout << "Core API date: " << timestamp_string << "\n"; @@ -541,12 +541,12 @@ finish_instance(P3DInstance *inst) { */ P3DAuthSession *P3DInstanceManager:: authorize_instance(P3DInstance *inst) { - if (_auth_session != NULL) { + if (_auth_session != nullptr) { // We only want one auth_session window open at a time, to minimize user // confusion, so close any previous window. _auth_session->shutdown(true); p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } _auth_session = new P3DAuthSession(inst); @@ -566,7 +566,7 @@ validate_instance(P3D_instance *instance) { return (*ii); } - return NULL; + return nullptr; } /** @@ -583,7 +583,7 @@ check_request() { } } - return NULL; + return nullptr; } /** @@ -600,7 +600,7 @@ wait_request(double timeout) { int stop_tick = int(GetTickCount() + timeout * 1000.0); #else struct timeval stop_time; - gettimeofday(&stop_time, NULL); + gettimeofday(&stop_time, nullptr); int seconds = (int)floor(timeout); stop_time.tv_sec += seconds; @@ -612,7 +612,7 @@ wait_request(double timeout) { #endif _request_ready.acquire(); - if (check_request() != (P3DInstance *)NULL) { + if (check_request() != nullptr) { _request_ready.release(); return; } @@ -633,7 +633,7 @@ wait_request(double timeout) { timeout = remaining_ticks * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); struct timeval remaining; remaining.tv_sec = stop_time.tv_sec - now.tv_sec; @@ -649,7 +649,7 @@ wait_request(double timeout) { timeout = remaining.tv_sec + remaining.tv_usec * 0.001; #endif - if (check_request() != (P3DInstance *)NULL) { + if (check_request() != nullptr) { _request_ready.release(); return; } @@ -713,7 +713,7 @@ get_unique_id() { */ void P3DInstanceManager:: signal_request_ready(P3DInstance *inst) { - if (inst->get_request_ready_func() != NULL) { + if (inst->get_request_ready_func() != nullptr) { // This instance requires asynchronous notifications of requests. Thus, // we should tell the notify thread to wake up and make the callback. _notify_ready.acquire(); @@ -765,7 +765,7 @@ make_temp_filename(const string &extension) { if (tid == 0) { tid = 1; } - int hash = ((clock() + _next_temp_filename_counter) * ((time(NULL) * tid) >> 8)) & 0xffffff; + int hash = ((clock() + _next_temp_filename_counter) * ((time(nullptr) * tid) >> 8)) & 0xffffff; ++_next_temp_filename_counter; char hex_code[10]; sprintf(hex_code, "%06x", hash); @@ -847,8 +847,8 @@ find_cert(X509 *cert) { vector::iterator si; for (si = contents.begin(); si != contents.end(); ++si) { string filename = this_cert_dir + "/" + (*si); - X509 *x509 = NULL; - FILE *fp = NULL; + X509 *x509 = nullptr; + FILE *fp = nullptr; #ifdef _WIN32 wstring filename_w; if (string_to_wstring(filename_w, filename)) { @@ -857,12 +857,12 @@ find_cert(X509 *cert) { #else // _WIN32 fp = fopen(filename.c_str(), "r"); #endif // _WIN32 - if (fp != NULL) { - x509 = PEM_read_X509(fp, NULL, NULL, (void *)""); + if (fp != nullptr) { + x509 = PEM_read_X509(fp, nullptr, nullptr, (void *)""); fclose(fp); } - if (x509 != NULL) { + if (x509 != nullptr) { string der2 = cert_to_der(x509); // We might as well save this cert in the table for next time, even if // it's not the one we're looking for right now. @@ -896,8 +896,8 @@ read_certlist(P3DPackage *package) { string suffix = basename.substr(basename.length() - 4); if (suffix == ".pem" || suffix == ".crt") { string filename = package->get_package_dir() + "/" + basename; - X509 *x509 = NULL; - FILE *fp = NULL; + X509 *x509 = nullptr; + FILE *fp = nullptr; #ifdef _WIN32 wstring filename_w; if (string_to_wstring(filename_w, filename)) { @@ -906,12 +906,12 @@ read_certlist(P3DPackage *package) { #else // _WIN32 fp = fopen(filename.c_str(), "r"); #endif // _WIN32 - if (fp != NULL) { - x509 = PEM_read_X509(fp, NULL, NULL, (void *)""); + if (fp != nullptr) { + x509 = PEM_read_X509(fp, nullptr, nullptr, (void *)""); fclose(fp); } - if (x509 != NULL) { + if (x509 != nullptr) { string der2 = cert_to_der(x509); _approved_certs.insert(der2); } @@ -952,7 +952,7 @@ get_cert_dir(X509 *cert) { */ string P3DInstanceManager:: cert_to_der(X509 *cert) { - int buffer_size = i2d_X509(cert, NULL); + int buffer_size = i2d_X509(cert, nullptr); unsigned char *buffer = new unsigned char[buffer_size]; unsigned char *p = buffer; i2d_X509(cert, &p); @@ -1001,7 +1001,7 @@ uninstall_all() { */ P3DInstanceManager *P3DInstanceManager:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new P3DInstanceManager; } return _global_ptr; @@ -1013,9 +1013,9 @@ get_global_ptr() { */ void P3DInstanceManager:: delete_global_ptr() { - if (_global_ptr != NULL) { + if (_global_ptr != nullptr) { delete _global_ptr; - _global_ptr = NULL; + _global_ptr = nullptr; } } @@ -1072,13 +1072,13 @@ scan_directory(const string &dirname, vector &contents) { size_t orig_size = contents.size(); DIR *root = opendir(dirname.c_str()); - if (root == (DIR *)NULL) { + if (root == nullptr) { return false; } struct dirent *d; d = readdir(root); - while (d != (struct dirent *)NULL) { + while (d != nullptr) { if (d->d_name[0] != '.') { contents.push_back(d->d_name); } @@ -1347,13 +1347,13 @@ create_runtime_environment() { // $TEMP or $TMP being defined specifically, and if they are, we'll use // GetTempPath(); otherwise, we'll fall back to SHGetSpecialFolderPath(). - if (getenv("TEMP") != NULL || getenv("TMP") != NULL) { + if (getenv("TEMP") != nullptr || getenv("TMP") != nullptr) { if (GetTempPathW(MAX_PATH, buffer_1) != 0) { temp_directory_w = buffer_1; } } if (temp_directory_w.empty()) { - if (SHGetSpecialFolderPathW(NULL, buffer_1, CSIDL_INTERNET_CACHE, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer_1, CSIDL_INTERNET_CACHE, true)) { temp_directory_w = buffer_1; // That just *might* return a non-writable folder, if we're in Protected @@ -1379,9 +1379,9 @@ create_runtime_environment() { } // Also insist that the temp directory is fully specified. - size_t needs_size_2 = GetFullPathNameW(temp_directory_w.c_str(), 0, NULL, NULL); + size_t needs_size_2 = GetFullPathNameW(temp_directory_w.c_str(), 0, nullptr, nullptr); wchar_t *buffer_2 = new wchar_t[needs_size_2]; - if (GetFullPathNameW(temp_directory_w.c_str(), needs_size_2, buffer_2, NULL) != 0) { + if (GetFullPathNameW(temp_directory_w.c_str(), needs_size_2, buffer_2, nullptr) != 0) { temp_directory_w = buffer_2; } delete[] buffer_2; @@ -1428,7 +1428,7 @@ create_runtime_environment() { struct sigaction ignore; memset(&ignore, 0, sizeof(ignore)); ignore.sa_handler = SIG_IGN; - sigaction(SIGINT, &ignore, NULL); + sigaction(SIGINT, &ignore, nullptr); } #endif @@ -1482,9 +1482,9 @@ nt_thread_run() { for (ni = instances.begin(); ni != instances.end(); ++ni) { // TODO: a race condition here when instances are deleted. P3DInstance *inst = (*ni); - assert(inst != NULL); + assert(inst != nullptr); P3D_request_ready_func *func = inst->get_request_ready_func(); - if (func != NULL) { + if (func != nullptr) { (*func)(inst); } } @@ -1505,7 +1505,7 @@ supports_win64() { LPFN_ISWOW64PROCESS _IsWow64Process; _IsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process"); - if (_IsWow64Process != NULL) { + if (_IsWow64Process != nullptr) { if (!_IsWow64Process(GetCurrentProcess(), &is_win64)) { is_win64 = false; } diff --git a/direct/src/plugin/p3dMainObject.cxx b/direct/src/plugin/p3dMainObject.cxx index c905c8805b..adda6129d6 100644 --- a/direct/src/plugin/p3dMainObject.cxx +++ b/direct/src/plugin/p3dMainObject.cxx @@ -23,8 +23,8 @@ */ P3DMainObject:: P3DMainObject() : - _pyobj(NULL), - _inst(NULL), + _pyobj(nullptr), + _inst(nullptr), _unauth_play(false) { } @@ -34,7 +34,7 @@ P3DMainObject() : */ P3DMainObject:: ~P3DMainObject() { - set_pyobj(NULL); + set_pyobj(nullptr); // Clear the local properties. Properties::const_iterator pi; @@ -83,10 +83,10 @@ get_float() { */ void P3DMainObject:: make_string(string &value) { - if (_pyobj == NULL) { + if (_pyobj == nullptr) { value = "P3DMainObject"; } else { - int size = P3D_OBJECT_GET_STRING(_pyobj, NULL, 0); + int size = P3D_OBJECT_GET_STRING(_pyobj, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(_pyobj, buffer, size); value = string(buffer, size); @@ -100,7 +100,7 @@ make_string(string &value) { */ P3D_object *P3DMainObject:: get_property(const string &property) { - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // Without a pyobj, we just report whatever's been stored locally. Properties::const_iterator pi; pi = _properties.find(property); @@ -109,7 +109,7 @@ get_property(const string &property) { P3D_OBJECT_INCREF(result); return result; } - return NULL; + return nullptr; } // With a pyobj, we pass the query down to it. @@ -123,9 +123,9 @@ get_property(const string &property) { bool P3DMainObject:: set_property(const string &property, bool needs_response, P3D_object *value) { // First, we set the property locally. - if (value != NULL) { + if (value != nullptr) { Properties::iterator pi; - pi = _properties.insert(Properties::value_type(property, (P3D_object *)NULL)).first; + pi = _properties.insert(Properties::value_type(property, nullptr)).first; assert(pi != _properties.end()); P3D_object *orig_value = (*pi).second; if (orig_value != value) { @@ -144,7 +144,7 @@ set_property(const string &property, bool needs_response, P3D_object *value) { } } - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // Without a pyobj, that's all we do. return true; } @@ -171,7 +171,7 @@ has_method(const string &method_name) { return true; } - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // No methods until we get our pyobj. return false; } @@ -197,7 +197,7 @@ call(const string &method_name, bool needs_response, if (i != 0) { nout << ", "; } - int buffer_size = P3D_OBJECT_GET_REPR(params[i], NULL, 0); + int buffer_size = P3D_OBJECT_GET_REPR(params[i], nullptr, 0); char *buffer = new char[buffer_size]; P3D_OBJECT_GET_REPR(params[i], buffer, buffer_size); nout.write(buffer, buffer_size); @@ -217,9 +217,9 @@ call(const string &method_name, bool needs_response, return call_uninstall(params, num_params); } - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // No methods until we get our pyobj. - return NULL; + return nullptr; } return P3D_OBJECT_CALL(_pyobj, method_name.c_str(), needs_response, @@ -251,9 +251,9 @@ set_pyobj(P3D_object *pyobj) { // actually need to set the reference; instead, we clear anything we had // set. nout << "application shares main object\n"; - pyobj = NULL; + pyobj = nullptr; - } else if (pyobj != NULL) { + } else if (pyobj != nullptr) { // In the alternate case, the application has its own, separate // appRunner.main object. Thus, we do need to set the pointer. nout << "application has its own main object\n"; @@ -262,7 +262,7 @@ set_pyobj(P3D_object *pyobj) { if (_pyobj != pyobj) { P3D_OBJECT_XDECREF(_pyobj); _pyobj = pyobj; - if (_pyobj != NULL) { + if (_pyobj != nullptr) { P3D_OBJECT_INCREF(_pyobj); // Now that we have a pyobj, we have to transfer down all of the @@ -288,7 +288,7 @@ get_pyobj() const { */ void P3DMainObject:: apply_properties(P3D_object *pyobj) { - P3DPythonObject *p3dpyobj = NULL; + P3DPythonObject *p3dpyobj = nullptr; if (pyobj->_class == &P3DObject::_object_class) { p3dpyobj = ((P3DObject *)pyobj)->as_python_object(); } @@ -297,7 +297,7 @@ apply_properties(P3D_object *pyobj) { for (pi = _properties.begin(); pi != _properties.end(); ++pi) { const string &property_name = (*pi).first; P3D_object *value = (*pi).second; - if (p3dpyobj != NULL && P3D_OBJECT_GET_TYPE(value) != P3D_OT_object) { + if (p3dpyobj != nullptr && P3D_OBJECT_GET_TYPE(value) != P3D_OT_object) { // If we know we have an actual P3DPythonObject (we really expect this), // then we can call set_property_insecure() directly, because we want to // allow setting the initial properties even if Javascript has no @@ -317,7 +317,7 @@ apply_properties(P3D_object *pyobj) { */ void P3DMainObject:: set_instance(P3DInstance *inst) { - if (_inst != NULL) { + if (_inst != nullptr) { // Save the game log filename of the instance just before it goes away, in // case JavaScript asks for it later. _game_log_pathname = _inst->get_log_pathname(); @@ -341,7 +341,7 @@ set_instance(P3DInstance *inst) { P3D_object *P3DMainObject:: call_play(P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - if (_inst == NULL) { + if (_inst == nullptr) { return inst_mgr->new_bool_object(false); } @@ -372,7 +372,7 @@ call_play(P3D_object *params[], int num_params) { */ P3D_object *P3DMainObject:: call_read_game_log(P3D_object *params[], int num_params) { - if (_inst != NULL) { + if (_inst != nullptr) { string log_pathname = _inst->get_log_pathname(); return read_log(log_pathname, params, num_params); } @@ -413,7 +413,7 @@ call_read_log(P3D_object *params[], int num_params) { return inst_mgr->new_undefined_object(); } - int size = P3D_OBJECT_GET_STRING(params[0], NULL, 0); + int size = P3D_OBJECT_GET_STRING(params[0], nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(params[0], buffer, size); string log_filename = string(buffer, size); @@ -599,7 +599,7 @@ read_log_file(const string &log_pathname, size_t buffer_bytes = max(max(full_bytes, head_bytes), tail_bytes) + 1; nout << "allocating " << buffer_bytes << " bytes to read at a time from file of size " << file_size << ".\n"; char *buffer = new char[buffer_bytes]; - if (buffer == NULL) { + if (buffer == nullptr) { log_data << "== PandaLog-" << "Error allocating buffer"; log_data << " " << "(" << log_leafname << ")" << "\n"; return; @@ -659,7 +659,7 @@ read_log_file(const string &log_pathname, // cleanup delete[] buffer; - buffer = NULL; + buffer = nullptr; } /** @@ -673,7 +673,7 @@ call_uninstall(P3D_object *params[], int num_params) { // Get the first parameter, the uninstall mode. string mode; if (num_params > 0) { - int size = P3D_OBJECT_GET_STRING(params[0], NULL, 0); + int size = P3D_OBJECT_GET_STRING(params[0], nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(params[0], buffer, size); mode = string(buffer, size); @@ -686,7 +686,7 @@ call_uninstall(P3D_object *params[], int num_params) { return inst_mgr->new_bool_object(true); } - if (_inst != NULL) { + if (_inst != nullptr) { nout << "uninstall " << mode << " for " << _inst << "\n"; bool success = false; if (mode == "host") { diff --git a/direct/src/plugin/p3dMultifileReader.cxx b/direct/src/plugin/p3dMultifileReader.cxx index 2ab529f887..dfaf4d8a2d 100644 --- a/direct/src/plugin/p3dMultifileReader.cxx +++ b/direct/src/plugin/p3dMultifileReader.cxx @@ -88,7 +88,7 @@ extract_all(const string &to_dir, P3DPackage *package, for (si = _subfiles.begin(); si != _subfiles.end(); ++si) { const Subfile &s = (*si); FileSpec file; - if (package != NULL && !package->is_extractable(file, s._filename)) { + if (package != nullptr && !package->is_extractable(file, s._filename)) { continue; } @@ -127,7 +127,7 @@ extract_all(const string &to_dir, P3DPackage *package, // or something. chmod(output_pathname.c_str(), 0555); - if (step != NULL && package != NULL) { + if (step != nullptr && package != nullptr) { step->thread_add_bytes_done(s._data_length); } } @@ -409,7 +409,7 @@ check_signatures() { // Now convert each of the certificates to an X509 object, and store it in // our CertChain. CertChain chain; - EVP_PKEY *pkey = NULL; + EVP_PKEY *pkey = nullptr; if (buffer_size > 0) { #if OPENSSL_VERSION_NUMBER >= 0x00908000L // Beginning in 0.9.8, d2i_X509() accepted a const unsigned char **. @@ -420,13 +420,13 @@ check_signatures() { #endif bp = (unsigned char *)&buffer[0]; bp_end = bp + buffer_size; - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (num_certs > 0 && x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (num_certs > 0 && x509 != nullptr) { chain.push_back(CertRecord(x509)); --num_certs; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } - if (num_certs != 0 || x509 != NULL) { + if (num_certs != 0 || x509 != nullptr) { nout << "Extra data in signature record.\n"; } } @@ -437,7 +437,7 @@ check_signatures() { pkey = X509_get_pubkey(chain[0]._cert); } - if (pkey != NULL) { + if (pkey != nullptr) { EVP_MD_CTX *md_ctx; #if OPENSSL_VERSION_NUMBER >= 0x00907000L md_ctx = EVP_MD_CTX_create(); diff --git a/direct/src/plugin/p3dObject.cxx b/direct/src/plugin/p3dObject.cxx index 5f17ee3e2e..a8393a6c11 100644 --- a/direct/src/plugin/p3dObject.cxx +++ b/direct/src/plugin/p3dObject.cxx @@ -77,7 +77,7 @@ static P3D_object * object_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { - if (method_name == NULL) { + if (method_name == nullptr) { method_name = ""; } return ((P3DObject *)object)->call(method_name, needs_response, params, num_params); @@ -147,7 +147,7 @@ generic_get_repr(P3D_object *object, char *buffer, int buffer_length) { static P3D_object * generic_get_property(P3D_object *object, const char *property) { - return NULL; + return nullptr; } static bool @@ -164,12 +164,12 @@ generic_has_method(P3D_object *object, const char *method_name) { static P3D_object * generic_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { - return NULL; + return nullptr; } static P3D_object * generic_eval(P3D_object *object, const char *expression) { - return NULL; + return nullptr; } P3D_class_definition P3DObject::_generic_class = { @@ -244,7 +244,7 @@ get_repr(char *buffer, int buffer_length) { */ P3D_object *P3DObject:: get_property(const string &property) { - return NULL; + return nullptr; } /** @@ -275,7 +275,7 @@ has_method(const string &method_name) { P3D_object *P3DObject:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { - return NULL; + return nullptr; } /** @@ -284,7 +284,7 @@ call(const string &method_name, bool needs_response, */ P3D_object *P3DObject:: eval(const string &expression) { - return NULL; + return nullptr; } /** @@ -317,7 +317,7 @@ fill_xml(TiXmlElement *xvalue, P3DSession *session) { */ P3D_object **P3DObject:: get_object_array() { - return NULL; + return nullptr; } /** @@ -335,7 +335,7 @@ get_object_array_size() { */ P3DPythonObject *P3DObject:: as_python_object() { - return NULL; + return nullptr; } /** @@ -345,7 +345,7 @@ as_python_object() { bool P3DObject:: get_bool_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return 0; } bool bresult = P3D_OBJECT_GET_BOOL(result); @@ -370,7 +370,7 @@ set_bool_property(const string &property, bool value) { int P3DObject:: get_int_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return 0; } int iresult = P3D_OBJECT_GET_INT(result); @@ -395,7 +395,7 @@ set_int_property(const string &property, int value) { double P3DObject:: get_float_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return 0.0; } double fresult = P3D_OBJECT_GET_FLOAT(result); @@ -421,11 +421,11 @@ set_float_property(const string &property, double value) { string P3DObject:: get_string_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return string(); } - int size = P3D_OBJECT_GET_STRING(result, NULL, 0); + int size = P3D_OBJECT_GET_STRING(result, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(result, buffer, size); string sresult(buffer, size); diff --git a/direct/src/plugin/p3dOsxSplashWindow.I b/direct/src/plugin/p3dOsxSplashWindow.I index 4778fd40cc..a9573dafa4 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.I +++ b/direct/src/plugin/p3dOsxSplashWindow.I @@ -16,11 +16,11 @@ */ inline P3DOsxSplashWindow::OsxImageData:: OsxImageData() { - _raw_data = NULL; - _image = NULL; - _color_space = NULL; - _provider = NULL; - _data = NULL; + _raw_data = nullptr; + _image = nullptr; + _color_space = nullptr; + _provider = nullptr; + _data = nullptr; } /** diff --git a/direct/src/plugin/p3dOsxSplashWindow.cxx b/direct/src/plugin/p3dOsxSplashWindow.cxx index c8fc969679..d504d58671 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.cxx +++ b/direct/src/plugin/p3dOsxSplashWindow.cxx @@ -33,7 +33,7 @@ P3DOsxSplashWindow:: P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : P3DSplashWindow(inst, make_visible) { - _font_attribs = NULL; + _font_attribs = nullptr; _install_progress = 0; _progress_known = true; _received_data = 0; @@ -41,7 +41,7 @@ P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : // We have to start with _mouse_active true; firefox doesn't send activate // events. _mouse_active = true; - _toplevel_window = NULL; + _toplevel_window = nullptr; } /** @@ -49,13 +49,13 @@ P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : */ P3DOsxSplashWindow:: ~P3DOsxSplashWindow() { - if (_toplevel_window != NULL) { + if (_toplevel_window != nullptr) { SetWRefCon(_toplevel_window, 0); HideWindow(_toplevel_window); DisposeWindow(_toplevel_window); - _toplevel_window = NULL; + _toplevel_window = nullptr; } - if (_font_attribs != NULL) { + if (_font_attribs != nullptr) { CFRelease(_font_attribs); } } @@ -72,7 +72,7 @@ set_wparams(const P3DWindowParams &wparams) { if (_wparams.get_window_type() == P3D_WT_toplevel || _wparams.get_window_type() == P3D_WT_fullscreen) { // Creating a toplevel splash window. - if (_toplevel_window == NULL) { + if (_toplevel_window == nullptr) { Rect r; r.top = _wparams.get_win_y(); r.left = _wparams.get_win_x(); @@ -134,7 +134,7 @@ set_wparams(const P3DWindowParams &wparams) { CFTypeRef traits_values[1] = { symbolic_ref }; CFDictionaryRef traits = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&traits_keys, (const void **)&traits_values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFStringRef family = CFStringCreateWithCString(NULL, _font_family.c_str(), kCFStringEncodingUTF8); + CFStringRef family = CFStringCreateWithCString(nullptr, _font_family.c_str(), kCFStringEncodingUTF8); CFStringRef attribs_keys[2] = { kCTFontFamilyNameAttribute, kCTFontTraitsAttribute }; CFTypeRef attribs_values[2] = { family, traits }; @@ -142,7 +142,7 @@ set_wparams(const P3DWindowParams &wparams) { // Create the font object. CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes(attribs); - CTFontRef font = CTFontCreateWithFontDescriptor(font_desc, _font_size, NULL); + CTFontRef font = CTFontCreateWithFontDescriptor(font_desc, _font_size, nullptr); CFStringRef keys[1] = { kCTFontAttributeName }; CFTypeRef values[1] = { font }; @@ -164,7 +164,7 @@ void P3DOsxSplashWindow:: set_visible(bool visible) { P3DSplashWindow::set_visible(visible); - if (_toplevel_window != NULL) { + if (_toplevel_window != nullptr) { if (_visible) { ShowWindow(_toplevel_window); } else { @@ -266,7 +266,7 @@ refresh() { if (!_visible) { return; } - if (_toplevel_window != NULL) { + if (_toplevel_window != nullptr) { Rect r = { 0, 0, (short)_win_height, (short)_win_width }; InvalWindowRect(_toplevel_window, &r); @@ -284,13 +284,13 @@ paint_window() { return; } - if (_toplevel_window != NULL || + if (_toplevel_window != nullptr || _wparams.get_parent_window()._window_handle_type == P3D_WHT_osx_port) { // The old QuickDraw-style window handle. We use CreateCGContextForPort() // to map this to the new CoreGraphics-style. - GrafPtr out_port = NULL; - if (_toplevel_window != NULL) { + GrafPtr out_port = nullptr; + if (_toplevel_window != nullptr) { GetPort(&out_port); } else { @@ -394,13 +394,13 @@ handle_event_osx_event_record(const P3D_event_data &event) { const P3D_window_handle &handle = _wparams.get_parent_window(); if (handle._window_handle_type == P3D_WHT_osx_port) { GrafPtr out_port = handle._handle._osx_port._port; - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(out_port, &port_save); GlobalToLocal(&pt); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } } else if (handle._window_handle_type == P3D_WHT_osx_cgcontext) { @@ -408,7 +408,7 @@ handle_event_osx_event_record(const P3D_event_data &event) { // window coordinates. WindowRef window = handle._handle._osx_cgcontext._window; CGPoint cgpt = { (CGFloat)pt.h, (CGFloat)pt.v }; - HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL, + HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, nullptr, kHICoordSpaceWindow, window); // Then convert to plugin coordinates. @@ -536,7 +536,7 @@ load_image(OsxImageData &image, const string &image_filename) { } image._data = - CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, + CFDataCreateWithBytesNoCopy(nullptr, (const UInt8 *)image._raw_data, image._height * new_row_stride, kCFAllocatorNull); image._provider = CGDataProviderCreateWithCFData(image._data); image._color_space = CGColorSpaceCreateDeviceRGB(); @@ -545,7 +545,7 @@ load_image(OsxImageData &image, const string &image_filename) { CGImageCreate(image._width, image._height, 8, 32, new_row_stride, image._color_space, kCGImageAlphaFirst | kCGBitmapByteOrder32Little, - image._provider, NULL, false, kCGRenderingIntentDefault); + image._provider, nullptr, false, kCGRenderingIntentDefault); } /** @@ -554,7 +554,7 @@ load_image(OsxImageData &image, const string &image_filename) { */ bool P3DOsxSplashWindow:: paint_image(CGContextRef context, const OsxImageData &image) { - if (image._image == NULL) { + if (image._image == nullptr) { return false; } @@ -675,8 +675,8 @@ paint_progress_bar(CGContextRef context) { CGContextSetTextMatrix(context, text_xform); // Now draw the install_label right above it. - CFStringRef string = CFStringCreateWithCString(NULL, _install_label.c_str(), kCFStringEncodingUTF8); - CFAttributedStringRef attr_string = CFAttributedStringCreate(NULL, string, _font_attribs); + CFStringRef string = CFStringCreateWithCString(nullptr, _install_label.c_str(), kCFStringEncodingUTF8); + CFAttributedStringRef attr_string = CFAttributedStringCreate(nullptr, string, _font_attribs); CTLineRef line = CTLineCreateWithAttributedString(attr_string); // Determine the placement based on the size of the text. @@ -716,11 +716,11 @@ OSStatus P3DOsxSplashWindow:: event_callback(EventHandlerCallRef my_handler, EventRef event) { OSStatus result = eventNotHandledErr; - WindowRef window = NULL; + WindowRef window = nullptr; UInt32 the_class = GetEventClass(event); UInt32 kind = GetEventKind(event); - GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, - sizeof(WindowRef), NULL, (void*) &window); + GetEventParameter(event, kEventParamWindowRef, typeWindowRef, nullptr, + sizeof(WindowRef), nullptr, (void*) &window); switch (the_class) { case kEventClassWindow: switch (kind) { @@ -773,17 +773,17 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) { case kEventMouseDragged: { Point point; - GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof(Point), NULL, (void *)&point); + GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, nullptr, + sizeof(Point), nullptr, (void *)&point); GrafPtr port; - assert(_toplevel_window != NULL); + assert(_toplevel_window != nullptr); port = GetWindowPort(_toplevel_window); - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(port, &port_save); GlobalToLocal(&point); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } set_mouse_data(point.h, point.v, _mouse_down); @@ -800,25 +800,25 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) { */ void P3DOsxSplashWindow::OsxImageData:: dump_image() { - if (_image != NULL) { + if (_image != nullptr) { CGImageRelease(_image); - _image = NULL; + _image = nullptr; } - if (_color_space != NULL) { + if (_color_space != nullptr) { CGColorSpaceRelease(_color_space); - _color_space = NULL; + _color_space = nullptr; } - if (_provider != NULL) { + if (_provider != nullptr) { CGDataProviderRelease(_provider); - _provider = NULL; + _provider = nullptr; } - if (_data != NULL) { + if (_data != nullptr) { CFRelease(_data); - _data = NULL; + _data = nullptr; } - if (_raw_data != NULL) { + if (_raw_data != nullptr) { delete[] _raw_data; - _raw_data = NULL; + _raw_data = nullptr; } } diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 0560c0f6da..1efead479b 100644 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -59,16 +59,16 @@ P3DPackage(P3DHost *host, const string &package_name, _host_contents_iseq = 0; - _xconfig = NULL; - _temp_contents_file = NULL; + _xconfig = nullptr; + _temp_contents_file = nullptr; _computed_plan_size = false; _info_ready = false; _allow_data_download = false; _ready = false; _failed = false; - _active_download = NULL; - _saved_download = NULL; + _active_download = nullptr; + _saved_download = nullptr; _updated = false; } @@ -89,24 +89,24 @@ P3DPackage:: } _instances.clear(); - if (_xconfig != NULL) { + if (_xconfig != nullptr) { delete _xconfig; - _xconfig = NULL; + _xconfig = nullptr; } // Cancel any pending download. - if (_active_download != NULL) { + if (_active_download != nullptr) { _active_download->cancel(); - set_active_download(NULL); + set_active_download(nullptr); } - if (_saved_download != NULL) { + if (_saved_download != nullptr) { _saved_download->cancel(); - set_saved_download(NULL); + set_saved_download(nullptr); } - if (_temp_contents_file != NULL) { + if (_temp_contents_file != nullptr) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } } @@ -192,9 +192,9 @@ remove_instance(P3DInstance *inst) { if (inst == _instances[0]) { // This was the primary instance. Cancel any pending download and move to // the next instance. - if (_active_download != NULL) { + if (_active_download != nullptr) { _active_download->cancel(); - set_active_download(NULL); + set_active_download(nullptr); } } @@ -226,12 +226,12 @@ mark_used() { } TiXmlElement *xusage = doc.FirstChildElement("usage"); - if (xusage == NULL) { + if (xusage == nullptr) { xusage = new TiXmlElement("usage"); doc.LinkEndChild(xusage); } - time_t now = time(NULL); + time_t now = time(nullptr); int count = 0; xusage->Attribute("count_runtime", &count); if (count == 0) { @@ -292,7 +292,7 @@ uninstall() { for (ii = _instances.begin(); ii != _instances.end(); ++ii) { P3DInstance *inst = (*ii); P3DSession *session = inst->get_session(); - if (session != NULL) { + if (session != nullptr) { nout << "Stopping session " << session << "\n"; session->shutdown(); } @@ -350,7 +350,7 @@ begin_info_download() { return; } - if (_active_download != NULL) { + if (_active_download != nullptr) { // In the middle of downloading. return; } @@ -387,9 +387,9 @@ download_contents_file() { // Download contents.xml to a temporary filename first, in case multiple // packages are downloading it simultaneously. - if (_temp_contents_file != NULL) { + if (_temp_contents_file != nullptr) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } _temp_contents_file = new P3DTemporaryFile(".xml"); @@ -404,7 +404,7 @@ void P3DPackage:: contents_file_download_finished(bool success) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (!_host->has_current_contents_file(inst_mgr)) { - if (!success || _temp_contents_file == NULL || + if (!success || _temp_contents_file == nullptr || !_host->read_contents_file(_temp_contents_file->get_filename(), true)) { if (_temp_contents_file) { @@ -429,7 +429,7 @@ contents_file_download_finished(bool success) { report_done(false); if (_temp_contents_file) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } return; } @@ -439,7 +439,7 @@ contents_file_download_finished(bool success) { // The file is correctly installed by now; we can remove the temporary file. if (_temp_contents_file) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } host_got_contents_file(); @@ -460,8 +460,8 @@ contents_file_download_finished(bool success) { */ void P3DPackage:: redownload_contents_file(P3DPackage::Download *download) { - assert(_active_download == NULL); - assert(_saved_download == NULL); + assert(_active_download == nullptr); + assert(_saved_download == nullptr); if (_host->get_contents_iseq() != _host_contents_iseq) { // If the contents_iseq number has changed, we don't even need to download @@ -479,9 +479,9 @@ redownload_contents_file(P3DPackage::Download *download) { set_saved_download(download); // Download contents.xml to a temporary filename first. - if (_temp_contents_file != NULL) { + if (_temp_contents_file != nullptr) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } _temp_contents_file = new P3DTemporaryFile(".xml"); @@ -521,14 +521,14 @@ contents_file_redownload_finished(bool success) { // We no longer need the temporary file. if (_temp_contents_file) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } if (contents_changed) { // OK, the contents.xml has changed; this means we have to restart the // whole download process from the beginning. nout << "Redownloading contents.xml made a difference.\n"; - set_saved_download(NULL); + set_saved_download(nullptr); host_got_contents_file(); } else { @@ -536,8 +536,8 @@ contents_file_redownload_finished(bool success) { // you to our regularly scheduled download. nout << "Redownloading contents.xml didn't help.\n"; Download *download = _saved_download; - _saved_download = NULL; - if (download == NULL) { + _saved_download = nullptr; + if (download == nullptr) { // But, if _saved_download was NULL (meaning NULL was passed to // redownload_contents_file(), above), it means that we were called from // download_desc_file(), and there's nothing more to do. We're just @@ -639,7 +639,7 @@ download_desc_file() { nout << "Couldn't find package " << _package_fullname << ", platform \"" << _package_platform << "\" in contents file.\n"; - redownload_contents_file(NULL); + redownload_contents_file(nullptr); return; } @@ -730,7 +730,7 @@ desc_file_download_finished(bool success) { void P3DPackage:: got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { TiXmlElement *xpackage = doc->FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { nout << _package_name << " desc file contains no \n"; if (!freshly_downloaded) { download_desc_file(); @@ -752,9 +752,9 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { xpackage->Attribute("patch_version", &_patch_version); TiXmlElement *xconfig = xpackage->FirstChildElement("config"); - if (xconfig != NULL) { + if (xconfig != nullptr) { const char *display_name_cstr = xconfig->Attribute("display_name"); - if (display_name_cstr != NULL) { + if (display_name_cstr != nullptr) { _package_display_name = display_name_cstr; } @@ -767,7 +767,7 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { TiXmlElement *xcompressed_archive = xpackage->FirstChildElement("compressed_archive"); - if (xuncompressed_archive == NULL || xcompressed_archive == NULL) { + if (xuncompressed_archive == nullptr || xcompressed_archive == nullptr) { // The desc file didn't include the archive file itself, weird. if (!freshly_downloaded) { download_desc_file(); @@ -784,7 +784,7 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { _unpack_size = 0; _extracts.clear(); TiXmlElement *xextract = xpackage->FirstChildElement("extract"); - while (xextract != NULL) { + while (xextract != nullptr) { FileSpec file; file.load_xml(xextract); _extracts.push_back(file); @@ -797,16 +797,16 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { // Get the required packages. _requires.clear(); TiXmlElement *xrequires = xpackage->FirstChildElement("requires"); - while (xrequires != NULL) { + while (xrequires != nullptr) { const char *package_name = xrequires->Attribute("name"); const char *host_url = xrequires->Attribute("host"); - if (package_name != NULL && host_url != NULL) { + if (package_name != nullptr && host_url != nullptr) { const char *version = xrequires->Attribute("version"); - if (version == NULL) { + if (version == nullptr) { version = ""; } const char *seq = xrequires->Attribute("seq"); - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } P3DHost *host = inst_mgr->get_host(host_url); @@ -969,14 +969,14 @@ build_install_plans(TiXmlDocument *doc) { // Maybe we've already read the md5 hash and we have it stored here. const FileSpec *on_disk_ptr = _uncompressed_archive.get_actual_file(); FileSpec on_disk; - if (on_disk_ptr == NULL) { + if (on_disk_ptr == nullptr) { // If not, we have to go read it now. if (on_disk.read_hash(_uncompressed_archive.get_pathname(_package_dir))) { on_disk_ptr = &on_disk; } } - if (on_disk_ptr != NULL) { + if (on_disk_ptr != nullptr) { P3DPatchFinder patch_finder; P3DPatchFinder::Patchfiles chain; if (patch_finder.get_patch_chain_to_current(chain, doc, *on_disk_ptr)) { @@ -1218,7 +1218,7 @@ P3DPackage::Download *P3DPackage:: start_download(P3DPackage::DownloadType dtype, const string &urlbase, const string &pathname, const FileSpec &file_spec) { // Only one download should be active at a time - assert(_active_download == NULL); + assert(_active_download == nullptr); // This can't happen! If verify_contents is set to P3D_VC_never, we're not // allowed to download anything, so we shouldn't get here P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -1249,7 +1249,7 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, } else { strm << _host->get_download_url_prefix(); } - strm << urlbase << "?" << time(NULL); + strm << urlbase << "?" << time(nullptr); string url = strm.str(); download->_try_urls.push_back(url); @@ -1315,11 +1315,11 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, void P3DPackage:: set_active_download(Download *download) { if (_active_download != download) { - if (_active_download != NULL) { + if (_active_download != nullptr) { p3d_unref_delete(_active_download); } _active_download = download; - if (_active_download != NULL) { + if (_active_download != nullptr) { _active_download->ref(); } } @@ -1332,11 +1332,11 @@ set_active_download(Download *download) { void P3DPackage:: set_saved_download(Download *download) { if (_saved_download != download) { - if (_saved_download != NULL) { + if (_saved_download != nullptr) { p3d_unref_delete(_saved_download); } _saved_download = download; - if (_saved_download != NULL) { + if (_saved_download != nullptr) { _saved_download->ref(); } } @@ -1456,11 +1456,11 @@ download_finished(bool success) { if (get_ref_count() == 1) { // No one cares anymore. nout << "No one cares about " << get_url() << "\n"; - _package->set_active_download(NULL); + _package->set_active_download(nullptr); return; } - _package->set_active_download(NULL); + _package->set_active_download(nullptr); assert(get_ref_count() > 0); if (success && !_file_spec.get_filename().empty()) { @@ -1471,7 +1471,7 @@ download_finished(bool success) { nout << "expected: "; _file_spec.output_hash(nout); nout << "\n"; - if (_file_spec.get_actual_file() != (FileSpec *)NULL) { + if (_file_spec.get_actual_file() != nullptr) { nout << " got: "; _file_spec.get_actual_file()->output_hash(nout); nout << "\n"; @@ -1578,7 +1578,7 @@ InstallStepDownloadFile(P3DPackage *package, const FileSpec &file) : _pathname = _package->get_package_dir() + "/" + _file.get_filename(); - _download = NULL; + _download = nullptr; } /** @@ -1586,7 +1586,7 @@ InstallStepDownloadFile(P3DPackage *package, const FileSpec &file) : */ P3DPackage::InstallStepDownloadFile:: ~InstallStepDownloadFile() { - if (_download != NULL) { + if (_download != nullptr) { p3d_unref_delete(_download); } } @@ -1596,13 +1596,13 @@ P3DPackage::InstallStepDownloadFile:: */ P3DPackage::InstallToken P3DPackage::InstallStepDownloadFile:: do_step(bool download_finished) { - if (_download == NULL) { + if (_download == nullptr) { // First, we have to start the download going. - assert(_package->_active_download == NULL); + assert(_package->_active_download == nullptr); _download = _package->start_download(DT_install_step, _urlbase, _pathname, _file); - assert(_download != NULL); + assert(_download != nullptr); _download->ref(); } @@ -1632,7 +1632,7 @@ do_step(bool download_finished) { nout << "Restarting download of " << _urlbase << " on new instance\n"; p3d_unref_delete(_download); - _download = NULL; + _download = nullptr; return IT_continue; } else { diff --git a/direct/src/plugin/p3dPatchFinder.cxx b/direct/src/plugin/p3dPatchFinder.cxx index c3e5b80c86..044953b3af 100644 --- a/direct/src/plugin/p3dPatchFinder.cxx +++ b/direct/src/plugin/p3dPatchFinder.cxx @@ -24,8 +24,8 @@ PackageVersion(const PackageVersionKey &key) : _host_url(key._host_url), _file(key._file) { - _package_current = NULL; - _package_base = NULL; + _package_current = nullptr; + _package_base = nullptr; } /** @@ -58,7 +58,7 @@ get_patch_chain(Patchfiles &chain, PackageVersion *start_pv, for (pi = _from_patches.begin(); pi != _from_patches.end(); ++pi) { Patchfile *patchfile = (*pi); PackageVersion *from_pv = patchfile->_from_pv; - assert(from_pv != NULL); + assert(from_pv != nullptr); Patchfiles this_chain; if (from_pv->get_patch_chain(this_chain, start_pv, already_visited)) { // There's a path through this patchfile. @@ -129,8 +129,8 @@ output(ostream &out) const { P3DPatchFinder::Patchfile:: Patchfile(Package *package) : _package(package), - _from_pv(NULL), - _to_pv(NULL) + _from_pv(nullptr), + _to_pv(nullptr) { _package_name = package->_package_name; _platform = package->_platform; @@ -161,30 +161,30 @@ get_target_key() const { void P3DPatchFinder::Patchfile:: load_xml(TiXmlElement *xpatch) { const char *package_name_cstr = xpatch->Attribute("name"); - if (package_name_cstr != NULL && *package_name_cstr) { + if (package_name_cstr != nullptr && *package_name_cstr) { _package_name = package_name_cstr; } const char *platform_cstr = xpatch->Attribute("platform"); - if (platform_cstr != NULL && *platform_cstr) { + if (platform_cstr != nullptr && *platform_cstr) { _platform = platform_cstr; } const char *version_cstr = xpatch->Attribute("version"); - if (version_cstr != NULL && *version_cstr) { + if (version_cstr != nullptr && *version_cstr) { _version = version_cstr; } const char *host_url_cstr = xpatch->Attribute("host"); - if (host_url_cstr != NULL && *host_url_cstr) { + if (host_url_cstr != nullptr && *host_url_cstr) { _host_url = host_url_cstr; } _file.load_xml(xpatch); TiXmlElement *xsource = xpatch->FirstChildElement("source"); - if (xsource != NULL) { + if (xsource != nullptr) { _source_file.load_xml(xsource); } TiXmlElement *xtarget = xpatch->FirstChildElement("target"); - if (xtarget != NULL) { + if (xtarget != nullptr) { _target_file.load_xml(xtarget); } } @@ -194,8 +194,8 @@ load_xml(TiXmlElement *xpatch) { */ P3DPatchFinder::Package:: Package() { - _current_pv = NULL; - _base_pv = NULL; + _current_pv = nullptr; + _base_pv = nullptr; _got_base_file = false; } @@ -230,43 +230,43 @@ get_generic_key(const FileSpec &file) const { bool P3DPatchFinder::Package:: read_desc_file(TiXmlDocument *doc) { TiXmlElement *xpackage = doc->FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { return false; } const char *package_name_cstr = xpackage->Attribute("name"); - if (package_name_cstr != NULL && *package_name_cstr) { + if (package_name_cstr != nullptr && *package_name_cstr) { _package_name = package_name_cstr; } const char *platform_cstr = xpackage->Attribute("platform"); - if (platform_cstr != NULL && *platform_cstr) { + if (platform_cstr != nullptr && *platform_cstr) { _platform = platform_cstr; } const char *version_cstr = xpackage->Attribute("version"); - if (version_cstr != NULL && *version_cstr) { + if (version_cstr != nullptr && *version_cstr) { _version = version_cstr; } const char *host_url_cstr = xpackage->Attribute("host"); - if (host_url_cstr != NULL && *host_url_cstr) { + if (host_url_cstr != nullptr && *host_url_cstr) { _host_url = host_url_cstr; } // Get the current version. TiXmlElement *xarchive = xpackage->FirstChildElement("uncompressed_archive"); - if (xarchive != NULL) { + if (xarchive != nullptr) { _current_file.load_xml(xarchive); } // Get the base_version--the bottom (oldest) of the patch chain. xarchive = xpackage->FirstChildElement("base_version"); - if (xarchive != NULL) { + if (xarchive != nullptr) { _base_file.load_xml(xarchive); _got_base_file = true; } _patches.clear(); TiXmlElement *xpatch = xpackage->FirstChildElement("patch"); - while (xpatch != NULL) { + while (xpatch != nullptr) { Patchfile *patchfile = new Patchfile(this); patchfile->load_xml(xpatch); _patches.push_back(patchfile); @@ -301,7 +301,7 @@ get_patch_chain_to_current(Patchfiles &chain, TiXmlDocument *doc, const FileSpec &file) { chain.clear(); Package *package = read_package_desc_file(doc); - if (package == NULL) { + if (package == nullptr) { return false; } @@ -309,7 +309,7 @@ get_patch_chain_to_current(Patchfiles &chain, TiXmlDocument *doc, PackageVersion *from_pv = get_package_version(package->get_generic_key(file)); PackageVersion *to_pv = package->_current_pv; - if (to_pv != NULL && from_pv != NULL) { + if (to_pv != nullptr && from_pv != nullptr) { return to_pv->get_patch_chain(chain, from_pv, PackageVersionsList()); } @@ -326,7 +326,7 @@ read_package_desc_file(TiXmlDocument *doc) { Package *package = new Package; if (!package->read_desc_file(doc)) { delete package; - return NULL; + return nullptr; } _packages.push_back(package); diff --git a/direct/src/plugin/p3dPythonMain.cxx b/direct/src/plugin/p3dPythonMain.cxx index 76cf92c7e4..3d8bbdc9e8 100644 --- a/direct/src/plugin/p3dPythonMain.cxx +++ b/direct/src/plugin/p3dPythonMain.cxx @@ -94,10 +94,10 @@ WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { int main(int argc, char *argv[]) { const char *program_name = argv[0]; - const char *archive_file = NULL; - const char *input_handle_str = NULL; - const char *output_handle_str = NULL; - const char *interactive_console_str = NULL; + const char *archive_file = nullptr; + const char *input_handle_str = nullptr; + const char *output_handle_str = nullptr; + const char *interactive_console_str = nullptr; if (argc > 1) { archive_file = argv[1]; @@ -112,13 +112,13 @@ main(int argc, char *argv[]) { interactive_console_str = argv[4]; } - if (archive_file == NULL || *archive_file == '\0') { + if (archive_file == nullptr || *archive_file == '\0') { cerr << "No archive filename specified on command line.\n"; return 1; } FHandle input_handle = invalid_fhandle; - if (input_handle_str != NULL && *input_handle_str) { + if (input_handle_str != nullptr && *input_handle_str) { stringstream stream(input_handle_str); stream >> input_handle; if (!stream) { @@ -127,7 +127,7 @@ main(int argc, char *argv[]) { } FHandle output_handle = invalid_fhandle; - if (output_handle_str != NULL && *output_handle_str) { + if (output_handle_str != nullptr && *output_handle_str) { stringstream stream(output_handle_str); stream >> output_handle; if (!stream) { @@ -136,7 +136,7 @@ main(int argc, char *argv[]) { } bool interactive_console = false; - if (interactive_console_str != NULL && *interactive_console_str) { + if (interactive_console_str != nullptr && *interactive_console_str) { stringstream stream(interactive_console_str); int flag; stream >> flag; @@ -146,7 +146,7 @@ main(int argc, char *argv[]) { } int status = run_p3dpython(program_name, archive_file, input_handle, - output_handle, NULL, interactive_console); + output_handle, nullptr, interactive_console); if (status != 0) { cerr << "Failure on startup.\n"; } diff --git a/direct/src/plugin/p3dPythonObject.cxx b/direct/src/plugin/p3dPythonObject.cxx index 3a771dbf72..fb52163b71 100644 --- a/direct/src/plugin/p3dPythonObject.cxx +++ b/direct/src/plugin/p3dPythonObject.cxx @@ -51,8 +51,8 @@ bool P3DPythonObject:: get_bool() { bool bresult = 0; - P3D_object *result = call("__bool__", true, NULL, 0); - if (result != NULL) { + P3D_object *result = call("__bool__", true, nullptr, 0); + if (result != nullptr) { bresult = P3D_OBJECT_GET_BOOL(result); P3D_OBJECT_DECREF(result); } @@ -67,8 +67,8 @@ int P3DPythonObject:: get_int() { int iresult = 0; - P3D_object *result = call("__int__", true, NULL, 0); - if (result != NULL) { + P3D_object *result = call("__int__", true, nullptr, 0); + if (result != nullptr) { iresult = P3D_OBJECT_GET_INT(result); P3D_OBJECT_DECREF(result); } @@ -83,8 +83,8 @@ double P3DPythonObject:: get_float() { double fresult = 0.0; - P3D_object *result = call("__float__", true, NULL, 0); - if (result != NULL) { + P3D_object *result = call("__float__", true, nullptr, 0); + if (result != nullptr) { fresult = P3D_OBJECT_GET_FLOAT(result); P3D_OBJECT_DECREF(result); } @@ -98,9 +98,9 @@ get_float() { */ void P3DPythonObject:: make_string(string &value) { - P3D_object *result = call("__str__", true, NULL, 0); - if (result != NULL) { - int size = P3D_OBJECT_GET_STRING(result, NULL, 0); + P3D_object *result = call("__str__", true, nullptr, 0); + if (result != nullptr) { + int size = P3D_OBJECT_GET_STRING(result, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(result, buffer, size); value = string(buffer, size); @@ -150,9 +150,9 @@ set_property_insecure(const string &property, bool needs_response, P3D_object *params[2]; params[0] = new P3DStringObject(property); - P3D_object *result = NULL; + P3D_object *result = nullptr; - if (value == NULL) { + if (value == nullptr) { // Delete an attribute. result = call_insecure("__del_property__", needs_response, params, 1); @@ -164,7 +164,7 @@ set_property_insecure(const string &property, bool needs_response, P3D_OBJECT_DECREF(params[0]); - if (result != NULL) { + if (result != nullptr) { bresult = P3D_OBJECT_GET_BOOL(result); P3D_OBJECT_DECREF(result); } @@ -193,7 +193,7 @@ has_method(const string &method_name) { P3D_object *result = call("__has_method__", true, params, 1); P3D_OBJECT_DECREF(params[0]); - if (result != NULL) { + if (result != nullptr) { bresult = P3D_OBJECT_GET_BOOL(result); P3D_OBJECT_DECREF(result); } @@ -219,7 +219,7 @@ call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { if (!_session->get_matches_script_origin()) { // If you can't be scripting us, you can't be calling methods. - return NULL; + return nullptr; } return call_insecure(method_name, needs_response, params, num_params); @@ -255,18 +255,18 @@ call_insecure(const string &method_name, bool needs_response, // NULL. if (!needs_response) { _session->send_command(doc); - return NULL; + return nullptr; } // If a response is requested, we have to send the command and wait for it. TiXmlDocument *response = _session->command_and_response(doc); - P3D_object *result = NULL; - if (response != NULL) { + P3D_object *result = nullptr; + if (response != nullptr) { TiXmlElement *xresponse = response->FirstChildElement("response"); - if (xresponse != NULL) { + if (xresponse != nullptr) { TiXmlElement *xvalue = xresponse->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { result = _session->xml_to_p3dobj(xvalue); } } @@ -282,9 +282,9 @@ call_insecure(const string &method_name, bool needs_response, */ void P3DPythonObject:: output(ostream &out) { - P3D_object *result = call("__repr__", true, NULL, 0); + P3D_object *result = call("__repr__", true, nullptr, 0); out << "Python " << _object_id; - if (result != NULL) { + if (result != nullptr) { out << ": " << *result; P3D_OBJECT_DECREF(result); } diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index 542c47acb8..3d657597fe 100644 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/direct/src/plugin/p3dPythonRun.cxx @@ -28,7 +28,7 @@ extern "C" { // There is only one P3DPythonRun object in any given process space. Makes // the statics easier to deal with, and we don't need multiple instances of // this thing. -P3DPythonRun *P3DPythonRun::_global_ptr = NULL; +P3DPythonRun *P3DPythonRun::_global_ptr = nullptr; TypeHandle P3DPythonRun::P3DWindowHandle::_type_handle; @@ -45,7 +45,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, _read_thread_continue = false; _program_continue = true; _session_terminated = false; - _taskMgr = NULL; + _taskMgr = nullptr; INIT_LOCK(_commands_lock); INIT_THREAD(_read_thread); @@ -55,7 +55,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, _interactive_console = interactive_console; - if (program_name != NULL) { + if (program_name != nullptr) { #if PY_MAJOR_VERSION >= 3 // Python 3 case: we have to convert it to a wstring. TextEncoder enc; @@ -66,7 +66,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, _program_name = program_name; #endif } - if (archive_file != NULL) { + if (archive_file != nullptr) { _archive_file = Filename::from_os_specific(archive_file); } @@ -76,7 +76,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, #else _py_argv[0] = (char *)_program_name.c_str(); #endif - _py_argv[1] = NULL; + _py_argv[1] = nullptr; #ifdef NDEBUG // In OPTIMIZE 4 compilation mode, run Python in optimized mode too. @@ -113,7 +113,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, PySys_SetArgvEx(_py_argc, _py_argv, 0); // Open the error output before we do too much more. - if (log_pathname != NULL && *log_pathname != '\0') { + if (log_pathname != nullptr && *log_pathname != '\0') { Filename f = Filename::from_os_specific(log_pathname); f.set_text(); if (f.open_write(_error_log)) { @@ -178,7 +178,7 @@ run_python() { // We could simply freeze it, but Python has a bug setting __path__ of // frozen modules properly. PyObject *panda3d_module = PyImport_AddModule("panda3d"); - if (panda3d_module == NULL) { + if (panda3d_module == nullptr) { nout << "Failed to add panda3d module:\n"; PyErr_Print(); return 1; @@ -192,7 +192,7 @@ run_python() { // Import the VFSImporter module that was frozen in. PyObject *vfsimporter_module = PyImport_ImportModule("direct.showbase.VFSImporter"); - if (vfsimporter_module == NULL) { + if (vfsimporter_module == nullptr) { nout << "Failed to import VFSImporter:\n"; PyErr_Print(); return 1; @@ -203,14 +203,14 @@ run_python() { // such that we can still find the other direct modules. Filename direct_dir(dir, "direct"); PyObject *direct_module = PyImport_AddModule("direct"); - if (direct_module != NULL) { + if (direct_module != nullptr) { dir_str = direct_dir.to_os_specific(); PyModule_AddObject(direct_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); PyModule_AddStringConstant(direct_module, "__package__", "direct"); } PyObject *showbase_module = PyImport_AddModule("direct.showbase"); - if (showbase_module != NULL) { + if (showbase_module != nullptr) { Filename showbase_dir(direct_dir, "showbase"); dir_str = showbase_dir.to_os_specific(); PyModule_AddObject(showbase_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); @@ -218,7 +218,7 @@ run_python() { } PyObject *stdpy_module = PyImport_AddModule("direct.stdpy"); - if (stdpy_module != NULL) { + if (stdpy_module != nullptr) { Filename stdpy_dir(direct_dir, "stdpy"); dir_str = stdpy_dir.to_os_specific(); PyModule_AddObject(stdpy_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); @@ -229,7 +229,7 @@ run_python() { // bunch of encodings modules as part of the frozen bundle. Filename encodings_dir(dir, "encodings"); PyObject *encodings_module = PyImport_AddModule("encodings"); - if (encodings_module != NULL) { + if (encodings_module != nullptr) { dir_str = encodings_dir.to_os_specific(); PyModule_AddObject(encodings_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); PyModule_AddStringConstant(encodings_module, "__package__", "encodings"); @@ -237,7 +237,7 @@ run_python() { // And register the VFSImporter. PyObject *result = PyObject_CallMethod(vfsimporter_module, (char *)"register", (char *)""); - if (result == NULL) { + if (result == nullptr) { nout << "Failed to call VFSImporter.register():\n"; PyErr_Print(); return 1; @@ -261,7 +261,7 @@ run_python() { // And finally, we can import the startup module. PyObject *app_runner_module = PyImport_ImportModule("direct.p3d.AppRunner"); - if (app_runner_module == NULL) { + if (app_runner_module == nullptr) { nout << "Failed to import direct.p3d.AppRunner\n"; PyErr_Print(); return 1; @@ -269,7 +269,7 @@ run_python() { // Get the pointers to the objects needed within the module. PyObject *app_runner_class = PyObject_GetAttrString(app_runner_module, "AppRunner"); - if (app_runner_class == NULL) { + if (app_runner_class == nullptr) { nout << "Failed to get AppRunner class\n"; PyErr_Print(); return 1; @@ -277,7 +277,7 @@ run_python() { // Construct an instance of AppRunner. _runner = PyObject_CallFunction(app_runner_class, (char *)""); - if (_runner == NULL) { + if (_runner == nullptr) { nout << "Failed to construct AppRunner instance\n"; PyErr_Print(); return 1; @@ -286,7 +286,7 @@ run_python() { // Import the JavaScript module. PyObject *javascript_module = PyImport_ImportModule("direct.p3d.JavaScript"); - if (javascript_module == NULL) { + if (javascript_module == nullptr) { nout << "Failed to import direct.p3d.JavaScript\n"; PyErr_Print(); return false; @@ -294,35 +294,35 @@ run_python() { // Get the UndefinedObject class. _undefined_object_class = PyObject_GetAttrString(javascript_module, "UndefinedObject"); - if (_undefined_object_class == NULL) { + if (_undefined_object_class == nullptr) { PyErr_Print(); return 1; } // And the "Undefined" instance. _undefined = PyObject_GetAttrString(javascript_module, "Undefined"); - if (_undefined == NULL) { + if (_undefined == nullptr) { PyErr_Print(); return 1; } // Get the ConcreteStruct class. _concrete_struct_class = PyObject_GetAttrString(javascript_module, "ConcreteStruct"); - if (_concrete_struct_class == NULL) { + if (_concrete_struct_class == nullptr) { PyErr_Print(); return 1; } // Get the BrowserObject class. _browser_object_class = PyObject_GetAttrString(javascript_module, "BrowserObject"); - if (_browser_object_class == NULL) { + if (_browser_object_class == nullptr) { PyErr_Print(); return 1; } // Get the global TaskManager. _taskMgr = PyObject_GetAttrString(app_runner_module, "taskMgr"); - if (_taskMgr == NULL) { + if (_taskMgr == nullptr) { PyErr_Print(); return 1; } @@ -337,28 +337,28 @@ run_python() { "Poll for communications from the parent process" }, { "request_func", P3DPythonRun::st_request_func, METH_VARARGS, "Send an asynchronous request to the plugin host" }, - { NULL, NULL, 0, NULL } /* Sentinel */ + { nullptr, nullptr, 0, nullptr } /* Sentinel */ }; #if PY_MAJOR_VERSION >= 3 static PyModuleDef p3dpython_module = { PyModuleDef_HEAD_INIT, "p3dpython", - NULL, + nullptr, -1, p3dpython_methods, - NULL, NULL, NULL, NULL + nullptr, nullptr, nullptr, nullptr }; PyObject *p3dpython = PyModule_Create(&p3dpython_module); #else PyObject *p3dpython = Py_InitModule("p3dpython", p3dpython_methods); #endif - if (p3dpython == NULL) { + if (p3dpython == nullptr) { PyErr_Print(); return 1; } PyObject *request_func = PyObject_GetAttrString(p3dpython, "request_func"); - if (request_func == NULL) { + if (request_func == nullptr) { PyErr_Print(); return 1; } @@ -366,7 +366,7 @@ run_python() { // Now pass that func pointer back to our AppRunner instance, so it can call // up to us. result = PyObject_CallMethod(_runner, (char *)"setRequestFunc", (char *)"N", request_func); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); return 1; } @@ -384,7 +384,7 @@ run_python() { chain->set_thread_priority(TP_low); PyObject *check_comm = PyObject_GetAttrString(p3dpython, "check_comm"); - if (check_comm == NULL) { + if (check_comm == nullptr) { PyErr_Print(); return 1; } @@ -392,7 +392,7 @@ run_python() { // Add it to the task manager. We do this instead of constructing a // PythonTask because linking p3dpython with core.pyd is problematic. result = PyObject_CallMethod(_taskMgr, (char *)"add", (char *)"Ns", check_comm, "check_comm"); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); return 1; } @@ -401,7 +401,7 @@ run_python() { // Finally, get lost in AppRunner.run() (which is really a call to // taskMgr.run()). PyObject *done = PyObject_CallMethod(_runner, (char *)"run", (char *)""); - if (done == NULL) { + if (done == nullptr) { int status = 1; // An uncaught application exception, and not handled by @@ -409,10 +409,10 @@ run_python() { // status that we should return. if (PyErr_ExceptionMatches(PyExc_SystemExit)) { PyObject *ptype, *ptraceback; - PyObject *value = NULL; + PyObject *value = nullptr; PyErr_Fetch(&ptype, &value, &ptraceback); - if (value != NULL && PyExceptionInstance_Check(value)) { + if (value != nullptr && PyExceptionInstance_Check(value)) { PyObject *code = PyObject_GetAttrString(value, "code"); if (code) { Py_DECREF(value); @@ -420,7 +420,7 @@ run_python() { } } - if (value == NULL || value == Py_None) { + if (value == nullptr || value == Py_None) { status = 0; #if PY_MAJOR_VERSION >= 3 } else if (PyLong_Check(value)) { @@ -510,13 +510,13 @@ void P3DPythonRun:: run_interactive_console() { #ifdef _WIN32 // Make sure that control-C support is enabled for the interpreter. - SetConsoleCtrlHandler(NULL, false); + SetConsoleCtrlHandler(nullptr, false); #endif // The "readline" module makes the Python prompt friendlier, with command // history and everything. Simply importing it is sufficient. PyObject *readline_module = PyImport_ImportModule("readline"); - if (readline_module == NULL) { + if (readline_module == nullptr) { // But, the module might not exist on certain platforms. If not, no // sweat. PyErr_Clear(); @@ -536,7 +536,7 @@ run_interactive_console() { void P3DPythonRun:: handle_command(TiXmlDocument *doc) { TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { bool needs_response = false; int want_response_id; if (xcommand->QueryIntAttribute("want_response_id", &want_response_id) == TIXML_SUCCESS) { @@ -545,7 +545,7 @@ handle_command(TiXmlDocument *doc) { } const char *cmd = xcommand->Attribute("cmd"); - if (cmd != NULL) { + if (cmd != nullptr) { if (strcmp(cmd, "init") == 0) { assert(!needs_response); @@ -565,7 +565,7 @@ handle_command(TiXmlDocument *doc) { } else if (strcmp(cmd, "start_instance") == 0) { assert(!needs_response); TiXmlElement *xinstance = xcommand->FirstChildElement("instance"); - if (xinstance != (TiXmlElement *)NULL) { + if (xinstance != nullptr) { P3DCInstance *inst = new P3DCInstance(xinstance); start_instance(inst, xinstance); } @@ -581,7 +581,7 @@ handle_command(TiXmlDocument *doc) { assert(!needs_response); int instance_id; TiXmlElement *xwparams = xcommand->FirstChildElement("wparams"); - if (xwparams != (TiXmlElement *)NULL && + if (xwparams != nullptr && xcommand->QueryIntAttribute("instance_id", &instance_id) == TIXML_SUCCESS) { setup_window(instance_id, xwparams); } @@ -657,11 +657,11 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, doc.LinkEndChild(xresponse); const char *op = xcommand->Attribute("op"); - if (op != NULL && !PyErr_Occurred()) { + if (op != nullptr && !PyErr_Occurred()) { if (strcmp(op, "get_panda_script_object") == 0) { // Get Panda's toplevel Python object. PyObject *obj = PyObject_CallMethod(_runner, (char*)"getPandaScriptObject", (char *)""); - if (obj != NULL) { + if (obj != nullptr) { xresponse->LinkEndChild(pyobj_to_xml(obj)); Py_DECREF(obj); } @@ -670,7 +670,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, // Set the Browser's toplevel window object. PyObject *obj; TiXmlElement *xvalue = xcommand->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { obj = xml_to_pyobj(xvalue); } else { obj = Py_None; @@ -684,7 +684,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, // Call the named method on the indicated object, or the object itself // if method_name isn't given. TiXmlElement *xobject = xcommand->FirstChildElement("object"); - if (xobject != NULL) { + if (xobject != nullptr) { PyObject *obj = xml_to_pyobj(xobject); const char *method_name = xcommand->Attribute("method_name"); @@ -693,7 +693,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, PyObject *list = PyList_New(0); TiXmlElement *xchild = xcommand->FirstChildElement("value"); - while (xchild != NULL) { + while (xchild != nullptr) { PyObject *child = xml_to_pyobj(xchild); PyList_Append(list, child); Py_DECREF(child); @@ -705,8 +705,8 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, Py_DECREF(list); // Now call the method. - PyObject *result = NULL; - if (method_name == NULL) { + PyObject *result = nullptr; + if (method_name == nullptr) { // No method name; call the object directly. result = PyObject_CallObject(obj, params); @@ -811,7 +811,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, if (PyObject_HasAttrString(obj, property_name)) { result = PyObject_GetAttrString(obj, property_name); - if (result != NULL) { + if (result != nullptr) { success = true; } else { PyErr_Clear(); @@ -821,7 +821,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, if (!success) { if (PyMapping_HasKeyString(obj, property_name)) { result = PyMapping_GetItemString(obj, property_name); - if (result != NULL) { + if (result != nullptr) { success = true; } else { PyErr_Clear(); @@ -830,7 +830,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } if (!success) { - result = NULL; + result = nullptr; } } @@ -859,7 +859,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } else { // Not a special-case name. Call the named method. PyObject *method = PyObject_GetAttrString(obj, (char *)method_name); - if (method != NULL) { + if (method != nullptr) { result = PyObject_CallObject(method, params); Py_DECREF(method); } @@ -867,7 +867,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, Py_DECREF(params); // Feed the return value back through the XML pipe to the caller. - if (result != NULL) { + if (result != nullptr) { xresponse->LinkEndChild(pyobj_to_xml(result)); Py_DECREF(result); } else { @@ -948,10 +948,10 @@ wait_script_response(int response_id) { TiXmlDocument *doc = (*ci); TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { const char *cmd = xcommand->Attribute("cmd"); - if ((cmd != NULL && strcmp(cmd, "script_response") == 0) || - xcommand->Attribute("want_response_id") != NULL) { + if ((cmd != nullptr && strcmp(cmd, "script_response") == 0) || + xcommand->Attribute("want_response_id") != nullptr) { // This is either a response, or it's a command that will want a // response itself. In either case we should handle it right away. @@ -960,7 +960,7 @@ wait_script_response(int response_id) { RELEASE_LOCK(_commands_lock); handle_command(doc); if (_session_terminated) { - return NULL; + return nullptr; } ACQUIRE_LOCK(_commands_lock); break; @@ -976,9 +976,9 @@ wait_script_response(int response_id) { TiXmlDocument *doc = (*ci); TiXmlElement *xcommand = doc->FirstChildElement("command"); - assert(xcommand != NULL); + assert(xcommand != nullptr); const char *cmd = xcommand->Attribute("cmd"); - assert(cmd != NULL && strcmp(cmd, "script_response") == 0); + assert(cmd != nullptr && strcmp(cmd, "script_response") == 0); int unique_id; if (xcommand->QueryIntAttribute("unique_id", &unique_id) == TIXML_SUCCESS) { @@ -995,7 +995,7 @@ wait_script_response(int response_id) { if (!_program_continue) { terminate_session(); - return NULL; + return nullptr; } #ifdef _WIN32 @@ -1005,7 +1005,7 @@ wait_script_response(int response_id) { // We appear to be best off with just a single PeekMessage() call here; // the full message pump seems to cause problems. MSG msg; - PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); + PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE | PM_NOYIELD); #endif // _WIN32 // nout << "."; @@ -1027,7 +1027,7 @@ py_request_func(PyObject *args) { const char *request_type; PyObject *extra_args; if (!PyArg_ParseTuple(args, "isO", &instance_id, &request_type, &extra_args)) { - return NULL; + return nullptr; } if (strcmp(request_type, "wait_script_response") == 0) { @@ -1035,20 +1035,20 @@ py_request_func(PyObject *args) { // means to wait for a particular script_response to come in on the wire. int response_id; if (!PyArg_ParseTuple(extra_args, "i", &response_id)) { - return NULL; + return nullptr; } TiXmlDocument *doc = wait_script_response(response_id); if (_session_terminated) { return Py_BuildValue(""); } - assert(doc != NULL); + assert(doc != nullptr); TiXmlElement *xcommand = doc->FirstChildElement("command"); - assert(xcommand != NULL); + assert(xcommand != nullptr); TiXmlElement *xvalue = xcommand->FirstChildElement("value"); - PyObject *value = NULL; - if (xvalue != NULL) { + PyObject *value = nullptr; + if (xvalue != nullptr) { value = xml_to_pyobj(xvalue); } else { // An absence of a element is an exception. We will return NULL @@ -1070,7 +1070,7 @@ py_request_func(PyObject *args) { // A general notification to be sent directly to the instance. const char *message; if (!PyArg_ParseTuple(extra_args, "s", &message)) { - return NULL; + return nullptr; } xrequest->SetAttribute("message", message); @@ -1087,7 +1087,7 @@ py_request_func(PyObject *args) { if (!PyArg_ParseTuple(extra_args, "sOsOii", &operation, &object, &property_name, &value, &needs_response, &unique_id)) { - return NULL; + return nullptr; } xrequest->SetAttribute("operation", operation); @@ -1106,7 +1106,7 @@ py_request_func(PyObject *args) { // Release a particular P3D_object that we were holding a reference to. int object_id; if (!PyArg_ParseTuple(extra_args, "i", &object_id)) { - return NULL; + return nullptr; } xrequest->SetAttribute("object_id", object_id); @@ -1119,7 +1119,7 @@ py_request_func(PyObject *args) { const char *package_name; const char *package_version; if (!PyArg_ParseTuple(extra_args, "sss", &host_url, &package_name, &package_version)) { - return NULL; + return nullptr; } xrequest->SetAttribute("host_url", host_url); @@ -1134,7 +1134,7 @@ py_request_func(PyObject *args) { } else { string message = string("Unsupported request type: ") + string(request_type); PyErr_SetString(PyExc_ValueError, message.c_str()); - return NULL; + return nullptr; } return Py_BuildValue(""); @@ -1185,18 +1185,18 @@ start_instance(P3DCInstance *inst, TiXmlElement *xinstance) { set_instance_info(inst, xinstance); TiXmlElement *xpackage = xinstance->FirstChildElement("package"); - while (xpackage != (TiXmlElement *)NULL) { + while (xpackage != nullptr) { add_package_info(inst, xpackage); xpackage = xpackage->NextSiblingElement("package"); } TiXmlElement *xfparams = xinstance->FirstChildElement("fparams"); - if (xfparams != (TiXmlElement *)NULL) { + if (xfparams != nullptr) { set_p3d_filename(inst, xfparams); } TiXmlElement *xwparams = xinstance->FirstChildElement("wparams"); - if (xwparams != (TiXmlElement *)NULL) { + if (xwparams != nullptr) { setup_window(inst, xwparams); } } @@ -1228,12 +1228,12 @@ terminate_instance(int id) { void P3DPythonRun:: set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { const char *root_dir = xinstance->Attribute("root_dir"); - if (root_dir == NULL) { + if (root_dir == nullptr) { root_dir = ""; } const char *log_directory = xinstance->Attribute("log_directory"); - if (log_directory == NULL) { + if (log_directory == nullptr) { log_directory = ""; } @@ -1241,14 +1241,14 @@ set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { xinstance->Attribute("verify_contents", &verify_contents); const char *super_mirror = xinstance->Attribute("super_mirror"); - if (super_mirror == NULL) { + if (super_mirror == nullptr) { super_mirror = ""; } // Get the initial "main" object, if specified. PyObject *main; TiXmlElement *xmain = xinstance->FirstChildElement("main"); - if (xmain != NULL) { + if (xmain != nullptr) { main = xml_to_pyobj(xmain); } else { main = Py_None; @@ -1262,7 +1262,7 @@ set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { (_runner, (char *)"setInstanceInfo", (char *)"sssiNi", root_dir, log_directory, super_mirror, verify_contents, main, respect_per_platform); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1282,16 +1282,16 @@ add_package_info(P3DCInstance *inst, TiXmlElement *xpackage) { const char *version = xpackage->Attribute("version"); const char *host = xpackage->Attribute("host"); const char *host_dir = xpackage->Attribute("host_dir"); - if (name == NULL || host == NULL) { + if (name == nullptr || host == nullptr) { return; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (host_dir == NULL) { + if (host_dir == nullptr) { host_dir = ""; } @@ -1299,7 +1299,7 @@ add_package_info(P3DCInstance *inst, TiXmlElement *xpackage) { (_runner, (char *)"addPackageInfo", (char *)"sssss", name, platform, version, host, host_dir); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1317,7 +1317,7 @@ void P3DPythonRun:: set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { string p3d_filename; const char *p3d_filename_c = xfparams->Attribute("p3d_filename"); - if (p3d_filename_c != NULL) { + if (p3d_filename_c != nullptr) { p3d_filename = p3d_filename_c; } @@ -1326,21 +1326,21 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { string p3d_url; const char *p3d_url_c = xfparams->Attribute("p3d_url"); - if (p3d_url_c != NULL) { + if (p3d_url_c != nullptr) { p3d_url = p3d_url_c; } PyObject *token_list = PyList_New(0); TiXmlElement *xtoken = xfparams->FirstChildElement("token"); - while (xtoken != NULL) { + while (xtoken != nullptr) { string keyword, value; const char *keyword_c = xtoken->Attribute("keyword"); - if (keyword_c != NULL) { + if (keyword_c != nullptr) { keyword = keyword_c; } const char *value_c = xtoken->Attribute("value"); - if (value_c != NULL) { + if (value_c != nullptr) { value = value_c; } @@ -1354,10 +1354,10 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { PyObject *arg_list = PyList_New(0); TiXmlElement *xarg = xfparams->FirstChildElement("arg"); - while (xarg != NULL) { + while (xarg != nullptr) { string value; const char *value_c = xarg->Attribute("value"); - if (value_c != NULL) { + if (value_c != nullptr) { value = value_c; } @@ -1373,7 +1373,7 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { token_list, arg_list, inst->get_instance_id(), _interactive_console, p3d_offset, p3d_url.c_str()); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1405,7 +1405,7 @@ void P3DPythonRun:: setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { string window_type; const char *window_type_c = xwparams->Attribute("window_type"); - if (window_type_c != NULL) { + if (window_type_c != nullptr) { window_type = window_type_c; } @@ -1429,7 +1429,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { // to go through this subprocess-window nonsense. const char *subprocess_window = xwparams->Attribute("subprocess_window"); - if (subprocess_window != NULL) { + if (subprocess_window != nullptr) { Filename filename = Filename::from_os_specific(subprocess_window); parent_window_handle = NativeWindowHandle::make_subprocess(filename); } @@ -1437,7 +1437,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { #elif defined(HAVE_X11) // Use stringstream to decode the "long" attribute. const char *parent_cstr = xwparams->Attribute("parent_xwindow"); - if (parent_cstr != NULL) { + if (parent_cstr != nullptr) { long window; istringstream strm(parent_cstr); strm >> window; @@ -1446,7 +1446,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { #endif PyObject *py_handle = Py_None; - if (parent_window_handle != NULL) { + if (parent_window_handle != nullptr) { // We have a valid parent WindowHandle, but replace it with a // P3DWindowHandle so we can get the callbacks. @@ -1467,7 +1467,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { (_runner, (char *)"setupWindow", (char *)"siiiiN", window_type.c_str(), win_x, win_y, win_width, win_height, py_handle); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1489,7 +1489,7 @@ send_windows_message(int id, unsigned int msg, int wparam, int lparam) { } P3DCInstance *inst = (*ii).second; - if (inst->_parent_window_handle != (WindowHandle *)NULL) { + if (inst->_parent_window_handle != nullptr) { inst->_parent_window_handle->send_windows_message(msg, wparam, lparam); } } @@ -1507,9 +1507,9 @@ terminate_session() { _instances.clear(); if (!_session_terminated) { - if (_taskMgr != NULL) { + if (_taskMgr != nullptr) { PyObject *result = PyObject_CallMethod(_taskMgr, (char *)"stop", (char *)""); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); } else { Py_DECREF(result); @@ -1573,13 +1573,13 @@ pyobj_to_xml(PyObject *value) { // function for getting the UTF-8 encoded version. Py_ssize_t length = 0; char *buffer = PyUnicode_AsUTF8AndSize(value, &length); - if (buffer != NULL) { + if (buffer != nullptr) { string str(buffer, length); xvalue->SetAttribute("value", str); } #else PyObject *as_str = PyUnicode_AsUTF8String(value); - if (as_str != NULL) { + if (as_str != nullptr) { char *buffer; Py_ssize_t length; if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) { @@ -1594,13 +1594,13 @@ pyobj_to_xml(PyObject *value) { // using the standard encoding, then re-encoding it. xvalue->SetAttribute("type", "string"); - PyObject *ustr = PyUnicode_FromEncodedObject(value, NULL, NULL); - if (ustr == NULL) { + PyObject *ustr = PyUnicode_FromEncodedObject(value, nullptr, nullptr); + if (ustr == nullptr) { PyErr_Print(); return xvalue; } else { PyObject *as_str = PyUnicode_AsUTF8String(ustr); - if (as_str != NULL) { + if (as_str != nullptr) { char *buffer; Py_ssize_t length; if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) { @@ -1620,7 +1620,7 @@ pyobj_to_xml(PyObject *value) { Py_ssize_t length = PySequence_Length(value); for (Py_ssize_t i = 0; i < length; ++i) { PyObject *item = PySequence_GetItem(value, i); - if (item != NULL) { + if (item != nullptr) { xvalue->LinkEndChild(pyobj_to_xml(item)); Py_DECREF(item); } @@ -1631,7 +1631,7 @@ pyobj_to_xml(PyObject *value) { xvalue->SetAttribute("type", "concrete_struct"); PyObject *items = PyObject_CallMethod(value, (char *)"getConcreteProperties", (char *)""); - if (items == NULL) { + if (items == nullptr) { PyErr_Print(); return xvalue; } @@ -1639,11 +1639,11 @@ pyobj_to_xml(PyObject *value) { Py_ssize_t length = PySequence_Length(items); for (Py_ssize_t i = 0; i < length; ++i) { PyObject *item = PySequence_GetItem(items, i); - if (item != NULL) { + if (item != nullptr) { PyObject *a = PySequence_GetItem(item, 0); - if (a != NULL) { + if (a != nullptr) { PyObject *b = PySequence_GetItem(item, 1); - if (b != NULL) { + if (b != nullptr) { TiXmlElement *xitem = pyobj_to_xml(b); Py_DECREF(b); @@ -1664,7 +1664,7 @@ pyobj_to_xml(PyObject *value) { Py_ssize_t length; #if PY_MAJOR_VERSION >= 3 buffer = PyUnicode_AsUTF8AndSize(as_str, &length); - if (buffer != NULL) { + if (buffer != nullptr) { #else if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) { #endif @@ -1694,7 +1694,7 @@ pyobj_to_xml(PyObject *value) { // This is a BrowserObject, a reference to an object that actually exists // in the host namespace. So, pass up the appropriate object ID. PyObject *objectId = PyObject_GetAttrString(value, (char *)"_BrowserObject__objectId"); - if (objectId != NULL) { + if (objectId != nullptr) { int object_id = PyInt_AsLong(objectId); xvalue->SetAttribute("type", "browser"); xvalue->SetAttribute("object_id", object_id); @@ -1764,8 +1764,8 @@ xml_to_pyobj(TiXmlElement *xvalue) { // Using the string form here instead of the char * form, so we don't get // tripped up on embedded null characters. const string *value = xvalue->Attribute(string("value")); - if (value != NULL) { - return PyUnicode_DecodeUTF8(value->data(), value->length(), NULL); + if (value != nullptr) { + return PyUnicode_DecodeUTF8(value->data(), value->length(), nullptr); } } else if (strcmp(type, "undefined") == 0) { @@ -1785,9 +1785,9 @@ xml_to_pyobj(TiXmlElement *xvalue) { PyObject *list = PyList_New(0); TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { PyObject *item = xml_to_pyobj(xitem); - if (item != NULL) { + if (item != nullptr) { PyList_Append(list, item); Py_DECREF(item); } @@ -1802,13 +1802,13 @@ xml_to_pyobj(TiXmlElement *xvalue) { // Receive a concrete struct as a new ConcreteStruct instance. PyObject *obj = PyObject_CallFunction(_concrete_struct_class, (char *)""); - if (obj != NULL) { + if (obj != nullptr) { TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { const char *key = xitem->Attribute("key"); - if (key != NULL) { + if (key != nullptr) { PyObject *item = xml_to_pyobj(xitem); - if (item != NULL) { + if (item != nullptr) { PyObject_SetAttrString(obj, (char *)key, item); Py_DECREF(item); } @@ -1847,7 +1847,7 @@ void P3DPythonRun:: rt_thread_run() { while (_read_thread_continue) { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Some error on reading. Abort. _program_continue = false; return; @@ -1858,9 +1858,9 @@ rt_thread_run() { // Check for one special case: the "exit" command means we shut down the // read thread along with everything else. TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { const char *cmd = xcommand->Attribute("cmd"); - if (cmd != NULL) { + if (cmd != nullptr) { if (strcmp(cmd, "exit") == 0) { _read_thread_continue = false; } diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index 522936f61a..cb0fb58d78 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -143,7 +143,7 @@ shutdown() { #else // _WIN32 // Wait for a certain amount of time for the process to stop by itself. struct timeval start; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; int status; @@ -155,7 +155,7 @@ shutdown() { } struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; @@ -171,7 +171,7 @@ shutdown() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); result = waitpid(_p3dpython_pid, &status, WNOHANG); } _p3dpython_pid = -1; @@ -227,7 +227,7 @@ shutdown() { */ void P3DSession:: start_instance(P3DInstance *inst) { - assert(inst->_session == NULL); + assert(inst->_session == nullptr); assert(inst->get_session_key() == _session_key); if (_failed) { inst->set_failed(); @@ -279,7 +279,7 @@ terminate_instance(P3DInstance *inst) { if (inst->_session == this) { nout << "Assigning " << inst << "->log_pathname = " << _log_pathname << "\n"; inst->_log_pathname = _log_pathname; - inst->_session = NULL; + inst->_session = nullptr; _instances.erase(inst->get_instance_id()); } RELEASE_LOCK(_instances_lock); @@ -319,7 +319,7 @@ send_command(TiXmlDocument *command) { TiXmlDocument *P3DSession:: command_and_response(TiXmlDocument *command) { if (!_p3dpython_started) { - return NULL; + return nullptr; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -328,7 +328,7 @@ command_and_response(TiXmlDocument *command) { // Add the "want_response_id" attribute to the toplevel command, so the sub- // process knows we'll be waiting for its response. TiXmlElement *xcommand = command->FirstChildElement("command"); - assert(xcommand != NULL); + assert(xcommand != nullptr); xcommand->SetAttribute("want_response_id", response_id); write_xml(_pipe_write, command, nout); @@ -341,7 +341,7 @@ command_and_response(TiXmlDocument *command) { if (!_p3dpython_running) { // Hmm, looks like Python has gone away. _response_ready.release(); - return NULL; + return nullptr; } // Make sure we bake requests while we are waiting, to process recursive @@ -380,7 +380,7 @@ command_and_response(TiXmlDocument *command) { // coming and will block waiting for them. MSG msg; - PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); + PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE | PM_NOYIELD); // We wait with a timeout, so we can go back and spin the event loop some // more. On Windows, the timeout needs to be small, so we continue to @@ -444,16 +444,16 @@ xml_to_p3dobj(const TiXmlElement *xvalue) { // Using the string form here instead of the char * form, so we don't get // tripped up on embedded null characters. const string *value = xvalue->Attribute(string("value")); - if (value != NULL) { + if (value != nullptr) { return new P3DStringObject(*value); } } else if (strcmp(type, "concrete_sequence") == 0) { P3DConcreteSequence *obj = new P3DConcreteSequence; const TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { P3D_object *item = xml_to_p3dobj(xitem); - if (item != NULL) { + if (item != nullptr) { obj->append(item); P3D_OBJECT_DECREF(item); } @@ -464,11 +464,11 @@ xml_to_p3dobj(const TiXmlElement *xvalue) { } else if (strcmp(type, "concrete_struct") == 0) { P3DConcreteStruct *obj = new P3DConcreteStruct; const TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { const char *key = xitem->Attribute("key"); - if (key != NULL) { + if (key != nullptr) { P3D_object *item = xml_to_p3dobj(xitem); - if (item != NULL) { + if (item != nullptr) { obj->set_property(key, item); P3D_OBJECT_DECREF(item); } @@ -539,7 +539,7 @@ p3dobj_to_xml(P3D_object *obj) { case P3D_OT_string: { xvalue->SetAttribute("type", "string"); - int size = P3D_OBJECT_GET_STRING(obj, NULL, 0); + int size = P3D_OBJECT_GET_STRING(obj, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(obj, buffer, size); xvalue->SetAttribute("value", string(buffer, size)); @@ -548,12 +548,12 @@ p3dobj_to_xml(P3D_object *obj) { break; case P3D_OT_object: - P3DObject *p3dobj = NULL; + P3DObject *p3dobj = nullptr; if (obj->_class == &P3DObject::_object_class) { p3dobj = (P3DObject *)obj; } - if (p3dobj != NULL && p3dobj->fill_xml(xvalue, this)) { + if (p3dobj != nullptr && p3dobj->fill_xml(xvalue, this)) { // This object has a specialized XML representation, valid for this // particular session. It has already been filled into xvalue. @@ -666,7 +666,7 @@ start_p3dpython(P3DInstance *inst) { return; } - if (inst->_panda3d_package == NULL) { + if (inst->_panda3d_package == nullptr) { nout << "Couldn't start Python: no panda3d dependency.\n"; set_failed(); return; @@ -787,22 +787,22 @@ start_p3dpython(P3DInstance *inst) { string p3dpythonw_exe = _p3dpython_exe + "w"; if (_p3dpython_exe.empty()) { // Allow package to override the name of the p3dpython executables. - const char *p3dpython_name_xconfig = NULL; - const char *p3dpythonw_name_xconfig = NULL; + const char *p3dpython_name_xconfig = nullptr; + const char *p3dpythonw_name_xconfig = nullptr; const TiXmlElement *panda3d_xconfig = inst->_panda3d_package->get_xconfig(); - if (panda3d_xconfig != NULL) { + if (panda3d_xconfig != nullptr) { p3dpython_name_xconfig = panda3d_xconfig->Attribute("p3dpython_name"); p3dpythonw_name_xconfig = panda3d_xconfig->Attribute("p3dpythonw_name"); } string p3dpython_name = "p3dpython"; - if (p3dpython_name_xconfig != NULL) { + if (p3dpython_name_xconfig != nullptr) { nout << "p3dpython_name from panda3d xconfig: " << p3dpython_name_xconfig << "\n"; p3dpython_name = p3dpython_name_xconfig; } string p3dpythonw_name = p3dpython_name + "w"; - if (p3dpythonw_name_xconfig != NULL) { + if (p3dpythonw_name_xconfig != nullptr) { nout << "p3dpythonw_name from panda3d xconfig: " << p3dpythonw_name_xconfig << "\n"; p3dpythonw_name = p3dpythonw_name_xconfig; } @@ -848,9 +848,9 @@ start_p3dpython(P3DInstance *inst) { #ifdef HAVE_X11 "DISPLAY", "XAUTHORITY", #endif - NULL + nullptr }; - for (int ki = 0; keep[ki] != NULL; ++ki) { + for (int ki = 0; keep[ki] != nullptr; ++ki) { string value; if (get_env(value, keep[ki])) { _env += keep[ki]; @@ -867,7 +867,7 @@ start_p3dpython(P3DInstance *inst) { "PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "PYTHONPATH", "PYTHONHOME", "PRC_PATH", "PANDA_PRC_PATH", "TEMP", "CTPROJS", - NULL + nullptr }; #ifdef _WIN32 @@ -886,14 +886,14 @@ start_p3dpython(P3DInstance *inst) { #endif // _WIN32 char **ep; - for (ep = global_environ; *ep != NULL; ++ep) { + for (ep = global_environ; *ep != nullptr; ++ep) { string env = *ep; size_t equals = env.find('='); if (equals != string::npos) { string var = env.substr(0, equals); const char *varc = var.c_str(); bool found = false; - for (int i = 0; dont_keep[i] != NULL && !found; ++i) { + for (int i = 0; dont_keep[i] != nullptr && !found; ++i) { #ifdef _WIN32 found = (_stricmp(dont_keep[i], varc) == 0); #else @@ -1088,9 +1088,9 @@ start_p3dpython(P3DInstance *inst) { #else tzset(); #endif - time_t log_time_seconds = time(NULL); + time_t log_time_seconds = time(nullptr); struct tm *log_time_local_p = localtime(&log_time_seconds); - if (log_time_local_p != NULL) { + if (log_time_local_p != nullptr) { struct tm log_time_local = *log_time_local_p; static const size_t buffer_size = 16; char buffer[buffer_size]; @@ -1121,7 +1121,7 @@ start_p3dpython(P3DInstance *inst) { HANDLE r_to, w_to, r_from, w_from; // Create the pipe to the process. - if (!CreatePipe(&r_to, &w_to, NULL, 0)) { + if (!CreatePipe(&r_to, &w_to, nullptr, 0)) { nout << "failed to create pipe\n"; set_failed(); } else { @@ -1131,7 +1131,7 @@ start_p3dpython(P3DInstance *inst) { } // Create the pipe from the process. - if (!CreatePipe(&r_from, &w_from, NULL, 0)) { + if (!CreatePipe(&r_from, &w_from, nullptr, 0)) { nout << "failed to create pipe\n"; set_failed(); } else { @@ -1311,7 +1311,7 @@ void P3DSession:: rt_thread_run() { while (_read_thread_continue) { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Some error on reading. Abort. rt_terminate(); _p3dpython_running = false; @@ -1335,7 +1335,7 @@ rt_thread_run() { void P3DSession:: rt_handle_request(TiXmlDocument *doc) { TiXmlElement *xresponse = doc->FirstChildElement("response"); - if (xresponse != (TiXmlElement *)NULL) { + if (xresponse != nullptr) { int response_id; if (xresponse->QueryIntAttribute("response_id", &response_id) == TIXML_SUCCESS) { // This is a response to a previous command-and-response. Send it to @@ -1350,7 +1350,7 @@ rt_handle_request(TiXmlDocument *doc) { } TiXmlElement *xrequest = doc->FirstChildElement("request"); - if (xrequest != (TiXmlElement *)NULL) { + if (xrequest != nullptr) { int instance_id; if (xrequest->QueryIntAttribute("instance_id", &instance_id) == TIXML_SUCCESS) { // Look up the particular instance this is related to. @@ -1360,13 +1360,13 @@ rt_handle_request(TiXmlDocument *doc) { if (ii != _instances.end()) { P3DInstance *inst = (*ii).second; inst->add_raw_request(doc); - doc = NULL; + doc = nullptr; } RELEASE_LOCK(_instances_lock); } } - if (doc != NULL) { + if (doc != nullptr) { delete doc; } } @@ -1418,7 +1418,7 @@ win_create_process() { HANDLE handle = CreateFileW (log_pathname_w.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, CREATE_ALWAYS, 0, NULL); + nullptr, CREATE_ALWAYS, 0, nullptr); if (handle != INVALID_HANDLE_VALUE) { error_handle = handle; SetHandleInformation(error_handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); @@ -1447,7 +1447,7 @@ win_create_process() { const wchar_t *start_dir_cstr; wstring start_dir_w; if (_keep_user_env) { - start_dir_cstr = NULL; + start_dir_cstr = nullptr; nout << "Not changing working directory.\n"; } else { string_to_wstring(start_dir_w, _start_dir); @@ -1479,7 +1479,7 @@ win_create_process() { PROCESS_INFORMATION process_info; BOOL result = CreateProcessW - (p3dpython_exe_w.c_str(), command_line, NULL, NULL, TRUE, + (p3dpython_exe_w.c_str(), command_line, nullptr, nullptr, TRUE, CREATE_UNICODE_ENVIRONMENT, (void *)env_w.c_str(), start_dir_cstr, &startup_info, &process_info); bool started_program = (result != 0); @@ -1577,7 +1577,7 @@ posix_create_process() { p = zero + 1; zero = _env.find('\0', p); } - ptrs.push_back((char *)NULL); + ptrs.push_back(nullptr); stringstream input_handle_stream; input_handle_stream << _input_handle; @@ -1605,7 +1605,7 @@ posix_create_process() { // program" message. Maybe I'll put in the more reliable test later. struct timeval start; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; int status; @@ -1617,7 +1617,7 @@ posix_create_process() { } struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; if (elapsed > 100) { @@ -1631,7 +1631,7 @@ posix_create_process() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); result = waitpid(child, &status, WNOHANG); } @@ -1684,7 +1684,7 @@ p3dpython_thread_run() { _putenv(start); #else const char *equals = strchr(start, '='); - if (equals != NULL) { + if (equals != nullptr) { string variable(start, equals - start); setenv(variable.c_str(), equals + 1, true); } @@ -1703,7 +1703,7 @@ p3dpython_thread_run() { #endif SetErrorMode(0); HMODULE module = LoadLibrary(libp3dpython.c_str()); - if (module == NULL) { + if (module == nullptr) { // Couldn't load the DLL. nout << "Couldn't load " << libp3dpython << "\n"; return; @@ -1719,7 +1719,7 @@ p3dpython_thread_run() { libp3dpython += ".so"; #endif void *module = dlopen(libp3dpython.c_str(), RTLD_LAZY | RTLD_LOCAL); - if (module == NULL) { + if (module == nullptr) { // Couldn't load the .so. nout << "Couldn't load " << libp3dpython << "\n"; return; @@ -1730,7 +1730,7 @@ p3dpython_thread_run() { #endif // _WIN32 run_p3dpython_func *run_p3dpython = (run_p3dpython_func *)get_func(module, "run_p3dpython"); - if (run_p3dpython == NULL) { + if (run_p3dpython == nullptr) { nout << "Couldn't find run_p3dpython\n"; return; } @@ -1755,14 +1755,14 @@ get_env(string &value, const string &varname) { wstring varname_w; string_to_wstring(varname_w, varname); const wchar_t *vc = _wgetenv(varname_w.c_str()); - if (vc == NULL) { + if (vc == nullptr) { return false; } wstring_to_string(value, vc); return true; #else // _WIN32 const char *vc = getenv(varname.c_str()); - if (vc == NULL) { + if (vc == nullptr) { return false; } value = vc; diff --git a/direct/src/plugin/p3dSplashWindow.cxx b/direct/src/plugin/p3dSplashWindow.cxx index dc17b5c95a..2660cb2b3e 100644 --- a/direct/src/plugin/p3dSplashWindow.cxx +++ b/direct/src/plugin/p3dSplashWindow.cxx @@ -348,10 +348,10 @@ read_image_data(ImageData &image, string &data, unsigned char *imgdata = stbi_load(image_filename.c_str(), &image._width, &image._height, &image._num_channels, 0); - if (imgdata == NULL) { + if (imgdata == nullptr) { nout << "Couldn't read splash file image: " << image_filename << "\n"; const char *reason = stbi_failure_reason(); - if (reason != NULL) { + if (reason != nullptr) { nout << "stbi_failure_reason: " << reason << "\n"; } return false; @@ -492,7 +492,7 @@ set_mouse_data(int mouse_x, int mouse_y, bool mouse_down) { */ void P3DSplashWindow:: button_click_detected() { - assert(_inst != NULL); + assert(_inst != nullptr); nout << "Play button clicked by user\n"; _inst->splash_button_clicked_sub_thread(); } diff --git a/direct/src/plugin/p3dWinSplashWindow.I b/direct/src/plugin/p3dWinSplashWindow.I index 20cafcc1bf..bae5fb0680 100644 --- a/direct/src/plugin/p3dWinSplashWindow.I +++ b/direct/src/plugin/p3dWinSplashWindow.I @@ -17,7 +17,7 @@ inline P3DWinSplashWindow::WinImageData:: WinImageData() { _filename_changed = false; - _bitmap = NULL; + _bitmap = nullptr; } /** diff --git a/direct/src/plugin/p3dWinSplashWindow.cxx b/direct/src/plugin/p3dWinSplashWindow.cxx index eb4d242430..5cc189b31c 100644 --- a/direct/src/plugin/p3dWinSplashWindow.cxx +++ b/direct/src/plugin/p3dWinSplashWindow.cxx @@ -28,14 +28,14 @@ P3DWinSplashWindow:: P3DWinSplashWindow(P3DInstance *inst, bool make_visible) : P3DSplashWindow(inst, make_visible) { - _thread = NULL; + _thread = nullptr; _thread_id = 0; - _hwnd = NULL; - _font = NULL; - _fg_brush = NULL; - _bg_brush = NULL; - _bar_brush = NULL; - _bar_bg_brush = NULL; + _hwnd = nullptr; + _font = nullptr; + _fg_brush = nullptr; + _bg_brush = nullptr; + _bar_brush = nullptr; + _bar_bg_brush = nullptr; _thread_running = false; _install_progress = 0.0; _progress_known = true; @@ -97,7 +97,7 @@ set_visible(bool visible) { void P3DWinSplashWindow:: set_image_filename(const string &image_filename, ImagePlacement image_placement) { nout << "image_filename = " << image_filename << ", thread_id = " << _thread_id << "\n"; - WinImageData *image = NULL; + WinImageData *image = nullptr; switch (image_placement) { case IP_background: image = &_background_image; @@ -116,7 +116,7 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) image = &_button_click_image; break; } - if (image != NULL) { + if (image != nullptr) { ACQUIRE_LOCK(_install_lock); if (image->_filename != image_filename) { image->_filename = image_filename; @@ -211,13 +211,13 @@ request_keyboard_focus() { void P3DWinSplashWindow:: register_window_class() { if (!_registered_window_class) { - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); WNDCLASS wc; ZeroMemory(&wc, sizeof(WNDCLASS)); wc.lpfnWndProc = (WNDPROC)st_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.lpszClassName = "panda3d_splash"; if (!RegisterClass(&wc)) { @@ -234,7 +234,7 @@ register_window_class() { void P3DWinSplashWindow:: unregister_window_class() { if (_registered_window_class) { - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); if (!UnregisterClass("panda3d_splash", application)) { nout << "Could not unregister window class panda3d_splash\n"; @@ -261,8 +261,8 @@ void P3DWinSplashWindow:: start_thread() { _thread_continue = true; _thread_running = true; - _thread = CreateThread(NULL, 0, &win_thread_run, this, 0, &_thread_id); - if (_thread == NULL) { + _thread = CreateThread(nullptr, 0, &win_thread_run, this, 0, &_thread_id); + if (_thread == nullptr) { // Thread never got started. _thread_running = false; } @@ -280,17 +280,17 @@ stop_thread() { PostThreadMessage(_thread_id, WM_USER, 0, 0); } - if (_thread != NULL){ + if (_thread != nullptr){ // If the thread doesn't close right away, call PeekMessage() to check for // Windows messages that the thread might be waiting for. while (WaitForSingleObject(_thread, 200) == WAIT_TIMEOUT) { MSG msg; - PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); + PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE | PM_NOYIELD); nout << "Waiting for thread\n"; } CloseHandle(_thread); - _thread = NULL; + _thread = nullptr; // Now that the thread has exited, we can safely close its window. (We // couldn't close the window in the thread, because that would cause a @@ -310,7 +310,7 @@ thread_run() { int last_focus_seq = 0; MSG msg; int retval; - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); while (retval != 0 && _thread_continue) { if (retval == -1) { nout << "Error processing message queue.\n"; @@ -329,7 +329,7 @@ thread_run() { if (_drawn_label != _install_label) { // The label has changed. Redraw. _drawn_label = _install_label; - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); } // Also redraw when the progress bar changes. @@ -349,25 +349,25 @@ thread_run() { _drawn_progress = _install_progress; _drawn_progress_known = _progress_known; _drawn_received_data = _received_data; - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); } if (_drawn_bstate != _bstate) { // The button has changed state. Redraw it. _drawn_bstate = _bstate; - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); } if (_focus_seq != last_focus_seq) { last_focus_seq = _focus_seq; - if (SetFocus(_hwnd) == NULL && GetLastError() != 0) { + if (SetFocus(_hwnd) == nullptr && GetLastError() != 0) { nout << "SetFocus(" << _hwnd << ") failed: " << GetLastError() << "\n"; } } RELEASE_LOCK(_install_lock); - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); } // Tell our parent thread that we're done. @@ -392,7 +392,7 @@ win_thread_run(LPVOID data) { void P3DWinSplashWindow:: make_window() { register_window_class(); - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); int width = 320; int height = 240; @@ -420,7 +420,7 @@ make_window() { _hwnd = CreateWindow("panda3d_splash", "Panda3D", window_style, x, y, width, height, - parent_hwnd, NULL, application, 0); + parent_hwnd, nullptr, application, 0); if (!_hwnd) { nout << "Could not create embedded window!\n"; @@ -442,7 +442,7 @@ make_window() { x, y, win_rect.right - win_rect.left, win_rect.bottom - win_rect.top, - NULL, NULL, application, 0); + nullptr, nullptr, application, 0); if (!_hwnd) { nout << "Could not create toplevel window!\n"; return; @@ -463,7 +463,7 @@ make_window() { ANSI_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, _font_family.c_str()); - if (_font == NULL) { + if (_font == nullptr) { nout << "CreateFont failed: " << GetLastError() << "\n"; _font = (HFONT)GetStockObject(ANSI_VAR_FONT); } @@ -490,7 +490,7 @@ update_image(WinImageData &image) { image.dump_image(); // Since we'll be displaying a new image, we need to refresh the window. - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); // Go read the image. string data; @@ -583,27 +583,27 @@ update_image(WinImageData &image) { */ void P3DWinSplashWindow:: close_window() { - if (_hwnd != NULL) { + if (_hwnd != nullptr) { ShowWindow(_hwnd, SW_HIDE); CloseWindow(_hwnd); - _hwnd = NULL; + _hwnd = nullptr; } - if (_fg_brush != NULL) { + if (_fg_brush != nullptr) { DeleteObject(_fg_brush); - _fg_brush = NULL; + _fg_brush = nullptr; } - if (_bg_brush != NULL) { + if (_bg_brush != nullptr) { DeleteObject(_bg_brush); - _bg_brush = NULL; + _bg_brush = nullptr; } - if (_bar_brush != NULL) { + if (_bar_brush != nullptr) { DeleteObject(_bar_brush); - _bar_brush = NULL; + _bar_brush = nullptr; } - if (_bar_bg_brush != NULL) { + if (_bar_bg_brush != nullptr) { DeleteObject(_bar_bg_brush); - _bar_bg_brush = NULL; + _bar_bg_brush = nullptr; } _background_image.dump_image(); @@ -677,7 +677,7 @@ paint_window(HDC dc) { */ bool P3DWinSplashWindow:: paint_image(HDC dc, const WinImageData &image, bool use_alpha) { - if (image._bitmap == NULL) { + if (image._bitmap == nullptr) { return false; } @@ -738,7 +738,7 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { } } - SelectObject(mem_dc, NULL); + SelectObject(mem_dc, nullptr); DeleteDC(mem_dc); return true; @@ -831,7 +831,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_SIZE: - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(hwnd, nullptr, FALSE); break; case WM_ERASEBKGND: @@ -869,7 +869,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { { int elapsed = GetTickCount() - _request_focus_tick; if (elapsed < 200) { - if (SetFocus(_hwnd) == NULL && GetLastError() != 0) { + if (SetFocus(_hwnd) == nullptr && GetLastError() != 0) { nout << "Secondary SetFocus failed: " << GetLastError() << "\n"; } } @@ -889,7 +889,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_KEYDOWN: case WM_SYSKEYUP: case WM_KEYUP: - if (_inst->get_session() != NULL) { + if (_inst->get_session() != nullptr) { _inst->get_session()->send_windows_message(_inst, msg, wparam, lparam); } break; @@ -904,7 +904,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LRESULT P3DWinSplashWindow:: st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (self == NULL) { + if (self == nullptr) { // We haven't assigned the pointer yet. return DefWindowProc(hwnd, msg, wparam, lparam); } @@ -917,9 +917,9 @@ st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { */ void P3DWinSplashWindow::WinImageData:: dump_image() { - if (_bitmap != NULL) { + if (_bitmap != nullptr) { DeleteObject(_bitmap); - _bitmap = NULL; + _bitmap = nullptr; } } diff --git a/direct/src/plugin/p3dX11SplashWindow.cxx b/direct/src/plugin/p3dX11SplashWindow.cxx index 8be0edb050..2e1bbcb66e 100644 --- a/direct/src/plugin/p3dX11SplashWindow.cxx +++ b/direct/src/plugin/p3dX11SplashWindow.cxx @@ -39,12 +39,12 @@ P3DX11SplashWindow(P3DInstance *inst, bool make_visible) : INIT_THREAD(_read_thread); // Init for subprocess - _composite_image = NULL; + _composite_image = nullptr; _needs_new_composite = false; _display = None; _window = None; _screen = 0; - _font = NULL; + _font = nullptr; _graphics_context = None; _bar_context = None; _bar_bg_context = None; @@ -285,7 +285,7 @@ stop_subprocess() { // Wait for a certain amount of time for the process to stop by itself. struct timeval start; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; int status; @@ -297,7 +297,7 @@ stop_subprocess() { } struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; @@ -313,7 +313,7 @@ stop_subprocess() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); result = waitpid(_subprocess_pid, &status, WNOHANG); } @@ -406,7 +406,7 @@ void P3DX11SplashWindow:: rt_thread_run() { while (true) { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Some error on reading. The splash window must have gone away, e.g. // because the user explicitly closed it; tell the instance to exit. _inst->request_stop_sub_thread(); @@ -648,7 +648,7 @@ subprocess_run() { tv.tv_sec = 0; tv.tv_usec = 1000; // 1 usec is not enough. - int result = select(read_fd + 1, &fds, NULL, NULL, &tv); + int result = select(read_fd + 1, &fds, nullptr, nullptr, &tv); if (result > 0) { // There is some noise on the pipe, so read it. input_ready = true; @@ -668,7 +668,7 @@ subprocess_run() { struct timespec req; req.tv_sec = 0; req.tv_nsec = 50000000; // 50 ms - nanosleep(&req, NULL); + nanosleep(&req, nullptr); } close_window(); @@ -680,22 +680,22 @@ subprocess_run() { void P3DX11SplashWindow:: receive_command() { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Pipe closed or something. _subprocess_continue = false; return; } TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { const char *cmd = xcommand->Attribute("cmd"); - if (cmd != NULL) { + if (cmd != nullptr) { if (strcmp(cmd, "exit") == 0) { _subprocess_continue = false; } else if (strcmp(cmd, "set_visible") == 0) { int visible = 0; - if (xcommand->Attribute("visible", &visible) != NULL) { + if (xcommand->Attribute("visible", &visible) != nullptr) { _visible = visible; if (_visible) { XMapWindow(_display, _window); @@ -707,10 +707,10 @@ receive_command() { } else if (strcmp(cmd, "set_image_filename") == 0) { const string *image_filename = xcommand->Attribute(string("image_filename")); int image_placement; - if (image_filename != NULL && + if (image_filename != nullptr && xcommand->QueryIntAttribute("image_placement", &image_placement) == TIXML_SUCCESS) { - X11ImageData *image = NULL; + X11ImageData *image = nullptr; switch ((ImagePlacement)image_placement) { case IP_background: image = &_background_image; @@ -732,7 +732,7 @@ receive_command() { case IP_none: break; } - if (image != NULL) { + if (image != nullptr) { if (image->_filename != *image_filename) { image->_filename = *image_filename; image->_filename_changed = true; @@ -742,7 +742,7 @@ receive_command() { } else if (strcmp(cmd, "set_install_label") == 0) { const char *str = xcommand->Attribute("install_label"); - if (str != NULL) { + if (str != nullptr) { if (_install_label != string(str)) { _install_label = str; } @@ -775,7 +775,7 @@ receive_command() { */ void P3DX11SplashWindow:: redraw() { - if (_composite_image == NULL) { + if (_composite_image == nullptr) { // Clear the whole window, if there's no image. XClearWindow(_display, _window); @@ -823,10 +823,10 @@ make_window() { // _display = (X11_Display*) _wparams.get_parent_window()._xdisplay; // _own_display = false; if (_display == 0) { - _display = XOpenDisplay(NULL); + _display = XOpenDisplay(nullptr); _own_display = true; // } - assert(_display != NULL); + assert(_display != nullptr); _screen = DefaultScreen(_display); int x = _wparams.get_win_x(); @@ -972,7 +972,7 @@ setup_gc() { _font_family.c_str(), weight_name, style, _font_size); _font = XLoadQueryFont(_display, font_name); - if (_font != NULL) { + if (_font != nullptr) { break; } nout << "Font " << font_name << " unavailable.\n"; @@ -984,14 +984,14 @@ setup_gc() { _font_family.c_str(), weight_name, style2, _font_size); _font = XLoadQueryFont(_display, font_name); - if (_font != NULL) { + if (_font != nullptr) { break; } nout << "Font " << font_name << " unavailable.\n"; } } - if (_font != NULL) { + if (_font != nullptr) { nout << "Loaded font " << font_name << "\n"; } else { nout << "Using fallback font 6x13.\n"; @@ -1054,9 +1054,9 @@ setup_gc() { */ void P3DX11SplashWindow:: close_window() { - if (_composite_image != NULL) { + if (_composite_image != nullptr) { XDestroyImage(_composite_image); - _composite_image = NULL; + _composite_image = nullptr; } if (_bar_context != None) { @@ -1136,9 +1136,9 @@ update_image(X11ImageData &image) { */ void P3DX11SplashWindow:: compose_image() { - if (_composite_image != NULL) { + if (_composite_image != nullptr) { XDestroyImage(_composite_image); - _composite_image = NULL; + _composite_image = nullptr; } _needs_new_composite = false; diff --git a/direct/src/plugin/p3d_lock.h b/direct/src/plugin/p3d_lock.h index ed923de304..7c11ca5bb4 100644 --- a/direct/src/plugin/p3d_lock.h +++ b/direct/src/plugin/p3d_lock.h @@ -44,15 +44,15 @@ public: // Threads. #define THREAD HANDLE -#define INIT_THREAD(thread) (thread) = NULL; +#define INIT_THREAD(thread) (thread) = nullptr; #define SPAWN_THREAD(thread, callback_function, this) \ - (thread) = CreateThread(NULL, 0, &win_ ## callback_function, (this), 0, NULL) + (thread) = CreateThread(nullptr, 0, &win_ ## callback_function, (this), 0, nullptr) #define JOIN_THREAD(thread) \ { \ - assert((thread) != NULL); \ + assert((thread) != nullptr); \ WaitForSingleObject((thread), INFINITE); \ CloseHandle((thread)); \ - (thread) = NULL; \ + (thread) = nullptr; \ } // Declare this macro within your class declaration. This implements the @@ -115,7 +115,7 @@ public: static void * \ posix_ ## callback_function(void *data) { \ ((class *)data)->callback_function(); \ - return NULL; \ + return nullptr; \ } #endif // _WIN32 diff --git a/direct/src/plugin/p3d_plugin.cxx b/direct/src/plugin/p3d_plugin.cxx index 8fc91c881e..5cddf55b31 100644 --- a/direct/src/plugin/p3d_plugin.cxx +++ b/direct/src/plugin/p3d_plugin.cxx @@ -61,35 +61,35 @@ P3D_initialize(int api_version, const char *contents_filename, } ACQUIRE_LOCK(_api_lock); - if (contents_filename == NULL){ + if (contents_filename == nullptr){ contents_filename = ""; } - if (host_url == NULL){ + if (host_url == nullptr){ host_url = ""; } - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (log_directory == NULL) { + if (log_directory == nullptr) { log_directory = ""; } - if (log_basename == NULL) { + if (log_basename == nullptr) { log_basename = ""; } - if (api_version < 12 || root_dir == NULL) { + if (api_version < 12 || root_dir == nullptr) { root_dir = ""; } - if (api_version < 16 || host_dir == NULL) { + if (api_version < 16 || host_dir == nullptr) { host_dir = ""; } - if (api_version < 17 || start_dir == NULL) { + if (api_version < 17 || start_dir == nullptr) { start_dir = ""; } @@ -116,10 +116,10 @@ P3D_set_plugin_version(int major, int minor, int sequence, const char *coreapi_timestamp_str, const char *coreapi_set_ver) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (distributor == NULL) { + if (distributor == nullptr) { distributor = ""; } - if (coreapi_host_url == NULL) { + if (coreapi_host_url == nullptr) { coreapi_host_url = ""; } @@ -133,10 +133,10 @@ P3D_set_plugin_version(int major, int minor, int sequence, } else { // Passing a time_t causes problems with disagreements about word size, so // since version 15 we pass it as a string. - coreapi_timestamp = strtoul(coreapi_timestamp_str, NULL, 10); + coreapi_timestamp = strtoul(coreapi_timestamp_str, nullptr, 10); } - if (inst_mgr->get_api_version() < 14 || coreapi_set_ver == NULL) { + if (inst_mgr->get_api_version() < 14 || coreapi_set_ver == nullptr) { // Prior to version 14 this parameter was absent. coreapi_set_ver = ""; } @@ -150,7 +150,7 @@ P3D_set_plugin_version(int major, int minor, int sequence, void P3D_set_super_mirror(const char *super_mirror_url) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (super_mirror_url == NULL) { + if (super_mirror_url == nullptr) { super_mirror_url = ""; } @@ -177,7 +177,7 @@ bool P3D_instance_start(P3D_instance *instance, bool is_local, const char *p3d_filename, int p3d_offset) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (p3d_filename == NULL) { + if (p3d_filename == nullptr) { p3d_filename = ""; } ACQUIRE_LOCK(_api_lock); @@ -190,7 +190,7 @@ P3D_instance_start(P3D_instance *instance, bool is_local, P3DInstance *inst = inst_mgr->validate_instance(instance); bool result = false; - if (inst != NULL) { + if (inst != nullptr) { // We don't actually start it immediately; the instance will have to // download the p3d url and read it, reading the python version, before it // can start. @@ -204,14 +204,14 @@ P3D_instance_start(P3D_instance *instance, bool is_local, int P3D_instance_start_stream(P3D_instance *instance, const char *p3d_url) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (p3d_url == NULL) { + if (p3d_url == nullptr) { p3d_url = ""; } ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); int result = -1; - if (inst != NULL) { + if (inst != nullptr) { result = inst_mgr->make_p3d_stream(inst, p3d_url); } RELEASE_LOCK(_api_lock); @@ -224,7 +224,7 @@ P3D_instance_finish(P3D_instance *instance) { ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - if (inst != NULL) { + if (inst != nullptr) { inst_mgr->finish_instance(inst); } RELEASE_LOCK(_api_lock); @@ -243,7 +243,7 @@ P3D_instance_setup_window(P3D_instance *instance, ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - if (inst != NULL) { + if (inst != nullptr) { inst->set_wparams(wparams); } RELEASE_LOCK(_api_lock); @@ -356,7 +356,7 @@ P3D_object_eval(P3D_object *object, const char *expression) { void P3D_object_incref(P3D_object *object) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (object != NULL) { + if (object != nullptr) { ACQUIRE_LOCK(_api_lock); P3D_OBJECT_INCREF(object); RELEASE_LOCK(_api_lock); @@ -366,7 +366,7 @@ P3D_object_incref(P3D_object *object) { void P3D_object_decref(P3D_object *object) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (object != NULL) { + if (object != nullptr) { ACQUIRE_LOCK(_api_lock); P3D_OBJECT_DECREF(object); RELEASE_LOCK(_api_lock); @@ -461,8 +461,8 @@ P3D_instance_get_panda_script_object(P3D_instance *instance) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - P3D_object *result = NULL; - if (inst != NULL) { + P3D_object *result = nullptr; + if (inst != nullptr) { result = inst->get_panda_script_object(); } @@ -478,7 +478,7 @@ P3D_instance_set_browser_script_object(P3D_instance *instance, P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - if (inst != NULL) { + if (inst != nullptr) { inst->set_browser_script_object(object); } @@ -493,8 +493,8 @@ P3D_instance_get_request(P3D_instance *instance) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - P3D_request *result = NULL; - if (inst != NULL) { + P3D_request *result = nullptr; + if (inst != nullptr) { result = inst->get_request(); } @@ -509,7 +509,7 @@ P3D_check_request(double timeout) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3D_instance *inst = inst_mgr->check_request(); - if (inst != NULL || timeout <= 0.0) { + if (inst != nullptr || timeout <= 0.0) { RELEASE_LOCK(_api_lock); return inst; } @@ -518,7 +518,7 @@ P3D_check_request(double timeout) { int stop_tick = int(GetTickCount() + timeout * 1000.0); #else struct timeval stop_time; - gettimeofday(&stop_time, NULL); + gettimeofday(&stop_time, nullptr); int seconds = (int)floor(timeout); stop_time.tv_sec += seconds; @@ -535,7 +535,7 @@ P3D_check_request(double timeout) { ACQUIRE_LOCK(_api_lock); inst = inst_mgr->check_request(); - while (inst == NULL && inst_mgr->get_num_instances() != 0) { + while (inst == nullptr && inst_mgr->get_num_instances() != 0) { #ifdef _WIN32 int remaining_ticks = stop_tick - GetTickCount(); if (remaining_ticks <= 0) { @@ -544,7 +544,7 @@ P3D_check_request(double timeout) { timeout = remaining_ticks * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); struct timeval remaining; remaining.tv_sec = stop_time.tv_sec - now.tv_sec; @@ -574,7 +574,7 @@ void P3D_request_finish(P3D_request *request, bool handled) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { P3DInstance::finish_request(request, handled); } RELEASE_LOCK(_api_lock); @@ -593,7 +593,7 @@ P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id, P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); bool result = false; - if (inst != NULL) { + if (inst != nullptr) { result = inst-> feed_url_stream(unique_id, result_code, http_status_code, total_expected_data, @@ -613,7 +613,7 @@ P3D_instance_handle_event(P3D_instance *instance, P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); bool result = false; - if (inst != NULL) { + if (inst != nullptr) { result = inst->handle_event(*event); } diff --git a/direct/src/plugin/p3d_plugin.h b/direct/src/plugin/p3d_plugin.h index 6df6e281fc..1d7866e05c 100644 --- a/direct/src/plugin/p3d_plugin.h +++ b/direct/src/plugin/p3d_plugin.h @@ -633,7 +633,7 @@ struct _P3D_object { #define P3D_OBJECT_INCREF(object) (++(object)->_ref_count) #define P3D_OBJECT_DECREF(object) { if (--(object)->_ref_count <= 0) { (object)->_class->_finish((object)); } } -#define P3D_OBJECT_XDECREF(object) { if ((object) != (P3D_object *)NULL) { P3D_OBJECT_DECREF(object); } } +#define P3D_OBJECT_XDECREF(object) { if ((object) != nullptr) { P3D_OBJECT_DECREF(object); } } /* End of method pointer definitions. The following function types are once again meant to define actual function pointers to be found diff --git a/direct/src/plugin/p3d_plugin_common.h b/direct/src/plugin/p3d_plugin_common.h index 244ac70925..538f69f466 100644 --- a/direct/src/plugin/p3d_plugin_common.h +++ b/direct/src/plugin/p3d_plugin_common.h @@ -46,7 +46,7 @@ extern LOCK _api_lock; // A convenience function for formatting a generic P3D_object to an ostream. inline ostream & operator << (ostream &out, P3D_object &value) { - int size = P3D_OBJECT_GET_REPR(&value, NULL, 0); + int size = P3D_OBJECT_GET_REPR(&value, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_REPR(&value, buffer, size); out.write(buffer, size); diff --git a/direct/src/plugin/run_p3dpython.cxx b/direct/src/plugin/run_p3dpython.cxx index abbaa92730..1a0432a2d4 100644 --- a/direct/src/plugin/run_p3dpython.cxx +++ b/direct/src/plugin/run_p3dpython.cxx @@ -28,6 +28,6 @@ run_p3dpython(const char *program_name, const char *archive_file, log_pathname, interactive_console); int result = P3DPythonRun::_global_ptr->run_python(); delete P3DPythonRun::_global_ptr; - P3DPythonRun::_global_ptr = NULL; + P3DPythonRun::_global_ptr = nullptr; return result; } diff --git a/direct/src/plugin/wstring_encode.cxx b/direct/src/plugin/wstring_encode.cxx index bda90a4270..3766e7dc10 100644 --- a/direct/src/plugin/wstring_encode.cxx +++ b/direct/src/plugin/wstring_encode.cxx @@ -30,11 +30,11 @@ bool wstring_to_string(string &result, const wstring &source) { bool success = false; int size = WideCharToMultiByte(CP_UTF8, 0, source.data(), source.length(), - NULL, 0, NULL, NULL); + nullptr, 0, nullptr, nullptr); if (size > 0) { char *buffer = new char[size]; int rc = WideCharToMultiByte(CP_UTF8, 0, source.data(), source.length(), - buffer, size, NULL, NULL); + buffer, size, nullptr, nullptr); if (rc != 0) { result.assign(buffer, size); success = true; @@ -54,7 +54,7 @@ bool string_to_wstring(wstring &result, const string &source) { bool success = false; int size = MultiByteToWideChar(CP_UTF8, 0, source.data(), source.length(), - NULL, 0); + nullptr, 0); if (size > 0) { wchar_t *buffer = new wchar_t[size]; int rc = MultiByteToWideChar(CP_UTF8, 0, source.data(), source.length(), diff --git a/direct/src/plugin/xml_helpers.cxx b/direct/src/plugin/xml_helpers.cxx index e08511f07a..20da4ce7ca 100644 --- a/direct/src/plugin/xml_helpers.cxx +++ b/direct/src/plugin/xml_helpers.cxx @@ -24,7 +24,7 @@ bool parse_bool_attrib(TiXmlElement *xelem, const string &attrib, bool default_value) { const char *value = xelem->Attribute(attrib.c_str()); - if (value == NULL || *value == '\0') { + if (value == nullptr || *value == '\0') { return default_value; } diff --git a/direct/src/plugin_activex/PPDownloadRequest.h b/direct/src/plugin_activex/PPDownloadRequest.h index a9ad8f3b2d..26d5081fc7 100644 --- a/direct/src/plugin_activex/PPDownloadRequest.h +++ b/direct/src/plugin_activex/PPDownloadRequest.h @@ -30,19 +30,19 @@ public: }; PPDownloadRequest( PPInstance& instance, P3D_request* p3dRequest ) : - m_instance( instance ), m_p3dRequest( p3dRequest ), m_data( NULL ), + m_instance( instance ), m_p3dRequest( p3dRequest ), m_data( nullptr ), m_requestType( RequestType::P3DObject ), m_hFile( INVALID_HANDLE_VALUE ) { } PPDownloadRequest( PPInstance& instance, const std::string& fileName ) : - m_instance( instance ), m_p3dRequest( NULL ), m_fileName( fileName ), - m_data( NULL ), m_requestType( RequestType::File ), m_hFile( INVALID_HANDLE_VALUE ) + m_instance( instance ), m_p3dRequest( nullptr ), m_fileName( fileName ), + m_data( nullptr ), m_requestType( RequestType::File ), m_hFile( INVALID_HANDLE_VALUE ) { } PPDownloadRequest( PPInstance& instance, std::strstream* data ) : - m_instance( instance ), m_p3dRequest ( NULL ), m_data( data ), + m_instance( instance ), m_p3dRequest ( nullptr ), m_data( data ), m_requestType( RequestType::Data ), m_hFile( INVALID_HANDLE_VALUE ) { } diff --git a/direct/src/plugin_npapi/npruntime.h b/direct/src/plugin_npapi/npruntime.h index 6e89165045..2039225cbe 100644 --- a/direct/src/plugin_npapi/npruntime.h +++ b/direct/src/plugin_npapi/npruntime.h @@ -137,13 +137,13 @@ void NPN_ReleaseVariantValue(NPVariant *variant); #define VOID_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Void; \ - (_v).value.objectValue = NULL; \ + (_v).value.objectValue = nullptr; \ NP_END_MACRO #define NULL_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Null; \ - (_v).value.objectValue = NULL; \ + (_v).value.objectValue = nullptr; \ NP_END_MACRO #define BOOLEAN_TO_NPVARIANT(_val, _v) \ diff --git a/direct/src/plugin_npapi/ppBrowserObject.cxx b/direct/src/plugin_npapi/ppBrowserObject.cxx index 822f1f5657..9655295141 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.cxx +++ b/direct/src/plugin_npapi/ppBrowserObject.cxx @@ -44,7 +44,7 @@ static P3D_object * object_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { - if (method_name == NULL) { + if (method_name == nullptr) { method_name = ""; } P3D_object *response = ((const PPBrowserObject *)object)->call(method_name, params, num_params); @@ -52,7 +52,7 @@ object_call(P3D_object *object, const char *method_name, // No response was expected. Throw away the response we received, so we // can be consistent with defined semantics. P3D_OBJECT_XDECREF(response); - response = NULL; + response = nullptr; } return response; } @@ -123,14 +123,14 @@ get_property(const string &property) const { if (!browser->hasproperty(_instance->get_npp_instance(), _npobj, property_name)) { // No such property. - return NULL; + return nullptr; } NPVariant result; if (!browser->getproperty(_instance->get_npp_instance(), _npobj, property_name, &result)) { // Failed to retrieve property. - return NULL; + return nullptr; } P3D_object *object = _instance->variant_to_p3dobj(&result); @@ -146,7 +146,7 @@ bool PPBrowserObject:: set_property(const string &property, bool needs_response, P3D_object *value) { NPIdentifier property_name = browser->getstringidentifier(property.c_str()); bool result; - if (value != NULL) { + if (value != nullptr) { // Set the property. NPVariant npvalue; _instance->p3dobj_to_variant(&npvalue, value); @@ -183,7 +183,7 @@ call(const string &method_name, P3D_object *params[], int num_params) const { npparams, num_params, &result)) { // Failed to invoke. delete[] npparams; - return NULL; + return nullptr; } } else { // Call the named method. @@ -193,7 +193,7 @@ call(const string &method_name, P3D_object *params[], int num_params) const { npparams, num_params, &result)) { // Failed to invoke. delete[] npparams; - return NULL; + return nullptr; } } @@ -215,7 +215,7 @@ eval(const string &expression) const { if (!browser->evaluate(_instance->get_npp_instance(), _npobj, &npexpr, &result)) { // Failed to eval. - return NULL; + return nullptr; } P3D_object *object = _instance->variant_to_p3dobj(&result); @@ -229,7 +229,7 @@ eval(const string &expression) const { */ void PPBrowserObject:: clear_class_definition() { - _browser_object_class = NULL; + _browser_object_class = nullptr; } /** @@ -238,7 +238,7 @@ clear_class_definition() { */ P3D_class_definition *PPBrowserObject:: get_class_definition() { - if (_browser_object_class == NULL) { + if (_browser_object_class == nullptr) { // Create a default class_definition object, and fill in the appropriate // pointers. _browser_object_class = P3D_make_class_definition_ptr(); diff --git a/direct/src/plugin_npapi/ppInstance.I b/direct/src/plugin_npapi/ppInstance.I index 122b396912..1c929d849b 100644 --- a/direct/src/plugin_npapi/ppInstance.I +++ b/direct/src/plugin_npapi/ppInstance.I @@ -27,5 +27,5 @@ get_window() const { if (_got_window) { return &_window; } - return NULL; + return nullptr; } diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 47aa5b3cd0..8e3281c405 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -54,13 +54,13 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved, P3D_window_handle_type window_handle_type, P3D_event_type event_type) { - _p3d_inst = NULL; + _p3d_inst = nullptr; _npp_instance = instance; _npp_mode = mode; _window_handle_type = window_handle_type; _event_type = event_type; - _script_object = NULL; + _script_object = nullptr; _contents_expiration = 0; _failed = false; _started = false; @@ -68,9 +68,9 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, // Copy the tokens and save them within this object. _tokens.reserve(argc); for (int i = 0; i < argc; ++i) { - if (argn[i] != NULL) { + if (argn[i] != nullptr) { const char *v = argv[i]; - if (v == NULL) { + if (v == nullptr) { // Firefox might give us a NULL argv[i] in some cases. v = ""; } @@ -130,13 +130,13 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, #ifdef HAVE_X11 _twirl_subprocess_pid = -1; #ifdef HAVE_GTK - _plug = NULL; + _plug = nullptr; #endif // HAVE_GTK #endif // HAVE_X11 #ifdef _WIN32 - _hwnd = NULL; - _bg_brush = NULL; + _hwnd = nullptr; + _bg_brush = nullptr; #endif // _WIN32 #ifndef _WIN32 @@ -144,7 +144,7 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, // use this to measure elapsed time from the window parameters having been // received. struct timeval tv; - gettimeofday(&tv, (struct timezone *)NULL); + gettimeofday(&tv, nullptr); _init_sec = tv.tv_sec; _init_usec = tv.tv_usec; #endif // !_WIN32 @@ -155,16 +155,16 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, // thread.) _run_loop_main = CFRunLoopGetCurrent(); CFRetain(_run_loop_main); - _request_timer = NULL; + _request_timer = nullptr; INIT_LOCK(_timer_lock); // Also set up a timer to twirl the icon until the instance loads. - _twirl_timer = NULL; + _twirl_timer = nullptr; CFRunLoopTimerContext timer_context; memset(&timer_context, 0, sizeof(timer_context)); timer_context.info = this; _twirl_timer = CFRunLoopTimerCreate - (NULL, 0, 0.1, 0, 0, st_twirl_timer_callback, &timer_context); + (nullptr, 0, 0.1, 0, 0, st_twirl_timer_callback, &timer_context); CFRunLoopAddTimer(_run_loop_main, _twirl_timer, kCFRunLoopCommonModes); #endif // __APPLE__ @@ -181,15 +181,15 @@ PPInstance:: cleanup_window(); #ifdef __APPLE__ - if (_twirl_timer != NULL) { + if (_twirl_timer != nullptr) { CFRunLoopTimerInvalidate(_twirl_timer); CFRelease(_twirl_timer); - _twirl_timer = NULL; + _twirl_timer = nullptr; } - if (_request_timer != NULL) { + if (_request_timer != nullptr) { CFRunLoopTimerInvalidate(_request_timer); CFRelease(_request_timer); - _request_timer = NULL; + _request_timer = nullptr; } _run_loop_main = CFRunLoopGetCurrent(); CFRelease(_run_loop_main); @@ -200,15 +200,15 @@ PPInstance:: osx_release_twirl_images(); #endif // MACOSX_HAS_EVENT_MODELS - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { P3D_instance_finish_ptr(_p3d_inst); - _p3d_inst = NULL; + _p3d_inst = nullptr; } assert(_streams.empty()); assert(_file_datas.empty()); - if (_script_object != NULL) { + if (_script_object != nullptr) { browser->releaseobject(_script_object); } @@ -259,7 +259,7 @@ begin() { string contents_filename = _root_dir + "/contents.xml"; if (read_contents_file(contents_filename, false)) { - if (time(NULL) < _contents_expiration) { + if (time(nullptr) < _contents_expiration) { // Got the file, and it's good. get_core_api(); success = true; @@ -276,7 +276,7 @@ begin() { // Append a uniquifying query string to the URL to force the download to // go all the way through any caches. We use the time in seconds; // that's unique enough. - strm << "?" << time(NULL); + strm << "?" << time(nullptr); url = strm.str(); PPDownloadRequest *req = new PPDownloadRequest(PPDownloadRequest::RT_contents_file); @@ -308,7 +308,7 @@ set_window(NPWindow *window) { if (!_got_window) { #ifdef _WIN32 - _orig_window_proc = NULL; + _orig_window_proc = nullptr; if (window->type == NPWindowTypeWindow) { // Save the window handle. _hwnd = (HWND)window->window; @@ -330,7 +330,7 @@ set_window(NPWindow *window) { // twirling icon, and also to catch events in case something slips // through. _init_time = GetTickCount(); - SetTimer(_hwnd, 1, 100, NULL); + SetTimer(_hwnd, 1, 100, nullptr); } #endif // _WIN32 #ifdef MACOSX_HAS_EVENT_MODELS @@ -342,9 +342,9 @@ set_window(NPWindow *window) { if (_use_xembed) { if (!_got_window || _window.window != window->window) { // The window has changed. Destroy the old GtkPlug. - if (_plug != NULL) { + if (_plug != nullptr) { gtk_widget_destroy(_plug); - _plug = NULL; + _plug = nullptr; } // Create a new GtkPlug to bind to the XEmbed socket. @@ -367,7 +367,7 @@ set_window(NPWindow *window) { #endif // HAVE_X11 if (!_failed) { - if (_p3d_inst == NULL) { + if (_p3d_inst == nullptr) { create_instance(); } else { send_window(); @@ -385,16 +385,16 @@ new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { return NPERR_GENERIC_ERROR; } - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { // This is an unsolicited stream. Assume the first unsolicited stream we // receive is the instance data; any other unsolicited stream is an error. - if (!_got_instance_url && stream->url != NULL) { + if (!_got_instance_url && stream->url != nullptr) { _got_instance_url = true; _instance_url = stream->url; stream->notifyData = new PPDownloadRequest(PPDownloadRequest::RT_instance_data); - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { // If we already have an instance by the time we get this stream, // start sending the data to the instance (instead of having to mess // around with a temporary file). @@ -488,7 +488,7 @@ write_ready(NPStream *stream) { */ int PPInstance:: write_stream(NPStream *stream, int offset, int len, void *buffer) { - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { nout << "Unexpected write_stream on " << stream->url << "\n"; browser->destroystream(_npp_instance, stream, NPRES_USER_BREAK); return 0; @@ -523,7 +523,7 @@ write_stream(NPStream *stream, int offset, int len, void *buffer) { // Nowadays we solve this problem by writing the data to a temporary file // until the instance is ready for it. - if (_p3d_inst == NULL) { + if (_p3d_inst == nullptr) { // The instance isn't ready, so stuff it in a temporary file. if (!_p3d_temp_file.feed(stream->end, buffer, len)) { set_failed(); @@ -575,7 +575,7 @@ destroy_stream(NPStream *stream, NPReason reason) { _streams.erase(si); } - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { nout << "Unexpected destroy_stream on " << stream->url << "\n"; return NPERR_NO_ERROR; } @@ -595,14 +595,14 @@ destroy_stream(NPStream *stream, NPReason reason) { case PPDownloadRequest::RT_user: if (!req->_notified_done) { P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, - result_code, 0, stream->end, NULL, 0); + result_code, 0, stream->end, nullptr, 0); req->_notified_done = true; } break; case PPDownloadRequest::RT_instance_data: if (!req->_notified_done) { - if (_p3d_inst == NULL) { + if (_p3d_inst == nullptr) { // The instance still isn't ready; just mark the data done. We'll // send the entire file to the instance when it is ready. _p3d_temp_file.finish(); @@ -614,7 +614,7 @@ destroy_stream(NPStream *stream, NPReason reason) { // The instance has (only just) been created. Tell it we've sent it // all the data it will get. P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, - result_code, 0, stream->end, NULL, 0); + result_code, 0, stream->end, nullptr, 0); } req->_notified_done = true; } @@ -655,7 +655,7 @@ destroy_stream(NPStream *stream, NPReason reason) { */ void PPInstance:: url_notify(const char *url, NPReason reason, void *notifyData) { - if (notifyData == NULL) { + if (notifyData == nullptr) { return; } @@ -675,7 +675,7 @@ url_notify(const char *url, NPReason reason, void *notifyData) { assert(reason != NPRES_DONE); P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, - P3D_RC_generic_error, 0, 0, NULL, 0); + P3D_RC_generic_error, 0, 0, nullptr, 0); req->_notified_done = true; } break; @@ -739,7 +739,7 @@ url_notify(const char *url, NPReason reason, void *notifyData) { */ void PPInstance:: stream_as_file(NPStream *stream, const char *fname) { - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { nout << "Unexpected stream_as_file on " << stream->url << "\n"; return; } @@ -772,7 +772,7 @@ stream_as_file(NPStream *stream, const char *fname) { // the file that Safari tells us about appears to be a temporary file // that Safari's about to delete. In order to protect ourselves from // this, we need to temporarily copy the file somewhere else. - char *name = tempnam(NULL, "p3d_"); + char *name = tempnam(nullptr, "p3d_"); // We prefer just making a hard link; it's quick and easy. if (link(filename.c_str(), name) != 0) { @@ -802,7 +802,7 @@ stream_as_file(NPStream *stream, const char *fname) { */ bool PPInstance:: handle_request(P3D_request *request) { - if (_p3d_inst == NULL || _failed) { + if (_p3d_inst == nullptr || _failed) { return false; } assert(request->_instance == _p3d_inst); @@ -811,9 +811,9 @@ handle_request(P3D_request *request) { switch (request->_request_type) { case P3D_RT_stop: - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { P3D_instance_finish_ptr(_p3d_inst); - _p3d_inst = NULL; + _p3d_inst = nullptr; } cleanup_window(); // Guess the browser doesn't really care. @@ -911,7 +911,7 @@ handle_event(void *event) { #endif // MACOSX_HAS_EVENT_MODELS } - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { if (P3D_instance_handle_event_ptr(_p3d_inst, &edata)) { retval = true; } @@ -926,15 +926,15 @@ handle_event(void *event) { */ NPObject *PPInstance:: get_panda_script_object() { - if (_script_object != NULL) { + if (_script_object != nullptr) { // NPRuntime "steals" a reference to this object. browser->retainobject(_script_object); return _script_object; } - P3D_object *main = NULL; + P3D_object *main = nullptr; - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { main = P3D_instance_get_panda_script_object_ptr(_p3d_inst); } nout << "get_panda_script_object, main = " << main << "\n"; @@ -985,7 +985,7 @@ p3dobj_to_variant(NPVariant *result, P3D_object *object) { case P3D_OT_string: { - int size = P3D_OBJECT_GET_STRING(object, NULL, 0); + int size = P3D_OBJECT_GET_STRING(object, nullptr, 0); char *buffer = (char *)browser->memalloc(size); P3D_OBJECT_GET_STRING(object, buffer, size); STRINGN_TO_NPVARIANT(buffer, size, *result); @@ -1071,9 +1071,9 @@ void PPInstance:: find_host(TiXmlElement *xcontents) { string host_url = PANDA_PACKAGE_HOST_URL; TiXmlElement *xhost = xcontents->FirstChildElement("host"); - if (xhost != NULL) { + if (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && host_url == string(url)) { + if (url != nullptr && host_url == string(url)) { // We're the primary host. This is the normal case. read_xhost(xhost); return; @@ -1081,9 +1081,9 @@ find_host(TiXmlElement *xcontents) { } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *url = xalthost->Attribute("url"); - if (url != NULL && host_url == string(url)) { + if (url != nullptr && host_url == string(url)) { // Yep, we're this alternate host. read_xhost(xhost); return; @@ -1107,7 +1107,7 @@ read_xhost(TiXmlElement *xhost) { // Get the "download" URL, which is the source from which we download // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); - if (download_url != NULL) { + if (download_url != nullptr) { _download_url_prefix = download_url; } else { _download_url_prefix = PANDA_PACKAGE_HOST_URL; @@ -1119,9 +1119,9 @@ read_xhost(TiXmlElement *xhost) { } TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); - while (xmirror != NULL) { + while (xmirror != nullptr) { const char *url = xmirror->Attribute("url"); - if (url != NULL) { + if (url != nullptr) { add_mirror(url); } xmirror = xmirror->NextSiblingElement("mirror"); @@ -1175,15 +1175,15 @@ choose_random_mirrors(vector &result, int num_mirrors) { void PPInstance:: request_ready(P3D_instance *instance) { PPInstance *inst = (PPInstance *)(instance->_user_data); - assert(inst != NULL); + assert(inst != nullptr); if (has_plugin_thread_async_call) { #ifdef HAS_PLUGIN_THREAD_ASYNC_CALL // Since we are running at least Gecko 1.9, and we have this very useful // function, let's use it to ask the browser to call us back in the main // thread. - assert((void *)browser->pluginthreadasynccall != (void *)NULL); - browser->pluginthreadasynccall(inst->_npp_instance, browser_sync_callback, NULL); + assert((void *)browser->pluginthreadasynccall != nullptr); + browser->pluginthreadasynccall(inst->_npp_instance, browser_sync_callback, nullptr); #endif // HAS_PLUGIN_THREAD_ASYNC_CALL } else { @@ -1195,7 +1195,7 @@ request_ready(P3D_instance *instance) { // Get the window handle for the window associated with this instance. const NPWindow *win = inst->get_window(); - if (win != NULL && win->type == NPWindowTypeWindow) { + if (win != nullptr && win->type == NPWindowTypeWindow) { PostMessage((HWND)(win->window), WM_USER, 0, 0); } #endif // _WIN32 @@ -1205,12 +1205,12 @@ request_ready(P3D_instance *instance) { // Only set a new timer if we don't have one already started. ACQUIRE_LOCK(inst->_timer_lock); - if (inst->_request_timer == NULL) { + if (inst->_request_timer == nullptr) { CFRunLoopTimerContext timer_context; memset(&timer_context, 0, sizeof(timer_context)); timer_context.info = inst; inst->_request_timer = CFRunLoopTimerCreate - (NULL, 0, 0, 0, 0, timer_callback, &timer_context); + (nullptr, 0, 0, 0, 0, timer_callback, &timer_context); CFRunLoopAddTimer(inst->_run_loop_main, inst->_request_timer, kCFRunLoopCommonModes); } RELEASE_LOCK(inst->_timer_lock); @@ -1232,7 +1232,7 @@ start_download(const string &url, PPDownloadRequest *req) { delete req; } else { // Otherwise, ask the browser to download it. - browser->geturlnotify(_npp_instance, url.c_str(), NULL, req); + browser->geturlnotify(_npp_instance, url.c_str(), nullptr, req); } } @@ -1283,19 +1283,19 @@ read_contents_file(const string &contents_filename, bool fresh_download) { bool found_core_package = false; TiXmlElement *xcontents = doc.FirstChildElement("contents"); - if (xcontents != NULL) { + if (xcontents != nullptr) { int max_age = P3D_CONTENTS_DEFAULT_MAX_AGE; xcontents->Attribute("max_age", &max_age); // Get the latest possible expiration time, based on the max_age // indication. Any expiration time later than this is in error. - time_t now = time(NULL); + time_t now = time(nullptr); _contents_expiration = now + (time_t)max_age; if (fresh_download) { // Update the XML with the new download information. TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - while (xorig != NULL) { + while (xorig != nullptr) { xcontents->RemoveChild(xorig); xorig = xcontents->FirstChildElement("orig"); } @@ -1309,7 +1309,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Read the expiration time from the XML. int expiration = 0; TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - if (xorig != NULL) { + if (xorig != nullptr) { xorig->Attribute("expiration", &expiration); } @@ -1327,14 +1327,14 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Now look for the core API package. _coreapi_set_ver = ""; TiXmlElement *xpackage = xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); - if (name != NULL && strcmp(name, "coreapi") == 0) { + if (name != nullptr && strcmp(name, "coreapi") == 0) { const char *platform = xpackage->Attribute("platform"); - if (platform != NULL && strcmp(platform, DTOOL_PLATFORM) == 0) { + if (platform != nullptr && strcmp(platform, DTOOL_PLATFORM) == 0) { _coreapi_dll.load_xml(xpackage); const char *set_ver = xpackage->Attribute("set_ver"); - if (set_ver != NULL) { + if (set_ver != nullptr) { _coreapi_set_ver = set_ver; } found_core_package = true; @@ -1491,7 +1491,7 @@ send_p3d_temp_file_data() { // If we'd already finished the stream earlier, tell the plugin. P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, P3D_RC_done, 0, _p3d_temp_file._total_size, - NULL, 0); + nullptr, 0); } _p3d_temp_file.cleanup(); } @@ -1515,7 +1515,7 @@ get_core_api() { // uniquifier, to break through any caches. ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() - << "?" << time(NULL); + << "?" << time(nullptr); url = strm.str(); _core_urls.push_back(url); @@ -1566,7 +1566,7 @@ downloaded_plugin(const string &filename) { nout << "Expected:\n"; _coreapi_dll.write(nout); const FileSpec *actual = _coreapi_dll.force_get_actual_file(filename); - if (actual != NULL) { + if (actual != nullptr) { nout << "Found:\n"; actual->write(nout); } @@ -1671,10 +1671,10 @@ create_instance() { #ifdef __APPLE__ // We no longer need to twirl the icon. Stop the timer. - if (_twirl_timer != NULL) { + if (_twirl_timer != nullptr) { CFRunLoopTimerInvalidate(_twirl_timer); CFRelease(_twirl_timer); - _twirl_timer = NULL; + _twirl_timer = nullptr; } #endif // __APPLE__ @@ -1685,21 +1685,21 @@ create_instance() { // In the Windows case, we let the timer keep running, because it also // checks for wayward messages. - P3D_token *tokens = NULL; + P3D_token *tokens = nullptr; if (!_tokens.empty()) { tokens = &_tokens[0]; } _started = true; _p3d_inst = P3D_new_instance_ptr(request_ready, tokens, _tokens.size(), - 0, NULL, this); - if (_p3d_inst == NULL) { + 0, nullptr, this); + if (_p3d_inst == nullptr) { set_failed(); return; } // Now get the browser's toplevel DOM object (called the "window" object in // JavaScript), to pass to the plugin. - NPObject *window_object = NULL; + NPObject *window_object = nullptr; if (browser->getvalue(_npp_instance, NPNVWindowNPObject, &window_object) == NPERR_NO_ERROR) { PPBrowserObject *pobj = new PPBrowserObject(this, window_object); @@ -1709,7 +1709,7 @@ create_instance() { nout << "Couldn't get window_object\n"; } - if (_script_object != NULL) { + if (_script_object != nullptr) { // Now that we have a true instance, initialize our script_object with the // proper P3D_object pointer. P3D_object *main = P3D_instance_get_panda_script_object_ptr(_p3d_inst); @@ -1740,7 +1740,7 @@ create_instance() { */ void PPInstance:: send_window() { - assert(_p3d_inst != NULL); + assert(_p3d_inst != nullptr); int x = _window.x; int y = _window.y; @@ -1770,7 +1770,7 @@ send_window() { #endif } else if (_window_handle_type == P3D_WHT_osx_cgcontext) { NP_CGContext *context = (NP_CGContext *)_window.window; - if (context != NULL) { + if (context != nullptr) { parent_window._handle._osx_cgcontext._context = context->context; parent_window._handle._osx_cgcontext._window = (WindowRef)context->window; } @@ -1784,7 +1784,7 @@ send_window() { // If we're using XEmbed, pass the X11 Window pointer of our plug down // to Panda. (Hmm, it would be nice to pass the XID object and use this // system in general within Panda, but that's for the future, I think.) - assert(_plug != NULL); + assert(_plug != nullptr); parent_window._window_handle_type = P3D_WHT_x11_window; parent_window._handle._x11_window._xwindow = GDK_DRAWABLE_XID(_plug->window); #endif // HAVE_GTK @@ -1818,7 +1818,7 @@ send_window() { #endif } else if (_window_handle_type == P3D_WHT_osx_cgcontext) { NP_CGContext *context = (NP_CGContext *)_window.window; - if (context != NULL) { + if (context != nullptr) { parent_window._handle._osx_cgcontext._context = context->context; parent_window._handle._osx_cgcontext._window = (WindowRef)context->window; } @@ -1845,7 +1845,7 @@ send_window() { #endif P3D_window_type window_type = P3D_WT_embedded; - if (_window.window == NULL && _event_type != P3D_ET_osx_cocoa) { + if (_window.window == nullptr && _event_type != P3D_ET_osx_cocoa) { // No parent window: it must be a hidden window. window_type = P3D_WT_hidden; } else if (_window.width == 0 || _window.height == 0) { @@ -1870,16 +1870,16 @@ cleanup_window() { // Restore the parent window to its own window handler. HWND hwnd = (HWND)_window.window; SetWindowLongPtr(hwnd, GWLP_WNDPROC, _orig_window_proc); - InvalidateRect(hwnd, NULL, true); + InvalidateRect(hwnd, nullptr, true); - if (_bg_brush != NULL) { + if (_bg_brush != nullptr) { DeleteObject(_bg_brush); - _bg_brush = NULL; + _bg_brush = nullptr; } for (int step = 0; step < twirl_num_steps + 1; ++step) { - if (_twirl_bitmaps[step] != NULL) { + if (_twirl_bitmaps[step] != nullptr) { DeleteObject(_twirl_bitmaps[step]); - _twirl_bitmaps[step] = NULL; + _twirl_bitmaps[step] = nullptr; } } #endif // _WIN32 @@ -1888,9 +1888,9 @@ cleanup_window() { x11_stop_twirl_subprocess(); #ifdef HAVE_GTK - if (_plug != NULL) { + if (_plug != nullptr) { gtk_widget_destroy(_plug); - _plug = NULL; + _plug = nullptr; } #endif // HAVE_GTK #endif // HAVE_X11 @@ -2037,7 +2037,7 @@ set_failed() { if (!expression.empty()) { // Now attempt to evaluate the expression. - NPObject *window_object = NULL; + NPObject *window_object = nullptr; if (browser->getvalue(_npp_instance, NPNVWindowNPObject, &window_object) == NPERR_NO_ERROR) { NPString npexpr = { expression.c_str(), (uint32_t)expression.length() }; @@ -2054,9 +2054,9 @@ set_failed() { } } - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { P3D_instance_finish_ptr(_p3d_inst); - _p3d_inst = NULL; + _p3d_inst = nullptr; } cleanup_window(); } @@ -2073,11 +2073,11 @@ handle_request_loop() { } P3D_instance *p3d_inst = P3D_check_request_ptr(0.0); - while (p3d_inst != (P3D_instance *)NULL) { + while (p3d_inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(p3d_inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { PPInstance *inst = (PPInstance *)(p3d_inst->_user_data); - assert(inst != NULL); + assert(inst != nullptr); if (!inst->handle_request(request)) { // If handling the request is meant to yield control temporarily to // JavaScript (e.g. P3D_RT_callback), then do so now. @@ -2130,7 +2130,7 @@ browser_sync_callback(void *) { LONG PPInstance:: st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (self == NULL) { + if (self == nullptr) { // We haven't assigned the pointer yet (!?) return DefWindowProc(hwnd, msg, wparam, lparam); } @@ -2174,7 +2174,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_TIMER: if (!_started) { - InvalidateRect(_hwnd, NULL, FALSE); + InvalidateRect(_hwnd, nullptr, FALSE); } break; @@ -2286,7 +2286,7 @@ win_paint_twirl(HWND hwnd, HDC dc) { BitBlt(bdc, left, top, twirl_width, twirl_height, mem_dc, 0, 0, SRCCOPY); - SelectObject(mem_dc, NULL); + SelectObject(mem_dc, nullptr); DeleteDC(mem_dc); } } @@ -2414,7 +2414,7 @@ const wchar_t *PPInstance:: make_ansi_string(wstring &result, NPNSString *ns_string) { result.clear(); - if (ns_string != NULL) { + if (ns_string != nullptr) { // An NPNSString is really just an NSString, which is itself just a // CFString. CFStringRef cfstr = (CFStringRef)ns_string; @@ -2492,7 +2492,7 @@ osx_get_twirl_images() { image._raw_data = new_data; image._data = - CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, + CFDataCreateWithBytesNoCopy(nullptr, (const UInt8 *)image._raw_data, twirl_size * 4, kCFAllocatorNull); image._provider = CGDataProviderCreateWithCFData(image._data); image._color_space = CGColorSpaceCreateDeviceRGB(); @@ -2501,7 +2501,7 @@ osx_get_twirl_images() { CGImageCreate(twirl_width, twirl_height, 8, 32, twirl_width * 4, image._color_space, kCGImageAlphaFirst | kCGBitmapByteOrder32Little, - image._provider, NULL, false, kCGRenderingIntentDefault); + image._provider, nullptr, false, kCGRenderingIntentDefault); } } #endif // MACOSX_HAS_EVENT_MODELS @@ -2520,25 +2520,25 @@ osx_release_twirl_images() { for (int step = 0; step < twirl_num_steps + 1; ++step) { OsxImageData &image = _twirl_images[step]; - if (image._image != NULL) { + if (image._image != nullptr) { CGImageRelease(image._image); - image._image = NULL; + image._image = nullptr; } - if (image._color_space != NULL) { + if (image._color_space != nullptr) { CGColorSpaceRelease(image._color_space); - image._color_space = NULL; + image._color_space = nullptr; } - if (image._provider != NULL) { + if (image._provider != nullptr) { CGDataProviderRelease(image._provider); - image._provider = NULL; + image._provider = nullptr; } - if (image._data != NULL) { + if (image._data != nullptr) { CFRelease(image._data); - image._data = NULL; + image._data = nullptr; } - if (image._raw_data != NULL) { + if (image._raw_data != nullptr) { delete[] image._raw_data; - image._raw_data = NULL; + image._raw_data = nullptr; } } } @@ -2571,7 +2571,7 @@ paint_twirl_osx_cgcontext(CGContextRef context) { } else { struct timeval tv; - gettimeofday(&tv, (struct timezone *)NULL); + gettimeofday(&tv, nullptr); double now = (double)(tv.tv_sec - _init_sec) + (double)(tv.tv_usec - _init_usec) / 1000000.0; // Don't draw the twirling icon until at least half a second has passed, @@ -2591,7 +2591,7 @@ paint_twirl_osx_cgcontext(CGContextRef context) { */ bool PPInstance:: osx_paint_image(CGContextRef context, const OsxImageData &image) { - if (image._image == NULL) { + if (image._image == nullptr) { return false; } @@ -2627,10 +2627,10 @@ void PPInstance:: timer_callback(CFRunLoopTimerRef timer, void *info) { PPInstance *self = (PPInstance *)info; ACQUIRE_LOCK(self->_timer_lock); - if (self->_request_timer != NULL) { + if (self->_request_timer != nullptr) { CFRunLoopTimerInvalidate(self->_request_timer); CFRelease(self->_request_timer); - self->_request_timer = NULL; + self->_request_timer = nullptr; } RELEASE_LOCK(self->_timer_lock); @@ -2744,14 +2744,14 @@ x11_twirl_subprocess_run() { struct timespec req; req.tv_sec = 0; req.tv_nsec = 500000000; // 500 ms - nanosleep(&req, NULL); + nanosleep(&req, nullptr); // We haven't been killed yet, so the plugin is still loading. Start // twirling. // First, embed a window. - X11_Display *display = XOpenDisplay(NULL); - assert(display != NULL); + X11_Display *display = XOpenDisplay(nullptr); + assert(display != nullptr); int screen = DefaultScreen(display); int depth = DefaultDepth(display, screen); @@ -2796,7 +2796,7 @@ x11_twirl_subprocess_run() { X11_Window parent = 0; if (_use_xembed) { #ifdef HAVE_GTK - assert(_plug != NULL); + assert(_plug != nullptr); parent = GDK_DRAWABLE_XID(_plug->window); #endif // HAVE_GTK } else { @@ -2874,7 +2874,7 @@ x11_twirl_subprocess_run() { // What step are we on now? struct timeval tv; - gettimeofday(&tv, (struct timezone *)NULL); + gettimeofday(&tv, nullptr); double now = (double)(tv.tv_sec - _init_sec) + (double)(tv.tv_usec - _init_usec) / 1000000.0; int step = ((int)(now * 10.0)) % twirl_num_steps; if (step != last_step) { @@ -2896,7 +2896,7 @@ x11_twirl_subprocess_run() { struct timespec req; req.tv_sec = 0; req.tv_nsec = 100000000; // 100 ms - nanosleep(&req, NULL); + nanosleep(&req, nullptr); } } #endif // HAVE_X11 @@ -2990,7 +2990,7 @@ thread_run() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 10000; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); #endif } @@ -3002,7 +3002,7 @@ thread_run() { } P3D_instance_feed_url_stream_ptr - (_p3d_inst, _user_id, result, 0, _total_count, NULL, 0); + (_p3d_inst, _user_id, result, 0, _total_count, nullptr, 0); // All done. _thread_done = true; @@ -3041,7 +3041,7 @@ open() { _current_size = 0; _total_size = 0; - char *name = tempnam(NULL, "p3d_"); + char *name = tempnam(nullptr, "p3d_"); _filename = name; free(name); diff --git a/direct/src/plugin_npapi/ppPandaObject.I b/direct/src/plugin_npapi/ppPandaObject.I index 1f50908246..eafcfbd83c 100644 --- a/direct/src/plugin_npapi/ppPandaObject.I +++ b/direct/src/plugin_npapi/ppPandaObject.I @@ -18,7 +18,7 @@ */ inline P3D_object *PPPandaObject:: get_p3d_object() const { - if (_p3d_object != NULL) { + if (_p3d_object != nullptr) { P3D_OBJECT_INCREF(_p3d_object); } return _p3d_object; diff --git a/direct/src/plugin_npapi/ppPandaObject.cxx b/direct/src/plugin_npapi/ppPandaObject.cxx index c403868a41..f85ef43407 100644 --- a/direct/src/plugin_npapi/ppPandaObject.cxx +++ b/direct/src/plugin_npapi/ppPandaObject.cxx @@ -52,7 +52,7 @@ make_new(PPInstance *inst, P3D_object *p3d_object) { */ void PPPandaObject:: set_p3d_object(P3D_object *p3d_object) { - if (p3d_object != NULL) { + if (p3d_object != nullptr) { P3D_OBJECT_INCREF(p3d_object); } P3D_OBJECT_XDECREF(_p3d_object); @@ -67,7 +67,7 @@ set_p3d_object(P3D_object *p3d_object) { void PPPandaObject:: construct(PPInstance *inst, P3D_object *p3d_object) { _instance = inst; - _p3d_object = NULL; + _p3d_object = nullptr; set_p3d_object(p3d_object); } @@ -76,8 +76,8 @@ construct(PPInstance *inst, P3D_object *p3d_object) { */ void PPPandaObject:: invalidate() { - _instance = NULL; - set_p3d_object(NULL); + _instance = nullptr; + set_p3d_object(nullptr); } /** @@ -87,7 +87,7 @@ bool PPPandaObject:: has_method(NPIdentifier name) { string method_name = identifier_to_string(name); // nout << this << ".has_method(" << method_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -114,7 +114,7 @@ invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { string method_name = identifier_to_string(name); // nout << this << ".invoke(" << method_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -132,7 +132,7 @@ invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, } delete[] p3dargs; - if (value == NULL) { + if (value == nullptr) { // No such method, or some problem with the parameters. return false; } @@ -151,7 +151,7 @@ bool PPPandaObject:: invoke_default(const NPVariant *args, uint32_t argCount, NPVariant *result) { // nout << this << ".invoke_default()\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -169,7 +169,7 @@ invoke_default(const NPVariant *args, uint32_t argCount, } delete[] p3dargs; - if (value == NULL) { + if (value == nullptr) { // No such method, or some problem with the parameters. return false; } @@ -187,7 +187,7 @@ bool PPPandaObject:: has_property(NPIdentifier name) { string property_name = identifier_to_string(name); // nout << this << ".has_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -215,14 +215,14 @@ get_property(NPIdentifier name, NPVariant *result) { string property_name = identifier_to_string(name); // nout << this << ".get_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. VOID_TO_NPVARIANT(*result); return true; } P3D_object *value = P3D_OBJECT_GET_PROPERTY(_p3d_object, property_name.c_str()); - if (value == NULL) { + if (value == nullptr) { // No such property. VOID_TO_NPVARIANT(*result); return true; @@ -242,7 +242,7 @@ bool PPPandaObject:: set_property(NPIdentifier name, const NPVariant *value) { string property_name = identifier_to_string(name); // nout << this << ".set_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -262,13 +262,13 @@ bool PPPandaObject:: remove_property(NPIdentifier name) { string property_name = identifier_to_string(name); // nout << this << ".remove_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } bool result = P3D_OBJECT_SET_PROPERTY(_p3d_object, property_name.c_str(), - true, NULL); + true, nullptr); return result; } @@ -281,7 +281,7 @@ enumerate(NPIdentifier **value, uint32_t *count) { // nout << this << ".enumerate()\n"; TODO: Not implemented yet. // Note that the array of values must be allocated here with NPN_MemAlloc(). - *value = NULL; + *value = nullptr; *count = 0; return false; } @@ -294,7 +294,7 @@ string PPPandaObject:: identifier_to_string(NPIdentifier ident) { if (browser->identifierisstring(ident)) { NPUTF8 *result = browser->utf8fromidentifier(ident); - if (result != NULL) { + if (result != nullptr) { string strval(result); browser->memfree(result); return strval; diff --git a/direct/src/plugin_npapi/ppToplevelObject.cxx b/direct/src/plugin_npapi/ppToplevelObject.cxx index a7f9c879e3..a3790d5039 100644 --- a/direct/src/plugin_npapi/ppToplevelObject.cxx +++ b/direct/src/plugin_npapi/ppToplevelObject.cxx @@ -52,7 +52,7 @@ make_new(PPInstance *inst) { */ void PPToplevelObject:: set_main(P3D_object *p3d_object) { - if (p3d_object != NULL) { + if (p3d_object != nullptr) { P3D_OBJECT_INCREF(p3d_object); } P3D_OBJECT_XDECREF(_main); @@ -67,7 +67,7 @@ set_main(P3D_object *p3d_object) { void PPToplevelObject:: construct(PPInstance *inst) { _instance = inst; - _main = NULL; + _main = nullptr; // Get our one property name as an identifier, so we can look for it. _main_id = browser->getstringidentifier("main"); @@ -78,8 +78,8 @@ construct(PPInstance *inst) { */ void PPToplevelObject:: invalidate() { - _instance = NULL; - set_main(NULL); + _instance = nullptr; + set_main(nullptr); } /** @@ -87,7 +87,7 @@ invalidate() { */ bool PPToplevelObject:: has_property(NPIdentifier name) { - if (_main == NULL) { + if (_main == nullptr) { // Not powered up yet. return false; } @@ -105,7 +105,7 @@ has_property(NPIdentifier name) { */ bool PPToplevelObject:: get_property(NPIdentifier name, NPVariant *result) { - if (_main == NULL) { + if (_main == nullptr) { // Not powered up yet. return false; } diff --git a/direct/src/plugin_npapi/startup.cxx b/direct/src/plugin_npapi/startup.cxx index 8d64c71dc7..0c6a99c258 100644 --- a/direct/src/plugin_npapi/startup.cxx +++ b/direct/src/plugin_npapi/startup.cxx @@ -127,7 +127,7 @@ NP_GetMIMEDescription(void) { */ NPError NP_GetValue(void*, NPPVariable variable, void* value) { - if (value == NULL) { + if (value == nullptr) { return NPERR_INVALID_PARAM; } @@ -175,7 +175,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, // On Unix, we have to use the pluginFuncs argument to pass our entry // points. #if !defined(_WIN32) && !defined(__APPLE__) - if (pluginFuncs != NULL) { + if (pluginFuncs != nullptr) { NP_GetEntryPoints(pluginFuncs); } #endif @@ -194,7 +194,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, #ifdef HAS_PLUGIN_THREAD_ASYNC_CALL // Check if the browser offers this very useful call. if (browser_major > 0 || browser_minor >= NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) { - if ((void *)browser->pluginthreadasynccall == (void *)NULL) { + if ((void *)browser->pluginthreadasynccall == nullptr) { nout << "Browser should have PLUGIN_THREAD_ASYNC_CALL, but the pointer is NULL.\n"; has_plugin_thread_async_call = false; } else { @@ -205,7 +205,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, // Seed the lame random number generator in rand(); we use it to select a // mirror for downloading. - srand((unsigned int)time(NULL)); + srand((unsigned int)time(nullptr)); return NPERR_NO_ERROR; } @@ -370,11 +370,11 @@ NPP_Destroy(NPP instance, NPSavedData **save) { nout << "save = " << (void *)save << "\n"; // (*save) = NULL; PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->stop_outstanding_streams(); delete inst; - instance->pdata = NULL; + instance->pdata = nullptr; return NPERR_NO_ERROR; } @@ -392,7 +392,7 @@ NPP_SetWindow(NPP instance, NPWindow *window) { << "\n"; PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->set_window(window); return NPERR_NO_ERROR; @@ -414,7 +414,7 @@ NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, << ", " << (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->new_stream(type, stream, seekable != 0, stype); } @@ -432,7 +432,7 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) { PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->destroy_stream(stream, reason); } @@ -446,7 +446,7 @@ NPP_WriteReady_x(NPP instance, NPStream *stream) { // (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->write_ready(stream); } @@ -462,7 +462,7 @@ NPP_Write_x(NPP instance, NPStream *stream, int32_t offset, // " << instance << ", " << (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->write_stream(stream, offset, len, buffer); } @@ -481,7 +481,7 @@ NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) { PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->stream_as_file(stream, fname); } @@ -504,7 +504,7 @@ NPP_HandleEvent(NPP instance, void *event) { PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->handle_event(event); } @@ -522,7 +522,7 @@ NPP_URLNotify(NPP instance, const char *url, PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->url_notify(url, reason, notifyData); } @@ -535,11 +535,11 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { nout << "GetValue " << variable << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); if (variable == NPPVpluginScriptableNPObject) { NPObject *obj = inst->get_panda_script_object(); - if (obj != NULL) { + if (obj != nullptr) { *(NPObject **)value = obj; return NPERR_NO_ERROR; } @@ -571,7 +571,7 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { return NPERR_NO_ERROR; } else { - return NP_GetValue(NULL, variable, value); + return NP_GetValue(nullptr, variable, value); } return NPERR_GENERIC_ERROR; diff --git a/direct/src/plugin_standalone/p3dEmbed.cxx b/direct/src/plugin_standalone/p3dEmbed.cxx index 87918f66f4..14903aa600 100644 --- a/direct/src/plugin_standalone/p3dEmbed.cxx +++ b/direct/src/plugin_standalone/p3dEmbed.cxx @@ -76,8 +76,8 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { string curstr; bool havenull = false; P3D_token token; - token._keyword = NULL; - token._value = NULL; + token._keyword = nullptr; + token._value = nullptr; string keyword; string value; string root_dir; diff --git a/direct/src/plugin_standalone/panda3d.cxx b/direct/src/plugin_standalone/panda3d.cxx index 10876d2e64..8710d92696 100644 --- a/direct/src/plugin_standalone/panda3d.cxx +++ b/direct/src/plugin_standalone/panda3d.cxx @@ -144,12 +144,12 @@ run_command_line(int argc, char *argv[]) { // will be delivered to the subordinate Python process and return to a // command shell, and won't just kill the panda3d process. #ifdef _WIN32 - SetConsoleCtrlHandler(NULL, true); + SetConsoleCtrlHandler(nullptr, true); #else struct sigaction ignore; memset(&ignore, 0, sizeof(ignore)); ignore.sa_handler = SIG_IGN; - sigaction(SIGINT, &ignore, NULL); + sigaction(SIGINT, &ignore, nullptr); #endif // _WIN32 } break; @@ -348,7 +348,7 @@ get_plugin() { Filename contents_filename = Filename(Filename::from_os_specific(_root_dir), "contents.xml"); if (_verify_contents != P3D_VC_force) { if (read_contents_file(contents_filename, false)) { - if (_verify_contents == P3D_VC_none || time(NULL) < _contents_expiration) { + if (_verify_contents == P3D_VC_none || time(nullptr) < _contents_expiration) { // Got the file, and it's good. success = true; } @@ -415,7 +415,7 @@ download_contents_file(const Filename &contents_filename) { // Append a uniquifying query string to the URL to force the download to // go all the way through any caches. We use the time in seconds; that's // unique enough. - strm << "?" << time(NULL); + strm << "?" << time(nullptr); string url = strm.str(); // We might as well explicitly request the cache to be disabled too, since @@ -468,19 +468,19 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { bool found_core_package = false; TiXmlElement *xcontents = doc.FirstChildElement("contents"); - if (xcontents != NULL) { + if (xcontents != nullptr) { int max_age = P3D_CONTENTS_DEFAULT_MAX_AGE; xcontents->Attribute("max_age", &max_age); // Get the latest possible expiration time, based on the max_age // indication. Any expiration time later than this is in error. - time_t now = time(NULL); + time_t now = time(nullptr); _contents_expiration = now + (time_t)max_age; if (fresh_download) { // Update the XML with the new download information. TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - while (xorig != NULL) { + while (xorig != nullptr) { xcontents->RemoveChild(xorig); xorig = xcontents->FirstChildElement("orig"); } @@ -494,7 +494,7 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { // Read the expiration time from the XML. int expiration = 0; TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - if (xorig != NULL) { + if (xorig != nullptr) { xorig->Attribute("expiration", &expiration); } @@ -508,14 +508,14 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { // Now look for the core API package. _coreapi_set_ver = ""; TiXmlElement *xpackage = xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); - if (name != NULL && strcmp(name, "coreapi") == 0) { + if (name != nullptr && strcmp(name, "coreapi") == 0) { const char *platform = xpackage->Attribute("platform"); - if (platform != NULL && _coreapi_platform == string(platform)) { + if (platform != nullptr && _coreapi_platform == string(platform)) { _coreapi_dll.load_xml(xpackage); const char *set_ver = xpackage->Attribute("set_ver"); - if (set_ver != NULL) { + if (set_ver != nullptr) { _coreapi_set_ver = set_ver; } found_core_package = true; @@ -583,9 +583,9 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { void Panda3D:: find_host(TiXmlElement *xcontents) { TiXmlElement *xhost = xcontents->FirstChildElement("host"); - if (xhost != NULL) { + if (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // We're the primary host. This is the normal case. read_xhost(xhost); return; @@ -593,9 +593,9 @@ find_host(TiXmlElement *xcontents) { } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *url = xalthost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // Yep, we're this alternate host. read_xhost(xhost); return; @@ -619,11 +619,11 @@ read_xhost(TiXmlElement *xhost) { // Get the "download" URL, which is the source from which we download // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); - if (download_url == NULL) { + if (download_url == nullptr) { download_url = xhost->Attribute("url"); } - if (download_url != NULL) { + if (download_url != nullptr) { _download_url_prefix = download_url; } else { _download_url_prefix = _host_url_prefix; @@ -635,9 +635,9 @@ read_xhost(TiXmlElement *xhost) { } TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); - while (xmirror != NULL) { + while (xmirror != nullptr) { const char *url = xmirror->Attribute("url"); - if (url != NULL) { + if (url != nullptr) { add_mirror(url); } xmirror = xmirror->NextSiblingElement("mirror"); @@ -767,7 +767,7 @@ download_core_api() { // uniquifier, to break through any caches. ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() - << "?" << time(NULL); + << "?" << time(nullptr); url = strm.str(); core_urls.push_back(url); diff --git a/direct/src/plugin_standalone/panda3dBase.cxx b/direct/src/plugin_standalone/panda3dBase.cxx index 0b3884f17c..07f86fb18a 100644 --- a/direct/src/plugin_standalone/panda3dBase.cxx +++ b/direct/src/plugin_standalone/panda3dBase.cxx @@ -74,7 +74,7 @@ Panda3DBase(bool console_environment) { // Seed the lame random number generator in rand(); we use it to select a // mirror for downloading. - srand((unsigned int)time(NULL)); + srand((unsigned int)time(nullptr)); _prepend_filename_to_args = true; } @@ -90,7 +90,7 @@ run_main_loop() { // Wait for new messages from Windows, and new requests from the plugin. MSG msg; int retval; - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); while (retval != 0 && !time_to_exit()) { if (retval == -1) { cerr << "Error processing message queue.\n"; @@ -101,20 +101,20 @@ run_main_loop() { // Check for new requests from the Panda3D plugin. P3D_instance *inst = P3D_check_request_ptr(wait_cycle); - while (inst != (P3D_instance *)NULL) { + while (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } inst = P3D_check_request_ptr(wait_cycle); } while (!_url_getters.empty() && - !PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + !PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { // If there are no Windows messages, check the download tasks. run_getters(); } - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); } // WM_QUIT has been received. Terminate all instances, and fall through. @@ -128,9 +128,9 @@ run_main_loop() { // Windows events. Instead, just wait for requests. while (!time_to_exit()) { P3D_instance *inst = P3D_check_request_ptr(wait_cycle); - if (inst != (P3D_instance *)NULL) { + if (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } } @@ -162,9 +162,9 @@ run_main_loop() { // Now wait while we process pending requests. while (!time_to_exit()) { P3D_instance *inst = P3D_check_request_ptr(wait_cycle); - if (inst != (P3D_instance *)NULL) { + if (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } } @@ -207,7 +207,7 @@ handle_request(P3D_request *request) { delete_instance(request->_instance); #ifdef _WIN32 // Post a silly message to spin the event loop. - PostMessage(NULL, WM_USER, 0, 0); + PostMessage(nullptr, WM_USER, 0, 0); #endif handled = true; break; @@ -267,7 +267,7 @@ void Panda3DBase:: make_parent_window() { WNDCLASS wc; - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); ZeroMemory(&wc, sizeof(WNDCLASS)); wc.lpfnWndProc = (WNDPROC)window_proc; wc.hInstance = application; @@ -287,7 +287,7 @@ make_parent_window() { HWND toplevel_window = CreateWindow("panda3d", "Panda3D", window_style, CW_USEDEFAULT, CW_USEDEFAULT, _win_width, _win_height, - NULL, NULL, application, 0); + nullptr, nullptr, application, 0); if (!toplevel_window) { cerr << "Could not create toplevel window!\n"; exit(1); @@ -364,7 +364,7 @@ create_instance(const string &p3d, bool start_instance, token._value = "1"; tokens.push_back(token); - P3D_token *tokens_p = NULL; + P3D_token *tokens_p = nullptr; size_t num_tokens = tokens.size(); if (!tokens.empty()) { tokens_p = &tokens[0]; @@ -379,10 +379,10 @@ create_instance(const string &p3d, bool start_instance, argv.push_back(args[i]); } - P3D_instance *inst = P3D_new_instance_ptr(NULL, tokens_p, num_tokens, - argv.size(), &argv[0], NULL); + P3D_instance *inst = P3D_new_instance_ptr(nullptr, tokens_p, num_tokens, + argv.size(), &argv[0], nullptr); - if (inst != NULL) { + if (inst != nullptr) { if (start_instance) { // We call start() first, to give the core API a chance to notice the // "hidden" attrib before we set the window parameters. @@ -443,11 +443,11 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { return false; } TiXmlElement *xpackage = doc.FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { return false; } TiXmlElement *xconfig = xpackage->FirstChildElement("config"); - if (xconfig == NULL) { + if (xconfig == nullptr) { return false; } @@ -473,7 +473,7 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { bool Panda3DBase:: parse_token(const char *arg) { const char *equals = strchr(arg, '='); - if (equals == NULL) { + if (equals == nullptr) { return false; } @@ -624,12 +624,12 @@ report_downloading_package(P3D_instance *instance) { P3D_object *obj = P3D_instance_get_panda_script_object_ptr(instance); P3D_object *display_name = P3D_object_get_property_ptr(obj, "downloadPackageDisplayName"); - if (display_name == NULL) { + if (display_name == nullptr) { cerr << "Installing package.\n"; return; } - int name_length = P3D_object_get_string_ptr(display_name, NULL, 0); + int name_length = P3D_object_get_string_ptr(display_name, nullptr, 0); char *name = new char[name_length + 1]; P3D_object_get_string_ptr(display_name, name, name_length + 1); @@ -670,9 +670,9 @@ void Panda3DBase:: timer_callback(EventLoopTimerRef timer) { // Check for new requests from the Panda3D plugin. P3D_instance *inst = P3D_check_request_ptr(0.0); - while (inst != (P3D_instance *)NULL) { + while (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } inst = P3D_check_request_ptr(0.0); @@ -758,6 +758,6 @@ run() { P3D_instance_feed_url_stream_ptr (_instance, _unique_id, status, _channel->get_status_code(), - _bytes_sent, NULL, 0); + _bytes_sent, nullptr, 0); return false; } diff --git a/direct/src/plugin_standalone/panda3dMac.cxx b/direct/src/plugin_standalone/panda3dMac.cxx index 2b7ab47e8c..06877b9af0 100644 --- a/direct/src/plugin_standalone/panda3dMac.cxx +++ b/direct/src/plugin_standalone/panda3dMac.cxx @@ -53,7 +53,7 @@ open_p3d_file(FSRef *ref) { } // Create an instance. - create_instance((char *)filename, true, NULL, 0); + create_instance((char *)filename, true, nullptr, 0); } static pascal OSErr @@ -74,7 +74,7 @@ open_documents_handler(const AppleEvent *theAppleEvent, AppleEvent *reply, for (index = 1; index <= count; index++) { err = AEGetNthPtr(&docList, index, typeFSRef, - NULL, NULL, &theFSRef, sizeof(FSRef), NULL);// 5 + nullptr, nullptr, &theFSRef, sizeof(FSRef), nullptr);// 5 require_noerr(err, CantGetDocDescPtr); // Here's the file, do something with it. diff --git a/dtool/src/cppparser/cppArrayType.cxx b/dtool/src/cppparser/cppArrayType.cxx index ce861c1d69..0226420aaf 100644 --- a/dtool/src/cppparser/cppArrayType.cxx +++ b/dtool/src/cppparser/cppArrayType.cxx @@ -85,7 +85,7 @@ is_trivial() const { */ bool CPPArrayType:: is_default_constructible() const { - return _bounds != NULL && _element_type->is_default_constructible(); + return _bounds != nullptr && _element_type->is_default_constructible(); } /** @@ -105,7 +105,7 @@ is_copy_constructible() const { bool CPPArrayType:: is_equivalent(const CPPType &other) const { const CPPArrayType *ot = ((CPPType *)&other)->as_array_type(); - if (ot == (CPPArrayType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -128,7 +128,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, _element_type->substitute_decl(subst, current_scope, global_scope) ->as_type(); - if (_bounds != NULL) { + if (_bounds != nullptr) { rep->_bounds = _bounds->substitute_decl(subst, current_scope, global_scope) ->as_expression(); @@ -171,7 +171,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, const string &name) const { ostringstream brackets; brackets << "["; - if (_bounds != NULL) { + if (_bounds != nullptr) { brackets << *_bounds; } brackets << "]"; @@ -204,13 +204,13 @@ as_array_type() { bool CPPArrayType:: is_equal(const CPPDeclaration *other) const { const CPPArrayType *ot = ((CPPDeclaration *)other)->as_array_type(); - assert(ot != NULL); + assert(ot != nullptr); - if (_bounds != NULL && ot->_bounds != NULL) { + if (_bounds != nullptr && ot->_bounds != nullptr) { if (*_bounds != *ot->_bounds) { return false; } - } else if ((_bounds == NULL) != (ot->_bounds == NULL)) { + } else if ((_bounds == nullptr) != (ot->_bounds == nullptr)) { return false; } @@ -225,13 +225,13 @@ is_equal(const CPPDeclaration *other) const { bool CPPArrayType:: is_less(const CPPDeclaration *other) const { const CPPArrayType *ot = ((CPPDeclaration *)other)->as_array_type(); - assert(ot != NULL); + assert(ot != nullptr); - if (_bounds != NULL && ot->_bounds != NULL) { + if (_bounds != nullptr && ot->_bounds != nullptr) { if (*_bounds != *ot->_bounds) { return *_bounds < *ot->_bounds; } - } else if ((_bounds == NULL) != (ot->_bounds == NULL)) { + } else if ((_bounds == nullptr) != (ot->_bounds == nullptr)) { return _bounds < ot->_bounds; } diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index 2167d06578..f1985d488e 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -110,14 +110,13 @@ static CPPEnumType *current_enum = NULL; static int current_storage_class = 0; static CPPType *current_type = NULL; static CPPExpression *current_expr = NULL; -static CPPClosureType *current_closure = NULL; static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; -static vector last_scopes; -static vector last_storage_classes; -static vector last_structs; +static std::vector last_scopes; +static std::vector last_storage_classes; +static std::vector last_structs; int yyparse(); diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 68f4f96706..d132677763 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -36,23 +36,22 @@ // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// -CPPScope *current_scope = NULL; -CPPScope *global_scope = NULL; -CPPPreprocessor *current_lexer = NULL; +CPPScope *current_scope = nullptr; +CPPScope *global_scope = nullptr; +CPPPreprocessor *current_lexer = nullptr; -static CPPStructType *current_struct = NULL; -static CPPEnumType *current_enum = NULL; +static CPPStructType *current_struct = nullptr; +static CPPEnumType *current_enum = nullptr; static int current_storage_class = 0; -static CPPType *current_type = NULL; -static CPPExpression *current_expr = NULL; -static CPPClosureType *current_closure = NULL; +static CPPType *current_type = nullptr; +static CPPExpression *current_expr = nullptr; static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; -static vector last_scopes; -static vector last_storage_classes; -static vector last_structs; +static std::vector last_scopes; +static std::vector last_storage_classes; +static std::vector last_structs; int yyparse(); @@ -119,7 +118,7 @@ parse_const_expr(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_expr = (CPPExpression *)NULL; + current_expr = nullptr; current_lexer = pp; yyparse(); @@ -143,7 +142,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_type = (CPPType *)NULL; + current_type = nullptr; current_lexer = pp; yyparse(); @@ -160,7 +159,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, static void push_scope(CPPScope *new_scope) { last_scopes.push_back(current_scope); - if (new_scope != NULL) { + if (new_scope != nullptr) { current_scope = new_scope; } } @@ -653,7 +652,7 @@ declaration: CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer); @@ -689,7 +688,7 @@ declaration: CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer); @@ -891,18 +890,18 @@ declaration: | KW_MAKE_SEQ '(' name ',' IDENTIFIER ',' IDENTIFIER ')' ';' { CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer); - if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *element_getter = $7->find_symbol(current_scope, global_scope, current_lexer); - if (element_getter == (CPPDeclaration *)NULL || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (element_getter == nullptr || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid element method: " + $7->get_fully_scoped_name(), @5); - element_getter = NULL; + element_getter = nullptr; } - if (length_getter != (CPPDeclaration *)NULL && element_getter != (CPPDeclaration *)NULL) { + if (length_getter != nullptr && element_getter != nullptr) { CPPMakeSeq *make_seq = new CPPMakeSeq($3, length_getter->as_function_group(), element_getter->as_function_group(), @@ -1071,7 +1070,7 @@ type_like_declaration: } | storage_class constructor_prototype { - if ($2 != (CPPInstance *)NULL) { + if ($2 != nullptr) { // Push the scope so that the initializers can make use of things defined // in the class body. push_scope($2->get_scope(current_scope, global_scope)); @@ -1080,7 +1079,7 @@ type_like_declaration: } maybe_initialize_or_constructor_body { - if ($2 != (CPPInstance *)NULL) { + if ($2 != nullptr) { pop_scope(); current_scope->add_declaration($2, global_scope, current_lexer, @2); $2->set_initializer($4); @@ -1088,7 +1087,7 @@ type_like_declaration: } | storage_class function_prototype maybe_initialize_or_function_body { - if ($2 != (CPPInstance *)NULL) { + if ($2 != nullptr) { $2->_storage_class |= (current_storage_class | $1); current_scope->add_declaration($2, global_scope, current_lexer, @2); $2->set_initializer($3); @@ -1145,9 +1144,9 @@ typedef_declaration: } | storage_class function_prototype maybe_initialize_or_function_body { - if ($2 != (CPPDeclaration *)NULL) { + if ($2 != nullptr) { CPPInstance *inst = $2->as_instance(); - if (inst != (CPPInstance *)NULL) { + if (inst != nullptr) { inst->_storage_class |= (current_storage_class | $1); current_scope->add_declaration(inst, global_scope, current_lexer, @2); CPPTypedefType *typedef_type = new CPPTypedefType(inst->_type, inst->_ident, current_scope); @@ -1270,10 +1269,10 @@ function_prototype: { pop_scope(); CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = $4; ii->add_modifier(IIT_pointer); @@ -1288,10 +1287,10 @@ function_prototype: { pop_scope(); CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = $5; ii->add_scoped_pointer_modifier($3); @@ -1302,13 +1301,13 @@ function_prototype: /* Typecast operators */ | KW_OPERATOR type not_paren_formal_parameter_identifier '(' { - if ($1 != NULL) { + if ($1 != nullptr) { push_scope($1->get_scope(current_scope, global_scope)); } } function_parameter_list ')' function_post { - if ($1 != NULL) { + if ($1 != nullptr) { pop_scope(); } @@ -1323,7 +1322,7 @@ function_prototype: // the method's return type to determine the full type description. string name = "operator typecast " + $2->get_simple_name(); CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier(name, @2); } else { ident->add_name(name); @@ -1333,18 +1332,18 @@ function_prototype: } | KW_OPERATOR KW_CONST type not_paren_formal_parameter_identifier '(' { - if ($1 != NULL) { + if ($1 != nullptr) { push_scope($1->get_scope(current_scope, global_scope)); } } function_parameter_list ')' function_post { - if ($1 != NULL) { + if ($1 != nullptr) { pop_scope(); } CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator typecast", @4); } else { ident->add_name("operator typecast"); @@ -1361,10 +1360,10 @@ function_prototype: { CPPDeclaration *decl = $1->find_symbol(current_scope, global_scope, current_lexer); - if (decl != (CPPDeclaration *)NULL) { + if (decl != nullptr) { $$ = decl->as_instance(); } else { - $$ = (CPPInstance *)NULL; + $$ = nullptr; } } ; @@ -1627,13 +1626,13 @@ template_nonempty_formal_parameters: template_formal_parameter { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter($1); } | template_nonempty_formal_parameters ',' template_formal_parameter { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter($3); } ; @@ -1646,7 +1645,7 @@ typename_keyword: template_formal_parameter: typename_keyword { - $$ = CPPType::new_type(new CPPClassTemplateParameter((CPPIdentifier *)NULL)); + $$ = CPPType::new_type(new CPPClassTemplateParameter(nullptr)); } | typename_keyword name { @@ -1658,7 +1657,7 @@ template_formal_parameter: } | typename_keyword ELLIPSIS { - CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((CPPIdentifier *)NULL); + CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter(nullptr); ctp->_packed = true; $$ = CPPType::new_type(ctp); } @@ -1707,18 +1706,18 @@ template_formal_parameter_type: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | TYPEPACK_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } ; @@ -1734,7 +1733,7 @@ instance_identifier: // ficticious name for the function; in other respects it's just // like a regular function. CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator "+$2, @2); } else { ident->_names.push_back("operator "+$2); @@ -1749,7 +1748,7 @@ instance_identifier: yyerror("expected empty string", @2); } CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator \"\" "+$3->get_simple_name(), @3); } else { ident->_names.push_back("operator \"\" "+$3->get_simple_name()); @@ -1833,7 +1832,7 @@ instance_identifier_and_maybe_trailing_return_type: // This is handled a bit awkwardly right now. Ideally it'd be wrapped // up in the instance_identifier rule, but then more needs to happen in // order to avoid shift/reduce conflicts. - if ($2 != NULL) { + if ($2 != nullptr) { $1->add_trailing_return_type($2); } $$ = $1; @@ -1850,7 +1849,7 @@ instance_identifier_and_maybe_trailing_return_type: maybe_trailing_return_type: empty { - $$ = NULL; + $$ = nullptr; } | POINTSAT predefined_type empty_instance_identifier { @@ -1867,7 +1866,7 @@ maybe_trailing_return_type: maybe_comma_identifier: empty { - $$ = NULL; + $$ = nullptr; } | ',' IDENTIFIER { @@ -1957,7 +1956,7 @@ formal_parameters: template_parameter_maybe_initialize: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' no_angle_bracket_const_expr { @@ -1968,7 +1967,7 @@ template_parameter_maybe_initialize: maybe_initialize: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' const_expr { @@ -1979,15 +1978,15 @@ maybe_initialize: maybe_initialize_or_constructor_body: ';' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '{' code '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | ':' constructor_inits '{' code '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' KW_DEFAULT ';' { @@ -2002,11 +2001,11 @@ maybe_initialize_or_constructor_body: maybe_initialize_or_function_body: ';' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '{' code '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' const_expr ';' { @@ -2022,7 +2021,7 @@ maybe_initialize_or_function_body: } | '=' '{' structure_init '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } ; @@ -2107,7 +2106,7 @@ formal_parameter: not_paren_formal_parameter_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | name_no_final { @@ -2153,7 +2152,7 @@ not_paren_formal_parameter_identifier: formal_parameter_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | name_no_final { @@ -2210,7 +2209,7 @@ formal_parameter_identifier: parameter_pack_identifier: ELLIPSIS { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->_packed = true; } | ELLIPSIS name @@ -2269,11 +2268,11 @@ parameter_pack_identifier: not_paren_empty_instance_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | ELLIPSIS { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->_packed = true; } | ELLIPSIS name @@ -2321,11 +2320,11 @@ not_paren_empty_instance_identifier: empty_instance_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | ELLIPSIS { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->_packed = true; } | ELLIPSIS name @@ -2370,7 +2369,7 @@ empty_instance_identifier: } | '(' function_parameter_list ')' function_post maybe_trailing_return_type { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->add_modifier(IIT_paren); $$->add_func_modifier($2, $4, $5); } @@ -2405,10 +2404,10 @@ type: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | KW_TYPENAME name { @@ -2429,14 +2428,14 @@ type: | struct_keyword struct_attributes name { CPPType *type = $3->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $3, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $3->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2445,14 +2444,14 @@ type: | enum_keyword name_no_final ':' enum_element_type { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2461,7 +2460,7 @@ type: | KW_DECLTYPE '(' const_expr ')' { $$ = $3->determine_type(); - if ($$ == (CPPType *)NULL) { + if ($$ == nullptr) { stringstream str; str << *$3; yyerror("could not determine type of " + str.str(), @3); @@ -2474,7 +2473,7 @@ type: | KW_UNDERLYING_TYPE '(' full_type ')' { CPPEnumType *enum_type = $3->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", @3); $$ = $3; } else { @@ -2491,10 +2490,10 @@ type_pack: TYPEPACK_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } ; @@ -2506,10 +2505,10 @@ type_decl: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | KW_TYPENAME name { @@ -2530,14 +2529,14 @@ type_decl: | struct_keyword struct_attributes name { CPPType *type = $3->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $3, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $3->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2546,14 +2545,14 @@ type_decl: | enum_keyword name_no_final ':' enum_element_type { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2564,14 +2563,14 @@ type_decl: yywarning(string("C++ does not permit forward declaration of untyped enum ") + $2->get_fully_scoped_name(), @1); CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2580,7 +2579,7 @@ type_decl: | KW_DECLTYPE '(' const_expr ')' { $$ = $3->determine_type(); - if ($$ == (CPPType *)NULL) { + if ($$ == nullptr) { stringstream str; str << *$3; yyerror("could not determine type of " + str.str(), @3); @@ -2593,7 +2592,7 @@ type_decl: | KW_UNDERLYING_TYPE '(' full_type ')' { CPPEnumType *enum_type = $3->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", @3); $$ = $3; } else { @@ -2614,10 +2613,10 @@ predefined_type: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | KW_TYPENAME name { @@ -2626,14 +2625,14 @@ predefined_type: | struct_keyword struct_attributes name { CPPType *type = $3->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $3, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $3->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2642,14 +2641,14 @@ predefined_type: | enum_keyword name { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2658,7 +2657,7 @@ predefined_type: | KW_DECLTYPE '(' const_expr ')' { $$ = $3->determine_type(); - if ($$ == (CPPType *)NULL) { + if ($$ == nullptr) { stringstream str; str << *$3; yyerror("could not determine type of " + str.str(), @3); @@ -2667,7 +2666,7 @@ predefined_type: | KW_UNDERLYING_TYPE '(' full_type ')' { CPPEnumType *enum_type = $3->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", @3); $$ = $3; } else { @@ -2728,7 +2727,7 @@ anonymous_struct: CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("anon"), starting_vis); - CPPStructType *st = new CPPStructType($1, NULL, current_scope, + CPPStructType *st = new CPPStructType($1, nullptr, current_scope, new_scope, @1.file); new_scope->set_struct_type(st); @@ -2751,7 +2750,7 @@ named_struct: ($1 == CPPExtensionType::T_class) ? V_private : V_public; CPPScope *scope = $3->get_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { scope = current_scope; } CPPScope *new_scope = new CPPScope(scope, $3->_names.back(), @@ -2839,18 +2838,18 @@ enum: enum_decl '{' enum_body '}' { $$ = current_enum; - current_enum = NULL; + current_enum = nullptr; } ; enum_decl: enum_keyword ':' enum_element_type { - current_enum = new CPPEnumType($1, NULL, $3, current_scope, NULL, @1.file); + current_enum = new CPPEnumType($1, nullptr, $3, current_scope, nullptr, @1.file); } | enum_keyword { - current_enum = new CPPEnumType($1, NULL, current_scope, NULL, @1.file); + current_enum = new CPPEnumType($1, nullptr, current_scope, nullptr, @1.file); } | enum_keyword name_no_final ':' enum_element_type { @@ -2879,12 +2878,12 @@ enum_body_trailing_comma: empty | enum_body_trailing_comma name ',' { - assert(current_enum != NULL); - current_enum->add_element($2->get_simple_name(), NULL, current_lexer, @2); + assert(current_enum != nullptr); + current_enum->add_element($2->get_simple_name(), nullptr, current_lexer, @2); } | enum_body_trailing_comma name '=' const_expr ',' { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element($2->get_simple_name(), $4, current_lexer, @2); }; @@ -2892,12 +2891,12 @@ enum_body: enum_body_trailing_comma | enum_body_trailing_comma name { - assert(current_enum != NULL); - current_enum->add_element($2->get_simple_name(), NULL, current_lexer, @2); + assert(current_enum != nullptr); + current_enum->add_element($2->get_simple_name(), nullptr, current_lexer, @2); } | enum_body_trailing_comma name '=' const_expr { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element($2->get_simple_name(), $4, current_lexer, @2); } ; @@ -2936,11 +2935,11 @@ namespace_declaration: KW_NAMESPACE name '{' { CPPScope *scope = $2->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = $2->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, $2->_names.back(), V_public); @@ -2958,11 +2957,11 @@ namespace_declaration: | KW_INLINE KW_NAMESPACE name '{' { CPPScope *scope = $3->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = $3->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, $3->_names.back(), V_public); @@ -3166,7 +3165,7 @@ element: optional_const_expr: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | const_expr { @@ -3177,7 +3176,7 @@ optional_const_expr: optional_const_expr_comma: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | const_expr_comma { @@ -3228,7 +3227,7 @@ no_angle_bracket_const_expr: | KW_SIZEOF '(' IDENTIFIER ')' %prec UNARY { CPPDeclaration *arg = $3->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + $3->get_fully_scoped_name(), @3); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -3393,20 +3392,20 @@ const_expr: { // A constructor call. CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); $$ = new CPPExpression(CPPExpression::construct_op(type, $3)); } | TYPENAME_IDENTIFIER '{' optional_const_expr_comma '}' { // Aggregate initialization. CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); $$ = new CPPExpression(CPPExpression::aggregate_init_op(type, $3)); } | KW_INT '(' optional_const_expr_comma ')' @@ -3492,7 +3491,7 @@ const_expr: | KW_SIZEOF '(' IDENTIFIER ')' %prec UNARY { CPPDeclaration *arg = $3->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + $3->get_fully_scoped_name(), @3); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -3836,7 +3835,7 @@ formal_const_expr: | KW_SIZEOF '(' IDENTIFIER ')' %prec UNARY { CPPDeclaration *arg = $3->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + $3->get_fully_scoped_name(), @3); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -4124,7 +4123,7 @@ class_derivation_name: name { CPPType *type = $1->find_type(current_scope, global_scope, true); - if (type == NULL) { + if (type == nullptr) { type = CPPType::new_type(new CPPTBDType($1)); } $$ = type; diff --git a/dtool/src/cppparser/cppClassTemplateParameter.cxx b/dtool/src/cppparser/cppClassTemplateParameter.cxx index 7ed9a94faf..46fb525b8b 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.cxx +++ b/dtool/src/cppparser/cppClassTemplateParameter.cxx @@ -46,7 +46,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_packed) { out << "..."; } - if (_ident != NULL) { + if (_ident != nullptr) { out << " "; _ident->output(out, scope); } @@ -83,7 +83,7 @@ as_class_template_parameter() { bool CPPClassTemplateParameter:: is_equal(const CPPDeclaration *other) const { const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter(); - assert(ot != NULL); + assert(ot != nullptr); if (_default_type != ot->_default_type) { return false; @@ -93,7 +93,7 @@ is_equal(const CPPDeclaration *other) const { return false; } - if (_ident == NULL || ot->_ident == NULL) { + if (_ident == nullptr || ot->_ident == nullptr) { return _ident == ot->_ident; } @@ -108,7 +108,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPClassTemplateParameter:: is_less(const CPPDeclaration *other) const { const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter(); - assert(ot != NULL); + assert(ot != nullptr); if (_default_type != ot->_default_type) { return _default_type < ot->_default_type; @@ -118,7 +118,7 @@ is_less(const CPPDeclaration *other) const { return _packed < ot->_packed; } - if (_ident == NULL || ot->_ident == NULL) { + if (_ident == nullptr || ot->_ident == nullptr) { return _ident < ot->_ident; } diff --git a/dtool/src/cppparser/cppClassTemplateParameter.h b/dtool/src/cppparser/cppClassTemplateParameter.h index d936ca01ea..5192619ed2 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.h +++ b/dtool/src/cppparser/cppClassTemplateParameter.h @@ -26,7 +26,7 @@ class CPPIdentifier; class CPPClassTemplateParameter : public CPPType { public: CPPClassTemplateParameter(CPPIdentifier *ident, - CPPType *default_type = NULL); + CPPType *default_type = nullptr); virtual bool is_fully_specified() const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppClosureType.cxx b/dtool/src/cppparser/cppClosureType.cxx index 30197057a6..974742e5df 100644 --- a/dtool/src/cppparser/cppClosureType.cxx +++ b/dtool/src/cppparser/cppClosureType.cxx @@ -20,7 +20,7 @@ */ CPPClosureType:: CPPClosureType(CaptureType default_capture) : - CPPFunctionType(NULL, NULL, 0), + CPPFunctionType(nullptr, nullptr, 0), _default_capture(default_capture) { } @@ -134,7 +134,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } out << capture._name; - if (capture._initializer != NULL) { + if (capture._initializer != nullptr) { out << " = " << *capture._initializer; } @@ -142,7 +142,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } out.put(']'); - if (_parameters != NULL) { + if (_parameters != nullptr) { out.put('('); _parameters->output(out, scope, true, -1); out.put(')'); @@ -152,7 +152,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << " noexcept"; } - if (_return_type != NULL) { + if (_return_type != nullptr) { out << " -> "; _return_type->output(out, indent_level, scope, false); } diff --git a/dtool/src/cppparser/cppClosureType.h b/dtool/src/cppparser/cppClosureType.h index 9c3533ad4a..96ac38ed17 100644 --- a/dtool/src/cppparser/cppClosureType.h +++ b/dtool/src/cppparser/cppClosureType.h @@ -39,12 +39,12 @@ public: CaptureType _type; CPPExpression *_initializer; }; - typedef vector Captures; + typedef std::vector Captures; Captures _captures; CaptureType _default_capture; - void add_capture(string name, CaptureType type, CPPExpression *initializer = NULL); + void add_capture(string name, CaptureType type, CPPExpression *initializer = nullptr); virtual bool is_fully_specified() const; diff --git a/dtool/src/cppparser/cppCommentBlock.h b/dtool/src/cppparser/cppCommentBlock.h index d3e8ef0a02..614012ce61 100644 --- a/dtool/src/cppparser/cppCommentBlock.h +++ b/dtool/src/cppparser/cppCommentBlock.h @@ -36,6 +36,6 @@ public: string _comment; }; -typedef list CPPComments; +typedef std::list CPPComments; #endif diff --git a/dtool/src/cppparser/cppConstType.cxx b/dtool/src/cppparser/cppConstType.cxx index f1851b5233..f7eb198782 100644 --- a/dtool/src/cppparser/cppConstType.cxx +++ b/dtool/src/cppparser/cppConstType.cxx @@ -160,7 +160,7 @@ is_convertible_to(const CPPType *other) const { bool CPPConstType:: is_equivalent(const CPPType &other) const { const CPPConstType *ot = ((CPPType *)&other)->as_const_type(); - if (ot == (CPPConstType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -213,7 +213,7 @@ as_const_type() { bool CPPConstType:: is_equal(const CPPDeclaration *other) const { const CPPConstType *ot = ((CPPDeclaration *)other)->as_const_type(); - assert(ot != NULL); + assert(ot != nullptr); return _wrapped_around == ot->_wrapped_around; } @@ -226,7 +226,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPConstType:: is_less(const CPPDeclaration *other) const { const CPPConstType *ot = ((CPPDeclaration *)other)->as_const_type(); - assert(ot != NULL); + assert(ot != nullptr); return _wrapped_around < ot->_wrapped_around; } diff --git a/dtool/src/cppparser/cppDeclaration.cxx b/dtool/src/cppparser/cppDeclaration.cxx index 3d2e5e68f5..444801ceea 100644 --- a/dtool/src/cppparser/cppDeclaration.cxx +++ b/dtool/src/cppparser/cppDeclaration.cxx @@ -22,8 +22,8 @@ CPPDeclaration(const CPPFile &file) : _file(file) { _vis = V_unknown; - _template_scope = NULL; - _leading_comment = (CPPCommentBlock *)NULL; + _template_scope = nullptr; + _leading_comment = nullptr; } /** @@ -86,7 +86,7 @@ operator < (const CPPDeclaration &other) const { */ bool CPPDeclaration:: is_template() const { - return _template_scope != NULL; + return _template_scope != nullptr; } /** @@ -116,7 +116,7 @@ CPPDeclaration *CPPDeclaration:: instantiate(const CPPTemplateParameterList *, CPPScope *, CPPScope *, CPPPreprocessor *error_sink) const { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters"); } return (CPPDeclaration *)this; @@ -129,7 +129,7 @@ CPPDeclaration *CPPDeclaration:: substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) { SubstDecl::const_iterator si = subst.find(this); if (si != subst.end()) { - assert((*si).second != NULL); + assert((*si).second != nullptr); return (*si).second; } return this; @@ -140,7 +140,7 @@ substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) { */ CPPInstance *CPPDeclaration:: as_instance() { - return (CPPInstance *)NULL; + return nullptr; } /** @@ -148,7 +148,7 @@ as_instance() { */ CPPClassTemplateParameter *CPPDeclaration:: as_class_template_parameter() { - return (CPPClassTemplateParameter *)NULL; + return nullptr; } /** @@ -156,7 +156,7 @@ as_class_template_parameter() { */ CPPTypedefType *CPPDeclaration:: as_typedef_type() { - return (CPPTypedefType *)NULL; + return nullptr; } /** @@ -164,7 +164,7 @@ as_typedef_type() { */ CPPTypeDeclaration *CPPDeclaration:: as_type_declaration() { - return (CPPTypeDeclaration *)NULL; + return nullptr; } /** @@ -172,7 +172,7 @@ as_type_declaration() { */ CPPExpression *CPPDeclaration:: as_expression() { - return (CPPExpression *)NULL; + return nullptr; } /** @@ -180,7 +180,7 @@ as_expression() { */ CPPType *CPPDeclaration:: as_type() { - return (CPPType *)NULL; + return nullptr; } /** @@ -188,7 +188,7 @@ as_type() { */ CPPNamespace *CPPDeclaration:: as_namespace() { - return (CPPNamespace *)NULL; + return nullptr; } /** @@ -196,7 +196,7 @@ as_namespace() { */ CPPUsing *CPPDeclaration:: as_using() { - return (CPPUsing *)NULL; + return nullptr; } /** @@ -204,7 +204,7 @@ as_using() { */ CPPSimpleType *CPPDeclaration:: as_simple_type() { - return (CPPSimpleType *)NULL; + return nullptr; } /** @@ -212,7 +212,7 @@ as_simple_type() { */ CPPPointerType *CPPDeclaration:: as_pointer_type() { - return (CPPPointerType *)NULL; + return nullptr; } /** @@ -220,7 +220,7 @@ as_pointer_type() { */ CPPReferenceType *CPPDeclaration:: as_reference_type() { - return (CPPReferenceType *)NULL; + return nullptr; } /** @@ -228,7 +228,7 @@ as_reference_type() { */ CPPArrayType *CPPDeclaration:: as_array_type() { - return (CPPArrayType *)NULL; + return nullptr; } /** @@ -236,7 +236,7 @@ as_array_type() { */ CPPConstType *CPPDeclaration:: as_const_type() { - return (CPPConstType *)NULL; + return nullptr; } /** @@ -244,7 +244,7 @@ as_const_type() { */ CPPFunctionType *CPPDeclaration:: as_function_type() { - return (CPPFunctionType *)NULL; + return nullptr; } /** @@ -252,7 +252,7 @@ as_function_type() { */ CPPFunctionGroup *CPPDeclaration:: as_function_group() { - return (CPPFunctionGroup *)NULL; + return nullptr; } /** @@ -260,7 +260,7 @@ as_function_group() { */ CPPExtensionType *CPPDeclaration:: as_extension_type() { - return (CPPExtensionType *)NULL; + return nullptr; } /** @@ -268,7 +268,7 @@ as_extension_type() { */ CPPStructType *CPPDeclaration:: as_struct_type() { - return (CPPStructType *)NULL; + return nullptr; } /** @@ -276,7 +276,7 @@ as_struct_type() { */ CPPEnumType *CPPDeclaration:: as_enum_type() { - return (CPPEnumType *)NULL; + return nullptr; } /** @@ -284,7 +284,7 @@ as_enum_type() { */ CPPTBDType *CPPDeclaration:: as_tbd_type() { - return (CPPTBDType *)NULL; + return nullptr; } /** @@ -292,7 +292,7 @@ as_tbd_type() { */ CPPTypeProxy *CPPDeclaration:: as_type_proxy() { - return (CPPTypeProxy *)NULL; + return nullptr; } /** @@ -300,7 +300,7 @@ as_type_proxy() { */ CPPMakeProperty *CPPDeclaration:: as_make_property() { - return (CPPMakeProperty *)NULL; + return nullptr; } /** @@ -308,7 +308,7 @@ as_make_property() { */ CPPMakeSeq *CPPDeclaration:: as_make_seq() { - return (CPPMakeSeq *)NULL; + return nullptr; } /** @@ -316,7 +316,7 @@ as_make_seq() { */ CPPClosureType *CPPDeclaration:: as_closure_type() { - return (CPPClosureType *)NULL; + return nullptr; } /** @@ -343,13 +343,13 @@ operator << (ostream &out, const CPPDeclaration::SubstDecl &subst) { CPPDeclaration::SubstDecl::const_iterator it; for (it = subst.begin(); it != subst.end(); ++it) { out << " "; - if (it->first == NULL) { + if (it->first == nullptr) { out << "(null)"; } else { out << *(it->first); } out << " -> "; - if (it->second == NULL) { + if (it->second == nullptr) { out << "(null)"; } else { out << *(it->second); diff --git a/dtool/src/cppparser/cppDeclaration.h b/dtool/src/cppparser/cppDeclaration.h index 8acaf6e50c..f590f435fa 100644 --- a/dtool/src/cppparser/cppDeclaration.h +++ b/dtool/src/cppparser/cppDeclaration.h @@ -105,7 +105,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; typedef map SubstDecl; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, @@ -226,7 +226,7 @@ protected: inline ostream & operator << (ostream &out, const CPPDeclaration &decl) { - decl.output(out, 0, (CPPScope *)NULL, false); + decl.output(out, 0, nullptr, false); return out; } diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index fbc3a7df53..ffbce64a7d 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -29,12 +29,12 @@ CPPEnumType(Type type, CPPIdentifier *ident, CPPScope *current_scope, CPPScope *scope, const CPPFile &file) : CPPExtensionType(type, ident, current_scope, file), _scope(scope), - _element_type(NULL), - _last_value(NULL) + _element_type(nullptr), + _last_value(nullptr) { _parent_scope = (type == T_enum) ? current_scope : scope; - if (ident != NULL) { + if (ident != nullptr) { ident->_native_scope = current_scope; } } @@ -48,10 +48,10 @@ CPPEnumType(Type type, CPPIdentifier *ident, CPPType *element_type, CPPExtensionType(type, ident, current_scope, file), _scope(scope), _element_type(element_type), - _last_value(NULL) + _last_value(nullptr) { _parent_scope = (type == T_enum) ? current_scope : scope; - if (ident != NULL) { + if (ident != nullptr) { ident->_native_scope = current_scope; } } @@ -69,11 +69,11 @@ is_scoped() const { */ CPPType *CPPEnumType:: get_underlying_type() { - if (_element_type == NULL) { + if (_element_type == nullptr) { // This enum is untyped. Use a suitable default, ie. 'int'. In the // future, we might want to check whether it fits in an int. - static CPPType *default_element_type = NULL; - if (default_element_type == NULL) { + static CPPType *default_element_type = nullptr; + if (default_element_type == nullptr) { default_element_type = CPPType::new_type(new CPPConstType(new CPPSimpleType(CPPSimpleType::T_int, 0))); } @@ -104,8 +104,8 @@ add_element(const string &name, CPPExpression *value, CPPPreprocessor *preproces inst->_storage_class |= CPPInstance::SC_constexpr; _elements.push_back(inst); - if (value == (CPPExpression *)NULL) { - if (_last_value == (CPPExpression *)NULL) { + if (value == nullptr) { + if (_last_value == nullptr) { // This is the first value, and should therefore be 0. static CPPExpression *const zero = new CPPExpression(0); value = zero; @@ -123,17 +123,17 @@ add_element(const string &name, CPPExpression *value, CPPPreprocessor *preproces inst->_initializer = value; _last_value = value; - if (preprocessor != (CPPPreprocessor *)NULL) { + if (preprocessor != nullptr) { // Same-line comment? CPPCommentBlock *comment = preprocessor->get_comment_on(pos.first_line, pos.file); - if (comment == (CPPCommentBlock *)NULL) { + if (comment == nullptr) { // Nope. Check for a comment before this line. comment = preprocessor->get_comment_before(pos.first_line, pos.file); - if (comment != NULL) { + if (comment != nullptr) { // This is a bit of a hack, but it prevents us from picking up a same- // line comment from the previous line. if (comment->_line_number != pos.first_line - 1 || @@ -148,12 +148,12 @@ add_element(const string &name, CPPExpression *value, CPPPreprocessor *preproces } // Add the value to the enum scope (as per C++11), assuming it's not anonymous. - if (_scope != NULL) { + if (_scope != nullptr) { _scope->add_enum_value(inst); } // Now add it to the containing scope as well if it's not an "enum class". - if (!is_scoped() && _parent_scope != NULL) { + if (!is_scoped() && _parent_scope != nullptr) { _parent_scope->add_enum_value(inst); } @@ -179,11 +179,11 @@ is_fully_specified() const { return false; } - if (_ident != NULL && !_ident->is_fully_specified()) { + if (_ident != nullptr && !_ident->is_fully_specified()) { return false; } - if (_element_type != NULL && !_element_type->is_fully_specified()) { + if (_element_type != nullptr && !_element_type->is_fully_specified()) { return false; } @@ -210,12 +210,12 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPEnumType *rep = new CPPEnumType(*this); - if (_ident != NULL) { + if (_ident != nullptr) { rep->_ident = _ident->substitute_decl(subst, current_scope, global_scope); } - if (_element_type != NULL) { + if (_element_type != nullptr) { rep->_element_type = _element_type->substitute_decl(subst, current_scope, global_scope) ->as_type(); @@ -263,7 +263,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ void CPPEnumType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (!complete && _ident != NULL) { + if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { out << _type << " "; @@ -272,10 +272,10 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } else { out << _type; - if (_ident != NULL) { + if (_ident != nullptr) { out << " " << _ident->get_local_name(scope); } - if (_element_type != NULL) { + if (_element_type != nullptr) { out << " : " << _element_type->get_local_name(scope); } @@ -283,7 +283,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { Elements::const_iterator ei; for (ei = _elements.begin(); ei != _elements.end(); ++ei) { indent(out, indent_level + 2) << (*ei)->get_local_name(); - if ((*ei)->_initializer != NULL) { + if ((*ei)->_initializer != nullptr) { out << " = " << *(*ei)->_initializer; } out << ",\n"; diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index 139ac72d1b..ed36275af9 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -131,7 +131,7 @@ as_pointer() const { default: cerr << "Invalid type\n"; assert(false); - return (void *)NULL; + return nullptr; } } @@ -148,7 +148,7 @@ as_boolean() const { return (_u._real != 0.0); case RT_pointer: - return (_u._pointer != NULL); + return (_u._pointer != nullptr); default: cerr << "Invalid type\n"; @@ -250,15 +250,15 @@ CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, CPPDeclaration *decl = ident->find_symbol(current_scope, global_scope); - if (decl != NULL) { + if (decl != nullptr) { CPPInstance *inst = decl->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { _type = T_variable; _u._variable = inst; return; } CPPFunctionGroup *fgroup = decl->as_function_group(); - if (fgroup != NULL) { + if (fgroup != nullptr) { _type = T_function; _u._fgroup = fgroup; return; @@ -280,8 +280,8 @@ CPPExpression(int unary_operator, CPPExpression *op1) : _type = T_unary_operation; _u._op._operator = unary_operator; _u._op._op1 = op1; - _u._op._op2 = NULL; - _u._op._op3 = NULL; + _u._op._op2 = nullptr; + _u._op._op3 = nullptr; } /** @@ -295,7 +295,7 @@ CPPExpression(int binary_operator, CPPExpression *op1, CPPExpression *op2) : _u._op._operator = binary_operator; _u._op._op1 = op1; _u._op._op2 = op2; - _u._op._op3 = NULL; + _u._op._op3 = nullptr; } /** @@ -332,11 +332,11 @@ typecast_op(CPPType *type, CPPExpression *op1, Type cast_type) { CPPExpression CPPExpression:: construct_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); - if (op1 == NULL) { + if (op1 == nullptr) { // A default constructor call--no parameters. expr._type = T_default_construct; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; } else { // A normal constructor call, with parameters. expr._type = T_construct; @@ -352,7 +352,7 @@ construct_op(CPPType *type, CPPExpression *op1) { CPPExpression CPPExpression:: aggregate_init_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); - if (op1 == NULL) { + if (op1 == nullptr) { expr._type = T_empty_aggregate_init; } else { expr._type = T_aggregate_init; @@ -368,11 +368,11 @@ aggregate_init_op(CPPType *type, CPPExpression *op1) { CPPExpression CPPExpression:: new_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); - if (op1 == NULL) { + if (op1 == nullptr) { // A default new operation--no parameters. expr._type = T_default_new; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; } else { // A normal new operation, with parameters. expr._type = T_new; @@ -427,7 +427,7 @@ sizeof_func(CPPType *type) { CPPExpression expr(0); expr._type = T_sizeof; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; return expr; } @@ -450,7 +450,7 @@ alignof_func(CPPType *type) { CPPExpression expr(0); expr._type = T_alignof; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; return expr; } @@ -509,7 +509,7 @@ raw_literal(const string &raw, CPPInstance *lit_op) { CPPExpression expr(0); expr._type = T_raw_literal; expr._str = raw; - expr._u._literal._value = (CPPExpression *)NULL; + expr._u._literal._value = nullptr; expr._u._literal._operator = lit_op; return expr; } @@ -553,7 +553,7 @@ evaluate() const { switch (_type) { case T_nullptr: - return Result((void *)0); + return Result(nullptr); case T_boolean: return Result((int)_u._boolean); @@ -572,15 +572,15 @@ evaluate() const { return Result(); case T_variable: - if (_u._variable->_type != NULL && - _u._variable->_initializer != NULL) { + if (_u._variable->_type != nullptr && + _u._variable->_initializer != nullptr) { // A constexpr variable, which is treated as const. if (_u._variable->_storage_class & CPPInstance::SC_constexpr) { return _u._variable->_initializer->evaluate(); } // A const variable. Fetch its assigned value. CPPConstType *const_type = _u._variable->_type->as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return _u._variable->_initializer->evaluate(); } } @@ -597,11 +597,11 @@ evaluate() const { case T_dynamic_cast: case T_const_cast: case T_reinterpret_cast: - assert(_u._typecast._op1 != NULL); + assert(_u._typecast._op1 != nullptr); r1 = _u._typecast._op1->evaluate(); if (r1._type != RT_error) { CPPSimpleType *stype = _u._typecast._to->as_simple_type(); - if (stype != NULL) { + if (stype != nullptr) { if (stype->_type == CPPSimpleType::T_bool) { return Result(r1.as_boolean()); @@ -630,18 +630,18 @@ evaluate() const { return Result(); case T_alignof: - if (_u._typecast._to != NULL) { + if (_u._typecast._to != nullptr) { // Check if the type is defined with an alignas. TODO: this should // probably be moved to a virtual getter on CPPType. CPPExtensionType *etype = _u._typecast._to->as_extension_type(); - if (etype != NULL && etype->_alignment != NULL) { + if (etype != nullptr && etype->_alignment != nullptr) { return etype->_alignment->evaluate(); } } return Result(); case T_binary_operation: - assert(_u._op._op2 != NULL); + assert(_u._op._op2 != nullptr); r2 = _u._op._op2->evaluate(); // The operators && and || are special cases: these are shirt-circuiting @@ -666,7 +666,7 @@ evaluate() const { // Fall through case T_unary_operation: - assert(_u._op._op1 != NULL); + assert(_u._op._op1 != nullptr); r1 = _u._op._op1->evaluate(); if (r1._type == RT_error) { // Here's one more special case: if the first operand is invalid, it @@ -854,39 +854,39 @@ evaluate() const { case KW_HAS_VIRTUAL_DESTRUCTOR: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->has_virtual_destructor()); + return Result(struct_type != nullptr && struct_type->has_virtual_destructor()); } case KW_IS_ABSTRACT: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_abstract()); + return Result(struct_type != nullptr && struct_type->is_abstract()); } case KW_IS_BASE_OF: { CPPStructType *struct_type1 = _u._type_trait._type->as_struct_type(); CPPStructType *struct_type2 = _u._type_trait._arg->as_struct_type(); - return Result(struct_type1 != NULL && struct_type2 != NULL && struct_type1->is_base_of(struct_type2)); + return Result(struct_type1 != nullptr && struct_type2 != nullptr && struct_type1->is_base_of(struct_type2)); } case KW_IS_CLASS: { CPPExtensionType *ext_type = _u._type_trait._type->as_extension_type(); - return Result(ext_type != NULL && ( + return Result(ext_type != nullptr && ( ext_type->_type == CPPExtensionType::T_class || ext_type->_type == CPPExtensionType::T_struct)); } case KW_IS_CONSTRUCTIBLE: - if (_u._type_trait._arg == NULL) { + if (_u._type_trait._arg == nullptr) { return Result(_u._type_trait._type->is_default_constructible()); } else { return Result(_u._type_trait._type->is_constructible(_u._type_trait._arg)); } case KW_IS_CONVERTIBLE_TO: - assert(_u._type_trait._arg != NULL); + assert(_u._type_trait._arg != nullptr); return Result(_u._type_trait._type->is_convertible_to(_u._type_trait._arg)); case KW_IS_DESTRUCTIBLE: @@ -895,7 +895,7 @@ evaluate() const { case KW_IS_EMPTY: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_empty()); + return Result(struct_type != nullptr && struct_type->is_empty()); } case KW_IS_ENUM: @@ -904,7 +904,7 @@ evaluate() const { case KW_IS_FINAL: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_final()); + return Result(struct_type != nullptr && struct_type->is_final()); } case KW_IS_FUNDAMENTAL: @@ -917,7 +917,7 @@ evaluate() const { case KW_IS_POLYMORPHIC: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_polymorphic()); + return Result(struct_type != nullptr && struct_type->is_polymorphic()); } case KW_IS_STANDARD_LAYOUT: @@ -929,7 +929,7 @@ evaluate() const { case KW_IS_UNION: { CPPExtensionType *ext_type = _u._type_trait._type->as_extension_type(); - return Result(ext_type != NULL && + return Result(ext_type != nullptr && ext_type->_type == CPPExtensionType::T_union); } @@ -952,8 +952,8 @@ evaluate() const { */ CPPType *CPPExpression:: determine_type() const { - CPPType *t1 = (CPPType *)NULL; - CPPType *t2 = (CPPType *)NULL; + CPPType *t1 = nullptr; + CPPType *t2 = nullptr; static CPPType *nullptr_type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_nullptr)); @@ -1028,16 +1028,16 @@ determine_type() const { return _u._variable->_type; case T_function: - if (_u._fgroup->get_return_type() == (CPPType *)NULL) { + if (_u._fgroup->get_return_type() == nullptr) { // There are multiple functions by this name that have different return // types. We could attempt to differentiate them based on the parameter // list, but that's a lot of work. Let's just give up. - return (CPPType *)NULL; + return nullptr; } return _u._fgroup->_instances.front()->_type; case T_unknown_ident: - return (CPPType *)NULL; + return nullptr; case T_typecast: case T_static_cast: @@ -1064,12 +1064,12 @@ determine_type() const { case T_binary_operation: case T_trinary_operation: - assert(_u._op._op2 != NULL); + assert(_u._op._op2 != nullptr); t2 = _u._op._op2->determine_type(); // Fall through case T_unary_operation: - assert(_u._op._op1 != NULL); + assert(_u._op._op1 != nullptr); t1 = _u._op._op1->determine_type(); switch (_u._op._operator) { @@ -1081,7 +1081,7 @@ determine_type() const { case UNARY_MINUS: case UNARY_PLUS: - if (t1 != NULL) { + if (t1 != nullptr) { switch (t1->get_subtype()) { case CPPDeclaration::ST_array: // Decay into pointer. @@ -1107,11 +1107,11 @@ determine_type() const { return t1; } } - return NULL; + return nullptr; case UNARY_STAR: case '[': // Array element reference - if (t1 != NULL) { + if (t1 != nullptr) { if (t1->as_pointer_type()) { return t1->as_pointer_type()->_pointing_at; } @@ -1119,7 +1119,7 @@ determine_type() const { return t1->as_array_type()->_element_type; } } - return NULL; + return nullptr; case UNARY_REF: return t1; @@ -1128,9 +1128,9 @@ determine_type() const { case '/': case '+': case '-': - if (t1 == NULL) { + if (t1 == nullptr) { return t2; - } else if (t2 == NULL) { + } else if (t2 == nullptr) { return t1; } else if (t1->as_pointer_type()) { if (t2->as_pointer_type()) { @@ -1162,25 +1162,25 @@ determine_type() const { case '.': case POINTSAT: - return NULL; + return nullptr; case 'f': // Function evaluation - if (t1 != NULL) { + if (t1 != nullptr) { // Easy case, function with only a single overload. CPPFunctionType *ftype = t1->as_function_type(); - if (ftype != (CPPFunctionType *)NULL) { + if (ftype != nullptr) { return ftype->_return_type; } } else if (_u._op._op1->_type == T_function) { CPPFunctionGroup *fgroup = _u._op._op1->_u._fgroup; - if (_u._op._op2 == NULL) { + if (_u._op._op2 == nullptr) { // If we are passing no args, look for an overload that has takes no // args. for (auto it = fgroup->_instances.begin(); it != fgroup->_instances.end(); ++it) { CPPInstance *inst = *it; - if (inst != NULL && inst->_type != NULL) { + if (inst != nullptr && inst->_type != nullptr) { CPPFunctionType *type = inst->_type->as_function_type(); - if (type != NULL && type->accepts_num_parameters(0)) { + if (type != nullptr && type->accepts_num_parameters(0)) { return type->_return_type; } } @@ -1189,7 +1189,7 @@ determine_type() const { //TODO } } - return NULL; + return nullptr; case ',': return t2; @@ -1201,15 +1201,15 @@ determine_type() const { case T_literal: case T_raw_literal: - if (_u._literal._operator != NULL) { + if (_u._literal._operator != nullptr) { CPPType *type = _u._literal._operator->_type; CPPFunctionType *ftype = type->as_function_type(); - if (ftype != (CPPFunctionType *)NULL) { + if (ftype != nullptr) { return ftype->_return_type; } } - return NULL; + return nullptr; case T_typeid_type: case T_typeid_expr: @@ -1226,7 +1226,7 @@ determine_type() const { abort(); } - return NULL; // Compiler kludge; can't get here. + return nullptr; // Compiler kludge; can't get here. } /** @@ -1361,9 +1361,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, // See if we can define it now. decl = rep->_u._ident->find_symbol(current_scope, global_scope, subst); - if (decl != NULL) { + if (decl != nullptr) { CPPInstance *inst = decl->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { rep->_type = T_variable; rep->_u._variable = inst; any_changed = true; @@ -1384,7 +1384,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, break; } CPPFunctionGroup *fgroup = decl->as_function_group(); - if (fgroup != NULL) { + if (fgroup != nullptr) { rep->_type = T_function; rep->_u._fgroup = fgroup; any_changed = true; @@ -1481,13 +1481,13 @@ bool CPPExpression:: is_tbd() const { switch (_type) { case T_variable: - if (_u._variable->_type != NULL && - _u._variable->_initializer != NULL) { + if (_u._variable->_type != nullptr && + _u._variable->_initializer != nullptr) { if (_u._variable->_storage_class & CPPInstance::SC_constexpr) { return false; } CPPConstType *const_type = _u._variable->_type->as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return false; } } @@ -1643,13 +1643,13 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { // We can just refer to the variable by name, except if it's a private // constant, in which case we have to compute the value, since we may have // to use it in generated code. - if (_u._variable->_type != NULL && - _u._variable->_initializer != NULL && + if (_u._variable->_type != nullptr && + _u._variable->_initializer != nullptr && _u._variable->_vis > V_public) { // A constexpr or const variable. Fetch its assigned value. CPPConstType *const_type = _u._variable->_type->as_const_type(); if ((_u._variable->_storage_class & CPPInstance::SC_constexpr) != 0 || - const_type != NULL) { + const_type != nullptr) { _u._variable->_initializer->output(out, indent_level, scope, false); break; } @@ -1659,7 +1659,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { case T_function: // Pick any instance; they all have the same name anyway. - if (!_u._fgroup->_instances.empty() && _u._fgroup->_instances[0]->_ident != NULL) { + if (!_u._fgroup->_instances.empty() && _u._fgroup->_instances[0]->_ident != nullptr) { _u._fgroup->_instances[0]->_ident->output(out, scope); } else { out << _u._fgroup->_name; @@ -1936,7 +1936,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { case T_literal: _u._literal._value->output(out, indent_level, scope, false); - if (_u._literal._operator != NULL) { + if (_u._literal._operator != nullptr) { string name = _u._literal._operator->get_simple_name(); assert(name.substr(0, 12) == "operator \"\" "); out << name.substr(12); @@ -1945,7 +1945,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { case T_raw_literal: out << _str; - if (_u._literal._operator != NULL) { + if (_u._literal._operator != nullptr) { string name = _u._literal._operator->get_simple_name(); assert(name.substr(0, 12) == "operator \"\" "); out << name.substr(12); @@ -2064,9 +2064,9 @@ elevate_type(CPPType *t1, CPPType *t2) { CPPSimpleType *st1 = t1->as_simple_type(); CPPSimpleType *st2 = t2->as_simple_type(); - if (st1 == NULL || st2 == NULL) { + if (st1 == nullptr || st2 == nullptr) { // Nothing we can do about this. Who knows? - return NULL; + return nullptr; } if (st1->_type == st2->_type) { @@ -2113,7 +2113,7 @@ elevate_type(CPPType *t1, CPPType *t2) { bool CPPExpression:: is_equal(const CPPDeclaration *other) const { const CPPExpression *ot = ((CPPDeclaration *)other)->as_expression(); - assert(ot != NULL); + assert(ot != nullptr); if (_type != ot->_type) { return false; @@ -2213,7 +2213,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPExpression:: is_less(const CPPDeclaration *other) const { const CPPExpression *ot = ((CPPDeclaration *)other)->as_expression(); - assert(ot != NULL); + assert(ot != nullptr); if (_type != ot->_type) { return (int)_type < (int)ot->_type; diff --git a/dtool/src/cppparser/cppExpression.h b/dtool/src/cppparser/cppExpression.h index 3178d4d178..0f9bc880e4 100644 --- a/dtool/src/cppparser/cppExpression.h +++ b/dtool/src/cppparser/cppExpression.h @@ -76,7 +76,7 @@ public: CPPExpression(const string &value); CPPExpression(long double value); CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, - CPPScope *global_scope, CPPPreprocessor *error_sink = NULL); + CPPScope *global_scope, CPPPreprocessor *error_sink = nullptr); CPPExpression(int unary_operator, CPPExpression *op1); CPPExpression(int binary_operator, CPPExpression *op1, CPPExpression *op2); CPPExpression(int trinary_operator, CPPExpression *op1, CPPExpression *op2, CPPExpression *op3); @@ -84,10 +84,10 @@ public: static CPPExpression typecast_op(CPPType *type, CPPExpression *op1, Type cast_type = T_typecast); static CPPExpression construct_op(CPPType *type, CPPExpression *op1); static CPPExpression aggregate_init_op(CPPType *type, CPPExpression *op1); - static CPPExpression new_op(CPPType *type, CPPExpression *op1 = NULL); + static CPPExpression new_op(CPPType *type, CPPExpression *op1 = nullptr); static CPPExpression typeid_op(CPPType *type, CPPType *std_type_info); static CPPExpression typeid_op(CPPExpression *op1, CPPType *std_type_info); - static CPPExpression type_trait(int trait, CPPType *type, CPPType *arg = NULL); + static CPPExpression type_trait(int trait, CPPType *type, CPPType *arg = nullptr); static CPPExpression sizeof_func(CPPType *type); static CPPExpression sizeof_ellipsis_func(CPPIdentifier *ident); static CPPExpression alignof_func(CPPType *type); diff --git a/dtool/src/cppparser/cppExpressionParser.cxx b/dtool/src/cppparser/cppExpressionParser.cxx index 2ab7b30771..c0821712fc 100644 --- a/dtool/src/cppparser/cppExpressionParser.cxx +++ b/dtool/src/cppparser/cppExpressionParser.cxx @@ -22,7 +22,7 @@ CPPExpressionParser(CPPScope *current_scope, CPPScope *global_scope) : _current_scope(current_scope), _global_scope(global_scope) { - _expr = NULL; + _expr = nullptr; } /** @@ -69,7 +69,7 @@ parse_expr(const string &expr, const CPPPreprocessor &filepos) { */ void CPPExpressionParser:: output(ostream &out) const { - if (_expr == NULL) { + if (_expr == nullptr) { out << "(null expr)"; } else { out << *_expr; diff --git a/dtool/src/cppparser/cppExtensionType.cxx b/dtool/src/cppparser/cppExtensionType.cxx index eba135eb64..ef5168334b 100644 --- a/dtool/src/cppparser/cppExtensionType.cxx +++ b/dtool/src/cppparser/cppExtensionType.cxx @@ -26,9 +26,9 @@ CPPExtensionType(CPPExtensionType::Type type, const CPPFile &file) : CPPType(file), _type(type), _ident(ident), - _alignment(NULL) + _alignment(nullptr) { - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } } @@ -38,7 +38,7 @@ CPPExtensionType(CPPExtensionType::Type type, */ string CPPExtensionType:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_simple_name(); @@ -49,7 +49,7 @@ get_simple_name() const { */ string CPPExtensionType:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_local_name(scope); @@ -60,7 +60,7 @@ get_local_name(CPPScope *scope) const { */ string CPPExtensionType:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_fully_scoped_name(); @@ -81,7 +81,7 @@ is_incomplete() const { */ bool CPPExtensionType:: is_tbd() const { - if (_ident != (CPPIdentifier *)NULL) { + if (_ident != nullptr) { return _ident->is_tbd(); } return false; @@ -110,7 +110,7 @@ bool CPPExtensionType:: is_constructible(const CPPType *given_type) const { if (_type == T_enum || _type == T_enum_class || _type == T_enum_struct) { const CPPExtensionType *other = ((CPPType *)given_type)->remove_reference()->remove_const()->as_extension_type(); - return other != NULL && is_equal(other); + return other != nullptr && is_equal(other); } return false; } @@ -151,7 +151,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } CPPExtensionType *rep = new CPPExtensionType(*this); - if (_ident != NULL) { + if (_ident != nullptr) { rep->_ident = _ident->substitute_decl(subst, current_scope, global_scope); } @@ -172,7 +172,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ CPPType *CPPExtensionType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { - if (_ident == NULL) { + if (_ident == nullptr) { // We can't resolve anonymous types. But that's OK, since they can't be // forward declared anyway. return this; @@ -180,7 +180,7 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { // Maybe it has been defined by now. CPPType *type = _ident->find_type(current_scope, global_scope); - if (type != NULL) { + if (type != nullptr) { return type; } return this; @@ -195,7 +195,7 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { bool CPPExtensionType:: is_equivalent(const CPPType &other) const { const CPPExtensionType *ot = ((CPPType *)&other)->as_extension_type(); - if (ot == (CPPExtensionType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -210,7 +210,7 @@ is_equivalent(const CPPType &other) const { */ void CPPExtensionType:: output(ostream &out, int, CPPScope *scope, bool complete) const { - if (_ident != NULL) { + if (_ident != nullptr) { // If we have a name, use it. if (complete || cppparser_output_class_keyword) { out << _type << " "; diff --git a/dtool/src/cppparser/cppExtensionType.h b/dtool/src/cppparser/cppExtensionType.h index dca9cf8cb3..5a44788af2 100644 --- a/dtool/src/cppparser/cppExtensionType.h +++ b/dtool/src/cppparser/cppExtensionType.h @@ -42,7 +42,7 @@ public: const CPPFile &file); virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual bool is_incomplete() const; diff --git a/dtool/src/cppparser/cppFunctionGroup.cxx b/dtool/src/cppparser/cppFunctionGroup.cxx index 2243d14708..fdec00184d 100644 --- a/dtool/src/cppparser/cppFunctionGroup.cxx +++ b/dtool/src/cppparser/cppFunctionGroup.cxx @@ -40,7 +40,7 @@ CPPFunctionGroup:: */ CPPType *CPPFunctionGroup:: get_return_type() const { - CPPType *return_type = NULL; + CPPType *return_type = nullptr; if (!_instances.empty()) { Instances::const_iterator ii = _instances.begin(); @@ -48,7 +48,7 @@ get_return_type() const { ++ii; while (ii != _instances.end()) { if ((*ii)->_type->as_function_type()->_return_type != return_type) { - return (CPPType *)NULL; + return nullptr; } ++ii; } diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index 38eb3d98ba..221297061d 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -27,16 +27,16 @@ CPPFunctionType(CPPType *return_type, CPPParameterList *parameters, _parameters(parameters), _flags(flags) { - _class_owner = NULL; + _class_owner = nullptr; // If the parameter list contains just the token "void", it means no // parameters. - if (_parameters != NULL && + if (_parameters != nullptr && _parameters->_parameters.size() == 1 && - _parameters->_parameters.front()->_type->as_simple_type() != NULL && + _parameters->_parameters.front()->_type->as_simple_type() != nullptr && _parameters->_parameters.front()->_type->as_simple_type()->_type == CPPSimpleType::T_void && - _parameters->_parameters.front()->_ident == NULL) { + _parameters->_parameters.front()->_ident == nullptr) { _parameters->_parameters.clear(); } } @@ -71,19 +71,21 @@ operator = (const CPPFunctionType ©) { */ bool CPPFunctionType:: accepts_num_parameters(int num_parameters) { - if (_parameters == NULL) { + assert(num_parameters >= 0); + if (_parameters == nullptr) { return (num_parameters == 0); } + size_t actual_num_parameters = _parameters->_parameters.size(); // If we passed too many parameters, it must have an ellipsis. - if (num_parameters > actual_num_parameters) { + if ((size_t)num_parameters > actual_num_parameters) { return _parameters->_includes_ellipsis; } // Make sure all superfluous parameters have a default value. - for (size_t i = num_parameters; i < actual_num_parameters; ++i) { + for (size_t i = (size_t)num_parameters; i < actual_num_parameters; ++i) { CPPInstance *param = _parameters->_parameters[i]; - if (param->_initializer == NULL) { + if (param->_initializer == nullptr) { return false; } } @@ -115,13 +117,13 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } CPPFunctionType *rep = new CPPFunctionType(*this); - if (_return_type != NULL) { + if (_return_type != nullptr) { rep->_return_type = _return_type->substitute_decl(subst, current_scope, global_scope) ->as_type(); } - if (_parameters != NULL) { + if (_parameters != nullptr) { rep->_parameters = _parameters->substitute_decl(subst, current_scope, global_scope); } @@ -146,8 +148,8 @@ CPPType *CPPFunctionType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *rtype = _return_type->resolve_type(current_scope, global_scope); CPPParameterList *params; - if (_parameters == NULL) { - params = NULL; + if (_parameters == nullptr) { + params = nullptr; } else { params = _parameters->resolve_type(current_scope, global_scope); } @@ -171,7 +173,7 @@ is_tbd() const { if (_return_type->is_tbd()) { return true; } - return _parameters == NULL || _parameters->is_tbd(); + return _parameters == nullptr || _parameters->is_tbd(); } /** @@ -326,7 +328,7 @@ get_num_default_parameters() const { // The trick is just to count, beginning from the end and working towards // the front, the number of parameters that have some initializer. - if (_parameters == NULL) { + if (_parameters == nullptr) { return 0; } @@ -334,7 +336,7 @@ get_num_default_parameters() const { CPPParameterList::Parameters::const_reverse_iterator pi; int count = 0; for (pi = params.rbegin(); - pi != params.rend() && (*pi)->_initializer != (CPPExpression *)NULL; + pi != params.rend() && (*pi)->_initializer != nullptr; ++pi) { count++; } @@ -390,7 +392,7 @@ match_virtual_override(const CPPFunctionType &other) const { bool CPPFunctionType:: is_equal(const CPPDeclaration *other) const { const CPPFunctionType *ot = ((CPPDeclaration *)other)->as_function_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_return_type != ot->_return_type) { return false; @@ -401,7 +403,7 @@ is_equal(const CPPDeclaration *other) const { if (_parameters == ot->_parameters) { return true; } - if (_parameters == NULL || ot->_parameters == NULL || + if (_parameters == nullptr || ot->_parameters == nullptr || *_parameters != *ot->_parameters) { return false; } @@ -416,7 +418,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPFunctionType:: is_less(const CPPDeclaration *other) const { const CPPFunctionType *ot = ((CPPDeclaration *)other)->as_function_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_return_type != ot->_return_type) { return _return_type < ot->_return_type; @@ -427,7 +429,7 @@ is_less(const CPPDeclaration *other) const { if (_parameters == ot->_parameters) { return 0; } - if (_parameters == NULL || ot->_parameters == NULL) { + if (_parameters == nullptr || ot->_parameters == nullptr) { return _parameters < ot->_parameters; } return *_parameters < *ot->_parameters; diff --git a/dtool/src/cppparser/cppIdentifier.cxx b/dtool/src/cppparser/cppIdentifier.cxx index 940b2a5daf..9fd7b500c8 100644 --- a/dtool/src/cppparser/cppIdentifier.cxx +++ b/dtool/src/cppparser/cppIdentifier.cxx @@ -26,7 +26,7 @@ CPPIdentifier:: CPPIdentifier(const string &name, const CPPFile &file) { _names.push_back(CPPNameComponent(name)); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; _loc.first_line = 0; _loc.first_column = 0; _loc.last_line = 0; @@ -40,7 +40,7 @@ CPPIdentifier(const string &name, const CPPFile &file) { CPPIdentifier:: CPPIdentifier(const CPPNameComponent &name, const CPPFile &file) { _names.push_back(name); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; _loc.first_line = 0; _loc.first_column = 0; _loc.last_line = 0; @@ -54,7 +54,7 @@ CPPIdentifier(const CPPNameComponent &name, const CPPFile &file) { CPPIdentifier:: CPPIdentifier(const string &name, const cppyyltype &loc) : _loc(loc) { _names.push_back(CPPNameComponent(name)); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; } /** @@ -63,7 +63,7 @@ CPPIdentifier(const string &name, const cppyyltype &loc) : _loc(loc) { CPPIdentifier:: CPPIdentifier(const CPPNameComponent &name, const cppyyltype &loc) : _loc(loc) { _names.push_back(name); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; } /** @@ -150,7 +150,7 @@ get_local_name(CPPScope *scope) const { string result; - if (scope == NULL || (_native_scope == NULL && _names.size() == 1)) { + if (scope == nullptr || (_native_scope == nullptr && _names.size() == 1)) { result = _names.back().get_name_with_templ(scope); } else if (_names.front().empty()) { @@ -159,15 +159,15 @@ get_local_name(CPPScope *scope) const { } else { // Determine the scope of everything up until but not including the last // name. - CPPScope *my_scope = get_scope(scope, NULL); + CPPScope *my_scope = get_scope(scope, nullptr); // Strip off template scopes, since they don't add anything particularly // meaningful to the local name. - while (my_scope != NULL && my_scope->as_template_scope() != NULL) { + while (my_scope != nullptr && my_scope->as_template_scope() != nullptr) { my_scope = my_scope->get_parent_scope(); } - if (my_scope == NULL) { + if (my_scope == nullptr) { result = get_fully_scoped_name(); } else if (my_scope == scope) { return _names.back().get_name_with_templ(scope); @@ -240,7 +240,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, assert(!_names.empty()); CPPScope *scope = _native_scope; - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { scope = current_scope; } int i = 0; @@ -251,16 +251,16 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, i++; } - while (i + 1 < (int)_names.size() && scope != NULL) { - CPPScope *next_scope = scope->find_scope(_names[i].get_name()); - if (next_scope == (CPPScope *)NULL) { - if (error_sink != NULL) { + while (i + 1 < (int)_names.size() && scope != nullptr) { + CPPScope *next_scope = scope->find_scope(_names[i].get_name(), global_scope); + if (next_scope == nullptr) { + if (error_sink != nullptr) { error_sink->error("Symbol " + _names[i].get_name() + " is not a known scope in " + scope->get_fully_scoped_name(), _loc); } - return (CPPScope *)NULL; + return nullptr; } if (_names[i].has_templ()) { next_scope = next_scope->instantiate(_names[i].get_templ(), @@ -283,7 +283,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, assert(!_names.empty()); CPPScope *scope = _native_scope; - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { scope = current_scope; } int i = 0; @@ -294,17 +294,17 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, i++; } - while (i + 1 < (int)_names.size() && scope != NULL) { + while (i + 1 < (int)_names.size() && scope != nullptr) { CPPScope *next_scope = scope->find_scope(_names[i].get_name(), subst, global_scope); - if (next_scope == (CPPScope *)NULL) { - if (error_sink != NULL) { + if (next_scope == nullptr) { + if (error_sink != nullptr) { error_sink->error("Symbol " + _names[i].get_name() + " is not a known scope in " + scope->get_fully_scoped_name(), _loc); } - return (CPPScope *)NULL; + return nullptr; } if (_names[i].has_templ()) { next_scope = next_scope->instantiate(_names[i].get_templ(), @@ -330,11 +330,11 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, bool force_instantiate, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } - CPPType *type = NULL; + CPPType *type = nullptr; if (!_names.back().has_templ()) { type = scope->find_type(get_simple_name()); @@ -374,12 +374,12 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, subst, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } CPPType *type = scope->find_type(get_simple_name(), subst, global_scope); - if (type != NULL && _names.back().has_templ()) { + if (type != nullptr && _names.back().has_templ()) { // This is a template type. if (is_fully_specified()) { @@ -388,9 +388,9 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, type->instantiate(_names.back().get_templ(), current_scope, global_scope, error_sink); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); if (new_type == type) { type = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } else { @@ -413,8 +413,8 @@ CPPDeclaration *CPPIdentifier:: find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } CPPDeclaration *sym; @@ -430,9 +430,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, } else { sym = scope->find_template(get_simple_name()); - if (sym != NULL) { + if (sym != nullptr) { CPPType *type = sym->as_type(); - if (type != NULL && type->is_incomplete()) { + if (type != nullptr && type->is_incomplete()) { // We can't instantiate an incomplete type. sym = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } else { @@ -454,8 +454,8 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, subst, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } CPPDeclaration *sym; @@ -472,9 +472,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, } else { sym = scope->find_template(get_simple_name()); - if (sym != NULL) { + if (sym != nullptr) { CPPType *type = sym->as_type(); - if (type != NULL && type->is_incomplete()) { + if (type != nullptr && type->is_incomplete()) { // We can't instantiate an incomplete type. sym = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } else { @@ -495,8 +495,8 @@ CPPDeclaration *CPPIdentifier:: find_template(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } return scope->find_template(get_simple_name()); } @@ -508,10 +508,10 @@ CPPScope *CPPIdentifier:: find_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } - return scope->find_scope(get_simple_name()); + return scope->find_scope(get_simple_name(), global_scope); } @@ -547,7 +547,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ void CPPIdentifier:: output(ostream &out, CPPScope *scope) const { - if (scope == NULL) { + if (scope == nullptr) { output_fully_scoped_name(out); } else { output_local_name(out, scope); @@ -562,16 +562,16 @@ void CPPIdentifier:: output_local_name(ostream &out, CPPScope *scope) const { assert(!_names.empty()); - if (scope == NULL || (_native_scope == NULL && _names.size() == 1)) { + if (scope == nullptr || (_native_scope == nullptr && _names.size() == 1)) { out << _names.back(); } else if (_names.front().empty()) { output_fully_scoped_name(out); } else { // Determine the scope of everything up until but not including the last // name. - CPPScope *my_scope = get_scope(scope, NULL); + CPPScope *my_scope = get_scope(scope, nullptr); - if (my_scope == NULL) { + if (my_scope == nullptr) { output_fully_scoped_name(out); } else { out << my_scope->get_local_name(scope) << "::" << _names.back(); @@ -584,8 +584,8 @@ output_local_name(ostream &out, CPPScope *scope) const { */ void CPPIdentifier:: output_fully_scoped_name(ostream &out) const { - if (_native_scope != NULL) { - _native_scope->output(out, (CPPScope *)NULL); + if (_native_scope != nullptr) { + _native_scope->output(out, nullptr); out << "::"; } Names::const_iterator ni = _names.begin(); diff --git a/dtool/src/cppparser/cppIdentifier.h b/dtool/src/cppparser/cppIdentifier.h index abb6405fc6..57daf3b469 100644 --- a/dtool/src/cppparser/cppIdentifier.h +++ b/dtool/src/cppparser/cppIdentifier.h @@ -48,7 +48,7 @@ public: bool is_scoped() const; string get_simple_name() const; - string get_local_name(CPPScope *scope = NULL) const; + string get_local_name(CPPScope *scope = nullptr) const; string get_fully_scoped_name() const; bool is_fully_specified() const; @@ -56,30 +56,30 @@ public: CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope, bool force_instantiate = false, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPDeclaration *find_symbol(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPDeclaration *find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPDeclaration *find_template(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPScope *find_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPIdentifier *substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, @@ -96,7 +96,7 @@ public: }; inline ostream &operator << (ostream &out, const CPPIdentifier &identifier) { - identifier.output(out, (CPPScope *)NULL); + identifier.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index 0bfdcabde1..eb71e47315 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -35,10 +35,10 @@ CPPInstance(CPPType *type, const string &name, int storage_class) : _type(type), _ident(new CPPIdentifier(name)), _storage_class(storage_class), - _alignment(NULL), + _alignment(nullptr), _bit_width(-1) { - _initializer = NULL; + _initializer = nullptr; } /** @@ -50,10 +50,10 @@ CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class) : _type(type), _ident(ident), _storage_class(storage_class), - _alignment(NULL), + _alignment(nullptr), _bit_width(-1) { - _initializer = NULL; + _initializer = nullptr; } /** @@ -65,17 +65,17 @@ CPPInstance:: CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class, const CPPFile &file) : CPPDeclaration(file), - _alignment(NULL) + _alignment(nullptr) { _type = ii->unroll_type(type); _ident = ii->_ident; - ii->_ident = NULL; + ii->_ident = nullptr; _storage_class = storage_class; - _initializer = NULL; + _initializer = nullptr; _bit_width = ii->_bit_width; CPPParameterList *params = ii->get_initializer(); - if (params != (CPPParameterList *)NULL) { + if (params != nullptr) { // In this case, the instance has a parameter-list initializer, e.g.: int // foo(0); We really should save this initializer in the instance object. // But we don't for now, since no one really cares about initializers @@ -102,7 +102,7 @@ CPPInstance(const CPPInstance ©) : _alignment(copy._alignment), _bit_width(copy._bit_width) { - assert(_type != NULL); + assert(_type != nullptr); } /** @@ -150,17 +150,17 @@ operator == (const CPPInstance &other) const { // We *do* care about the identifier. We need to differentiate types of // function variables, among possibly other things, based on the identifier. - if ((_ident == NULL && other._ident != NULL) || - (_ident != NULL && other._ident == NULL) || - (_ident != NULL && other._ident != NULL && *_ident != *other._ident)) + if ((_ident == nullptr && other._ident != nullptr) || + (_ident != nullptr && other._ident == nullptr) || + (_ident != nullptr && other._ident != nullptr && *_ident != *other._ident)) { return false; } // We similarly care about the initializer. - if ((_initializer == NULL && other._initializer != NULL) || - (_initializer != NULL && other._initializer == NULL) || - (_initializer != NULL && other._initializer != NULL && + if ((_initializer == nullptr && other._initializer != nullptr) || + (_initializer != nullptr && other._initializer == nullptr) || + (_initializer != nullptr && other._initializer != nullptr && *_initializer != *other._initializer)) { return false; @@ -194,23 +194,23 @@ operator < (const CPPInstance &other) const { // We *do* care about the identifier. We need to differentiate types of // function variables, among possibly other things, based on the identifier. - if ((_ident == NULL && other._ident != NULL) || - (_ident != NULL && other._ident == NULL) || - (_ident != NULL && other._ident != NULL && *_ident != *other._ident)) + if ((_ident == nullptr && other._ident != nullptr) || + (_ident != nullptr && other._ident == nullptr) || + (_ident != nullptr && other._ident != nullptr && *_ident != *other._ident)) { - if (_ident == NULL || other._ident == NULL) { + if (_ident == nullptr || other._ident == nullptr) { return _ident < other._ident; } return *_ident < *other._ident; } // We similarly care about the initializer. - if ((_initializer == NULL && other._initializer != NULL) || - (_initializer != NULL && other._initializer == NULL) || - (_initializer != NULL && other._initializer != NULL && + if ((_initializer == nullptr && other._initializer != nullptr) || + (_initializer != nullptr && other._initializer == nullptr) || + (_initializer != nullptr && other._initializer != nullptr && *_initializer != *other._initializer)) { - if (_initializer == NULL || other._initializer == NULL) { + if (_initializer == nullptr || other._initializer == nullptr) { return _initializer < other._initializer; } return *_initializer < *other._initializer; @@ -226,12 +226,12 @@ operator < (const CPPInstance &other) const { */ void CPPInstance:: set_initializer(CPPExpression *initializer) { - if (_type->as_function_type() != (CPPFunctionType *)NULL) { + if (_type->as_function_type() != nullptr) { // This is a function declaration. _storage_class &= ~(SC_pure_virtual | SC_defaulted | SC_deleted); - _initializer = (CPPExpression *)NULL; + _initializer = nullptr; - if (initializer != (CPPExpression *)NULL) { + if (initializer != nullptr) { if (initializer->_type == CPPExpression::T_integer) { // = 0 _storage_class |= SC_pure_virtual; @@ -270,7 +270,7 @@ set_alignment(CPPExpression *const_expr) { */ bool CPPInstance:: is_scoped() const { - if (_ident == NULL) { + if (_ident == nullptr) { return false; } else { return _ident->is_scoped(); @@ -283,7 +283,7 @@ is_scoped() const { CPPScope *CPPInstance:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { - if (_ident == NULL) { + if (_ident == nullptr) { return current_scope; } else { return _ident->get_scope(current_scope, global_scope, error_sink); @@ -295,7 +295,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, */ string CPPInstance:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } else { return _ident->get_simple_name(); @@ -307,7 +307,7 @@ get_simple_name() const { */ string CPPInstance:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } else { return _ident->get_local_name(scope); @@ -319,7 +319,7 @@ get_local_name(CPPScope *scope) const { */ string CPPInstance:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } else { return _ident->get_fully_scoped_name(); @@ -334,12 +334,12 @@ get_fully_scoped_name() const { void CPPInstance:: check_for_constructor(CPPScope *current_scope, CPPScope *global_scope) { CPPScope *scope = get_scope(current_scope, global_scope); - if (scope == NULL) { + if (scope == nullptr) { scope = current_scope; } CPPFunctionType *func = _type->as_function_type(); - if (func != NULL) { + if (func != nullptr) { string method_name = get_local_name(scope); string class_name = scope->get_local_name(); @@ -359,7 +359,7 @@ check_for_constructor(CPPScope *current_scope, CPPScope *global_scope) { CPPType *param_type = params->_parameters[0]->_type; CPPReferenceType *ref_type = param_type->as_reference_type(); - if (ref_type != NULL) { + if (ref_type != nullptr) { param_type = ref_type->_pointing_at->remove_cv(); if (class_name == param_type->get_simple_name()) { @@ -404,7 +404,7 @@ instantiate(const CPPTemplateParameterList *actual_params, CPPPreprocessor *error_sink) const { if (!is_template()) { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters for instance " + _ident->get_local_name()); } @@ -434,7 +434,7 @@ instantiate(const CPPTemplateParameterList *actual_params, // change the name. inst = new CPPInstance(*this); } - assert(inst != NULL); + assert(inst != nullptr); inst->_ident = inst->_ident->substitute_decl(subst, current_scope, global_scope); if (inst->_ident == _ident) { inst->_ident = new CPPIdentifier(*inst->_ident); @@ -442,7 +442,7 @@ instantiate(const CPPTemplateParameterList *actual_params, inst->_ident->_names.back().set_templ (new CPPTemplateParameterList(*actual_params)); - inst->_template_scope = NULL; + inst->_template_scope = nullptr; ((CPPInstance *)this)->_instantiations.insert(Instantiations::value_type(actual_params, inst)); return inst; @@ -455,10 +455,10 @@ instantiate(const CPPTemplateParameterList *actual_params, */ bool CPPInstance:: is_fully_specified() const { - if (_ident != NULL && !_ident->is_fully_specified()) { + if (_ident != nullptr && !_ident->is_fully_specified()) { return false; } - if (_initializer != NULL && !_initializer->is_fully_specified()) { + if (_initializer != nullptr && !_initializer->is_fully_specified()) { return false; } return CPPDeclaration::is_fully_specified() && @@ -482,11 +482,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, _type->substitute_decl(subst, current_scope, global_scope); rep->_type = new_type->as_type(); - if (rep->_type == NULL) { + if (rep->_type == nullptr) { rep->_type = _type; } - if (_initializer != NULL) { + if (_initializer != nullptr) { rep->_initializer = _initializer->substitute_decl(subst, current_scope, global_scope) ->as_expression(); @@ -517,7 +517,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { void CPPInstance:: output(ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const { - assert(_type != NULL); + assert(_type != nullptr); if (_type->is_parameter_expr()) { // In this case, the whole thing is really an expression, and not an @@ -532,7 +532,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, indent(out, indent_level); } - if (_alignment != NULL) { + if (_alignment != nullptr) { out << "alignas(" << *_alignment << ") "; } @@ -571,7 +571,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, } string name; - if (_ident != NULL) { + if (_ident != nullptr) { name = _ident->get_local_name(scope); } if (_storage_class & SC_parameter_pack) { @@ -600,7 +600,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, if (_storage_class & SC_deleted) { out << " = delete"; } - if (_initializer != NULL) { + if (_initializer != nullptr) { out << " = " << *_initializer; } } diff --git a/dtool/src/cppparser/cppInstance.h b/dtool/src/cppparser/cppInstance.h index 675ba83507..137bbe56b7 100644 --- a/dtool/src/cppparser/cppInstance.h +++ b/dtool/src/cppparser/cppInstance.h @@ -94,10 +94,10 @@ public: bool is_scoped() const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; string get_simple_name() const; - string get_local_name(CPPScope *scope = NULL) const; + string get_local_name(CPPScope *scope = nullptr) const; string get_fully_scoped_name() const; void check_for_constructor(CPPScope *current_scope, CPPScope *global_scope); @@ -105,7 +105,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual bool is_fully_specified() const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index fe723f552d..b75dfc6424 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -27,10 +27,10 @@ CPPInstanceIdentifier::Modifier:: Modifier(CPPInstanceIdentifierType type) : _type(type), - _func_params(NULL), + _func_params(nullptr), _func_flags(0), - _scoping(NULL), - _expr(NULL) { + _scoping(nullptr), + _expr(nullptr) { } /** @@ -116,7 +116,7 @@ add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_ // check if the parameter list is empty. If it is, this is really a unary // operator, so set the unary_op flag. Operators () and [] are never // considered unary operators. - if (_ident != NULL && + if (_ident != nullptr && _ident->get_simple_name().substr(0, 9) == "operator ") { if (_ident->get_simple_name() != string("operator ()") && @@ -129,7 +129,7 @@ add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_ flags |= CPPFunctionType::F_operator; } - if (trailing_return_type != NULL) { + if (trailing_return_type != nullptr) { // Remember whether trailing return type notation was used. flags |= CPPFunctionType::F_trailing_return_type; } @@ -153,7 +153,7 @@ add_array_modifier(CPPExpression *expr) { // Special case for operator new[] and delete[]. We're not really adding an // array modifier to them, but appending [] to the identifier. This is to // work around a parser ambiguity. - if (_ident != NULL && (_ident->get_simple_name() == "operator delete" || + if (_ident != nullptr && (_ident->get_simple_name() == "operator delete" || _ident->get_simple_name() == "operator new")) { _ident->_names.back().append_name("[]"); @@ -206,7 +206,7 @@ get_initializer() const { } } - return NULL; + return nullptr; } /** @@ -215,7 +215,7 @@ get_initializer() const { CPPScope *CPPInstanceIdentifier:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { - if (_ident == NULL) { + if (_ident == nullptr) { return current_scope; } else { return _ident->get_scope(current_scope, global_scope, error_sink); @@ -228,7 +228,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPType *CPPInstanceIdentifier:: r_unroll_type(CPPType *start_type, CPPInstanceIdentifier::Modifiers::const_iterator mi) { - assert(start_type != NULL); + assert(start_type != nullptr); start_type = CPPType::new_type(start_type); @@ -239,7 +239,7 @@ r_unroll_type(CPPType *start_type, const Modifier &mod = (*mi); ++mi; - CPPType *result = NULL; + CPPType *result = nullptr; switch (mod._type) { case IIT_pointer: @@ -260,7 +260,7 @@ r_unroll_type(CPPType *start_type, { CPPType *type = r_unroll_type(start_type, mi); CPPFunctionType *ftype = type->as_function_type(); - if (ftype != NULL) { + if (ftype != nullptr) { ftype = new CPPFunctionType(*ftype); ftype->_class_owner = mod._scoping; ftype->_flags |= CPPFunctionType::F_method_pointer; @@ -291,9 +291,9 @@ r_unroll_type(CPPType *start_type, case IIT_func: { CPPType *return_type = r_unroll_type(start_type, mi); - if (mod._trailing_return_type != (CPPType *)NULL) { + if (mod._trailing_return_type != nullptr) { CPPSimpleType *simple_type = return_type->as_simple_type(); - if (simple_type != NULL && simple_type->_type == CPPSimpleType::T_auto) { + if (simple_type != nullptr && simple_type->_type == CPPSimpleType::T_auto) { return_type = mod._trailing_return_type; } else { cerr << "function with trailing return type needs auto\n"; diff --git a/dtool/src/cppparser/cppInstanceIdentifier.h b/dtool/src/cppparser/cppInstanceIdentifier.h index 8433b30313..582e149e2c 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.h +++ b/dtool/src/cppparser/cppInstanceIdentifier.h @@ -55,7 +55,7 @@ public: void add_modifier(CPPInstanceIdentifierType type); void add_func_modifier(CPPParameterList *params, int flags, - CPPType *trailing_return_type = NULL); + CPPType *trailing_return_type = nullptr); void add_scoped_pointer_modifier(CPPIdentifier *scoping); void add_array_modifier(CPPExpression *expr); void add_initializer_modifier(CPPParameterList *params); @@ -65,7 +65,7 @@ public: CPPParameterList *get_initializer() const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPIdentifier *_ident; diff --git a/dtool/src/cppparser/cppMakeProperty.cxx b/dtool/src/cppparser/cppMakeProperty.cxx index 02e4f21c60..e75cfb5676 100644 --- a/dtool/src/cppparser/cppMakeProperty.cxx +++ b/dtool/src/cppparser/cppMakeProperty.cxx @@ -64,41 +64,41 @@ get_fully_scoped_name() const { */ void CPPMakeProperty:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (_length_function != NULL) { + if (_length_function != nullptr) { out << "__make_seq_property"; } else { out << "__make_property"; } - if (_has_function != NULL) { + if (_has_function != nullptr) { out.put('2'); } out << "(" << _ident->get_local_name(scope); - if (_length_function != NULL) { + if (_length_function != nullptr) { out << ", " << _length_function->_name; } - if (_has_function != NULL) { + if (_has_function != nullptr) { out << ", " << _has_function->_name; } out << ", " << _get_function->_name; - if (_set_function != NULL) { + if (_set_function != nullptr) { out << ", " << _set_function->_name; } - if (_clear_function != NULL) { + if (_clear_function != nullptr) { out << ", " << _clear_function->_name; } - if (_del_function != NULL) { + if (_del_function != nullptr) { out << ", " << _del_function->_name; } - if (_insert_function != NULL) { + if (_insert_function != nullptr) { out << ", " << _insert_function->_name; } diff --git a/dtool/src/cppparser/cppMakeProperty.h b/dtool/src/cppparser/cppMakeProperty.h index cd364b30ec..d97369fc7d 100644 --- a/dtool/src/cppparser/cppMakeProperty.h +++ b/dtool/src/cppparser/cppMakeProperty.h @@ -92,7 +92,7 @@ public: CPPScope *current_scope, const CPPFile &file); virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppMakeSeq.h b/dtool/src/cppparser/cppMakeSeq.h index 0e48dd0ef4..9d4eae4261 100644 --- a/dtool/src/cppparser/cppMakeSeq.h +++ b/dtool/src/cppparser/cppMakeSeq.h @@ -33,7 +33,7 @@ public: CPPScope *current_scope, const CPPFile &file); virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppManifest.cxx b/dtool/src/cppparser/cppManifest.cxx index bb8f315c39..faaaced2d8 100644 --- a/dtool/src/cppparser/cppManifest.cxx +++ b/dtool/src/cppparser/cppManifest.cxx @@ -41,7 +41,7 @@ CPPManifest:: CPPManifest(const string &args, const cppyyltype &loc) : _variadic_param(-1), _loc(loc), - _expr((CPPExpression *)NULL), + _expr(nullptr), _vis(V_public) { assert(!args.empty()); @@ -84,7 +84,7 @@ CPPManifest(const string &args, const cppyyltype &loc) : CPPManifest:: CPPManifest(const string ¯o, const string &definition) : _variadic_param(-1), - _expr((CPPExpression *)NULL), + _expr(nullptr), _vis(V_public) { _loc.first_line = 0; @@ -125,7 +125,7 @@ CPPManifest(const string ¯o, const string &definition) : */ CPPManifest:: ~CPPManifest() { - if (_expr != (CPPExpression *)NULL) { + if (_expr != nullptr) { delete _expr; } } @@ -242,10 +242,10 @@ expand(const vector_string &args) const { */ CPPType *CPPManifest:: determine_type() const { - if (_expr != (CPPExpression *)NULL) { + if (_expr != nullptr) { return _expr->determine_type(); } - return (CPPType *)NULL; + return nullptr; } /** diff --git a/dtool/src/cppparser/cppNameComponent.cxx b/dtool/src/cppparser/cppNameComponent.cxx index 9287aaa89b..b5c7f825aa 100644 --- a/dtool/src/cppparser/cppNameComponent.cxx +++ b/dtool/src/cppparser/cppNameComponent.cxx @@ -21,7 +21,7 @@ CPPNameComponent:: CPPNameComponent(const string &name) : _name(name) { - _templ = (CPPTemplateParameterList *)NULL; + _templ = nullptr; } /** @@ -32,10 +32,10 @@ operator == (const CPPNameComponent &other) const { if (_name != other._name) { return false; } - if (_templ == NULL && other._templ == NULL) { + if (_templ == nullptr && other._templ == nullptr) { return true; } - if (_templ == NULL || other._templ == NULL) { + if (_templ == nullptr || other._templ == nullptr) { return false; } if (*_templ != *other._templ) { @@ -61,10 +61,10 @@ operator < (const CPPNameComponent &other) const { if (_name != other._name) { return _name < other._name; } - if (_templ == NULL && other._templ == NULL) { + if (_templ == nullptr && other._templ == nullptr) { return false; } - if (_templ == NULL || other._templ == NULL) { + if (_templ == nullptr || other._templ == nullptr) { return _templ < other._templ; } return (*_templ) < (*other._templ); @@ -85,7 +85,7 @@ string CPPNameComponent:: get_name_with_templ(CPPScope *scope) const { ostringstream strm; strm << _name; - if (_templ != NULL) { + if (_templ != nullptr) { strm << "< "; _templ->output(strm, scope); strm << " >"; @@ -114,7 +114,7 @@ empty() const { */ bool CPPNameComponent:: has_templ() const { - return _templ != (CPPTemplateParameterList *)NULL; + return _templ != nullptr; } /** @@ -123,7 +123,7 @@ has_templ() const { */ bool CPPNameComponent:: is_tbd() const { - if (_templ != (CPPTemplateParameterList *)NULL) { + if (_templ != nullptr) { return _templ->is_tbd(); } return false; @@ -159,7 +159,7 @@ set_templ(CPPTemplateParameterList *templ) { void CPPNameComponent:: output(ostream &out) const { out << _name; - if (_templ != NULL) { + if (_templ != nullptr) { out << "< " << *_templ << " >"; } } diff --git a/dtool/src/cppparser/cppNameComponent.h b/dtool/src/cppparser/cppNameComponent.h index e8f4a94ce4..9e6981e3d8 100644 --- a/dtool/src/cppparser/cppNameComponent.h +++ b/dtool/src/cppparser/cppNameComponent.h @@ -32,7 +32,7 @@ public: bool operator < (const CPPNameComponent &other) const; string get_name() const; - string get_name_with_templ(CPPScope *scope = (CPPScope *)NULL) const; + string get_name_with_templ(CPPScope *scope = nullptr) const; CPPTemplateParameterList *get_templ() const; bool empty() const; bool has_templ() const; diff --git a/dtool/src/cppparser/cppNamespace.cxx b/dtool/src/cppparser/cppNamespace.cxx index 36bad0a932..c8e84a3725 100644 --- a/dtool/src/cppparser/cppNamespace.cxx +++ b/dtool/src/cppparser/cppNamespace.cxx @@ -33,7 +33,7 @@ CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) : */ string CPPNamespace:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_simple_name(); @@ -44,7 +44,7 @@ get_simple_name() const { */ string CPPNamespace:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_local_name(scope); @@ -55,7 +55,7 @@ get_local_name(CPPScope *scope) const { */ string CPPNamespace:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_fully_scoped_name(); @@ -77,12 +77,12 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_is_inline) { out << "inline "; } - if (!complete && _ident != NULL) { + if (!complete && _ident != nullptr) { // If we have a name, use it. out << "namespace " << _ident->get_local_name(scope); } else { - if (_ident != NULL) { + if (_ident != nullptr) { out << "namespace " << _ident->get_local_name(scope) << " {\n"; } else { out << "namespace {\n"; diff --git a/dtool/src/cppparser/cppNamespace.h b/dtool/src/cppparser/cppNamespace.h index 81002b475f..c0dd98132e 100644 --- a/dtool/src/cppparser/cppNamespace.h +++ b/dtool/src/cppparser/cppNamespace.h @@ -30,7 +30,7 @@ public: const CPPFile &file); string get_simple_name() const; - string get_local_name(CPPScope *scope = NULL) const; + string get_local_name(CPPScope *scope = nullptr) const; string get_fully_scoped_name() const; CPPScope *get_scope() const; diff --git a/dtool/src/cppparser/cppParameterList.cxx b/dtool/src/cppparser/cppParameterList.cxx index 1d3c2b986d..6ecdbc665d 100644 --- a/dtool/src/cppparser/cppParameterList.cxx +++ b/dtool/src/cppparser/cppParameterList.cxx @@ -213,7 +213,7 @@ output(ostream &out, CPPScope *scope, bool parameter_names, if (num_default_parameters >= 0 && i < (int)_parameters.size() - num_default_parameters) { // Don't show the default value for this parameter. - _parameters[i]->_initializer = (CPPExpression *)NULL; + _parameters[i]->_initializer = nullptr; } if (parameter_names) { diff --git a/dtool/src/cppparser/cppParameterList.h b/dtool/src/cppparser/cppParameterList.h index 93e00a822e..77c7b2b889 100644 --- a/dtool/src/cppparser/cppParameterList.h +++ b/dtool/src/cppparser/cppParameterList.h @@ -59,7 +59,7 @@ public: inline ostream & operator << (ostream &out, const CPPParameterList &plist) { - plist.output(out, (CPPScope *)NULL, true); + plist.output(out, nullptr, true); return out; } diff --git a/dtool/src/cppparser/cppParser.cxx b/dtool/src/cppparser/cppParser.cxx index 4b27a87d6d..6b13d95dec 100644 --- a/dtool/src/cppparser/cppParser.cxx +++ b/dtool/src/cppparser/cppParser.cxx @@ -25,7 +25,7 @@ bool cppparser_output_class_keyword = false; * */ CPPParser:: -CPPParser() : CPPScope((CPPScope *)NULL, CPPNameComponent(""), V_public) { +CPPParser() : CPPScope(nullptr, CPPNameComponent(""), V_public) { } /** @@ -88,6 +88,6 @@ parse_type(const string &type) { if (ep.parse_type(type, *this)) { return ep._type; } else { - return (CPPType *)NULL; + return nullptr; } } diff --git a/dtool/src/cppparser/cppPointerType.cxx b/dtool/src/cppparser/cppPointerType.cxx index 4ae396e22d..9185455350 100644 --- a/dtool/src/cppparser/cppPointerType.cxx +++ b/dtool/src/cppparser/cppPointerType.cxx @@ -147,14 +147,14 @@ is_constructible(const CPPType *given_type) const { // Can initialize void pointer with any pointer. const CPPSimpleType *simple_type = a->as_simple_type(); - if (simple_type != NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_void; } // Can initialize from derived class pointer. const CPPStructType *a_struct = a->as_struct_type(); const CPPStructType *b_struct = b->as_struct_type(); - if (a_struct != NULL && b_struct != NULL) { + if (a_struct != nullptr && b_struct != nullptr) { return a_struct->is_base_of(b_struct); } @@ -194,7 +194,7 @@ is_copy_assignable() const { bool CPPPointerType:: is_equivalent(const CPPType &other) const { const CPPPointerType *ot = ((CPPType *)&other)->as_pointer_type(); - if (ot == (CPPPointerType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -241,7 +241,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, string star = "*"; CPPFunctionType *ftype = _pointing_at->as_function_type(); - if (ftype != NULL && + if (ftype != nullptr && ((ftype->_flags & CPPFunctionType::F_method_pointer) != 0)) { // We have to output pointers-to-method with a scoping before the '*'. star = ftype->_class_owner->get_fully_scoped_name() + "::*"; @@ -275,7 +275,7 @@ as_pointer_type() { bool CPPPointerType:: is_equal(const CPPDeclaration *other) const { const CPPPointerType *ot = ((CPPDeclaration *)other)->as_pointer_type(); - assert(ot != NULL); + assert(ot != nullptr); return _pointing_at == ot->_pointing_at; } @@ -288,7 +288,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPPointerType:: is_less(const CPPDeclaration *other) const { const CPPPointerType *ot = ((CPPDeclaration *)other)->as_pointer_type(); - assert(ot != NULL); + assert(ot != nullptr); return _pointing_at < ot->_pointing_at; } diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index ecaecb98b6..2a6c3270bc 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -87,8 +87,8 @@ trim_blanks(const string &str) { */ CPPPreprocessor::InputFile:: InputFile() { - _in = NULL; - _ignore_manifest = NULL; + _in = nullptr; + _ignore_manifest = nullptr; _line_number = 0; _col_number = 0; _next_line_number = 1; @@ -101,7 +101,7 @@ InputFile() { */ CPPPreprocessor::InputFile:: ~InputFile() { - if (_in != NULL) { + if (_in != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -120,7 +120,7 @@ CPPPreprocessor::InputFile:: */ bool CPPPreprocessor::InputFile:: open(const CPPFile &file) { - assert(_in == NULL); + assert(_in == nullptr); _file = file; pifstream *in = new pifstream; @@ -134,7 +134,7 @@ open(const CPPFile &file) { */ bool CPPPreprocessor::InputFile:: connect_input(const string &input) { - assert(_in == NULL); + assert(_in == nullptr); _input = input; _in = new istringstream(_input); @@ -146,7 +146,7 @@ connect_input(const string &input) { */ int CPPPreprocessor::InputFile:: get() { - assert(_in != NULL); + assert(_in != nullptr); if (!_lock_position) { _line_number = _next_line_number; @@ -186,7 +186,7 @@ get() { */ int CPPPreprocessor::InputFile:: peek() { - assert(_in != NULL); + assert(_in != nullptr); int c = _in->peek(); @@ -344,7 +344,7 @@ get_next_token0() { // instantiation and call yacc recursively to parse the template // parameters. CPPDeclaration *decl = ident->find_template(current_scope, global_scope); - if (decl != NULL) { + if (decl != nullptr) { ident->_names.back().set_templ (nested_parse_template_instantiation(decl->get_template_scope())); token = internal_get_next_token(); @@ -402,7 +402,7 @@ get_next_token0() { // parameters. CPPDeclaration *decl = ident->find_template(current_scope, global_scope); - if (decl != NULL) { + if (decl != nullptr) { ident->_names.back().set_templ (nested_parse_template_instantiation(decl->get_template_scope())); token = internal_get_next_token(); @@ -417,7 +417,7 @@ get_next_token0() { int token_type = IDENTIFIER; CPPDeclaration *decl = ident->find_symbol(current_scope, global_scope); - if (decl != NULL && decl->as_type() != NULL) { + if (decl != nullptr && decl->as_type() != nullptr) { // We need to see type pack template parameters as a different type of // identifier to resolve a parser ambiguity. CPPClassTemplateParameter *ctp = decl->as_class_template_parameter(); @@ -567,12 +567,12 @@ show_line(const YYLTYPE &loc) { } // Seek to the offending line in the file. - ifstream stream; + std::ifstream stream; if (loc.file._filename.open_read(stream)) { int l = 0; string linestr; while (l < loc.first_line) { - getline(stream, linestr); + std::getline(stream, linestr); ++l; } @@ -642,19 +642,19 @@ get_comment_before(int line, CPPFile file) { } if (comment->_last_line < line) { - return (CPPCommentBlock *)NULL; + return nullptr; } } else { wrong_file_count++; if (wrong_file_count > 10) { - return (CPPCommentBlock *)NULL; + return nullptr; } } ++ci; } - return (CPPCommentBlock *)NULL; + return nullptr; } /** @@ -672,14 +672,14 @@ get_comment_on(int line, CPPFile file) { if (comment->_line_number == line) { return comment; } else if (comment->_line_number < line) { - return (CPPCommentBlock *)NULL; + return nullptr; } } ++ci; } - return (CPPCommentBlock *)NULL; + return nullptr; } /** @@ -887,7 +887,7 @@ parse_expr(const string &input_expr, CPPScope *current_scope, if (ep.parse_expr(expr, *this)) { return ep._expr; } else { - return (CPPExpression *)NULL; + return nullptr; } } @@ -1579,7 +1579,6 @@ handle_if_directive(const string &args, const YYLTYPE &loc) { */ void CPPPreprocessor:: handle_include_directive(const string &args, const YYLTYPE &loc) { - bool okflag = false; Filename filename; Filename filename_as_referenced; bool angle_quotes = false; @@ -1599,7 +1598,6 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { if (!expr.empty()) { if (expr[0] == '"' && expr[expr.size() - 1] == '"') { filename = expr.substr(1, expr.size() - 2); - okflag = true; if (_files.size() == 1) { // If we're currently processing a top-level file, record the include @@ -1614,7 +1612,6 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { // same, as if they used quote marks. angle_quotes = true; } - okflag = true; if (_files.size() == 1) { // If we're currently processing a top-level file, record the include @@ -1677,7 +1674,7 @@ handle_pragma_directive(const string &args, const YYLTYPE &loc) { if (mi != _manifests.end()) { _manifest_stack[macro].push_back(mi->second); } else { - _manifest_stack[macro].push_back(NULL); + _manifest_stack[macro].push_back(nullptr); } } else if (sscanf(args.c_str(), "pop_macro ( \"%63[^\"]\" )", macro) == 1) { @@ -1686,7 +1683,7 @@ handle_pragma_directive(const string &args, const YYLTYPE &loc) { CPPManifest *manifest = stack.back(); stack.pop_back(); Manifests::iterator mi = _manifests.find(macro); - if (manifest == NULL) { + if (manifest == nullptr) { // It was undefined when it was pushed, so make it undefined again. if (mi != _manifests.end()) { _manifests.erase(mi); @@ -1969,7 +1966,7 @@ get_identifier(int c) { if (kw != 0) { YYSTYPE result; - result.u.identifier = (CPPIdentifier *)NULL; + result.u.identifier = nullptr; return CPPToken(kw, loc, name, result); } @@ -2022,24 +2019,24 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { CPPIdentifier *ident = new CPPIdentifier("operator \"\" " + suffix); CPPDeclaration *decl = ident->find_symbol(current_scope, global_scope, this); - if (decl == NULL || decl->get_subtype() != CPPDeclaration::ST_function_group) { + if (decl == nullptr || decl->get_subtype() != CPPDeclaration::ST_function_group) { error("unknown literal suffix " + suffix, loc); return CPPToken(token, loc, str, value); } // Find the overload with the appropriate signature. - CPPExpression *expr = NULL; - CPPInstance *instance = NULL; - CPPInstance *raw_instance = NULL; + CPPExpression *expr = nullptr; + CPPInstance *instance = nullptr; + CPPInstance *raw_instance = nullptr; CPPFunctionGroup *fgroup = decl->as_function_group(); CPPFunctionGroup::Instances::iterator it; for (it = fgroup->_instances.begin(); it != fgroup->_instances.end(); ++it) { - if ((*it)->_type == NULL) { + if ((*it)->_type == nullptr) { continue; } CPPFunctionType *ftype = (*it)->_type->as_function_type(); - if (ftype == NULL || ftype->_parameters == NULL) { + if (ftype == nullptr || ftype->_parameters == nullptr) { continue; } @@ -2052,7 +2049,7 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { } CPPInstance *param = params[0]; - if (param == NULL || param->_type == NULL) { + if (param == nullptr || param->_type == nullptr) { continue; } @@ -2086,11 +2083,11 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { } else if (type->get_subtype() == CPPDeclaration::ST_pointer) { // Must be a const pointer. Unwrap it. type = type->as_pointer_type()->_pointing_at; - if (type == NULL || type->get_subtype() != CPPDeclaration::ST_const) { + if (type == nullptr || type->get_subtype() != CPPDeclaration::ST_const) { continue; } type = type->as_const_type()->_wrapped_around; - if (type == NULL || type->get_subtype() != CPPDeclaration::ST_simple) { + if (type == nullptr || type->get_subtype() != CPPDeclaration::ST_simple) { continue; } @@ -2123,19 +2120,19 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { } YYSTYPE result; - if (instance != NULL) { + if (instance != nullptr) { result.u.expr = new CPPExpression(CPPExpression::literal(expr, instance)); return CPPToken(CUSTOM_LITERAL, loc, str, result); } - if ((token == REAL || token == INTEGER) && raw_instance != NULL) { + if ((token == REAL || token == INTEGER) && raw_instance != nullptr) { // For numeric constants, we can fall back to a raw literal operator. result.u.expr = new CPPExpression(CPPExpression::raw_literal(str, instance)); return CPPToken(CUSTOM_LITERAL, loc, str, result); } error(fgroup->_name + " has no suitable overload for literal of this type", loc); - result.u.expr = NULL; + result.u.expr = nullptr; return CPPToken(CUSTOM_LITERAL, loc, str, result); } @@ -2492,7 +2489,7 @@ get_number(int c) { loc.last_column = get_col_number(); YYSTYPE result; - result.u.integer = strtol(num.c_str(), (char **)NULL, 16); + result.u.integer = strtol(num.c_str(), nullptr, 16); return get_literal(INTEGER, loc, num, result); @@ -2511,7 +2508,7 @@ get_number(int c) { loc.last_column = get_col_number(); YYSTYPE result; - result.u.integer = strtol(bin.c_str(), (char **)NULL, 2); + result.u.integer = strtol(bin.c_str(), nullptr, 2); return get_literal(INTEGER, loc, bin, result); } @@ -2552,7 +2549,7 @@ get_number(int c) { loc.last_column = get_col_number(); YYSTYPE result; - result.u.real = pstrtod(num.c_str(), (char **)NULL); + result.u.real = (long double)pstrtod(num.c_str(), nullptr); return get_literal(REAL, loc, num, result); } @@ -2568,11 +2565,11 @@ get_number(int c) { // A leading zero implies an octal number. strtol() is supposed to be // able to make this distinction by itself, but we'll do it explicitly // just to be sure. - result.u.integer = strtol(num.c_str(), (char **)NULL, 8); + result.u.integer = strtol(num.c_str(), nullptr, 8); } else { // A decimal (base 10) integer. - result.u.integer = strtol(num.c_str(), (char **)NULL, 10); + result.u.integer = strtol(num.c_str(), nullptr, 10); } return get_literal(INTEGER, loc, num, result); @@ -2862,7 +2859,7 @@ bool CPPPreprocessor:: should_ignore_preprocessor() const { Files::const_iterator fi; for (fi = _files.begin(); fi != _files.end(); ++fi) { - if ((*fi)._ignore_manifest != NULL) { + if ((*fi)._ignore_manifest != nullptr) { return true; } } @@ -2960,7 +2957,7 @@ nested_parse_template_instantiation(CPPTemplateScope *scope) { indent(cerr, _files.size() * 2) << "Beginning nested parse\n"; #endif - assert(scope != NULL); + assert(scope != nullptr); State old_state = _state; int old_nesting = _paren_nesting; @@ -2994,7 +2991,7 @@ nested_parse_template_instantiation(CPPTemplateScope *scope) { // Parse a typename template parameter. _saved_tokens.push_back(CPPToken(START_TYPE)); CPPType *type = ::parse_type(this, current_scope, global_scope); - if (type == NULL) { + if (type == nullptr) { loc.last_line = get_line_number(); loc.last_column = get_col_number() - 1; warning("invalid type", loc); @@ -3011,7 +3008,7 @@ nested_parse_template_instantiation(CPPTemplateScope *scope) { // Parse a constant expression template parameter. _saved_tokens.push_back(CPPToken(START_CONST_EXPR)); CPPExpression *expr = parse_const_expr(this, current_scope, global_scope); - if (expr == NULL) { + if (expr == nullptr) { loc.last_line = get_line_number(); loc.last_column = get_col_number() - 1; warning("invalid expression", loc); diff --git a/dtool/src/cppparser/cppReferenceType.cxx b/dtool/src/cppparser/cppReferenceType.cxx index bbb1f1a50e..0b351c830e 100644 --- a/dtool/src/cppparser/cppReferenceType.cxx +++ b/dtool/src/cppparser/cppReferenceType.cxx @@ -114,7 +114,7 @@ is_constructible(const CPPType *given_type) const { const CPPType *b; CPPReferenceType *ref_type = ((CPPType *)given_type)->as_reference_type(); - if (ref_type != NULL) { + if (ref_type != nullptr) { if (ref_type->_value_category == VC_rvalue) { return is_constructible(ref_type->_pointing_at); } @@ -159,7 +159,7 @@ is_constructible(const CPPType *given_type) const { // Can initialize from derived class pointer. const CPPStructType *a_struct = a->as_struct_type(); const CPPStructType *b_struct = b->as_struct_type(); - if (a_struct != NULL && b_struct != NULL) { + if (a_struct != nullptr && b_struct != nullptr) { return a_struct->is_base_of(b_struct); } @@ -199,7 +199,7 @@ is_destructible() const { bool CPPReferenceType:: is_equivalent(const CPPType &other) const { const CPPReferenceType *ot = ((CPPType *)&other)->as_reference_type(); - if (ot == (CPPReferenceType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -261,7 +261,7 @@ as_reference_type() { bool CPPReferenceType:: is_equal(const CPPDeclaration *other) const { const CPPReferenceType *ot = ((CPPDeclaration *)other)->as_reference_type(); - assert(ot != NULL); + assert(ot != nullptr); return (_pointing_at == ot->_pointing_at) && (_value_category == ot->_value_category); @@ -275,7 +275,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPReferenceType:: is_less(const CPPDeclaration *other) const { const CPPReferenceType *ot = ((CPPDeclaration *)other)->as_reference_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_value_category != ot->_value_category) { return (_value_category < ot->_value_category); diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index a873cfa3cf..878daa8812 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -43,7 +43,7 @@ CPPScope(CPPScope *parent_scope, _parent_scope(parent_scope), _current_vis(starting_vis) { - _struct_type = NULL; + _struct_type = nullptr; _is_fully_specified = false; _fully_specified_known = false; _is_fully_specified_recursive_protect = false; @@ -111,7 +111,7 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, // that appeared preceding this particular declaration; they might be // relevant to the declaration. - if (decl->_leading_comment == (CPPCommentBlock *)NULL) { + if (decl->_leading_comment == nullptr) { decl->_leading_comment = preprocessor->get_comment_before(pos.first_line, pos.file); } @@ -151,13 +151,13 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { // We don't do redefinitions of typedefs. But we don't complain as long // as this is actually a typedef to the previous definition. if (other_type != type->_type && - (other_td == NULL || !other_td->_type->is_equivalent(*type->_type))) { + (other_td == nullptr || !other_td->_type->is_equivalent(*type->_type))) { - if (error_sink != NULL) { + if (error_sink != nullptr) { ostringstream errstr; - type->output(errstr, 0, NULL, false); + type->output(errstr, 0, nullptr, false); errstr << " has conflicting declaration as "; - other_type->output(errstr, 0, NULL, true); + other_type->output(errstr, 0, nullptr, true); error_sink->error(errstr.str(), type->_ident->_loc); error_sink->error("previous definition is here", other_td->_ident->_loc); @@ -185,7 +185,7 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { // incomplete, replace it. CPPDeclaration *old_templ = (*result.first).second; CPPType *old_templ_type = old_templ->as_type(); - if (old_templ_type == NULL || old_templ_type->is_incomplete()) { + if (old_templ_type == nullptr || old_templ_type->is_incomplete()) { // The previous template definition was incomplete, maybe a forward // reference; replace it with the good one. (*result.first).second = type; @@ -199,7 +199,7 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { */ void CPPScope:: define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { - assert(type != NULL); + assert(type != nullptr); string name = type->get_local_name(this); if (name.empty()) { return; @@ -239,13 +239,13 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { CPPExtensionType *other_ext = other_type->as_extension_type(); if (other_ext->_type != type->_type) { - if (error_sink != NULL) { + if (error_sink != nullptr) { ostringstream errstr; errstr << type->_type << " " << type->get_fully_scoped_name() << " was previously declared as " << other_ext->_type; error_sink->error(errstr.str(), type->_ident->_loc); - if (other_ext->_ident != NULL) { + if (other_ext->_ident != nullptr) { error_sink->error("previous declaration is here", other_ext->_ident->_loc); } @@ -258,20 +258,20 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { // Error out if the declaration is different than the previous one. if (other_type != type && - (other_td == NULL || other_td->_type != type)) { + (other_td == nullptr || other_td->_type != type)) { - if (error_sink != NULL) { + if (error_sink != nullptr) { ostringstream errstr; if (!cppparser_output_class_keyword) { errstr << type->_type << " "; } - type->output(errstr, 0, NULL, false); + type->output(errstr, 0, nullptr, false); errstr << " has conflicting definition as "; - other_type->output(errstr, 0, NULL, true); + other_type->output(errstr, 0, nullptr, true); error_sink->error(errstr.str(), type->_ident->_loc); CPPExtensionType *other_ext = other_type->as_extension_type(); - if (other_ext != NULL && other_ext->_ident != NULL) { + if (other_ext != nullptr && other_ext->_ident != nullptr) { error_sink->error("previous definition is here", other_ext->_ident->_loc); } @@ -297,7 +297,7 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { // incomplete, replace it. CPPDeclaration *old_templ = (*result.first).second; CPPType *old_templ_type = old_templ->as_type(); - if (old_templ_type == NULL || old_templ_type->is_incomplete()) { + if (old_templ_type == nullptr || old_templ_type->is_incomplete()) { // The previous template definition was incomplete, maybe a forward // reference; replace it with the good one. (*result.first).second = type; @@ -330,19 +330,19 @@ add_using(CPPUsing *using_decl, CPPScope *global_scope, if (using_decl->_full_namespace) { CPPScope *scope = using_decl->_ident->find_scope(this, global_scope); - if (scope != NULL) { + if (scope != nullptr) { _using.insert(scope); } else { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Attempt to use undefined namespace: " + using_decl->_ident->get_fully_scoped_name(), using_decl->_ident->_loc); } } } else { CPPDeclaration *decl = using_decl->_ident->find_symbol(this, global_scope); - if (decl != NULL) { + if (decl != nullptr) { handle_declaration(decl, global_scope, error_sink); } else { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Attempt to use unknown symbol: " + using_decl->_ident->get_fully_scoped_name(), using_decl->_ident->_loc); } } @@ -368,7 +368,7 @@ is_fully_specified() const { bool specified = true; - if (_parent_scope != NULL && !_parent_scope->is_fully_specified()) { + if (_parent_scope != nullptr && !_parent_scope->is_fully_specified()) { specified = false; } @@ -397,9 +397,9 @@ instantiate(const CPPTemplateParameterList *actual_params, CPPPreprocessor *error_sink) const { CPPScope *this_scope = (CPPScope *)this; - if (_parent_scope == NULL || - _parent_scope->as_template_scope() == NULL) { - if (error_sink != NULL) { + if (_parent_scope == nullptr || + _parent_scope->as_template_scope() == nullptr) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters for scope " + get_local_name()); } @@ -448,7 +448,7 @@ instantiate(const CPPTemplateParameterList *actual_params, ++pi) { CPPDeclaration *decl = (*pi); CPPClassTemplateParameter *ctp = decl->as_class_template_parameter(); - if (ctp != NULL) { + if (ctp != nullptr) { // CPPTypedefType *td = new CPPTypedefType(ctp, ctp->_ident); // scope->_typedefs.insert(Typedefs::value_type // (ctp->_ident->get_local_name(), td)); @@ -487,8 +487,8 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *rep = new CPPScope(current_scope, _name, V_public); bool anything_changed; - if (_parent_scope != NULL && - _parent_scope->as_template_scope() != NULL) { + if (_parent_scope != nullptr && + _parent_scope->as_template_scope() != nullptr) { // If the parent of this scope is a template scope--e.g. this scope has // template parameters--then we must first remove any of the template // parameters from the subst list. These will later get substituted @@ -529,31 +529,31 @@ find_type(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPType *type = (*ui)->find_type(name, false); - if (type != NULL) { + if (type != nullptr) { return type; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPType *type = st->_scope->find_type(name, false); - if (type != NULL) { + if (type != nullptr) { return type; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_type(name); } - return NULL; + return nullptr; } /** @@ -573,97 +573,105 @@ find_type(const string &name, CPPDeclaration::SubstDecl &subst, Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPType *type = (*ui)->find_type(name, subst, global_scope, false); - if (type != NULL) { + if (type != nullptr) { return type; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPType *type = st->_scope->find_type(name, subst, global_scope, false); - if (type != NULL) { + if (type != nullptr) { return type; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_type(name, subst, global_scope); } - return NULL; + return nullptr; } /** * */ CPPScope *CPPScope:: -find_scope(const string &name, bool recurse) const { +find_scope(const string &name, CPPScope *global_scope, bool recurse) const { Namespaces::const_iterator ni = _namespaces.find(name); if (ni != _namespaces.end()) { return (*ni).second->get_scope(); } - CPPType *type = (CPPType *)NULL; + CPPType *type = nullptr; Types::const_iterator ti; ti = _types.find(name); if (ti != _types.end()) { type = (*ti).second; - // Resolve if this is a typedef or const. + // Resolve if this is a typedef or const, or a TBD type. while (type->get_subtype() == CPPDeclaration::ST_const || - type->get_subtype() == CPPDeclaration::ST_typedef) { - if (type->as_typedef_type() != (CPPType *)NULL) { + type->get_subtype() == CPPDeclaration::ST_typedef || + type->get_subtype() == CPPDeclaration::ST_tbd) { + if (type->as_typedef_type() != nullptr) { type = type->as_typedef_type()->_type; - } else { + } else if (type->as_const_type() != nullptr) { type = type->as_const_type()->_wrapped_around; + } else { + CPPType *new_type = type->resolve_type((CPPScope *)this, global_scope); + if (new_type != type) { + type = new_type; + } else { + break; + } } } - } else if (_struct_type != NULL) { + } else if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { type = st->_scope->find_type(name, false); } } } - if (type != NULL) { + if (type != nullptr) { CPPStructType *st = type->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { return st->_scope; } CPPEnumType *et = type->as_enum_type(); - if (et != NULL) { + if (et != nullptr) { return et->_scope; } } Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { - CPPScope *scope = (*ui)->find_scope(name, false); - if (scope != NULL) { + CPPScope *scope = (*ui)->find_scope(name, global_scope, false); + if (scope != nullptr) { return scope; } } - if (recurse && _parent_scope != NULL) { - return _parent_scope->find_scope(name); + if (recurse && _parent_scope != nullptr) { + return _parent_scope->find_scope(name, global_scope); } - return (CPPScope *)NULL; + return nullptr; } /** @@ -673,14 +681,14 @@ CPPScope *CPPScope:: find_scope(const string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse) const { CPPType *type = find_type(name, subst, global_scope, recurse); - if (type == NULL) { - return NULL; + if (type == nullptr) { + return nullptr; } // Resolve if this is a typedef or const. while (type->get_subtype() == CPPDeclaration::ST_const || type->get_subtype() == CPPDeclaration::ST_typedef) { - if (type->as_typedef_type() != (CPPType *)NULL) { + if (type->as_typedef_type() != nullptr) { type = type->as_typedef_type()->_type; } else { type = type->as_const_type()->_wrapped_around; @@ -688,16 +696,16 @@ find_scope(const string &name, CPPDeclaration::SubstDecl &subst, } CPPStructType *st = type->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { return st->_scope; } CPPEnumType *et = type->as_enum_type(); - if (et != NULL) { + if (et != nullptr) { return et->_scope; } - return NULL; + return nullptr; } /** @@ -705,7 +713,7 @@ find_scope(const string &name, CPPDeclaration::SubstDecl &subst, */ CPPDeclaration *CPPScope:: find_symbol(const string &name, bool recurse) const { - if (_struct_type != NULL && name == get_simple_name()) { + if (_struct_type != nullptr && name == get_simple_name()) { return _struct_type; } @@ -735,31 +743,31 @@ find_symbol(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPDeclaration *decl = (*ui)->find_symbol(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPDeclaration *decl = st->_scope->find_symbol(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_symbol(name); } - return NULL; + return nullptr; } /** @@ -776,31 +784,31 @@ find_template(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPDeclaration *decl = (*ui)->find_template(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPDeclaration *decl = st->_scope->find_template(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_template(name); } - return NULL; + return nullptr; } /** @@ -827,7 +835,7 @@ get_local_name(CPPScope *scope) const { } */ - if (scope != NULL && _parent_scope != NULL/* && _parent_scope != scope*/) { + if (scope != nullptr && _parent_scope != nullptr/* && _parent_scope != scope*/) { string parent_scope_name = _parent_scope->get_local_name(scope); if (parent_scope_name.empty()) { return _name.get_name_with_templ(); @@ -851,7 +859,7 @@ get_fully_scoped_name() const { } */ - if (_parent_scope != NULL) { + if (_parent_scope != nullptr) { return _parent_scope->get_fully_scoped_name() + "::" + _name.get_name_with_templ(); } else { @@ -865,7 +873,7 @@ get_fully_scoped_name() const { void CPPScope:: output(ostream &out, CPPScope *scope) const { // out << get_local_name(scope); - if (_parent_scope != NULL && _parent_scope != scope) { + if (_parent_scope != nullptr && _parent_scope != scope) { _parent_scope->output(out, scope); out << "::"; } @@ -887,7 +895,7 @@ write(ostream &out, int indent_level, CPPScope *scope) const { } bool complete = false; - if (cd->as_type() != NULL || cd->as_namespace() != NULL) { + if (cd->as_type() != nullptr || cd->as_namespace() != nullptr) { complete = true; } @@ -906,10 +914,10 @@ get_template_scope() { if (as_template_scope()) { return as_template_scope(); } - if (_parent_scope != NULL) { + if (_parent_scope != nullptr) { return _parent_scope->get_template_scope(); } - return (CPPTemplateScope *)NULL; + return nullptr; } /** @@ -917,7 +925,7 @@ get_template_scope() { */ CPPTemplateScope *CPPScope:: as_template_scope() { - return (CPPTemplateScope *)NULL; + return nullptr; } /** @@ -933,9 +941,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope) const { bool anything_changed = false; - if (_struct_type != NULL) { - CPPScope *native_scope = (CPPScope *)NULL; - if (_struct_type->_ident != (CPPIdentifier *)NULL) { + if (_struct_type != nullptr) { + CPPScope *native_scope = nullptr; + if (_struct_type->_ident != nullptr) { native_scope = _struct_type->_ident->_native_scope; } to_scope->_struct_type = @@ -975,9 +983,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_structs.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -988,9 +996,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_classes.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -1001,9 +1009,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_unions.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -1014,9 +1022,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_enums.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -1028,7 +1036,7 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, string name = fgroup->_name; CPPFunctionGroup *&to_fgroup = to_scope->_functions[name]; - if (to_fgroup == (CPPFunctionGroup *)NULL) { + if (to_fgroup == nullptr) { to_fgroup = new CPPFunctionGroup(name); } @@ -1095,30 +1103,30 @@ void CPPScope:: handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPPreprocessor *error_sink) { CPPTypedefType *def = decl->as_typedef_type(); - if (def != NULL) { + if (def != nullptr) { define_typedef_type(def, error_sink); CPPExtensionType *et = def->_type->as_extension_type(); - if (et != NULL) { + if (et != nullptr) { define_extension_type(et, error_sink); } return; } CPPTypeDeclaration *typedecl = decl->as_type_declaration(); - if (typedecl != (CPPTypeDeclaration *)NULL) { + if (typedecl != nullptr) { CPPExtensionType *et = typedecl->_type->as_extension_type(); - if (et != NULL) { + if (et != nullptr) { define_extension_type(et, error_sink); } return; } CPPInstance *inst = decl->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { inst->check_for_constructor(this, global_scope); - if (inst->_ident != NULL) { + if (inst->_ident != nullptr) { // Not sure if this is the best place to assign this. However, this // fixes a bug with variables in expressions not having the proper // scoping prefix. ~rdb @@ -1153,7 +1161,7 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, // Don't add a new template definition if we already had one by the // same name in another scope. - if (find_template(name) == NULL) { + if (find_template(name) == nullptr) { _templates.insert(Templates::value_type(name, inst)); } @@ -1170,7 +1178,7 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, } CPPExtensionType *et = decl->as_extension_type(); - if (et != NULL) { + if (et != nullptr) { define_extension_type(et, error_sink); } } diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index dc8c7e0295..d7df06b481 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -63,19 +63,19 @@ public: const cppyyltype &pos); virtual void add_enum_value(CPPInstance *inst); virtual void define_typedef_type(CPPTypedefType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_extension_type(CPPExtensionType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_namespace(CPPNamespace *scope); virtual void add_using(CPPUsing *using_decl, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual bool is_fully_specified() const; CPPScope * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPScope * substitute_decl(CPPDeclaration::SubstDecl &subst, @@ -87,7 +87,8 @@ public: CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse = true) const; - CPPScope *find_scope(const string &name, bool recurse = true) const; + CPPScope *find_scope(const string &name, CPPScope *global_scope, + bool recurse = true) const; CPPScope *find_scope(const string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, @@ -98,7 +99,7 @@ public: bool recurse = true) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, CPPScope *scope) const; @@ -113,7 +114,7 @@ private: CPPScope *global_scope) const; void handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); public: typedef vector Declarations; @@ -159,7 +160,7 @@ private: inline ostream & operator << (ostream &out, const CPPScope &scope) { - scope.output(out, (CPPScope *)NULL); + scope.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppSimpleType.cxx b/dtool/src/cppparser/cppSimpleType.cxx index 8107e7ee24..321e76c3cd 100644 --- a/dtool/src/cppparser/cppSimpleType.cxx +++ b/dtool/src/cppparser/cppSimpleType.cxx @@ -74,7 +74,7 @@ is_constructible(const CPPType *given_type) const { given_type = ((CPPType *)given_type)->remove_reference()->remove_cv(); const CPPSimpleType *simple_type = given_type->as_simple_type(); - if (simple_type == NULL) { + if (simple_type == nullptr) { return given_type->is_enum() && is_arithmetic(); } else if (_type == T_nullptr) { return simple_type->_type == T_nullptr; @@ -250,7 +250,7 @@ as_simple_type() { bool CPPSimpleType:: is_equal(const CPPDeclaration *other) const { const CPPSimpleType *ot = ((CPPDeclaration *)other)->as_simple_type(); - assert(ot != NULL); + assert(ot != nullptr); return _type == ot->_type && _flags == ot->_flags; } @@ -263,7 +263,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPSimpleType:: is_less(const CPPDeclaration *other) const { const CPPSimpleType *ot = ((CPPDeclaration *)other)->as_simple_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_type != ot->_type) { return _type < ot->_type; diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index fda8feaa2b..25337642a0 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -82,15 +82,15 @@ operator = (const CPPStructType ©) { */ void CPPStructType:: append_derivation(CPPType *base, CPPVisibility vis, bool is_virtual) { - if (base != NULL) { + if (base != nullptr) { // Unwrap any typedefs, since we can't inherit from a typedef. CPPTypedefType *def = base->as_typedef_type(); - while (def != NULL) { + while (def != nullptr) { base = def->_type; def = base->as_typedef_type(); } - if (vis == V_unknown && base->as_extension_type() != NULL) { + if (vis == V_unknown && base->as_extension_type() != nullptr) { // Default visibility. if (base->as_extension_type()->_type == T_class) { vis = V_private; @@ -139,7 +139,7 @@ is_base_of(const CPPStructType *other) const { Derivation::const_iterator di; for (di = other->_derivation.begin(); di != other->_derivation.end(); ++di) { const CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && is_base_of(base)) { + if (base != nullptr && is_base_of(base)) { return true; } } @@ -165,7 +165,7 @@ is_empty() const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if ((*di)._is_virtual || (base != NULL && !base->is_empty())) { + if ((*di)._is_virtual || (base != nullptr && !base->is_empty())) { return false; } } @@ -174,7 +174,7 @@ is_empty() const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -206,7 +206,7 @@ is_polymorphic() const { */ bool CPPStructType:: is_standard_layout() const { - assert(_scope != NULL); + assert(_scope != nullptr); CPPVisibility member_vis = V_unknown; @@ -214,7 +214,7 @@ is_standard_layout() const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -222,7 +222,7 @@ is_standard_layout() const { } // Finally, check if the data member itself is standard layout. - assert(instance->_type != NULL); + assert(instance->_type != nullptr); if (!instance->_type->is_standard_layout()) { return false; } @@ -230,7 +230,7 @@ is_standard_layout() const { if (member_vis == V_unknown) { // The first non-static data member may not be a base class. CPPStructType *struct_type = instance->_type->remove_cv()->as_struct_type(); - if (struct_type != NULL && struct_type->is_base_of(this)) { + if (struct_type != nullptr && struct_type->is_base_of(this)) { return false; } member_vis = instance->_vis; @@ -274,32 +274,32 @@ is_trivial() const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if ((*di)._is_virtual || (base != NULL && !base->is_trivial())) { + if ((*di)._is_virtual || (base != nullptr && !base->is_trivial())) { return false; } } - assert(_scope != NULL); + assert(_scope != nullptr); // Make sure all members are trivial. CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. continue; } - if (instance->_initializer != NULL) { + if (instance->_initializer != nullptr) { // A member with an initializer means the default constructor would // assign a value. This means the type can't be trivial. return false; } // Finally, check if the data member itself is non-trivial. - assert(instance->_type != NULL); + assert(instance->_type != nullptr); if (!instance->_type->is_trivial()) { return false; } @@ -325,9 +325,9 @@ is_trivial() const { continue; } - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if (ftype->_flags & (CPPFunctionType::F_destructor | CPPFunctionType::F_move_constructor | @@ -370,7 +370,7 @@ is_constructible(const CPPType *given_type) const { CPPType *base_type = ((CPPType *)given_type)->remove_reference(); if (is_equivalent(*base_type->remove_cv())) { const CPPReferenceType *ref_type = given_type->as_reference_type(); - if (ref_type == NULL || + if (ref_type == nullptr || ref_type->_value_category == CPPReferenceType::VC_rvalue) { return is_move_constructible(V_public); } else { @@ -384,16 +384,16 @@ is_constructible(const CPPType *given_type) const { // Check for a different constructor. CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup != (CPPFunctionGroup *)NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator ii; for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); CPPParameterList *params = ftype->_parameters; if (params->_parameters.size() == 1 && !params->_includes_ellipsis) { @@ -464,7 +464,7 @@ is_default_constructible(CPPVisibility min_vis) const { } CPPInstance *constructor = get_default_constructor(); - if (constructor != (CPPInstance *)NULL) { + if (constructor != nullptr) { // It has a default constructor. if (constructor->_vis > min_vis) { // Inaccessible default constructor. @@ -480,7 +480,7 @@ is_default_constructible(CPPVisibility min_vis) const { } // Does it have constructors at all? If so, no implicit one is generated. - if (get_constructor() != (CPPFunctionGroup *)NULL) { + if (get_constructor() != nullptr) { return false; } @@ -489,7 +489,7 @@ is_default_constructible(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { if (!base->is_default_constructible(V_protected)) { return false; } @@ -500,14 +500,14 @@ is_default_constructible(CPPVisibility min_vis) const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. continue; } - if (instance->_initializer != (CPPExpression *)NULL) { + if (instance->_initializer != nullptr) { // It has a default value. continue; } @@ -530,7 +530,7 @@ is_copy_constructible(CPPVisibility min_vis) const { } CPPInstance *constructor = get_copy_constructor(); - if (constructor != (CPPInstance *)NULL) { + if (constructor != nullptr) { // It has a copy constructor. if (constructor->_vis > min_vis) { // Inaccessible copy constructor. @@ -546,7 +546,7 @@ is_copy_constructible(CPPVisibility min_vis) const { } CPPInstance *destructor = get_destructor(); - if (destructor != (CPPInstance *)NULL) { + if (destructor != nullptr) { if (destructor->_vis > min_vis) { // Inaccessible destructor. return false; @@ -563,7 +563,7 @@ is_copy_constructible(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { if (!base->is_copy_constructible(V_protected)) { return false; } @@ -574,7 +574,7 @@ is_copy_constructible(CPPVisibility min_vis) const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -595,7 +595,7 @@ is_copy_constructible(CPPVisibility min_vis) const { bool CPPStructType:: is_move_constructible(CPPVisibility min_vis) const { CPPInstance *constructor = get_move_constructor(); - if (constructor != (CPPInstance *)NULL) { + if (constructor != nullptr) { // It has a user-declared move constructor. if (constructor->_vis > min_vis) { // Inaccessible move constructor. @@ -624,7 +624,7 @@ is_move_constructible(CPPVisibility min_vis) const { bool CPPStructType:: is_copy_assignable(CPPVisibility min_vis) const { CPPInstance *assignment_operator = get_copy_assignment_operator(); - if (assignment_operator != (CPPInstance *)NULL) { + if (assignment_operator != nullptr) { // It has a copy assignment operator. if (assignment_operator->_vis > min_vis) { // Inaccessible copy assignment operator. @@ -653,7 +653,7 @@ is_copy_assignable(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { if (!base->is_copy_assignable(V_protected)) { return false; } @@ -664,7 +664,7 @@ is_copy_assignable(CPPVisibility min_vis) const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -686,7 +686,7 @@ is_copy_assignable(CPPVisibility min_vis) const { bool CPPStructType:: is_move_assignable(CPPVisibility min_vis) const { CPPInstance *assignment_operator = get_move_assignment_operator(); - if (assignment_operator != (CPPInstance *)NULL) { + if (assignment_operator != nullptr) { // It has a user-declared move assignment_operator. if (assignment_operator->_vis > min_vis) { // Inaccessible move assignment_operator. @@ -715,7 +715,7 @@ bool CPPStructType:: is_destructible(CPPVisibility min_vis) const { // Do we have an explicit destructor? CPPInstance *destructor = get_destructor(); - if (destructor != (CPPInstance *)NULL) { + if (destructor != nullptr) { if (destructor->_vis > min_vis) { // Yes, but it's inaccessible. return false; @@ -733,18 +733,18 @@ is_destructible(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && !base->is_destructible(V_protected)) { + if (base != nullptr && !base->is_destructible(V_protected)) { return false; } } - assert(_scope != NULL); + assert(_scope != nullptr); // Make sure all members are destructible. CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -752,7 +752,7 @@ is_destructible(CPPVisibility min_vis) const { } // If the data member is not destructible, no go. - assert(instance->_type != NULL); + assert(instance->_type != nullptr); if (!instance->_type->is_destructible()) { return false; } @@ -791,11 +791,11 @@ is_convertible_to(const CPPType *other) const { continue; } - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); - if (ftype->_return_type != NULL && + if (ftype->_return_type != nullptr && (ftype->_flags & CPPFunctionType::F_operator_typecast) != 0) { // Yes, this is a typecast operator. Test using the return type. if (ftype->_return_type->is_convertible_to(other)) { @@ -809,7 +809,7 @@ is_convertible_to(const CPPType *other) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && (*di)._vis <= V_public && !base->is_convertible_to(other)) { + if (base != nullptr && (*di)._vis <= V_public && !base->is_convertible_to(other)) { return true; } } @@ -845,7 +845,7 @@ check_virtual() const { bool CPPStructType:: has_virtual_destructor() const { CPPInstance *destructor = get_destructor(); - if (destructor != NULL) { + if (destructor != nullptr) { if (destructor->_storage_class & CPPInstance::SC_virtual) { return true; } @@ -854,7 +854,7 @@ has_virtual_destructor() const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && base->has_virtual_destructor()) { + if (base != nullptr && base->has_virtual_destructor()) { return true; } } @@ -869,7 +869,7 @@ has_virtual_destructor() const { */ bool CPPStructType:: is_fully_specified() const { - if (_scope != NULL && !_scope->is_fully_specified()) { + if (_scope != nullptr && !_scope->is_fully_specified()) { return false; } return CPPType::is_fully_specified(); @@ -895,7 +895,7 @@ get_constructor() const { if (fi != _scope->_functions.end()) { return fi->second; } else { - return (CPPFunctionGroup *)NULL; + return nullptr; } } @@ -906,8 +906,8 @@ get_constructor() const { CPPInstance *CPPStructType:: get_default_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -915,19 +915,19 @@ get_default_constructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if (ftype->_parameters->_parameters.size() == 0 || - ftype->_parameters->_parameters.front()->_initializer != NULL) { + ftype->_parameters->_parameters.front()->_initializer != nullptr) { // It takes 0 parameters (or all parameters have default values). return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -937,8 +937,8 @@ get_default_constructor() const { CPPInstance *CPPStructType:: get_copy_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -946,17 +946,17 @@ get_copy_constructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_copy_constructor) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -966,8 +966,8 @@ get_copy_constructor() const { CPPInstance *CPPStructType:: get_move_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -975,17 +975,17 @@ get_move_constructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_move_constructor) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1000,7 +1000,7 @@ get_assignment_operator() const { if (fi != _scope->_functions.end()) { return fi->second; } else { - return (CPPFunctionGroup *)NULL; + return nullptr; } } @@ -1011,8 +1011,8 @@ get_assignment_operator() const { CPPInstance *CPPStructType:: get_copy_assignment_operator() const { CPPFunctionGroup *fgroup = get_assignment_operator(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -1020,17 +1020,17 @@ get_copy_assignment_operator() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_copy_assignment_operator) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1040,8 +1040,8 @@ get_copy_assignment_operator() const { CPPInstance *CPPStructType:: get_move_assignment_operator() const { CPPFunctionGroup *fgroup = get_assignment_operator(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -1049,17 +1049,17 @@ get_move_assignment_operator() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_move_assignment_operator) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1082,10 +1082,10 @@ get_destructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { return inst; @@ -1094,7 +1094,7 @@ get_destructor() const { ++fi; } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1108,8 +1108,8 @@ instantiate(const CPPTemplateParameterList *actual_params, // I *think* this assertion is no longer valid. Who knows. // assert(!_incomplete); - if (_scope == NULL) { - if (error_sink != NULL) { + if (_scope == nullptr) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters for class " + get_local_name()); } @@ -1149,7 +1149,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { SubstDecl::const_iterator si = subst.find(this); if (si != subst.end()) { - assert((*si).second != NULL); + assert((*si).second != nullptr); return (*si).second; } @@ -1163,19 +1163,19 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, // type which we'll define later. CPPTypeProxy *proxy = new CPPTypeProxy; _proxies.push_back(proxy); - assert(proxy != NULL); + assert(proxy != nullptr); return proxy; } _subst_decl_recursive_protect = true; CPPStructType *rep = new CPPStructType(*this); - if (_ident != NULL) { + if (_ident != nullptr) { rep->_ident = _ident->substitute_decl(subst, current_scope, global_scope); } - if (_scope != NULL) { + if (_scope != nullptr) { rep->_scope = _scope->substitute_decl(subst, current_scope, global_scope); if (rep->_scope != _scope) { @@ -1185,14 +1185,14 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, // parameters into our identifier. CPPScope *pscope = rep->_scope->get_parent_scope(); - if (pscope != (CPPScope *)NULL && + if (pscope != nullptr && pscope->_name.has_templ()) { // If the struct name didn't have an explicit template reference // before, now it does. - if (_ident != NULL && !_ident->_names.empty() && !_ident->_names.back().has_templ()) { + if (_ident != nullptr && !_ident->_names.empty() && !_ident->_names.back().has_templ()) { if (rep->is_template()) { - rep->_template_scope = (CPPTemplateScope *)NULL; + rep->_template_scope = nullptr; CPPNameComponent nc(get_simple_name()); nc.set_templ(pscope->_name.get_templ()); rep->_ident = new CPPIdentifier(nc, _file); @@ -1227,9 +1227,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, (*pi)->_actual_type = rep; } - assert(rep != NULL); + assert(rep != nullptr); rep = CPPType::new_type(rep)->as_struct_type(); - assert(rep != NULL); + assert(rep != nullptr); if (rep != this) { _instantiations.insert(rep); } @@ -1241,7 +1241,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ void CPPStructType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (!complete && _ident != NULL) { + if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { out << _type << " "; @@ -1258,7 +1258,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { get_template_scope()->_parameters.write_formal(out, scope); indent(out, indent_level); } - if (_ident != NULL) { + if (_ident != nullptr) { out << _type << " " << _ident->get_local_name(scope); } else { out << _type; @@ -1316,7 +1316,7 @@ get_virtual_funcs(VFunctions &funcs) const { for (di = _derivation.begin(); di != _derivation.end(); ++di) { VFunctions vf; CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { base->get_virtual_funcs(vf); funcs.splice(funcs.end(), vf); } @@ -1331,9 +1331,9 @@ get_virtual_funcs(VFunctions &funcs) const { ++vfnext; CPPInstance *inst = (*vfi); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *base_ftype = inst->_type->as_function_type(); - assert(base_ftype != (CPPFunctionType *)NULL); + assert(base_ftype != nullptr); if (inst->_storage_class & CPPInstance::SC_deleted) { // Ignore deleted functions. @@ -1342,7 +1342,7 @@ get_virtual_funcs(VFunctions &funcs) const { // Match destructor-for-destructor; don't try to match destructors up by // name. CPPInstance *destructor = get_destructor(); - if (destructor != (CPPInstance *)NULL) { + if (destructor != nullptr) { // It's a match! This destructor is virtual. funcs.erase(vfi); destructor->_storage_class |= @@ -1365,10 +1365,10 @@ get_virtual_funcs(VFunctions &funcs) const { ii != fgroup->_instances.end() && !match_found; ++ii) { CPPInstance *new_inst = (*ii); - assert(new_inst->_type != (CPPType *)NULL); + assert(new_inst->_type != nullptr); CPPFunctionType *new_ftype = new_inst->_type->as_function_type(); - assert(new_ftype != (CPPFunctionType *)NULL); + assert(new_ftype != nullptr); if (new_ftype->match_virtual_override(*base_ftype)) { // It's a match! We now know it's virtual. Erase this function diff --git a/dtool/src/cppparser/cppStructType.h b/dtool/src/cppparser/cppStructType.h index 9da8777a6c..fc8a9e45b2 100644 --- a/dtool/src/cppparser/cppStructType.h +++ b/dtool/src/cppparser/cppStructType.h @@ -80,7 +80,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, diff --git a/dtool/src/cppparser/cppTBDType.cxx b/dtool/src/cppparser/cppTBDType.cxx index 0b01c86817..664787cbe6 100644 --- a/dtool/src/cppparser/cppTBDType.cxx +++ b/dtool/src/cppparser/cppTBDType.cxx @@ -35,7 +35,7 @@ CPPTBDType(CPPIdentifier *ident) : CPPType *CPPTBDType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *type = _ident->find_type(current_scope, global_scope); - if (type != NULL) { + if (type != nullptr) { return type; } return this; @@ -108,13 +108,13 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } rep = CPPType::new_type(rep)->as_tbd_type(); - assert(rep != NULL); + assert(rep != nullptr); CPPType *result = rep; // Can we now define it as a real type? CPPType *type = rep->_ident->find_type(current_scope, global_scope, subst); - if (type != NULL) { + if (type != nullptr) { result = type; } @@ -156,7 +156,7 @@ as_tbd_type() { bool CPPTBDType:: is_equal(const CPPDeclaration *other) const { const CPPTBDType *ot = ((CPPDeclaration *)other)->as_tbd_type(); - assert(ot != NULL); + assert(ot != nullptr); return (*_ident) == (*ot->_ident); } @@ -169,7 +169,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPTBDType:: is_less(const CPPDeclaration *other) const { const CPPTBDType *ot = ((CPPDeclaration *)other)->as_tbd_type(); - assert(ot != NULL); + assert(ot != nullptr); return (*_ident) < (*ot->_ident); } diff --git a/dtool/src/cppparser/cppTBDType.h b/dtool/src/cppparser/cppTBDType.h index 6d35f053f4..f72833e3ff 100644 --- a/dtool/src/cppparser/cppTBDType.h +++ b/dtool/src/cppparser/cppTBDType.h @@ -36,7 +36,7 @@ public: virtual bool is_tbd() const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, diff --git a/dtool/src/cppparser/cppTemplateParameterList.cxx b/dtool/src/cppparser/cppTemplateParameterList.cxx index 54d4ae544c..24ee70e9e4 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.cxx +++ b/dtool/src/cppparser/cppTemplateParameterList.cxx @@ -65,7 +65,7 @@ build_subst_decl(const CPPTemplateParameterList &formal_params, if (decl->as_instance()) { // A value template parameter. Its default is an expression. CPPInstance *inst = decl->as_instance(); - if (inst->_initializer != NULL) { + if (inst->_initializer != nullptr) { CPPDeclaration *decl = inst->_initializer->substitute_decl(subst, current_scope, global_scope); @@ -77,7 +77,7 @@ build_subst_decl(const CPPTemplateParameterList &formal_params, } else if (decl->as_class_template_parameter()) { // A class template parameter. CPPClassTemplateParameter *cparam = decl->as_class_template_parameter(); - if (cparam->_default_type != NULL) { + if (cparam->_default_type != nullptr) { CPPDeclaration *decl = cparam->_default_type->substitute_decl(subst, current_scope, global_scope); @@ -116,12 +116,12 @@ bool CPPTemplateParameterList:: is_tbd() const { for (int i = 0; i < (int)_parameters.size(); ++i) { CPPType *type = _parameters[i]->as_type(); - if (type != (CPPType *)NULL && - (type->is_tbd() || type->as_class_template_parameter() != NULL)) { + if (type != nullptr && + (type->is_tbd() || type->as_class_template_parameter() != nullptr)) { return true; } CPPExpression *expr = _parameters[i]->as_expression(); - if (expr != NULL && expr->is_tbd()) { + if (expr != nullptr && expr->is_tbd()) { return true; } } diff --git a/dtool/src/cppparser/cppTemplateParameterList.h b/dtool/src/cppparser/cppTemplateParameterList.h index 712dd227cd..50b97247ea 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.h +++ b/dtool/src/cppparser/cppTemplateParameterList.h @@ -58,7 +58,7 @@ public: inline ostream & operator << (ostream &out, const CPPTemplateParameterList &plist) { - plist.output(out, (CPPScope *)NULL); + plist.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppTemplateScope.cxx b/dtool/src/cppparser/cppTemplateScope.cxx index 2960718205..34482ad64b 100644 --- a/dtool/src/cppparser/cppTemplateScope.cxx +++ b/dtool/src/cppparser/cppTemplateScope.cxx @@ -35,7 +35,7 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPPreprocessor *preprocessor, const cppyyltype &pos) { decl->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->add_declaration(decl, global_scope, preprocessor, pos); } @@ -45,7 +45,7 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, void CPPTemplateScope:: add_enum_value(CPPInstance *inst) { inst->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->add_enum_value(inst); } @@ -55,7 +55,7 @@ add_enum_value(CPPInstance *inst) { void CPPTemplateScope:: define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { type->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->define_typedef_type(type, error_sink); } @@ -65,7 +65,7 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { void CPPTemplateScope:: define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { type->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->define_extension_type(type, error_sink); } @@ -74,7 +74,7 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { */ void CPPTemplateScope:: define_namespace(CPPNamespace *scope) { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->define_namespace(scope); } @@ -84,7 +84,7 @@ define_namespace(CPPNamespace *scope) { void CPPTemplateScope:: add_using(CPPUsing *using_decl, CPPScope *global_scope, CPPPreprocessor *error_sink) { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->add_using(using_decl, global_scope, error_sink); } @@ -95,16 +95,16 @@ void CPPTemplateScope:: add_template_parameter(CPPDeclaration *param) { _parameters._parameters.push_back(param); CPPClassTemplateParameter *cl = param->as_class_template_parameter(); - if (cl != NULL) { + if (cl != nullptr) { // Create an implicit typedef for this class parameter. - if (cl->_ident != NULL) { + if (cl->_ident != nullptr) { string name = cl->_ident->get_local_name(); _types[name] = cl; } } CPPInstance *inst = param->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { // Register the variable for this value parameter. string name = inst->get_local_name(); if (!name.empty()) { @@ -128,7 +128,7 @@ is_fully_specified() const { */ string CPPTemplateScope:: get_simple_name() const { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); return _parent_scope->get_simple_name(); } @@ -137,7 +137,7 @@ get_simple_name() const { */ string CPPTemplateScope:: get_local_name(CPPScope *scope) const { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); return _parent_scope->get_local_name(scope); } @@ -146,7 +146,7 @@ get_local_name(CPPScope *scope) const { */ string CPPTemplateScope:: get_fully_scoped_name() const { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); return _parent_scope->get_fully_scoped_name(); } diff --git a/dtool/src/cppparser/cppTemplateScope.h b/dtool/src/cppparser/cppTemplateScope.h index 91235ff0fe..0cd987145e 100644 --- a/dtool/src/cppparser/cppTemplateScope.h +++ b/dtool/src/cppparser/cppTemplateScope.h @@ -35,17 +35,17 @@ public: const cppyyltype &pos); virtual void add_enum_value(CPPInstance *inst); virtual void define_typedef_type(CPPTypedefType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_extension_type(CPPExtensionType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_namespace(CPPNamespace *scope); virtual void add_using(CPPUsing *using_decl, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual bool is_fully_specified() const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, CPPScope *scope) const; diff --git a/dtool/src/cppparser/cppToken.cxx b/dtool/src/cppparser/cppToken.cxx index d2e00982dc..8504150bbd 100644 --- a/dtool/src/cppparser/cppToken.cxx +++ b/dtool/src/cppparser/cppToken.cxx @@ -357,7 +357,7 @@ output(ostream &out) const { break; case KW_OPERATOR: - if (_lval.u.identifier != NULL) { + if (_lval.u.identifier != nullptr) { out << *_lval.u.identifier << "::"; } out << "KW_OPERATOR"; diff --git a/dtool/src/cppparser/cppType.cxx b/dtool/src/cppparser/cppType.cxx index af3f511da4..26581c7205 100644 --- a/dtool/src/cppparser/cppType.cxx +++ b/dtool/src/cppparser/cppType.cxx @@ -36,7 +36,7 @@ CPPType:: CPPType(const CPPFile &file) : CPPDeclaration(file) { - _declaration = (CPPTypeDeclaration *)NULL; + _declaration = nullptr; // This is set true by interrogate when the "forcetype" keyword is used. _forcetype = false; @@ -143,11 +143,11 @@ is_parameter_expr() const { bool CPPType:: is_enum() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_enum(); } const CPPExtensionType *ext_type = as_extension_type(); - if (ext_type != NULL) { + if (ext_type != nullptr) { return ext_type->_type == CPPExtensionType::T_enum || ext_type->_type == CPPExtensionType::T_enum_struct || ext_type->_type == CPPExtensionType::T_enum_class; @@ -161,7 +161,7 @@ is_enum() const { bool CPPType:: is_const() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_const(); } return get_subtype() == ST_const; @@ -173,7 +173,7 @@ is_const() const { bool CPPType:: is_reference() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_reference(); } return get_subtype() == ST_reference; @@ -186,11 +186,11 @@ is_reference() const { bool CPPType:: is_pointer() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_pointer(); } const CPPConstType *const_type = as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return const_type->_wrapped_around->is_pointer(); } return get_subtype() == ST_pointer; @@ -203,7 +203,7 @@ is_pointer() const { CPPType *CPPType:: remove_const() { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { CPPType *unwrapped = td_type->_type->remove_const(); if (unwrapped != td_type->_type) { return unwrapped; @@ -212,7 +212,7 @@ remove_const() { } } const CPPConstType *const_type = as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return const_type->_wrapped_around->remove_const(); } return this; @@ -224,7 +224,7 @@ remove_const() { CPPType *CPPType:: remove_reference() { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { CPPType *unwrapped = td_type->_type->remove_reference(); if (unwrapped != td_type->_type) { return unwrapped; @@ -233,7 +233,7 @@ remove_reference() { } } const CPPReferenceType *ref_type = as_reference_type(); - if (ref_type != NULL) { + if (ref_type != nullptr) { return ref_type->_pointing_at; } return this; diff --git a/dtool/src/cppparser/cppType.h b/dtool/src/cppparser/cppType.h index a312f45d33..1bf89db2f5 100644 --- a/dtool/src/cppparser/cppType.h +++ b/dtool/src/cppparser/cppType.h @@ -68,10 +68,10 @@ public: CPPType *remove_pointer(); bool has_typedef_name() const; - string get_typedef_name(CPPScope *scope = NULL) const; + string get_typedef_name(CPPScope *scope = nullptr) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual string get_preferred_name() const; int get_num_alt_names() const; diff --git a/dtool/src/cppparser/cppTypeDeclaration.cxx b/dtool/src/cppparser/cppTypeDeclaration.cxx index 88509911b4..23c72cd2d0 100644 --- a/dtool/src/cppparser/cppTypeDeclaration.cxx +++ b/dtool/src/cppparser/cppTypeDeclaration.cxx @@ -18,10 +18,10 @@ */ CPPTypeDeclaration:: CPPTypeDeclaration(CPPType *type) : - CPPInstance(type, (CPPIdentifier *)NULL) + CPPInstance(type, nullptr) { - assert(_type != NULL); - if (_type->_declaration == (CPPTypeDeclaration *)NULL) { + assert(_type != nullptr); + if (_type->_declaration == nullptr) { _type->_declaration = this; } } @@ -34,11 +34,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { CPPDeclaration *decl = CPPInstance::substitute_decl(subst, current_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); if (decl->as_type_declaration()) { return decl; } - assert(decl->as_instance() != NULL); + assert(decl->as_instance() != nullptr); return new CPPTypeDeclaration(decl->as_instance()->_type); } diff --git a/dtool/src/cppparser/cppTypeParser.cxx b/dtool/src/cppparser/cppTypeParser.cxx index 815875dcf9..b88a1a079d 100644 --- a/dtool/src/cppparser/cppTypeParser.cxx +++ b/dtool/src/cppparser/cppTypeParser.cxx @@ -22,7 +22,7 @@ CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope) : _current_scope(current_scope), _global_scope(global_scope) { - _type = NULL; + _type = nullptr; } /** @@ -69,7 +69,7 @@ parse_type(const string &type, const CPPPreprocessor &filepos) { */ void CPPTypeParser:: output(ostream &out) const { - if (_type == NULL) { + if (_type == nullptr) { out << "(null type)"; } else { out << *_type; diff --git a/dtool/src/cppparser/cppTypeProxy.cxx b/dtool/src/cppparser/cppTypeProxy.cxx index 239ef04828..fe6bfb7c05 100644 --- a/dtool/src/cppparser/cppTypeProxy.cxx +++ b/dtool/src/cppparser/cppTypeProxy.cxx @@ -21,7 +21,7 @@ CPPTypeProxy:: CPPTypeProxy() : CPPType(CPPFile()) { - _actual_type = (CPPType *)NULL; + _actual_type = nullptr; } /** @@ -31,7 +31,7 @@ CPPTypeProxy() : */ CPPType *CPPTypeProxy:: resolve_type(CPPScope *, CPPScope *) { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return this; } return _actual_type; @@ -44,7 +44,7 @@ resolve_type(CPPScope *, CPPScope *) { */ bool CPPTypeProxy:: is_tbd() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return false; } return _actual_type->is_tbd(); @@ -57,7 +57,7 @@ is_tbd() const { */ bool CPPTypeProxy:: has_typedef_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return false; } return _actual_type->has_typedef_name(); @@ -69,7 +69,7 @@ has_typedef_name() const { */ string CPPTypeProxy:: get_typedef_name(CPPScope *) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return string(); } return _actual_type->get_typedef_name(); @@ -83,7 +83,7 @@ get_typedef_name(CPPScope *) const { */ string CPPTypeProxy:: get_simple_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_simple_name(); @@ -95,7 +95,7 @@ get_simple_name() const { */ string CPPTypeProxy:: get_local_name(CPPScope *scope) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_local_name(scope); @@ -107,7 +107,7 @@ get_local_name(CPPScope *scope) const { */ string CPPTypeProxy:: get_fully_scoped_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_fully_scoped_name(); @@ -121,7 +121,7 @@ get_fully_scoped_name() const { */ string CPPTypeProxy:: get_preferred_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_preferred_name(); @@ -132,7 +132,7 @@ get_preferred_name() const { */ bool CPPTypeProxy:: is_incomplete() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return true; } return _actual_type->is_incomplete(); @@ -147,7 +147,7 @@ void CPPTypeProxy:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, const string &name) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { out << "unknown " << prename << name; return; } @@ -160,7 +160,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, */ void CPPTypeProxy:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { out << "unknown"; return; } @@ -181,7 +181,7 @@ get_subtype() const { */ CPPType *CPPTypeProxy:: as_type() { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return this; } return _actual_type; @@ -192,8 +192,8 @@ as_type() { */ CPPSimpleType *CPPTypeProxy:: as_simple_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPSimpleType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_simple_type(); } @@ -203,8 +203,8 @@ as_simple_type() { */ CPPPointerType *CPPTypeProxy:: as_pointer_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPPointerType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_pointer_type(); } @@ -214,8 +214,8 @@ as_pointer_type() { */ CPPReferenceType *CPPTypeProxy:: as_reference_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPReferenceType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_reference_type(); } @@ -225,8 +225,8 @@ as_reference_type() { */ CPPArrayType *CPPTypeProxy:: as_array_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPArrayType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_array_type(); } @@ -236,8 +236,8 @@ as_array_type() { */ CPPConstType *CPPTypeProxy:: as_const_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPConstType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_const_type(); } @@ -247,8 +247,8 @@ as_const_type() { */ CPPFunctionType *CPPTypeProxy:: as_function_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPFunctionType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_function_type(); } @@ -258,8 +258,8 @@ as_function_type() { */ CPPExtensionType *CPPTypeProxy:: as_extension_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPExtensionType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_extension_type(); } @@ -269,8 +269,8 @@ as_extension_type() { */ CPPStructType *CPPTypeProxy:: as_struct_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPStructType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_struct_type(); } @@ -280,8 +280,8 @@ as_struct_type() { */ CPPEnumType *CPPTypeProxy:: as_enum_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPEnumType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_enum_type(); } @@ -291,8 +291,8 @@ as_enum_type() { */ CPPTBDType *CPPTypeProxy:: as_tbd_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPTBDType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_tbd_type(); } @@ -302,8 +302,8 @@ as_tbd_type() { */ CPPTypedefType *CPPTypeProxy:: as_typedef_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPTypedefType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_typedef_type(); } diff --git a/dtool/src/cppparser/cppTypeProxy.h b/dtool/src/cppparser/cppTypeProxy.h index da87e99ca6..fcd2ebe178 100644 --- a/dtool/src/cppparser/cppTypeProxy.h +++ b/dtool/src/cppparser/cppTypeProxy.h @@ -33,10 +33,10 @@ public: virtual bool is_tbd() const; bool has_typedef_name() const; - string get_typedef_name(CPPScope *scope = NULL) const; + string get_typedef_name(CPPScope *scope = nullptr) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual string get_preferred_name() const; diff --git a/dtool/src/cppparser/cppTypedefType.cxx b/dtool/src/cppparser/cppTypedefType.cxx index d965d5db48..32d4c55865 100644 --- a/dtool/src/cppparser/cppTypedefType.cxx +++ b/dtool/src/cppparser/cppTypedefType.cxx @@ -27,7 +27,7 @@ CPPTypedefType(CPPType *type, const string &name, CPPScope *current_scope) : _ident(new CPPIdentifier(name)), _using(false) { - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } @@ -47,7 +47,7 @@ CPPTypedefType(CPPType *type, CPPIdentifier *ident, CPPScope *current_scope) : _ident(ident), _using(false) { - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } _subst_decl_recursive_protect = false; @@ -64,13 +64,13 @@ CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, CPPType(file), _using(false) { - assert(ii != NULL); + assert(ii != nullptr); _type = ii->unroll_type(type); _ident = ii->_ident; - ii->_ident = NULL; + ii->_ident = nullptr; delete ii; - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } @@ -82,7 +82,7 @@ CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, */ bool CPPTypedefType:: is_scoped() const { - if (_ident == NULL) { + if (_ident == nullptr) { return false; } else { return _ident->is_scoped(); @@ -95,7 +95,7 @@ is_scoped() const { CPPScope *CPPTypedefType:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { - if (_ident == NULL) { + if (_ident == nullptr) { return current_scope; } else { return _ident->get_scope(current_scope, global_scope, error_sink); @@ -107,7 +107,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, */ string CPPTypedefType:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_simple_name(); @@ -118,7 +118,7 @@ get_simple_name() const { */ string CPPTypedefType:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_local_name(scope); @@ -129,7 +129,7 @@ get_local_name(CPPScope *scope) const { */ string CPPTypedefType:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_fully_scoped_name(); @@ -151,7 +151,7 @@ is_incomplete() const { */ bool CPPTypedefType:: is_tbd() const { - if (_ident != NULL && _ident->is_tbd()) { + if (_ident != nullptr && _ident->is_tbd()) { return true; } return _type->is_tbd(); @@ -228,7 +228,7 @@ is_destructible() const { */ bool CPPTypedefType:: is_fully_specified() const { - if (_ident != NULL && !_ident->is_fully_specified()) { + if (_ident != nullptr && !_ident->is_fully_specified()) { return false; } return CPPDeclaration::is_fully_specified() && @@ -253,7 +253,7 @@ CPPDeclaration *CPPTypedefType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { - if (_ident != NULL && _ident->get_scope(current_scope, global_scope) == global_scope) { + if (_ident != nullptr && _ident->get_scope(current_scope, global_scope) == global_scope) { // Hack... I know that size_t etc is supposed to work fine, so preserve // these top-level typedefs. CPPDeclaration *top = @@ -375,7 +375,7 @@ is_equivalent(const CPPType &other) const { void CPPTypedefType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { string name; - if (_ident != NULL) { + if (_ident != nullptr) { name = _ident->get_local_name(scope); } @@ -420,7 +420,7 @@ as_typedef_type() { bool CPPTypedefType:: is_equal(const CPPDeclaration *other) const { const CPPTypedefType *ot = ((CPPDeclaration *)other)->as_typedef_type(); - assert(ot != NULL); + assert(ot != nullptr); return (*_type == *ot->_type) && (*_ident == *ot->_ident) && (_using == ot->_using); } diff --git a/dtool/src/cppparser/cppTypedefType.h b/dtool/src/cppparser/cppTypedefType.h index 04a9b05995..d3a3ea3245 100644 --- a/dtool/src/cppparser/cppTypedefType.h +++ b/dtool/src/cppparser/cppTypedefType.h @@ -34,10 +34,10 @@ public: bool is_scoped() const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual bool is_incomplete() const; @@ -56,7 +56,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, diff --git a/dtool/src/dconfig/dconfig.I b/dtool/src/dconfig/dconfig.I index a49d57cd2c..0497ffc067 100644 --- a/dtool/src/dconfig/dconfig.I +++ b/dtool/src/dconfig/dconfig.I @@ -25,7 +25,7 @@ GetInt(const string &sym, int def) { float DConfig:: GetFloat(const string &sym, float def) { - ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); + ConfigVariableDouble var(sym, (double)def, "DConfig", ConfigFlags::F_dconfig); return (float)var.get_value(); } diff --git a/dtool/src/dtoolbase/deletedBufferChain.I b/dtool/src/dtoolbase/deletedBufferChain.I index 7f6a003f64..9eb17bd4fb 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.I +++ b/dtool/src/dtoolbase/deletedBufferChain.I @@ -21,7 +21,7 @@ INLINE bool DeletedBufferChain:: validate(void *ptr) { TAU_PROFILE("bool DeletedBufferChain::validate(void *)", " ", TAU_USER); - if (ptr == (void *)NULL) { + if (ptr == nullptr) { return false; } diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index 71756f3e25..303c9f1223 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -20,7 +20,7 @@ */ DeletedBufferChain:: DeletedBufferChain(size_t buffer_size) { - _deleted_chain = NULL; + _deleted_chain = nullptr; _buffer_size = buffer_size; // We must allocate at least this much space for bookkeeping reasons. @@ -44,7 +44,7 @@ allocate(size_t size, TypeHandle type_handle) { ObjectNode *obj; _lock.lock(); - if (_deleted_chain != (ObjectNode *)NULL) { + if (_deleted_chain != nullptr) { obj = _deleted_chain; _deleted_chain = _deleted_chain->_next; _lock.unlock(); @@ -103,7 +103,7 @@ deallocate(void *ptr, TypeHandle type_handle) { #ifdef USE_DELETED_CHAIN // TAU_PROFILE("void DeletedBufferChain::deallocate(void *, TypeHandle)", " // ", TAU_USER); - assert(ptr != (void *)NULL); + assert(ptr != nullptr); #ifdef DO_MEMORY_USAGE const size_t alloc_size = _buffer_size + flag_reserved_bytes + MEMORY_HOOK_ALIGNMENT - 1; diff --git a/dtool/src/dtoolbase/deletedChain.h b/dtool/src/dtoolbase/deletedChain.h index a25be5d429..1915223450 100644 --- a/dtool/src/dtoolbase/deletedChain.h +++ b/dtool/src/dtoolbase/deletedChain.h @@ -122,11 +122,11 @@ public: #define ALLOC_DELETED_CHAIN(Type) \ inline static bool validate_ptr(const void *ptr) { \ - return (ptr != NULL); \ + return (ptr != nullptr); \ } #define ALLOC_DELETED_CHAIN_DECL(Type) \ inline static bool validate_ptr(const void *ptr) { \ - return (ptr != NULL); \ + return (ptr != nullptr); \ } #define ALLOC_DELETED_CHAIN_DEF(Type) diff --git a/dtool/src/dtoolbase/dtoolbase.cxx b/dtool/src/dtoolbase/dtoolbase.cxx index 64b7425057..10d1790ccf 100644 --- a/dtool/src/dtoolbase/dtoolbase.cxx +++ b/dtool/src/dtoolbase/dtoolbase.cxx @@ -36,7 +36,7 @@ MemoryHook *memory_hook; */ void init_memory_hook() { - if (memory_hook == NULL) { + if (memory_hook == nullptr) { memory_hook = new MemoryHook; } } diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 3f8e07f998..1614d05cfd 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -73,10 +73,10 @@ // 'assume at least one of the cases is always true') #ifdef _DEBUG #define NODEFAULT default: assert(0); break; -#elif defined(_MSC_VER) -#define NODEFAULT default: __assume(0); // special VC keyword #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __has_builtin(__builtin_unreachable) #define NODEFAULT default: __builtin_unreachable(); +#elif defined(_MSC_VER) +#define NODEFAULT default: __assume(0); // special VC keyword #else #define NODEFAULT #endif @@ -123,7 +123,7 @@ // This is a workaround for a glibc bug that is triggered by clang when // compiling with -ffast-math. -#ifdef __clang__ +#if defined(__clang__) && defined(__GLIBC__) #include #ifndef __extern_always_inline #define __extern_always_inline extern __always_inline diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 98bf992cf9..db12cc8737 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -33,13 +33,13 @@ #ifdef CPPPARSER #include +#include #include - -using namespace std; +#include +#include #define INLINE inline #define ALWAYS_INLINE inline -#define TYPENAME typename #define MOVE(x) x #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) @@ -78,25 +78,7 @@ typedef int ios_seekdir; #include #include - -using namespace std; - -#define TYPENAME typename - -#ifndef HAVE_WCHAR_T -// Some C++ libraries (os x 3.1) don't define this. -typedef unsigned short wchar_t; -#endif - -#ifndef HAVE_WSTRING -// Some C++ libraries (gcc 2.95) don't define this. -typedef basic_string wstring; -#endif - -#ifndef HAVE_STREAMSIZE -// Some C++ libraries (Irix) don't define this. -typedef long streamsize; -#endif +#include #ifndef HAVE_IOS_TYPEDEFS typedef int ios_openmode; @@ -105,10 +87,10 @@ typedef int ios_iostate; // Old iostream libraries used ios::seek_dir instead of ios::seekdir. typedef ios::seek_dir ios_seekdir; #else -typedef ios::openmode ios_openmode; -typedef ios::fmtflags ios_fmtflags; -typedef ios::iostate ios_iostate; -typedef ios::seekdir ios_seekdir; +typedef std::ios::openmode ios_openmode; +typedef std::ios::fmtflags ios_fmtflags; +typedef std::ios::iostate ios_iostate; +typedef std::ios::seekdir ios_seekdir; #endif // Apple has an outdated libstdc++. Not all is lost, though, as we can fill @@ -176,6 +158,36 @@ namespace std { #endif // CPPPARSER +// This was previously `using namespace std`, but we don't want to pull in the +// entire namespace, so we enumerate the things we are using without std:: +// prefix in the Panda headers. It is intended that this list will shrink. +using std::cerr; +using std::cin; +using std::cout; +using std::dec; +using std::endl; +using std::hex; +using std::ios; +using std::iostream; +using std::istream; +using std::istringstream; +using std::max; +using std::min; +using std::move; +using std::ostream; +using std::ostringstream; +using std::pair; +using std::setfill; +using std::setw; +using std::streambuf; +using std::streamoff; +using std::streampos; +using std::streamsize; +using std::string; +using std::stringstream; +using std::swap; +using std::wstring; + // The ReferenceCount class is defined later, within Panda, but we need to // pass around forward references to it here at the very low level. class ReferenceCount; diff --git a/dtool/src/dtoolbase/epvector.h b/dtool/src/dtoolbase/epvector.h index c3c650d015..78db158f39 100644 --- a/dtool/src/dtoolbase/epvector.h +++ b/dtool/src/dtoolbase/epvector.h @@ -39,7 +39,7 @@ class epvector : public vector > { public: typedef Eigen::aligned_allocator allocator; typedef vector base_class; - typedef TYPENAME base_class::size_type size_type; + typedef typename base_class::size_type size_type; epvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator()) { } epvector(const epvector ©) : base_class(copy) { } diff --git a/dtool/src/dtoolbase/fakestringstream.h b/dtool/src/dtoolbase/fakestringstream.h index 4ff2a971f0..7132d6280e 100644 --- a/dtool/src/dtoolbase/fakestringstream.h +++ b/dtool/src/dtoolbase/fakestringstream.h @@ -18,8 +18,6 @@ #include #include -using namespace std; - class fake_istream_buffer { public: fake_istream_buffer() { diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 710ea9e65f..82ee8dc037 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -216,12 +216,12 @@ MemoryHook() { */ MemoryHook:: MemoryHook(const MemoryHook ©) : - _page_size(copy._page_size), _total_heap_single_size(copy._total_heap_single_size), _total_heap_array_size(copy._total_heap_array_size), _requested_heap_size(copy._requested_heap_size), _total_mmap_size(copy._total_mmap_size), - _max_heap_size(copy._max_heap_size) { + _max_heap_size(copy._max_heap_size), + _page_size(copy._page_size) { copy._lock.lock(); _deleted_chains = copy._deleted_chains; @@ -256,7 +256,7 @@ heap_alloc_single(size_t size) { void *alloc = call_malloc(inflated_size); #endif - while (alloc == (void *)NULL) { + while (alloc == nullptr) { alloc_fail(inflated_size); #ifdef MEMORY_HOOK_MALLOC_LOCK _lock.lock(); @@ -333,7 +333,7 @@ heap_alloc_array(size_t size) { void *alloc = call_malloc(inflated_size); #endif - while (alloc == (void *)NULL) { + while (alloc == nullptr) { alloc_fail(inflated_size); #ifdef MEMORY_HOOK_MALLOC_LOCK _lock.lock(); @@ -387,7 +387,7 @@ heap_realloc_array(void *ptr, size_t size) { alloc1 = call_realloc(alloc1, inflated_size); #endif - while (alloc1 == (void *)NULL) { + while (alloc1 == nullptr) { alloc_fail(inflated_size); // Recover the original pointer. @@ -517,16 +517,16 @@ mmap_alloc(size_t size, bool allow_exec) { #ifdef WIN32 // Windows case. - void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, + void *ptr = VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, allow_exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE); - if (ptr == (void *)NULL) { + if (ptr == nullptr) { DWORD err = GetLastError(); cerr << "Couldn't allocate memory page of size " << size << ": "; PVOID buffer; DWORD length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, err, 0, (LPTSTR)&buffer, 0, NULL); + nullptr, err, 0, (LPTSTR)&buffer, 0, nullptr); if (length != 0) { cerr << (char *)buffer << "\n"; } else { @@ -545,7 +545,7 @@ mmap_alloc(size_t size, bool allow_exec) { if (allow_exec) { prot |= PROT_EXEC; } - void *ptr = mmap(NULL, size, prot, MAP_PRIVATE | MAP_ANON, -1, 0); + void *ptr = mmap(nullptr, size, prot, MAP_PRIVATE | MAP_ANON, -1, 0); if (ptr == (void *)-1) { perror("mmap"); abort(); diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index bb30e7f03d..11d83439d3 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -84,7 +84,7 @@ protected: private: size_t _page_size; - typedef map DeletedChains; + typedef std::map DeletedChains; DeletedChains _deleted_chains; mutable MutexImpl _lock; diff --git a/dtool/src/dtoolbase/neverFreeMemory.I b/dtool/src/dtoolbase/neverFreeMemory.I index f34bdae28d..6e5216e993 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.I +++ b/dtool/src/dtoolbase/neverFreeMemory.I @@ -59,7 +59,7 @@ get_total_unused() { */ INLINE NeverFreeMemory *NeverFreeMemory:: get_global_ptr() { - if (_global_ptr == (NeverFreeMemory *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/dtool/src/dtoolbase/neverFreeMemory.cxx b/dtool/src/dtoolbase/neverFreeMemory.cxx index a1f720cfba..b933007dd5 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.cxx +++ b/dtool/src/dtoolbase/neverFreeMemory.cxx @@ -46,7 +46,7 @@ ns_alloc(size_t size) { // Look for a page that has sufficient space remaining. - Pages::iterator pi = _pages.lower_bound(Page(NULL, size)); + Pages::iterator pi = _pages.lower_bound(Page(nullptr, size)); if (pi != _pages.end()) { // Here's a page with enough remaining space. Page page = (*pi); @@ -82,8 +82,8 @@ void NeverFreeMemory:: make_global_ptr() { NeverFreeMemory *ptr = new NeverFreeMemory; void *result = AtomicAdjust::compare_and_exchange_ptr - ((void * TVOLATILE &)_global_ptr, (void *)NULL, (void *)ptr); - if (result != NULL) { + ((void * TVOLATILE &)_global_ptr, nullptr, (void *)ptr); + if (result != nullptr) { // Someone else got there first. delete ptr; } diff --git a/dtool/src/dtoolbase/neverFreeMemory.h b/dtool/src/dtoolbase/neverFreeMemory.h index d3f0cf51a1..8396313015 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.h +++ b/dtool/src/dtoolbase/neverFreeMemory.h @@ -57,7 +57,7 @@ private: size_t _remaining; }; - typedef set Pages; + typedef std::set Pages; Pages _pages; size_t _total_alloc; diff --git a/dtool/src/dtoolbase/pallocator.T b/dtool/src/dtoolbase/pallocator.T index 59af0f0ec1..f2776eb39e 100644 --- a/dtool/src/dtoolbase/pallocator.T +++ b/dtool/src/dtoolbase/pallocator.T @@ -20,7 +20,7 @@ pallocator_single(TypeHandle type_handle) noexcept : template INLINE Type *pallocator_single:: -allocate(TYPENAME pallocator_single::size_type n, TYPENAME allocator::const_pointer) { +allocate(typename pallocator_single::size_type n, typename allocator::const_pointer) { TAU_PROFILE("pallocator_single:allocate()", " ", TAU_USER); // This doesn't support allocating arrays. assert(n == 1); @@ -30,7 +30,7 @@ allocate(TYPENAME pallocator_single::size_type n, TYPENAME allocator template INLINE void pallocator_single:: -deallocate(TYPENAME pallocator_single::pointer p, TYPENAME pallocator_single::size_type) { +deallocate(typename pallocator_single::pointer p, typename pallocator_single::size_type) { TAU_PROFILE("pallocator_single:deallocate()", " ", TAU_USER); StaticDeletedChain::deallocate(p, _type_handle); } @@ -44,13 +44,13 @@ pallocator_array(TypeHandle type_handle) noexcept : template INLINE Type *pallocator_array:: -allocate(TYPENAME pallocator_array::size_type n, TYPENAME allocator::const_pointer) { - return (TYPENAME pallocator_array::pointer) +allocate(typename pallocator_array::size_type n, typename allocator::const_pointer) { + return (typename pallocator_array::pointer) ASSUME_ALIGNED(_type_handle.allocate_array(n * sizeof(Type)), MEMORY_HOOK_ALIGNMENT); } template INLINE void pallocator_array:: -deallocate(TYPENAME pallocator_array::pointer p, TYPENAME pallocator_array::size_type) { +deallocate(typename pallocator_array::pointer p, typename pallocator_array::size_type) { _type_handle.deallocate_array((void *)p); } diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index 8dfbb8178d..daca6fb275 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -20,6 +20,8 @@ #include "deletedChain.h" #include "typeHandle.h" +using std::allocator; + /** * This is our own Panda specialization on the default STL allocator. Its * main purpose is to call the hooks for MemoryUsage to properly track STL- @@ -36,8 +38,8 @@ // If we're not trying to make custom allocators (either we don't know what // kind of syntax this STL library wants, or we're compiling with OPTIMIZE 4), // then simply use the standard allocator. -#define pallocator_single allocator -#define pallocator_array allocator +#define pallocator_single std::allocator +#define pallocator_array std::allocator #else @@ -46,11 +48,11 @@ class pallocator_single : public allocator { public: // Nowadays we cannot implicitly inherit typedefs from base classes in a // template class; we must explicitly copy them here. - typedef TYPENAME allocator::pointer pointer; - typedef TYPENAME allocator::reference reference; - typedef TYPENAME allocator::const_pointer const_pointer; - typedef TYPENAME allocator::const_reference const_reference; - typedef TYPENAME allocator::size_type size_type; + typedef typename allocator::pointer pointer; + typedef typename allocator::reference reference; + typedef typename allocator::const_pointer const_pointer; + typedef typename allocator::const_reference const_reference; + typedef typename allocator::size_type size_type; INLINE pallocator_single(TypeHandle type_handle) noexcept; @@ -75,11 +77,11 @@ class pallocator_array : public allocator { public: // Nowadays we cannot implicitly inherit typedefs from base classes in a // template class; we must explicitly copy them here. - typedef TYPENAME allocator::pointer pointer; - typedef TYPENAME allocator::reference reference; - typedef TYPENAME allocator::const_pointer const_pointer; - typedef TYPENAME allocator::const_reference const_reference; - typedef TYPENAME allocator::size_type size_type; + typedef typename allocator::pointer pointer; + typedef typename allocator::reference reference; + typedef typename allocator::const_pointer const_pointer; + typedef typename allocator::const_reference const_reference; + typedef typename allocator::size_type size_type; INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) noexcept; diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index 96cf319e77..a7de9f5bb0 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -22,10 +22,12 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define pdeque deque +#define pdeque std::deque #else +using std::deque; + /** * This is our own Panda specialization on the default STL deque. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- @@ -35,7 +37,7 @@ template class pdeque : public deque > { public: typedef pallocator_array allocator; - typedef TYPENAME deque::size_type size_type; + typedef typename deque::size_type size_type; pdeque(TypeHandle type_handle = pdeque_type_handle) : deque >(allocator(type_handle)) { } pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : deque >(n, Type(), allocator(type_handle)) { } pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : deque >(n, value, allocator(type_handle)) { } diff --git a/dtool/src/dtoolbase/pdtoa.cxx b/dtool/src/dtoolbase/pdtoa.cxx index 47aa2db50a..2b508654ba 100644 --- a/dtool/src/dtoolbase/pdtoa.cxx +++ b/dtool/src/dtoolbase/pdtoa.cxx @@ -259,7 +259,7 @@ inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, cha *len = 0; while (kappa > 0) { - uint32_t d; + uint32_t d = 0; switch (kappa) { case 10: d = p1 / 1000000000; p1 %= 1000000000; break; case 9: d = p1 / 100000000; p1 %= 100000000; break; @@ -271,14 +271,7 @@ inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, cha case 3: d = p1 / 100; p1 %= 100; break; case 2: d = p1 / 10; p1 %= 10; break; case 1: d = p1; p1 = 0; break; - default: -#if defined(_MSC_VER) - __assume(0); -#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) - __builtin_unreachable(); -#else - d = 0; -#endif + NODEFAULT } if (d || *len) buffer[(*len)++] = '0' + static_cast(d); @@ -404,7 +397,7 @@ void pdtoa(double value, char *buffer) { #ifdef _MSC_VER if (copysign(1.0, value) < 0) { #else - if (signbit(value)) { + if (std::signbit(value)) { #endif *buffer++ = '-'; value = -value; diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index bbb9e55089..259eb68198 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -22,10 +22,12 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define plist list +#define plist std::list #else +using std::list; + /** * This is our own Panda specialization on the default STL list. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- @@ -36,15 +38,15 @@ class plist : public list > { public: typedef pallocator_single allocator; typedef list base_class; - typedef TYPENAME base_class::size_type size_type; + typedef typename base_class::size_type size_type; plist(TypeHandle type_handle = plist_type_handle) : base_class(allocator(type_handle)) { } plist(size_type n, TypeHandle type_handle = plist_type_handle) : base_class(n, Type(), allocator(type_handle)) { } plist(size_type n, const Type &value, TypeHandle type_handle = plist_type_handle) : base_class(n, value, allocator(type_handle)) { } - typedef TYPENAME base_class::iterator iterator; - typedef TYPENAME base_class::const_iterator const_iterator; - typedef TYPENAME base_class::reverse_iterator reverse_iterator; - typedef TYPENAME base_class::const_reverse_iterator const_reverse_iterator; + typedef typename base_class::iterator iterator; + typedef typename base_class::const_iterator const_iterator; + typedef typename base_class::reverse_iterator reverse_iterator; + typedef typename base_class::const_reverse_iterator const_reverse_iterator; // This exists because libc++'s remove implementation has a bug with Panda's // allocator class. diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index e115191b45..1a53836dd3 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -27,8 +27,8 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define pmap map -#define pmultimap multimap +#define pmap std::map +#define pmultimap std::multimap #ifdef HAVE_STL_HASH #define phash_map stdext::hash_map @@ -40,6 +40,9 @@ #else // USE_STL_ALLOCATOR +using std::map; +using std::multimap; + /** * This is our own Panda specialization on the default STL map. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- @@ -55,33 +58,33 @@ public: pmap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : base_class(comp, allocator(type_handle)) { } #ifdef USE_TAU - TYPENAME base_class::mapped_type & - operator [] (const TYPENAME base_class::key_type &k) { + typename base_class::mapped_type & + operator [] (const typename base_class::key_type &k) { TAU_PROFILE("pmap::operator [] (const key_type &)", " ", TAU_USER); return base_class::operator [] (k); } - std::pair - insert(const TYPENAME base_class::value_type &x) { + std::pair + insert(const typename base_class::value_type &x) { TAU_PROFILE("pmap::insert(const value_type &)", " ", TAU_USER); return base_class::insert(x); } - TYPENAME base_class::iterator - insert(TYPENAME base_class::iterator position, - const TYPENAME base_class::value_type &x) { + typename base_class::iterator + insert(typename base_class::iterator position, + const typename base_class::value_type &x) { TAU_PROFILE("pmap::insert(iterator, const value_type &)", " ", TAU_USER); return base_class::insert(position, x); } void - erase(TYPENAME base_class::iterator position) { + erase(typename base_class::iterator position) { TAU_PROFILE("pmap::erase(iterator)", " ", TAU_USER); base_class::erase(position); } - TYPENAME base_class::size_type - erase(const TYPENAME base_class::key_type &x) { + typename base_class::size_type + erase(const typename base_class::key_type &x) { TAU_PROFILE("pmap::erase(const key_type &)", " ", TAU_USER); return base_class::erase(x); } @@ -92,14 +95,14 @@ public: base_class::clear(); } - TYPENAME base_class::iterator - find(const TYPENAME base_class::key_type &x) { + typename base_class::iterator + find(const typename base_class::key_type &x) { TAU_PROFILE("pmap::find(const key_type &)", " ", TAU_USER); return base_class::find(x); } - TYPENAME base_class::const_iterator - find(const TYPENAME base_class::key_type &x) const { + typename base_class::const_iterator + find(const typename base_class::key_type &x) const { TAU_PROFILE("pmap::find(const key_type &)", " ", TAU_USER); return base_class::find(x); } diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index b7990ad671..1c194dff9b 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -27,19 +27,22 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define pset set -#define pmultiset multiset +#define pset std::set +#define pmultiset std::multiset #ifdef HAVE_STL_HASH #define phash_set stdext::hash_set #define phash_multiset stdext::hash_multiset #else // HAVE_STL_HASH -#define phash_set set -#define phash_multiset multiset +#define phash_set std::set +#define phash_multiset std::multiset #endif // HAVE_STL_HASH #else // USE_STL_ALLOCATOR +using std::set; +using std::multiset; + /** * This is our own Panda specialization on the default STL set. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- @@ -54,27 +57,27 @@ public: pset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : base_class(comp, type_handle) { } #ifdef USE_TAU - std::pair - insert(const TYPENAME base_class::value_type &x) { + std::pair + insert(const typename base_class::value_type &x) { TAU_PROFILE("pset::insert(const value_type &)", " ", TAU_USER); return base_class::insert(x); } - TYPENAME base_class::iterator - insert(TYPENAME base_class::iterator position, - const TYPENAME base_class::value_type &x) { + typename base_class::iterator + insert(typename base_class::iterator position, + const typename base_class::value_type &x) { TAU_PROFILE("pset::insert(iterator, const value_type &)", " ", TAU_USER); return base_class::insert(position, x); } void - erase(TYPENAME base_class::iterator position) { + erase(typename base_class::iterator position) { TAU_PROFILE("pset::erase(iterator)", " ", TAU_USER); base_class::erase(position); } - TYPENAME base_class::size_type - erase(const TYPENAME base_class::key_type &x) { + typename base_class::size_type + erase(const typename base_class::key_type &x) { TAU_PROFILE("pset::erase(const key_type &)", " ", TAU_USER); return base_class::erase(x); } @@ -85,14 +88,14 @@ public: base_class::clear(); } - TYPENAME base_class::iterator - find(const TYPENAME base_class::key_type &x) { + typename base_class::iterator + find(const typename base_class::key_type &x) { TAU_PROFILE("pset::find(x)", " ", TAU_USER); return base_class::find(x); } - TYPENAME base_class::const_iterator - find(const TYPENAME base_class::key_type &x) const { + typename base_class::const_iterator + find(const typename base_class::key_type &x) const { TAU_PROFILE("pset::find(x)", " ", TAU_USER); return base_class::find(x); } diff --git a/dtool/src/dtoolbase/pstrtod.cxx b/dtool/src/dtoolbase/pstrtod.cxx index 5a27ab6212..933d342f2c 100644 --- a/dtool/src/dtoolbase/pstrtod.cxx +++ b/dtool/src/dtoolbase/pstrtod.cxx @@ -104,7 +104,7 @@ pstrtod(const char *nptr, char **endptr) { if (!found_digits) { // Not a valid float. - if (endptr != NULL) { + if (endptr != nullptr) { *endptr = (char *)nptr; } return 0.0; @@ -139,7 +139,7 @@ pstrtod(const char *nptr, char **endptr) { value = -value; } - if (endptr != NULL) { + if (endptr != nullptr) { *endptr = (char *)p; } return value; @@ -154,5 +154,5 @@ pstrtod(const char *nptr, char **endptr) { */ double patof(const char *str) { - return pstrtod(str, (char **)NULL); + return pstrtod(str, nullptr); } diff --git a/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx b/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx index 7ecfde41f1..8cb0c882c5 100644 --- a/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx +++ b/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx @@ -259,20 +259,20 @@ typedef pthread_mutex_t mutex_t; pthread_mutex_t is at least one int wide. */ #define mutex_init(m) \ - (__pthread_mutex_init != NULL \ - ? __pthread_mutex_init (m, NULL) : (*(int *)(m) = 0)) + (__pthread_mutex_init != nullptr \ + ? __pthread_mutex_init (m, nullptr) : (*(int *)(m) = 0)) #define mutex_lock(m) \ - (__pthread_mutex_lock != NULL \ + (__pthread_mutex_lock != nullptr \ ? __pthread_mutex_lock (m) : ((*(int *)(m) = 1), 0)) #define mutex_trylock(m) \ - (__pthread_mutex_trylock != NULL \ + (__pthread_mutex_trylock != nullptr \ ? __pthread_mutex_trylock (m) : (*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0))) #define mutex_unlock(m) \ - (__pthread_mutex_unlock != NULL \ + (__pthread_mutex_unlock != nullptr \ ? __pthread_mutex_unlock (m) : (*(int*)(m) = 0)) #define thread_atfork(prepare, parent, child) \ - (__pthread_atfork != NULL ? __pthread_atfork(prepare, parent, child) : 0) + (__pthread_atfork != nullptr ? __pthread_atfork(prepare, parent, child) : 0) #elif defined(MUTEX_INITIALIZER) /* Assume hurd, with cthreads */ @@ -360,7 +360,7 @@ static inline int mutex_lock(mutex_t *m) { } else { tm.tv_sec = 0; tm.tv_nsec = 2000001; - nanosleep(&tm, NULL); + nanosleep(&tm, nullptr); cnt = 0; } } @@ -392,7 +392,7 @@ static inline int mutex_unlock(mutex_t *m) { typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#define mutex_init(m) pthread_mutex_init(m, NULL) +#define mutex_init(m) pthread_mutex_init(m, nullptr) #define mutex_lock(m) pthread_mutex_lock(m) #define mutex_trylock(m) pthread_mutex_trylock(m) #define mutex_unlock(m) pthread_mutex_unlock(m) @@ -438,7 +438,7 @@ typedef pthread_key_t tsd_key_t; typedef thread_t thread_id; #define MUTEX_INITIALIZER { 0 } -#define mutex_init(m) mutex_init(m, USYNC_THREAD, NULL) +#define mutex_init(m) mutex_init(m, USYNC_THREAD, nullptr) /* * Hack for thread-specific data on Solaris. We can't use thr_setspecific @@ -2040,7 +2040,7 @@ extern __malloc_ptr_t _int_memalign __MALLOC_P ((mstate __m, size_t __alignment, #define BOUNDED_N(ptr, sz) (ptr) #endif #ifndef RETURN_ADDRESS -#define RETURN_ADDRESS(X_) (NULL) +#define RETURN_ADDRESS(X_) (nullptr) #endif /* On some platforms we can compile internal, not exported functions better. @@ -3026,7 +3026,7 @@ int __malloc_initialized = -1; in the new arena. */ #define arena_get(ptr, size) do { \ - Void_t *vptr = NULL; \ + Void_t *vptr = nullptr; \ ptr = (mstate)tsd_getspecific(arena_key, vptr); \ if(ptr && !mutex_trylock(&ptr->mutex)) { \ THREAD_STAT(++(ptr->stat_lock_direct)); \ @@ -3088,7 +3088,7 @@ static Void_t* save_arena; static Void_t* malloc_atfork(size_t sz, const Void_t *caller) { - Void_t *vptr = NULL; + Void_t *vptr = nullptr; Void_t *victim; tsd_getspecific(arena_key, vptr); @@ -3115,7 +3115,7 @@ malloc_atfork(size_t sz, const Void_t *caller) static void free_atfork(Void_t* mem, const Void_t *caller) { - Void_t *vptr = NULL; + Void_t *vptr = nullptr; mstate ar_ptr; mchunkptr p; /* chunk corresponding to mem */ @@ -3232,9 +3232,9 @@ internal_function next_env_entry (char ***position) { char **current = *position; - char *result = NULL; + char *result = nullptr; - while (*current != NULL) + while (*current != nullptr) { if (__builtin_expect ((*current)[0] == 'M', 0) && (*current)[1] == 'A' @@ -3288,7 +3288,7 @@ ptmalloc_init __MALLOC_P((void)) __free_hook = free_starter; #ifdef _LIBC /* Initialize the pthreads interface. */ - if (__pthread_initialize != NULL) + if (__pthread_initialize != nullptr) __pthread_initialize(); #endif #endif /* !defined NO_THREADS */ @@ -3296,7 +3296,7 @@ ptmalloc_init __MALLOC_P((void)) main_arena.next = &main_arena; mutex_init(&list_lock); - tsd_key_create(&arena_key, NULL); + tsd_key_create(&arena_key, nullptr); tsd_setspecific(arena_key, (Void_t *)&main_arena); thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all2); #ifndef NO_THREADS @@ -3305,12 +3305,12 @@ ptmalloc_init __MALLOC_P((void)) #endif #ifdef _LIBC secure = __libc_enable_secure; - s = NULL; + s = nullptr; { char **runp = _environ; char *envline; - while (__builtin_expect ((envline = next_env_entry (&runp)) != NULL, + while (__builtin_expect ((envline = next_env_entry (&runp)) != nullptr, 0)) { size_t len = strcspn (envline, "="); @@ -3367,7 +3367,7 @@ ptmalloc_init __MALLOC_P((void)) if(s[0]) mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0')); __malloc_check_init(); } - if(__malloc_initialize_hook != NULL) + if(__malloc_initialize_hook != nullptr) (*__malloc_initialize_hook)(); __malloc_initialized = 1; } @@ -4103,7 +4103,7 @@ malloc_hook_ini(sz, caller) size_t sz; const __malloc_ptr_t caller; #endif { - __malloc_hook = NULL; + __malloc_hook = nullptr; ptmalloc_init(); return public_mALLOc(sz); } @@ -4116,8 +4116,8 @@ realloc_hook_ini(ptr, sz, caller) Void_t* ptr; size_t sz; const __malloc_ptr_t caller; #endif { - __malloc_hook = NULL; - __realloc_hook = NULL; + __malloc_hook = nullptr; + __realloc_hook = nullptr; ptmalloc_init(); return public_rEALLOc(ptr, sz); } @@ -4130,14 +4130,14 @@ memalign_hook_ini(alignment, sz, caller) size_t alignment; size_t sz; const __malloc_ptr_t caller; #endif { - __memalign_hook = NULL; + __memalign_hook = nullptr; ptmalloc_init(); return public_mEMALIGn(alignment, sz); } -void weak_variable (*__malloc_initialize_hook) __MALLOC_P ((void)) = NULL; +void weak_variable (*__malloc_initialize_hook) __MALLOC_P ((void)) = nullptr; void weak_variable (*__free_hook) __MALLOC_P ((__malloc_ptr_t __ptr, - const __malloc_ptr_t)) = NULL; + const __malloc_ptr_t)) = nullptr; __malloc_ptr_t weak_variable (*__malloc_hook) __MALLOC_P ((size_t __size, const __malloc_ptr_t)) = malloc_hook_ini; __malloc_ptr_t weak_variable (*__realloc_hook) @@ -4146,7 +4146,7 @@ __malloc_ptr_t weak_variable (*__realloc_hook) __malloc_ptr_t weak_variable (*__memalign_hook) __MALLOC_P ((size_t __alignment, size_t __size, const __malloc_ptr_t)) = memalign_hook_ini; -void weak_variable (*__after_morecore_hook) __MALLOC_P ((void)) = NULL; +void weak_variable (*__after_morecore_hook) __MALLOC_P ((void)) = nullptr; static int check_action = DEFAULT_CHECK_ACTION; @@ -4240,7 +4240,7 @@ mem2chunk_check(mem) Void_t* mem; unsigned char magic; p = mem2chunk(mem); - if(!aligned_OK(p)) return NULL; + if(!aligned_OK(p)) return nullptr; if( (char*)p>=mp_.sbrk_base && (char*)p<(mp_.sbrk_base+main_arena.system_mem) ) { /* Must be a chunk in conventional heap memory. */ @@ -4251,10 +4251,10 @@ mem2chunk_check(mem) Void_t* mem; ( !prev_inuse(p) && (p->prev_size&MALLOC_ALIGN_MASK || (long)prev_chunk(p)<(long)mp_.sbrk_base || next_chunk(prev_chunk(p))!=p) )) - return NULL; + return nullptr; magic = MAGICBYTE(p); for(sz += SIZE_SZ-1; (c = ((unsigned char*)p)[sz]) != magic; sz -= c) { - if(c<=0 || sz<(c+2*SIZE_SZ)) return NULL; + if(c<=0 || sz<(c+2*SIZE_SZ)) return nullptr; } ((unsigned char*)p)[sz] ^= 0xFF; } else { @@ -4271,10 +4271,10 @@ mem2chunk_check(mem) Void_t* mem; !chunk_is_mmapped(p) || (p->size & PREV_INUSE) || ( (((unsigned long)p - p->prev_size) & page_mask) != 0 ) || ( (sz = chunksize(p)), ((p->prev_size + sz) & page_mask) != 0 ) ) - return NULL; + return nullptr; magic = MAGICBYTE(p); for(sz -= 1; (c = ((unsigned char*)p)[sz]) != magic; sz -= c) { - if(c<=0 || sz<(c+2*SIZE_SZ)) return NULL; + if(c<=0 || sz<(c+2*SIZE_SZ)) return nullptr; } ((unsigned char*)p)[sz] ^= 0xFF; } @@ -4336,7 +4336,7 @@ malloc_check(sz, caller) size_t sz; const Void_t *caller; Void_t *victim; (void)mutex_lock(&main_arena.mutex); - victim = (top_check() >= 0) ? _int_malloc(&main_arena, sz+1) : NULL; + victim = (top_check() >= 0) ? _int_malloc(&main_arena, sz+1) : nullptr; (void)mutex_unlock(&main_arena.mutex); return mem2mem_check(victim, sz); } @@ -4387,7 +4387,7 @@ realloc_check(oldmem, bytes, caller) INTERNAL_SIZE_T nb, oldsize; Void_t* newmem = 0; - if (oldmem == 0) return malloc_check(bytes, NULL); + if (oldmem == 0) return malloc_check(bytes, nullptr); (void)mutex_lock(&main_arena.mutex); oldp = mem2chunk_check(oldmem); (void)mutex_unlock(&main_arena.mutex); @@ -4396,7 +4396,7 @@ realloc_check(oldmem, bytes, caller) fprintf(stderr, "realloc(): invalid pointer %p!\n", oldmem); if(check_action & 2) abort(); - return malloc_check(bytes, NULL); + return malloc_check(bytes, nullptr); } oldsize = chunksize(oldp); @@ -4460,13 +4460,13 @@ memalign_check(alignment, bytes, caller) INTERNAL_SIZE_T nb; Void_t* mem; - if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes, NULL); + if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes, nullptr); if (alignment < MINSIZE) alignment = MINSIZE; checked_request2size(bytes+1, nb); (void)mutex_lock(&main_arena.mutex); mem = (top_check() >= 0) ? _int_memalign(&main_arena, alignment, bytes+1) : - NULL; + nullptr; (void)mutex_unlock(&main_arena.mutex); return mem2mem_check(mem, bytes); } @@ -5367,7 +5367,7 @@ public_mALLOc(size_t bytes) __malloc_ptr_t (*hook) __MALLOC_P ((size_t, __const __malloc_ptr_t)) = __malloc_hook; - if (hook != NULL) + if (hook != nullptr) return (*hook)(bytes, RETURN_ADDRESS (0)); arena_get(ar_ptr, bytes); @@ -5407,7 +5407,7 @@ public_fREe(Void_t* mem) void (*hook) __MALLOC_P ((__malloc_ptr_t, __const __malloc_ptr_t)) = __free_hook; - if (hook != NULL) { + if (hook != nullptr) { (*hook)(mem, RETURN_ADDRESS (0)); return; } @@ -5454,11 +5454,11 @@ public_rEALLOc(Void_t* oldmem, size_t bytes) __malloc_ptr_t (*hook) __MALLOC_P ((__malloc_ptr_t, size_t, __const __malloc_ptr_t)) = __realloc_hook; - if (hook != NULL) + if (hook != nullptr) return (*hook)(oldmem, bytes, RETURN_ADDRESS (0)); #if REALLOC_ZERO_BYTES_FREES - if (bytes == 0 && oldmem != NULL) { public_fREe(oldmem); return 0; } + if (bytes == 0 && oldmem != nullptr) { public_fREe(oldmem); return 0; } #endif /* realloc of null is supposed to be same as malloc */ @@ -5523,7 +5523,7 @@ public_mEMALIGn(size_t alignment, size_t bytes) __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, __const __malloc_ptr_t)) = __memalign_hook; - if (hook != NULL) + if (hook != nullptr) return (*hook)(alignment, bytes, RETURN_ADDRESS (0)); /* If need less alignment than we give anyway, just relay to malloc */ @@ -5602,7 +5602,7 @@ public_cALLOc(size_t n, size_t elem_size) __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, __const __malloc_ptr_t)) = __malloc_hook; - if (hook != NULL) { + if (hook != nullptr) { sz = n * elem_size; mem = (*hook)(sz, RETURN_ADDRESS (0)); if(mem == 0) diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 8da0e88b85..8baf3c49c1 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -28,11 +28,13 @@ #elif defined(CPPPARSER) // Simplified definition to speed up Interrogate parsing. template -class pvector : public vector { +class pvector : public std::vector { }; #else +using std::vector; + /** * This is our own Panda specialization on the default STL vector. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/stl_compares.h b/dtool/src/dtoolbase/stl_compares.h index 57d989337a..0afffbf9a2 100644 --- a/dtool/src/dtoolbase/stl_compares.h +++ b/dtool/src/dtoolbase/stl_compares.h @@ -24,6 +24,8 @@ #ifdef HAVE_STL_HASH #include // for hash_compare +using std::less; + template > class stl_hash_compare : public stdext::hash_compare { public: @@ -36,6 +38,8 @@ public: #include // for less +using std::less; + // This is declared for the cases in which we don't have STL_HASH available. template > class stl_hash_compare : public Compare { diff --git a/dtool/src/dtoolbase/test_strtod.cxx b/dtool/src/dtoolbase/test_strtod.cxx index e2c10de958..169e90bfcf 100644 --- a/dtool/src/dtoolbase/test_strtod.cxx +++ b/dtool/src/dtoolbase/test_strtod.cxx @@ -24,7 +24,7 @@ main(int argc, char *argv[]) { #endif for (int i = 1; i < argc; ++i) { - char *endptr = NULL; + char *endptr = nullptr; double result = pstrtod(argv[i], &endptr); cerr << "pstrtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; result = strtod(argv[i], &endptr); diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index ed85da8d03..c3cad42e8c 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -30,8 +30,8 @@ get_memory_usage(MemoryClass memory_class) const { if ((*this) == TypeHandle::none()) { return 0; } else { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); return (size_t)AtomicAdjust::get(rnode->_memory_usage[memory_class]); } #endif // DO_MEMORY_USAGE @@ -49,8 +49,8 @@ inc_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); #endif if ((*this) != TypeHandle::none()) { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[memory_class], (AtomicAdjust::Integer)size); // cerr << *this << ".inc(" << memory_class << ", " << size << ") -> " << // rnode->_memory_usage[memory_class] << "\n"; @@ -73,8 +73,8 @@ dec_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); #endif if ((*this) != TypeHandle::none()) { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[memory_class], -(AtomicAdjust::Integer)size); // cerr << *this << ".dec(" << memory_class << ", " << size << ") -> " << // rnode->_memory_usage[memory_class] << "\n"; @@ -98,8 +98,8 @@ allocate_array(size_t size) { #ifdef _DEBUG assert(size <= alloc_size); #endif - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], (AtomicAdjust::Integer)alloc_size); if (rnode->_memory_usage[MC_array] < 0) { cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; @@ -125,8 +125,8 @@ reallocate_array(void *old_ptr, size_t size) { if ((*this) != TypeHandle::none()) { size_t new_size = MemoryHook::get_ptr_size(new_ptr); - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], (AtomicAdjust::Integer)new_size - (AtomicAdjust::Integer)old_size); assert(rnode->_memory_usage[MC_array] >= 0); } @@ -147,8 +147,8 @@ deallocate_array(void *ptr) { #ifdef DO_MEMORY_USAGE size_t alloc_size = MemoryHook::get_ptr_size(ptr); if ((*this) != TypeHandle::none()) { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], -(AtomicAdjust::Integer)alloc_size); assert(rnode->_memory_usage[MC_array] >= 0); } diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index b1b99c4ae0..03d0cd269c 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -108,18 +108,18 @@ PUBLISHED: INLINE int compare_to(const TypeHandle &other) const; INLINE size_t get_hash() const; - INLINE string get_name(TypedObject *object = (TypedObject *)NULL) const; + INLINE string get_name(TypedObject *object = nullptr) const; INLINE bool is_derived_from(TypeHandle parent, - TypedObject *object = (TypedObject *)NULL) const; + TypedObject *object = nullptr) const; - INLINE int get_num_parent_classes(TypedObject *object = (TypedObject *)NULL) const; + INLINE int get_num_parent_classes(TypedObject *object = nullptr) const; INLINE TypeHandle get_parent_class(int index) const; - INLINE int get_num_child_classes(TypedObject *object = (TypedObject *)NULL) const; + INLINE int get_num_child_classes(TypedObject *object = nullptr) const; INLINE TypeHandle get_child_class(int index) const; INLINE TypeHandle get_parent_towards(TypeHandle ancestor, - TypedObject *object = (TypedObject *)NULL) const; + TypedObject *object = nullptr) const; int get_best_parent_from_Set(const std::set< int > &legal_vals) const; diff --git a/dtool/src/dtoolbase/typeRegistry.I b/dtool/src/dtoolbase/typeRegistry.I index e35f37c207..7d47c7f7f7 100644 --- a/dtool/src/dtoolbase/typeRegistry.I +++ b/dtool/src/dtoolbase/typeRegistry.I @@ -30,7 +30,7 @@ INLINE TypeRegistry *TypeRegistry:: ptr() { // It's OK that we don't acquire the lock, because we guarantee that this is // called at static init time. - if (_global_pointer == NULL) { + if (_global_pointer == nullptr) { init_global_pointer(); } return _global_pointer; @@ -41,7 +41,7 @@ ptr() { */ INLINE void TypeRegistry:: init_lock() { - if (_lock == (MutexImpl *)NULL) { + if (_lock == nullptr) { _lock = new MutexImpl; } } diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index 7935f3221a..d7077727e1 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -20,8 +20,8 @@ #include -MutexImpl *TypeRegistry::_lock = NULL; -TypeRegistry *TypeRegistry::_global_pointer = NULL; +MutexImpl *TypeRegistry::_lock = nullptr; +TypeRegistry *TypeRegistry::_global_pointer = nullptr; /** * Creates a new Type of the given name and assigns a unique value to the @@ -37,7 +37,7 @@ register_type(TypeHandle &type_handle, const string &name) { if (type_handle != TypeHandle::none()) { // Here's a type that was already registered. Just make sure everything's // still kosher. - TypeRegistryNode *rnode = look_up(type_handle, NULL); + TypeRegistryNode *rnode = look_up(type_handle, nullptr); if (&type_handle == &rnode->_ref) { // No problem. _lock->unlock(); @@ -154,10 +154,10 @@ void TypeRegistry:: record_derivation(TypeHandle child, TypeHandle parent) { _lock->lock(); - TypeRegistryNode *cnode = look_up(child, NULL); - assert(cnode != (TypeRegistryNode *)NULL); - TypeRegistryNode *pnode = look_up(parent, NULL); - assert(pnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *cnode = look_up(child, nullptr); + assert(cnode != nullptr); + TypeRegistryNode *pnode = look_up(parent, nullptr); + assert(pnode != nullptr); // First, we'll just run through the list to make sure we hadn't already // made this connection. @@ -184,8 +184,8 @@ void TypeRegistry:: record_alternate_name(TypeHandle type, const string &name) { _lock->lock(); - TypeRegistryNode *rnode = look_up(type, (TypedObject *)NULL); - if (rnode != (TypeRegistryNode *)NULL) { + TypeRegistryNode *rnode = look_up(type, nullptr); + if (rnode != nullptr) { NameRegistry::iterator ri = _name_registry.insert(NameRegistry::value_type(name, rnode)).first; @@ -250,7 +250,7 @@ string TypeRegistry:: get_name(TypeHandle type, TypedObject *object) const { _lock->lock(); TypeRegistryNode *rnode = look_up(type, object); - assert(rnode != (TypeRegistryNode *)NULL); + assert(rnode != nullptr); string name = rnode->_name; _lock->unlock(); @@ -276,10 +276,10 @@ is_derived_from(TypeHandle child, TypeHandle base, _lock->lock(); const TypeRegistryNode *child_node = look_up(child, child_object); - const TypeRegistryNode *base_node = look_up(base, (TypedObject *)NULL); + const TypeRegistryNode *base_node = look_up(base, nullptr); - assert(child_node != (TypeRegistryNode *)NULL); - assert(base_node != (TypeRegistryNode *)NULL); + assert(child_node != nullptr); + assert(base_node != nullptr); freshen_derivations(); @@ -305,13 +305,13 @@ get_num_typehandles() { TypeHandle TypeRegistry:: get_typehandle(int n) { _lock->lock(); - TypeRegistryNode *rnode = NULL; + TypeRegistryNode *rnode = nullptr; if (n >= 0 && n < (int)_handle_registry.size()) { rnode = _handle_registry[n]; } _lock->unlock(); - if (rnode != (TypeRegistryNode *)NULL) { + if (rnode != nullptr) { return rnode->_handle; } @@ -364,7 +364,7 @@ int TypeRegistry:: get_num_parent_classes(TypeHandle child, TypedObject *child_object) const { _lock->lock(); TypeRegistryNode *rnode = look_up(child, child_object); - assert(rnode != (TypeRegistryNode *)NULL); + assert(rnode != nullptr); int num_parents = (int)rnode->_parent_classes.size(); _lock->unlock(); return num_parents; @@ -378,8 +378,8 @@ TypeHandle TypeRegistry:: get_parent_class(TypeHandle child, int index) const { _lock->lock(); TypeHandle handle; - TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = look_up(child, nullptr); + assert(rnode != nullptr); if (index >= 0 && index < (int)rnode->_parent_classes.size()) { handle = rnode->_parent_classes[index]->_handle; } else { @@ -401,7 +401,7 @@ int TypeRegistry:: get_num_child_classes(TypeHandle child, TypedObject *child_object) const { _lock->lock(); TypeRegistryNode *rnode = look_up(child, child_object); - assert(rnode != (TypeRegistryNode *)NULL); + assert(rnode != nullptr); int num_children = (int)rnode->_child_classes.size(); _lock->unlock(); return num_children; @@ -415,8 +415,8 @@ TypeHandle TypeRegistry:: get_child_class(TypeHandle child, int index) const { _lock->lock(); TypeHandle handle; - TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = look_up(child, nullptr); + assert(rnode != nullptr); if (index >= 0 && index < (int)rnode->_child_classes.size()) { handle = rnode->_child_classes[index]->_handle; } else { @@ -442,9 +442,9 @@ get_parent_towards(TypeHandle child, TypeHandle base, _lock->lock(); TypeHandle handle; const TypeRegistryNode *child_node = look_up(child, child_object); - const TypeRegistryNode *base_node = look_up(base, NULL); - assert(child_node != (TypeRegistryNode *)NULL && - base_node != (TypeRegistryNode *)NULL); + const TypeRegistryNode *base_node = look_up(base, nullptr); + assert(child_node != nullptr && + base_node != nullptr); freshen_derivations(); handle = TypeRegistryNode::get_parent_towards(child_node, base_node); _lock->unlock(); @@ -469,7 +469,7 @@ reregister_types() { ri != reg->_handle_registry.end(); ++ri) { TypeRegistryNode *rnode = (*ri); - if (rnode != NULL && rnode->_handle != rnode->_ref) { + if (rnode != nullptr && rnode->_handle != rnode->_ref) { cerr << "Reregistering " << rnode->_name << "\n"; } } @@ -496,7 +496,7 @@ TypeRegistry() { // We'll start out our handle_registry with a default entry for the // TypeHandles whose index number is zero, and are therefore (probably) // uninitialized. - _handle_registry.push_back(NULL); + _handle_registry.push_back(nullptr); _derivations_fresh = false; @@ -537,7 +537,7 @@ rebuild_derivations() { hi != _handle_registry.end(); ++hi) { TypeRegistryNode *node = *hi; - if (node != (TypeRegistryNode *)NULL) { + if (node != nullptr) { node->clear_subtree(); } } @@ -548,7 +548,7 @@ rebuild_derivations() { hi != _handle_registry.end(); ++hi) { TypeRegistryNode *node = *hi; - if (node != NULL && node->_parent_classes.empty()) { + if (node != nullptr && node->_parent_classes.empty()) { _root_classes.push_back(node); // Also, for each root class, define a subtree. @@ -570,7 +570,7 @@ do_write(ostream &out) const { hi != _handle_registry.end(); ++hi) { const TypeRegistryNode *root = *hi; - if (root != NULL && root->_parent_classes.empty()) { + if (root != nullptr && root->_parent_classes.empty()) { write_node(out, 2, root); } } @@ -609,7 +609,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { if (handle._index == 0) { // The TypeHandle is unregistered. This is an error condition. - if (object != NULL) { + if (object != nullptr) { // But we're lucky enough to have a TypedObject pointer handy! Maybe we // can use it to resolve the error. We have to drop the lock while we // do this, so we don't get a recursive lock. @@ -621,7 +621,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { // Strange. cerr << "Unable to force_init_type() on unregistered TypeHandle.\n"; - return NULL; + return nullptr; } // Now get the name for printing. We can't use TypeHandle:: get_name() @@ -629,7 +629,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { ostringstream name; if (handle._index > 0 && handle._index < (int)_handle_registry.size()) { TypeRegistryNode *rnode = _handle_registry[handle._index]; - if (rnode != (TypeRegistryNode *)NULL) { + if (rnode != nullptr) { name << rnode->_name; name << " (index " << handle._index << ")"; } else { @@ -650,7 +650,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { << "Attempt to reference unregistered TypeHandle. Type is of some\n" << "class derived from type " << name.str() << " that doesn't define\n" << "a good force_init_type() method.\n"; - return NULL; + return nullptr; } } else { @@ -660,7 +660,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { << "Attempt to reference unregistered TypeHandle!\n" << "Registered TypeHandles are:\n"; do_write(cerr); - return NULL; + return nullptr; } } @@ -669,7 +669,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { cerr << "Invalid TypeHandle index " << handle._index << "! Is memory corrupt?\n"; - return NULL; + return nullptr; } #endif // NDEBUG diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index 5c5c09ad4c..2227782862 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -100,13 +100,13 @@ private: static INLINE void init_lock(); - typedef vector HandleRegistry; + typedef std::vector HandleRegistry; HandleRegistry _handle_registry; - typedef map NameRegistry; + typedef std::map NameRegistry; NameRegistry _name_registry; - typedef vector RootClasses; + typedef std::vector RootClasses; RootClasses _root_classes; bool _derivations_fresh; diff --git a/dtool/src/dtoolbase/typeRegistryNode.I b/dtool/src/dtoolbase/typeRegistryNode.I index c9298aae27..4328a47d79 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.I +++ b/dtool/src/dtoolbase/typeRegistryNode.I @@ -16,7 +16,7 @@ */ INLINE TypeRegistryNode::Inherit:: Inherit() { - _top = (TypeRegistryNode *)NULL; + _top = nullptr; _mask = 0; _bits = 0; } diff --git a/dtool/src/dtoolbase/typeRegistryNode.cxx b/dtool/src/dtoolbase/typeRegistryNode.cxx index a88533a769..6d8d85ffc5 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.cxx +++ b/dtool/src/dtoolbase/typeRegistryNode.cxx @@ -45,7 +45,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { // additional work. (See r_build_subtrees()). if (child->_inherit._top == base->_inherit._top) { - assert(child->_inherit._top != (TypeRegistryNode *)NULL); + assert(child->_inherit._top != nullptr); bool derives = Inherit::is_derived_from(child->_inherit, base->_inherit); @@ -255,7 +255,7 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, if (_visit_count == (int)_parent_classes.size()) { // This is the last time we'll visit this node, so continue the // recursion now. - assert(_inherit._top == (TypeRegistryNode *)NULL); + assert(_inherit._top == nullptr); sort(_top_inheritance.begin(), _top_inheritance.end()); define_subtree(); } @@ -263,7 +263,7 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, } else { // This class singly inherits, so this had better be the only time this // function is called on it since clear_subtree(). - assert(_inherit._top == (TypeRegistryNode *)NULL); + assert(_inherit._top == nullptr); assert(bit_count < (int)(sizeof(SubtreeMaskType) * 8)); diff --git a/dtool/src/dtoolbase/typeRegistryNode.h b/dtool/src/dtoolbase/typeRegistryNode.h index a8df5c339e..c459d64805 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.h +++ b/dtool/src/dtoolbase/typeRegistryNode.h @@ -43,7 +43,7 @@ public: TypeHandle _handle; string _name; TypeHandle &_ref; - typedef vector Classes; + typedef std::vector Classes; Classes _parent_classes; Classes _child_classes; @@ -72,7 +72,7 @@ private: SubtreeMaskType _mask; SubtreeMaskType _bits; }; - typedef vector TopInheritance; + typedef std::vector TopInheritance; void r_build_subtrees(TypeRegistryNode *top, int bit_count, SubtreeMaskType bits); diff --git a/dtool/src/dtoolutil/config_dtoolutil.N b/dtool/src/dtoolutil/config_dtoolutil.N index 2577aa3b24..2ccd2b4210 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.N +++ b/dtool/src/dtoolutil/config_dtoolutil.N @@ -1,9 +1,10 @@ -forcetype ofstream -forcetype ifstream -forcetype fstream +forcetype std::ofstream +forcetype std::ifstream +forcetype std::fstream -forcetype ios_base -forcetype ios -forcetype istream -forcetype ostream -forcetype iostream +forcetype std::ios_base +forcetype std::basic_ios +forcetype std::ios +forcetype std::istream +forcetype std::ostream +forcetype std::iostream diff --git a/dtool/src/dtoolutil/dSearchPath.cxx b/dtool/src/dtoolutil/dSearchPath.cxx index d0aec4c3ad..f30f2156fc 100644 --- a/dtool/src/dtoolutil/dSearchPath.cxx +++ b/dtool/src/dtoolutil/dSearchPath.cxx @@ -220,8 +220,8 @@ append_path(const string &path, const string &separator) { */ void DSearchPath:: append_path(const DSearchPath &path) { - copy(path._directories.begin(), path._directories.end(), - back_inserter(_directories)); + std::copy(path._directories.begin(), path._directories.end(), + std::back_inserter(_directories)); } /** @@ -232,8 +232,8 @@ void DSearchPath:: prepend_path(const DSearchPath &path) { if (!path._directories.empty()) { Directories new_directories = path._directories; - copy(_directories.begin(), _directories.end(), - back_inserter(new_directories)); + std::copy(_directories.begin(), _directories.end(), + std::back_inserter(new_directories)); _directories.swap(new_directories); } } diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index c4f2e5093e..a2baf28343 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -86,7 +86,7 @@ extern int GLOBAL_ARGC; // safely access them at stat init time--at least, not in libc5. (It does seem // to work with glibc2, however.) -ExecutionEnvironment *ExecutionEnvironment::_global_ptr = NULL; +ExecutionEnvironment *ExecutionEnvironment::_global_ptr = nullptr; /** * You shouldn't need to construct one of these; there's only one and it @@ -162,13 +162,13 @@ get_cwd() { #ifdef WIN32_VC // getcwd() requires us to allocate a dynamic buffer and grow it on demand. static size_t bufsize = 1024; - static wchar_t *buffer = NULL; + static wchar_t *buffer = nullptr; - if (buffer == (wchar_t *)NULL) { + if (buffer == nullptr) { buffer = new wchar_t[bufsize]; } - while (_wgetcwd(buffer, bufsize) == (wchar_t *)NULL) { + while (_wgetcwd(buffer, bufsize) == nullptr) { if (errno != ERANGE) { perror("getcwd"); return string(); @@ -176,7 +176,7 @@ get_cwd() { delete[] buffer; bufsize = bufsize * 2; buffer = new wchar_t[bufsize]; - assert(buffer != (wchar_t *)NULL); + assert(buffer != nullptr); } Filename cwd = Filename::from_os_specific_w(buffer); @@ -185,13 +185,13 @@ get_cwd() { #else // WIN32_VC // getcwd() requires us to allocate a dynamic buffer and grow it on demand. static size_t bufsize = 1024; - static char *buffer = NULL; + static char *buffer = nullptr; - if (buffer == (char *)NULL) { + if (buffer == nullptr) { buffer = new char[bufsize]; } - while (getcwd(buffer, bufsize) == (char *)NULL) { + while (getcwd(buffer, bufsize) == nullptr) { if (errno != ERANGE) { perror("getcwd"); return string(); @@ -199,7 +199,7 @@ get_cwd() { delete[] buffer; bufsize = bufsize * 2; buffer = new char[bufsize]; - assert(buffer != (char *)NULL); + assert(buffer != nullptr); } Filename cwd = Filename::from_os_specific(buffer); @@ -217,7 +217,7 @@ ns_has_environment_variable(const string &var) const { #ifdef PREREAD_ENVIRONMENT return _variables.count(var) != 0; #else - return getenv(var.c_str()) != (char *)NULL; + return getenv(var.c_str()) != nullptr; #endif } @@ -257,7 +257,7 @@ ns_get_environment_variable(const string &var) const { #ifndef PREREAD_ENVIRONMENT const char *def = getenv(var.c_str()); - if (def != (char *)NULL) { + if (def != nullptr) { return def; } #endif @@ -327,13 +327,13 @@ ns_get_environment_variable(const string &var) const { { CSIDL_SYSTEMX86, "SYSTEMX86" }, { CSIDL_TEMPLATES, "TEMPLATES" }, { CSIDL_WINDOWS, "WINDOWS" }, - { 0, NULL }, + { 0, nullptr }, }; - for (int i = 0; csidl_table[i].name != NULL; ++i) { + for (int i = 0; csidl_table[i].name != nullptr; ++i) { if (strcmp(var.c_str(), csidl_table[i].name) == 0) { wchar_t buffer[MAX_PATH]; - if (SHGetSpecialFolderPathW(NULL, buffer, csidl_table[i].id, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, csidl_table[i].id, true)) { Filename pathname = Filename::from_os_specific_w(buffer); return pathname.to_os_specific(); } @@ -399,7 +399,7 @@ ns_clear_shadow(const string &var) { #ifdef PREREAD_ENVIRONMENT // Now we have to replace the value in the table. const char *def = getenv(var.c_str()); - if (def != (char *)NULL) { + if (def != nullptr) { (*vi).second = def; } else { _variables.erase(vi); @@ -457,7 +457,7 @@ ns_get_dtool_name() const { */ ExecutionEnvironment *ExecutionEnvironment:: get_ptr() { - if (_global_ptr == (ExecutionEnvironment *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ExecutionEnvironment; } return _global_ptr; @@ -577,20 +577,20 @@ read_args() { } #endif -#if defined(IS_FREEBSD) || (defined(IS_LINUX) && !defined(__ANDROID__)) - // FreeBSD and Linux have a function to get the origin of a loaded library. +#if defined(RTLD_DI_ORIGIN) + // When building with glibc/uClibc, we typically have access to RTLD_DI_ORIGIN in Unix-like operating systems. char origin[PATH_MAX + 1]; if (_dtool_name.empty()) { void *dtool_handle = dlopen("libp3dtool.so." PANDA_ABI_VERSION_STR, RTLD_NOW | RTLD_NOLOAD); - if (dtool_handle != NULL && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { + if (dtool_handle != nullptr && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { _dtool_name = origin; _dtool_name += "/libp3dtool.so." PANDA_ABI_VERSION_STR; } else { // Try the version of libp3dtool.so without ABI suffix. dtool_handle = dlopen("libp3dtool.so", RTLD_NOW | RTLD_NOLOAD); - if (dtool_handle != NULL && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { + if (dtool_handle != nullptr && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { _dtool_name = origin; _dtool_name += "/libp3dtool.so"; } @@ -598,14 +598,18 @@ read_args() { } #endif -#if defined(IS_FREEBSD) - // On FreeBSD, we can use dlinfo to get the linked libraries. - +#if !defined(RTLD_DI_ORIGIN) && defined(RTLD_DI_LINKMAP) + // On platforms without RTLD_DI_ORIGIN, we can use dlinfo with RTLD_DI_LINKMAP to get the origin of a loaded library. if (_dtool_name.empty()) { - Link_map *map; - dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map); + struct link_map *map; +#ifdef RTLD_SELF + void *self = RTLD_SELF; +#else + void *self = dlopen(NULL, RTLD_NOW | RTLD_NOLOAD); +#endif + dlinfo(self, RTLD_DI_LINKMAP, &map); - while (map != NULL) { + while (map != nullptr) { const char *tail = strrchr(map->l_name, '/'); const char *head = strchr(map->l_name, '/'); if (tail && head && (strcmp(tail, "/libp3dtool.so." PANDA_ABI_VERSION_STR) == 0 @@ -648,7 +652,7 @@ read_args() { if (_binary_name.empty()) { static const DWORD buffer_size = 1024; wchar_t buffer[buffer_size]; - DWORD size = GetModuleFileNameW(NULL, buffer, buffer_size); + DWORD size = GetModuleFileNameW(nullptr, buffer, buffer_size); if (size != 0) { Filename tmp = Filename::from_os_specific_w(wstring(buffer, size)); tmp.make_true_case(); @@ -677,7 +681,7 @@ read_args() { char buffer[4096]; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; mib[3] = getpid(); - if (sysctl(mib, 4, (void*) buffer, &bufsize, NULL, 0) == -1) { + if (sysctl(mib, 4, (void*) buffer, &bufsize, nullptr, 0) == -1) { perror("sysctl"); } else { _binary_name = buffer; @@ -715,7 +719,7 @@ read_args() { int argc = 0; LPWSTR *wargv = CommandLineToArgvW(cmdline, &argc); - if (wargv == NULL) { + if (wargv == nullptr) { cerr << "CommandLineToArgvW failed; command-line arguments unavailable to config.\n"; } else { @@ -745,16 +749,16 @@ read_args() { char buffer[4096]; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, 0}; mib[3] = getpid(); - if (sysctl(mib, 4, (void*) buffer, &bufsize, NULL, 0) == -1) { + if (sysctl(mib, 4, (void*) buffer, &bufsize, nullptr, 0) == -1) { perror("sysctl"); } else { if (_binary_name.empty()) { _binary_name = buffer; } - int idx = strlen(buffer) + 1; + size_t idx = strlen(buffer) + 1; while (idx < bufsize) { _args.push_back((char*)(buffer + idx)); - int newidx = strlen(buffer + idx); + size_t newidx = strlen(buffer + idx); idx += newidx + 1; } } @@ -764,7 +768,7 @@ read_args() { // On Windows, __argv can be NULL when the main entry point is compiled in // Unicode mode (as is the case with Python 3) - if (GLOBAL_ARGV != NULL) { + if (GLOBAL_ARGV != nullptr) { if (_binary_name.empty() && argc > 0) { _binary_name = GLOBAL_ARGV[0]; // This really needs to be resolved against PATH. @@ -819,14 +823,14 @@ read_args() { if (!_binary_name.empty()) { char newpath [PATH_MAX + 1]; - if (realpath(_binary_name.c_str(), newpath) != NULL) { + if (realpath(_binary_name.c_str(), newpath) != nullptr) { _binary_name = newpath; } } if (!_dtool_name.empty()) { char newpath [PATH_MAX + 1]; - if (realpath(_dtool_name.c_str(), newpath) != NULL) { + if (realpath(_dtool_name.c_str(), newpath) != nullptr) { _dtool_name = newpath; } } diff --git a/dtool/src/dtoolutil/filename.I b/dtool/src/dtoolutil/filename.I index 2f099548e3..989d77df98 100644 --- a/dtool/src/dtoolutil/filename.I +++ b/dtool/src/dtoolutil/filename.I @@ -192,7 +192,7 @@ operator = (const wstring &filename) { */ INLINE Filename &Filename:: operator = (const char *filename) { - assert(filename != NULL); + assert(filename != nullptr); return (*this) = string(filename); } diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 42bdf12e2f..61816e7a44 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -145,12 +145,12 @@ back_to_front_slash(const string &str) { static const string & get_panda_root() { - static string *panda_root = NULL; + static string *panda_root = nullptr; - if (panda_root == NULL) { + if (panda_root == nullptr) { panda_root = new string; const char *envvar = getenv("PANDA_ROOT"); - if (envvar != (const char *)NULL) { + if (envvar != nullptr) { (*panda_root) = front_to_back_slash(envvar); } @@ -430,7 +430,7 @@ temporary(const string &dirname, const string &prefix, const string &suffix, if (fdirname.empty()) { // If we are not given a dirname, use the system tempnam() function to // create a system-defined temporary filename. - char *name = tempnam(NULL, prefix.c_str()); + char *name = tempnam(nullptr, prefix.c_str()); Filename result = Filename::from_os_specific(name); free(name); result.set_type(type); @@ -446,7 +446,7 @@ temporary(const string &dirname, const string &prefix, const string &suffix, // We take the time of day and multiply it by the process time. This will // give us a very large number, of which we take the bottom 24 bits and // generate a 6-character hex code. - int hash = (clock() * time(NULL)) & 0xffffff; + int hash = (clock() * time(nullptr)) & 0xffffff; char hex_code[10]; #ifdef _WIN32 sprintf_s(hex_code, 10, "%06x", hash); @@ -467,12 +467,12 @@ temporary(const string &dirname, const string &prefix, const string &suffix, */ const Filename &Filename:: get_home_directory() { - if (AtomicAdjust::get_ptr(_home_directory) == NULL) { + if (AtomicAdjust::get_ptr(_home_directory) == nullptr) { Filename home_directory; // In all environments, check $HOME first. char *home = getenv("HOME"); - if (home != (char *)NULL) { + if (home != nullptr) { Filename dirname = from_os_specific(home); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -486,7 +486,7 @@ get_home_directory() { wchar_t buffer[MAX_PATH]; // On Windows, fall back to the "My Documents" folder. - if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_PERSONAL, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, CSIDL_PERSONAL, true)) { Filename dirname = from_os_specific_w(buffer); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -517,9 +517,9 @@ get_home_directory() { } Filename *newdir = new Filename(home_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_home_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_home_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_home_directory != NULL); + assert(_home_directory != nullptr); delete newdir; } } @@ -532,7 +532,7 @@ get_home_directory() { */ const Filename &Filename:: get_temp_directory() { - if (AtomicAdjust::get_ptr(_temp_directory) == NULL) { + if (AtomicAdjust::get_ptr(_temp_directory) == nullptr) { Filename temp_directory; #ifdef WIN32 @@ -565,9 +565,9 @@ get_temp_directory() { } Filename *newdir = new Filename(temp_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_temp_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_temp_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_temp_directory != NULL); + assert(_temp_directory != nullptr); delete newdir; } } @@ -582,13 +582,13 @@ get_temp_directory() { */ const Filename &Filename:: get_user_appdata_directory() { - if (AtomicAdjust::get_ptr(_user_appdata_directory) == NULL) { + if (AtomicAdjust::get_ptr(_user_appdata_directory) == nullptr) { Filename user_appdata_directory; #ifdef WIN32 wchar_t buffer[MAX_PATH]; - if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, CSIDL_LOCAL_APPDATA, true)) { Filename dirname = from_os_specific_w(buffer); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -622,9 +622,9 @@ get_user_appdata_directory() { } Filename *newdir = new Filename(user_appdata_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_user_appdata_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_user_appdata_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_user_appdata_directory != NULL); + assert(_user_appdata_directory != nullptr); delete newdir; } } @@ -638,13 +638,13 @@ get_user_appdata_directory() { */ const Filename &Filename:: get_common_appdata_directory() { - if (AtomicAdjust::get_ptr(_common_appdata_directory) == NULL) { + if (AtomicAdjust::get_ptr(_common_appdata_directory) == nullptr) { Filename common_appdata_directory; #ifdef WIN32 wchar_t buffer[MAX_PATH]; - if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_COMMON_APPDATA, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, CSIDL_COMMON_APPDATA, true)) { Filename dirname = from_os_specific_w(buffer); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -672,9 +672,9 @@ get_common_appdata_directory() { } Filename *newdir = new Filename(common_appdata_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_common_appdata_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_common_appdata_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_common_appdata_directory != NULL); + assert(_common_appdata_directory != nullptr); delete newdir; } } @@ -1017,7 +1017,7 @@ make_canonical() { #ifndef WIN32 // Use realpath in order to resolve symlinks properly char newpath [PATH_MAX + 1]; - if (realpath(c_str(), newpath) != NULL) { + if (realpath(c_str(), newpath) != nullptr) { Filename newpath_fn(newpath); newpath_fn._flags = _flags; (*this) = newpath_fn; @@ -1764,7 +1764,7 @@ scan_directory(vector_string &contents) const { dirname = _filename; } DIR *root = opendir(dirname.c_str()); - if (root == (DIR *)NULL) { + if (root == nullptr) { if (errno != ENOTDIR) { perror(dirname.c_str()); } @@ -1773,7 +1773,7 @@ scan_directory(vector_string &contents) const { struct dirent *d; d = readdir(root); - while (d != (struct dirent *)NULL) { + while (d != nullptr) { thread_consider_yield(); if (d->d_name[0] != '.') { contents.push_back(d->d_name); @@ -1814,7 +1814,7 @@ scan_directory(vector_string &contents) const { glob_t globbuf; - int r = glob(dirname.c_str(), GLOB_ERR, NULL, &globbuf); + int r = glob(dirname.c_str(), GLOB_ERR, nullptr, &globbuf); if (r != 0) { // Some error processing the match string. If our version of glob.h @@ -1834,7 +1834,7 @@ scan_directory(vector_string &contents) const { size_t offset = dirname.size() - 1; - for (int i = 0; globbuf.gl_pathv[i] != NULL; i++) { + for (int i = 0; globbuf.gl_pathv[i] != nullptr; i++) { contents.push_back(globbuf.gl_pathv[i] + offset); } globfree(&globbuf); @@ -1855,7 +1855,7 @@ scan_directory(vector_string &contents) const { * or set_binary(). */ bool Filename:: -open_read(ifstream &stream) const { +open_read(std::ifstream &stream) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -1891,7 +1891,7 @@ open_read(ifstream &stream) const { * if it already exists. Otherwise, the file is kept at its original length. */ bool Filename:: -open_write(ofstream &stream, bool truncate) const { +open_write(std::ofstream &stream, bool truncate) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -1921,15 +1921,10 @@ open_write(ofstream &stream, bool truncate) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -1942,7 +1937,7 @@ open_write(ofstream &stream, bool truncate) const { * or set_binary(). */ bool Filename:: -open_append(ofstream &stream) const { +open_append(std::ofstream &stream) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -1958,15 +1953,10 @@ open_append(ofstream &stream) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -1979,7 +1969,7 @@ open_append(ofstream &stream) const { * one of set_text() or set_binary(). */ bool Filename:: -open_read_write(fstream &stream, bool truncate) const { +open_read_write(std::fstream &stream, bool truncate) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -2005,15 +1995,10 @@ open_read_write(fstream &stream, bool truncate) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -2026,7 +2011,7 @@ open_read_write(fstream &stream, bool truncate) const { * open_read() without first calling one of set_text() or set_binary(). */ bool Filename:: -open_read_append(fstream &stream) const { +open_read_append(std::fstream &stream) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -2042,15 +2027,10 @@ open_read_append(fstream &stream) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -2125,11 +2105,7 @@ open_write(pofstream &stream, bool truncate) const { stream.clear(); string os_specific = to_os_specific(); -#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()); } @@ -2159,11 +2135,7 @@ open_append(pofstream &stream) const { stream.clear(); string os_specific = to_os_specific(); -#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()); } @@ -2203,11 +2175,7 @@ open_read_write(pfstream &stream, bool truncate) const { stream.clear(); string os_specific = to_os_specific(); -#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()); } @@ -2237,11 +2205,7 @@ open_read_append(pfstream &stream) const { stream.clear(); string os_specific = to_os_specific(); -#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()); } @@ -2262,7 +2226,7 @@ touch() const { wstring os_specific = to_os_specific_w(); HANDLE fhandle; fhandle = CreateFileW(os_specific.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, - NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (fhandle == INVALID_HANDLE_VALUE) { return false; } @@ -2276,7 +2240,7 @@ touch() const { return false; } - if (!SetFileTime(fhandle, NULL, NULL, &ftnow)) { + if (!SetFileTime(fhandle, nullptr, nullptr, &ftnow)) { CloseHandle(fhandle); return false; } @@ -2300,7 +2264,7 @@ touch() const { os_specific = result; } #endif // HAVE_CYGWIN - int result = utime(os_specific.c_str(), NULL); + int result = utime(os_specific.c_str(), nullptr); if (result < 0) { if (errno == ENOENT) { // So the file doesn't already exist; create it. @@ -2676,16 +2640,16 @@ atomic_compare_and_exchange_contents(string &orig_contents, #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); HANDLE hfile = CreateFileW(os_specific.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + 0, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); while (hfile == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); if (error == ERROR_SHARING_VIOLATION) { // If the file is locked by another process, yield and try again. Sleep(0); hfile = CreateFileW(os_specific.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + 0, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); } else { cerr << "Couldn't open file: " << os_specific << ", error " << error << "\n"; @@ -2705,7 +2669,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, orig_contents = string(); DWORD bytes_read; - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2714,7 +2678,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, while (bytes_read > 0) { orig_contents += string(buf, bytes_read); - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2728,7 +2692,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, SetFilePointer(hfile, 0, 0, FILE_BEGIN); DWORD bytes_written; if (!WriteFile(hfile, new_contents.data(), new_contents.size(), - &bytes_written, NULL)) { + &bytes_written, nullptr)) { cerr << "Error writing file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2812,16 +2776,16 @@ atomic_read_contents(string &contents) const { #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); HANDLE hfile = CreateFileW(os_specific.c_str(), GENERIC_READ, - FILE_SHARE_READ, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); while (hfile == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); if (error == ERROR_SHARING_VIOLATION) { // If the file is locked by another process, yield and try again. Sleep(0); hfile = CreateFileW(os_specific.c_str(), GENERIC_READ, - FILE_SHARE_READ, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); } else { cerr << "Couldn't open file: " << os_specific << ", error " << error << "\n"; @@ -2835,7 +2799,7 @@ atomic_read_contents(string &contents) const { contents = string(); DWORD bytes_read; - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2844,7 +2808,7 @@ atomic_read_contents(string &contents) const { while (bytes_read > 0) { contents += string(buf, bytes_read); - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); diff --git a/dtool/src/dtoolutil/filename.h b/dtool/src/dtoolutil/filename.h index 07927a846c..01297dfbee 100644 --- a/dtool/src/dtoolutil/filename.h +++ b/dtool/src/dtoolutil/filename.h @@ -203,11 +203,11 @@ PUBLISHED: EXTENSION(PyObject *scan_directory() const); #endif - bool open_read(ifstream &stream) const; - bool open_write(ofstream &stream, bool truncate = true) const; - bool open_append(ofstream &stream) const; - bool open_read_write(fstream &stream, bool truncate = false) const; - bool open_read_append(fstream &stream) const; + bool open_read(std::ifstream &stream) const; + bool open_write(std::ofstream &stream, bool truncate = true) const; + bool open_append(std::ofstream &stream) const; + bool open_read_write(std::fstream &stream, bool truncate = false) const; + bool open_read_append(std::fstream &stream) const; #ifdef USE_PANDAFILESTREAM bool open_read(pifstream &stream) const; diff --git a/dtool/src/dtoolutil/filename_ext.cxx b/dtool/src/dtoolutil/filename_ext.cxx index 3d71317786..196492d23f 100644 --- a/dtool/src/dtoolutil/filename_ext.cxx +++ b/dtool/src/dtoolutil/filename_ext.cxx @@ -24,8 +24,8 @@ extern Dtool_PyTypedObject Dtool_Filename; */ void Extension:: __init__(PyObject *path) { - nassertv(path != NULL); - nassertv(_this != NULL); + nassertv(path != nullptr); + nassertv(_this != nullptr); Py_ssize_t length; @@ -64,12 +64,12 @@ __init__(PyObject *path) { #if PY_VERSION_HEX >= 0x03060000 // It must be an os.PathLike object. Check for an __fspath__ method. PyObject *fspath = PyObject_GetAttrString((PyObject *)Py_TYPE(path), "__fspath__"); - if (fspath == NULL) { + if (fspath == nullptr) { PyErr_Format(PyExc_TypeError, "expected str, bytes or os.PathLike object, not %s", Py_TYPE(path)->tp_name); return; } - path_str = PyObject_CallFunctionObjArgs(fspath, path, NULL); + path_str = PyObject_CallFunctionObjArgs(fspath, path, nullptr); Py_DECREF(fspath); #else // There is no standard path protocol before Python 3.6, but let's try and @@ -89,7 +89,7 @@ __init__(PyObject *path) { } #endif - if (path_str == NULL) { + if (path_str == nullptr) { return; } @@ -133,8 +133,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyTypeObject *this_class = Py_TYPE(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *result = Py_BuildValue("(O(s))", this_class, _this->c_str()); diff --git a/dtool/src/dtoolutil/lineStreamBuf.cxx b/dtool/src/dtoolutil/lineStreamBuf.cxx index f2a795dab5..4e9f990540 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.cxx +++ b/dtool/src/dtoolutil/lineStreamBuf.cxx @@ -13,11 +13,6 @@ #include "lineStreamBuf.h" -#ifndef HAVE_STREAMSIZE -// Some compilers--notably SGI--don't define this for us. -typedef int streamsize; -#endif - /** * */ @@ -29,8 +24,8 @@ LineStreamBuf() { // 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); + setg(nullptr, nullptr, nullptr); + setp(nullptr, nullptr); } /** diff --git a/dtool/src/dtoolutil/load_dso.cxx b/dtool/src/dtoolutil/load_dso.cxx index ba63eee044..a54763afb1 100644 --- a/dtool/src/dtoolutil/load_dso.cxx +++ b/dtool/src/dtoolutil/load_dso.cxx @@ -45,7 +45,7 @@ void * load_dso(const DSearchPath &path, const Filename &filename) { Filename abspath = resolve_dso(path, filename); if (!abspath.is_regular_file()) { - return NULL; + return nullptr; } wstring os_specific_w = abspath.to_os_specific_w(); @@ -56,7 +56,7 @@ load_dso(const DSearchPath &path, const Filename &filename) { if (hLib) { pLoadLibraryEx = (tLoadLibraryEx)GetProcAddress(hLib, "LoadLibraryExW"); if (pLoadLibraryEx) { - return pLoadLibraryEx(os_specific_w.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + return pLoadLibraryEx(os_specific_w.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); } } @@ -130,7 +130,7 @@ void * load_dso(const DSearchPath &path, const Filename &filename) { Filename abspath = resolve_dso(path, filename); if (!abspath.is_regular_file()) { - return NULL; + return nullptr; } string os_specific = abspath.to_os_specific(); return dlopen(os_specific.c_str(), RTLD_NOW | RTLD_GLOBAL); @@ -144,7 +144,7 @@ unload_dso(void *dso_handle) { string load_dso_error() { const char *message = dlerror(); - if (message != (const char *)NULL) { + if (message != nullptr) { return std::string(message); } return "No error."; diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx index 037d421469..2e2c0ec035 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx @@ -41,7 +41,7 @@ PandaFileStreamBuf() { #ifdef _WIN32 // Windows case. - _handle = NULL; + _handle = nullptr; #else _fd = -1; #endif // _WIN32 @@ -132,7 +132,7 @@ open(const char *filename, ios::openmode mode) { encoder.set_text(_filename); wstring wfilename = encoder.get_wtext(); _handle = CreateFileW(wfilename.c_str(), access, share_mode, - NULL, creation_disposition, flags, NULL); + nullptr, creation_disposition, flags, nullptr); if (_handle != INVALID_HANDLE_VALUE) { // The file was successfully opened and locked. _is_open = true; @@ -251,10 +251,10 @@ close() { sync(); #ifdef _WIN32 - if (_handle != NULL) { + if (_handle != nullptr) { CloseHandle(_handle); } - _handle = NULL; + _handle = nullptr; #else if (_fd != -1) { ::close(_fd); diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index 79e5aa7762..5e7cc4b913 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -15,7 +15,7 @@ #include "pandaVersion.h" #include "dtool_platform.h" -PandaSystem *PandaSystem::_global_ptr = NULL; +PandaSystem *PandaSystem::_global_ptr = nullptr; TypeHandle PandaSystem::_type_handle; /** @@ -432,7 +432,7 @@ write(ostream &out) const { */ PandaSystem *PandaSystem:: get_global_ptr() { - if (_global_ptr == (PandaSystem *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PandaSystem; } diff --git a/dtool/src/dtoolutil/panda_getopt_impl.cxx b/dtool/src/dtoolutil/panda_getopt_impl.cxx index fe1d630a32..9a216bbda0 100644 --- a/dtool/src/dtoolutil/panda_getopt_impl.cxx +++ b/dtool/src/dtoolutil/panda_getopt_impl.cxx @@ -23,7 +23,7 @@ // ahead and provide it instead. -char *optarg = NULL; +char *optarg = nullptr; int optind = 0; int opterr = 1; int optopt = 0; @@ -72,7 +72,7 @@ private: class Param { public: Param(size_t opt_index, size_t argv_index, - char short_option, char *argument = NULL); + char short_option, char *argument = nullptr); size_t _opt_index; size_t _argv_index; @@ -121,7 +121,7 @@ private: // This global pointer is used to differentiate between getopt() being called // the first time, vs. subsequent times. -static PandaGetopt *pgetopt = NULL; +static PandaGetopt *pgetopt = nullptr; /** * @@ -129,7 +129,7 @@ static PandaGetopt *pgetopt = NULL; PandaGetopt:: PandaGetopt(int argc, char *const argv[], const char *optstring, const struct option *longopts, bool allow_one_hyphen_long) { - assert(optstring != NULL); + assert(optstring != nullptr); _return_in_order = false; _require_order = false; @@ -154,7 +154,7 @@ PandaGetopt(int argc, char *const argv[], const char *optstring, ++optstring; _require_order = true; - } else if (getenv("POSIXLY_CORRECT") != NULL) { + } else if (getenv("POSIXLY_CORRECT") != nullptr) { // REQUIRE_ORDER. _require_order = true; @@ -210,13 +210,13 @@ process(int opterr, int *longindex, char *&optarg, int &optind, int &optopt) { optarg = param._argument; optind = (int)param._argv_index; - if (longindex != NULL) { + if (longindex != nullptr) { *longindex = option._longopts_index; } - if (option._option != NULL) { + if (option._option != nullptr) { // This was a long option. Check the special longopt handling parameters. - if (option._option->flag == NULL) { + if (option._option->flag == nullptr) { return option._option->val; } *(option._option->flag) = option._option->val; @@ -298,9 +298,9 @@ scan_options(const char *optstring, const struct option *longopts) { _options.push_back(Option(short_option, has_arg)); } - if (longopts != NULL) { + if (longopts != nullptr) { int longopts_index = 0; - while (longopts[longopts_index].name != NULL) { + while (longopts[longopts_index].name != nullptr) { _options.push_back(Option(longopts, longopts_index)); ++longopts_index; } @@ -317,7 +317,7 @@ scan_args(int argc, char *const argv[]) { bool end_of_processing = false; while ((int)ai < argc) { - assert(argv[ai] != NULL); + assert(argv[ai] != nullptr); if (argv[ai][0] != '-' || end_of_processing) { // This is a non-option argument. @@ -342,8 +342,8 @@ scan_args(int argc, char *const argv[]) { } else { // An option argument. - char *option = NULL; - char *argument = NULL; + char *option = nullptr; + char *argument = nullptr; size_t opt_index = 0; bool is_long_option = false; bool has_argument = false; @@ -387,7 +387,7 @@ scan_args(int argc, char *const argv[]) { if (is_long_option) { char *equals = strchr(option, '='); - if (equals != NULL) { + if (equals != nullptr) { argument = equals + 1; has_argument = true; } @@ -416,7 +416,7 @@ scan_args(int argc, char *const argv[]) { // Now record the non-option arguments that followed the option arguments. while ((int)ai < argc) { - assert(argv[ai] != NULL); + assert(argv[ai] != nullptr); _arguments.push_back(argv[ai]); ++ai; } @@ -430,7 +430,7 @@ PandaGetopt::Option:: Option(char short_option, int has_arg) : _short_option(short_option), _has_arg(has_arg), - _option(NULL), + _option(nullptr), _longopts_index(-1) { } @@ -463,17 +463,17 @@ Param(size_t opt_index, size_t argv_index, char short_option, char *argument) : int getopt(int argc, char *const argv[], const char *optstring) { - if (pgetopt == NULL) { - pgetopt = new PandaGetopt(argc, argv, optstring, NULL, false); + if (pgetopt == nullptr) { + pgetopt = new PandaGetopt(argc, argv, optstring, nullptr, false); pgetopt->permute(argc, (char **)argv); } - return pgetopt->process(opterr, NULL, optarg, optind, optopt); + return pgetopt->process(opterr, nullptr, optarg, optind, optopt); } int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) { - if (pgetopt == NULL) { + if (pgetopt == nullptr) { pgetopt = new PandaGetopt(argc, argv, optstring, longopts, false); pgetopt->permute(argc, (char **)argv); } @@ -483,7 +483,7 @@ getopt_long(int argc, char *const argv[], const char *optstring, int getopt_long_only(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) { - if (pgetopt == NULL) { + if (pgetopt == nullptr) { pgetopt = new PandaGetopt(argc, argv, optstring, longopts, true); pgetopt->permute(argc, (char **)argv); } diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index a23d2f64df..591d2847e0 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -89,8 +89,8 @@ int PipeStreamBuf::sync(void) { int PipeStreamBuf::underflow(void) { assert(_dir == Input); - if ((eback() == (char*)0L) || (gptr() == (char*)0L) || - (egptr() == (char*)0L)) { + if ((eback() == nullptr) || (gptr() == nullptr) || + (egptr() == nullptr)) { // must be new-style iostream library char* buf = new char[4096]; char* ebuf = &(buf[4096]); @@ -162,7 +162,7 @@ void PipeStreamBuf::write_chars(const char* start, int length, bool flush) { */ void PipeStreamBuf:: init_pipe() { - _pipe = NULL; + _pipe = nullptr; } /** @@ -170,7 +170,7 @@ init_pipe() { */ bool PipeStreamBuf:: is_open() const { - return _pipe != NULL; + return _pipe != nullptr; } /** @@ -179,7 +179,7 @@ is_open() const { */ bool PipeStreamBuf:: eof_pipe() const { - return (_pipe == NULL) && feof(_pipe); + return (_pipe == nullptr) && feof(_pipe); } /** @@ -193,7 +193,7 @@ bool PipeStreamBuf:: open_pipe(const string &cmd) { const char *typ = (_dir == Output)?"w":"r"; _pipe = popen(cmd.c_str(), typ); - return (_pipe != NULL); + return (_pipe != nullptr); } /** @@ -201,9 +201,9 @@ open_pipe(const string &cmd) { */ void PipeStreamBuf:: close_pipe() { - if (_pipe != NULL) { + if (_pipe != nullptr) { fclose(_pipe); - _pipe = NULL; + _pipe = nullptr; } } @@ -289,7 +289,7 @@ open_pipe(const string &cmd) { SECURITY_ATTRIBUTES saAttr; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; + saAttr.lpSecurityDescriptor = nullptr; if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) { #ifndef NDEBUG cerr << "Unable to create output pipe\n"; @@ -391,7 +391,7 @@ read_pipe(char *data, size_t len) { return 0; } DWORD dwRead; - if (!ReadFile(_child_out, data, len, &dwRead, NULL)) { + if (!ReadFile(_child_out, data, len, &dwRead, nullptr)) { close_pipe(); return 0; } diff --git a/dtool/src/dtoolutil/stringDecoder.cxx b/dtool/src/dtoolutil/stringDecoder.cxx index ce73120543..847d8559bd 100644 --- a/dtool/src/dtoolutil/stringDecoder.cxx +++ b/dtool/src/dtoolutil/stringDecoder.cxx @@ -95,7 +95,7 @@ get_next_character() { // First byte of two. unsigned int two = 0; if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; } @@ -108,7 +108,7 @@ get_next_character() { } else if ((result & 0xf0) == 0xe0) { // First byte of three. if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; } @@ -116,7 +116,7 @@ get_next_character() { } unsigned int two = (unsigned char)_input[_p++]; if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; } @@ -129,7 +129,7 @@ get_next_character() { // Otherwise--the high bit is set but it is not one of the introductory // utf-8 bytes--we have an error. - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "Non utf-8 byte in string: 0x" << hex << result << dec << ", string is '" << _input << "'\n"; @@ -152,7 +152,7 @@ get_next_character() { unsigned int high = (unsigned char)_input[_p++]; if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "Unicode-encoded string has odd number of bytes.\n"; } diff --git a/dtool/src/dtoolutil/string_utils.I b/dtool/src/dtoolutil/string_utils.I index e4e71766f8..f7878c3ba8 100644 --- a/dtool/src/dtoolutil/string_utils.I +++ b/dtool/src/dtoolutil/string_utils.I @@ -32,7 +32,7 @@ format_string(bool value) { INLINE string format_string(float value) { char buffer[32]; - pdtoa(value, buffer); + pdtoa((double)value, buffer); return string(buffer); } diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index fb84aa316d..c46c03c0de 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -259,7 +259,7 @@ reencode_text(const string &text, TextEncoder::Encoding from, INLINE bool TextEncoder:: unicode_isalpha(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return false; } return entry->_char_type == UnicodeLatinMap::CT_upper || @@ -273,7 +273,7 @@ unicode_isalpha(int character) { INLINE bool TextEncoder:: unicode_isdigit(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { // The digits aren't actually listed in the map. return (character >= '0' && character <= '9'); } @@ -288,7 +288,7 @@ unicode_isdigit(int character) { INLINE bool TextEncoder:: unicode_ispunct(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { // Some punctuation marks aren't listed in the map. return (character >= 0 && character < 128 && ispunct(character)); } @@ -302,7 +302,7 @@ unicode_ispunct(int character) { INLINE bool TextEncoder:: unicode_isupper(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return false; } return entry->_char_type == UnicodeLatinMap::CT_upper; @@ -332,7 +332,7 @@ unicode_isspace(int character) { INLINE bool TextEncoder:: unicode_islower(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return false; } return entry->_char_type == UnicodeLatinMap::CT_lower; @@ -345,7 +345,7 @@ unicode_islower(int character) { INLINE int TextEncoder:: unicode_toupper(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return character; } return entry->_toupper_character; @@ -358,7 +358,7 @@ unicode_toupper(int character) { INLINE int TextEncoder:: unicode_tolower(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return character; } return entry->_tolower_character; diff --git a/dtool/src/dtoolutil/textEncoder.cxx b/dtool/src/dtoolutil/textEncoder.cxx index f4f788845e..90ce30d395 100644 --- a/dtool/src/dtoolutil/textEncoder.cxx +++ b/dtool/src/dtoolutil/textEncoder.cxx @@ -69,7 +69,7 @@ get_wtext_as_ascii() const { const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(character); - if (map_entry != NULL && map_entry->_ascii_equiv != 0) { + if (map_entry != nullptr && map_entry->_ascii_equiv != 0) { result += (wchar_t)map_entry->_ascii_equiv; if (map_entry->_ascii_additional != 0) { result += (wchar_t)map_entry->_ascii_additional; @@ -117,7 +117,7 @@ encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { // an unusual accent mark). const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(ch); - if (map_entry != NULL && map_entry->_ascii_equiv != 0) { + if (map_entry != nullptr && map_entry->_ascii_equiv != 0) { // Yes, it has an ascii equivalent. if (map_entry->_ascii_additional != 0) { // In fact, it has two of them. @@ -345,7 +345,7 @@ operator >> (istream &in, TextEncoder::Encoding &encoding) { encoding = TextEncoder::E_unicode; } else { ostream *notify_ptr = StringDecoder::get_notify_ptr(); - if (notify_ptr != (ostream *)NULL) { + if (notify_ptr != nullptr) { (*notify_ptr) << "Invalid TextEncoder::Encoding: " << word << "\n"; } diff --git a/dtool/src/dtoolutil/unicodeLatinMap.cxx b/dtool/src/dtoolutil/unicodeLatinMap.cxx index 3fc1e3cb1c..87c9cb5a7d 100644 --- a/dtool/src/dtoolutil/unicodeLatinMap.cxx +++ b/dtool/src/dtoolutil/unicodeLatinMap.cxx @@ -1392,7 +1392,7 @@ look_up(wchar_t character) { if (ci != _by_character->end()) { return (*ci).second; } - return NULL; + return nullptr; } } diff --git a/dtool/src/dtoolutil/win32ArgParser.cxx b/dtool/src/dtoolutil/win32ArgParser.cxx index 84ddb785a6..231b4af12b 100644 --- a/dtool/src/dtoolutil/win32ArgParser.cxx +++ b/dtool/src/dtoolutil/win32ArgParser.cxx @@ -29,7 +29,7 @@ */ Win32ArgParser:: Win32ArgParser() : - _argv(NULL), + _argv(nullptr), _argc(0) { } @@ -50,12 +50,12 @@ void Win32ArgParser:: clear() { assert(_argc == (int)_args.size()); - if (_argv != NULL) { + if (_argv != nullptr) { for (int i = 0; i < _argc; ++i) { PANDA_FREE_ARRAY(_argv[i]); } PANDA_FREE_ARRAY(_argv); - _argv = NULL; + _argv = nullptr; } _argc = 0; @@ -80,7 +80,7 @@ set_command_line(const string &command_line) { } } - assert(_argc == 0 && _argv == NULL); + assert(_argc == 0 && _argv == nullptr); _argc = (int)_args.size(); _argv = (char **)PANDA_MALLOC_ARRAY(_argc * sizeof(char *)); for (int i = 0; i < _argc; ++i) { diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index 42a420644f..745d084b72 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -39,7 +39,7 @@ FunctionRemap:: FunctionRemap(const InterrogateType &itype, const InterrogateFunction &ifunc, CPPInstance *cppfunc, int num_default_parameters, InterfaceMaker *interface_maker) { - _return_type = (ParameterRemap *)NULL; + _return_type = nullptr; _void_return = true; _ForcedVoidReturn = false; _has_this = false; @@ -117,7 +117,7 @@ call_function(ostream &out, int indent_level, bool convert_result, if (_type == T_destructor) { // A destructor wrapper is just a wrapper around the delete operator. assert(!container.empty()); - assert(_cpptype != (CPPType *)NULL); + assert(_cpptype != nullptr); if (TypeManager::is_reference_count(_cpptype)) { // Except for a reference-count type object, in which case the @@ -279,7 +279,7 @@ call_function(ostream &out, int indent_level, bool convert_result, void FunctionRemap:: write_orig_prototype(ostream &out, int indent_level, bool local, int num_default_args) const { if (local) { - _cppfunc->output(out, indent_level, NULL, false, num_default_args); + _cppfunc->output(out, indent_level, nullptr, false, num_default_args); } else { _cppfunc->output(out, indent_level, &parser, false, num_default_args); } @@ -299,7 +299,7 @@ make_wrapper_entry(FunctionIndex function_index) { iwrapper._name = _wrapper_name; iwrapper._unique_name = _unique_name; - if (_cppfunc->_leading_comment != (CPPCommentBlock *)NULL) { + if (_cppfunc->_leading_comment != nullptr) { iwrapper._comment = InterrogateBuilder::trim_blanks(_cppfunc->_leading_comment->_comment); } @@ -395,7 +395,7 @@ get_call_str(const string &container, const vector_string &pexprs) const { // It's not possible to assign arrays in C++, we have to copy them. CPPArrayType *array_type = _parameters[_first_true_parameter]._remap->get_orig_type()->as_array_type(); - if (array_type != NULL) { + if (array_type != nullptr) { call << "std::copy(" << expr << ", " << expr << " + " << *array_type->_bounds << ", "; } else { call << expr << " = "; @@ -404,7 +404,7 @@ get_call_str(const string &container, const vector_string &pexprs) const { _parameters[_first_true_parameter]._remap->pass_parameter(call, get_parameter_expr(_first_true_parameter, pexprs)); - if (array_type != NULL) { + if (array_type != nullptr) { call << ')'; } @@ -490,7 +490,7 @@ get_min_num_args() const { } for (; pi != _parameters.end(); ++pi) { ParameterRemap *param = (*pi)._remap; - if (param->get_default_value() != (CPPExpression *)NULL) { + if (param->get_default_value() != nullptr) { // We've reached the first parameter that takes a default value. break; } else { @@ -567,7 +567,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak string fname = _cppfunc->get_simple_name(); CPPType *rtype = _ftype->_return_type->resolve_type(&parser, _cppscope); - if (_cpptype != (CPPType *)NULL && + if (_cpptype != nullptr && ((_cppfunc->_storage_class & CPPInstance::SC_static) == 0) && _type != T_constructor) { @@ -609,10 +609,10 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak fname == "operator >>=") { _type = T_assignment_method; - } else if (fname == "operator []" && !_const_method && rtype != NULL) { + } else if (fname == "operator []" && !_const_method && rtype != nullptr) { // Check if this is an item-assignment operator. CPPReferenceType *reftype = rtype->as_reference_type(); - if (reftype != NULL && reftype->_pointing_at->as_const_type() == NULL) { + if (reftype != nullptr && reftype->_pointing_at->as_const_type() == nullptr) { // It returns a mutable reference. _type = T_item_assignment_operator; } @@ -638,7 +638,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } param._remap = interface_maker->remap_parameter(_cpptype, type); - if (param._remap == (ParameterRemap *)NULL) { + if (param._remap == nullptr) { // If we can't handle one of the parameter types, we can't call the // function. if (fname == "__traverse__") { @@ -666,13 +666,13 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // by the parser, but we know they actually return a new concrete // instance. - if (_cpptype == (CPPType *)NULL) { + if (_cpptype == nullptr) { nout << "Method " << *_cppfunc << " has no struct type\n"; return false; } _return_type = interface_maker->remap_parameter(_cpptype, _cpptype); - if (_return_type != (ParameterRemap *)NULL) { + if (_return_type != nullptr) { _void_return = false; } @@ -681,13 +681,13 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // return *this, which is a semi-standard C++ convention anyway. We just // enforce it. - if (_cpptype == (CPPType *)NULL) { + if (_cpptype == nullptr) { nout << "Method " << *_cppfunc << " has no struct type\n"; return false; } else { CPPType *ref_type = CPPType::new_type(new CPPReferenceType(_cpptype)); _return_type = interface_maker->remap_parameter(_cpptype, ref_type); - if (_return_type != (ParameterRemap *)NULL) { + if (_return_type != nullptr) { _void_return = false; } } @@ -697,7 +697,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // scripting languages, so we use this to denote item-access operators // that return a non-const reference. - if (_cpptype == (CPPType *)NULL) { + if (_cpptype == nullptr) { nout << "Method " << *_cppfunc << " has no struct type\n"; return false; } else { @@ -711,7 +711,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak param._name = "assign_val"; param._remap = interface_maker->remap_parameter(_cpptype, ref_type); - if (param._remap == NULL || !param._remap->is_valid()) { + if (param._remap == nullptr || !param._remap->is_valid()) { nout << "Invalid remap for assignment type of method " << *_cppfunc << "\n"; return false; } @@ -726,12 +726,12 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } else { // The normal case. _return_type = interface_maker->remap_parameter(_cpptype, rtype); - if (_return_type != (ParameterRemap *)NULL) { + if (_return_type != nullptr) { _void_return = TypeManager::is_void(rtype); } } - if (_return_type == (ParameterRemap *)NULL || + if (_return_type == nullptr || !_return_type->is_valid()) { // If our return type isn't something we can deal with, treat the function // as if it returns NULL. @@ -739,7 +739,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _ForcedVoidReturn = true; CPPType *void_type = TypeManager::get_void_type(); _return_type = interface_maker->remap_parameter(_cpptype, void_type); - assert(_return_type != (ParameterRemap *)NULL); + assert(_return_type != nullptr); } // Do we need to manage the return value? @@ -767,12 +767,12 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } // Check for a special meaning by name and signature. - int first_param = 0; + size_t first_param = 0; if (_has_this) { first_param = 1; } - if (_parameters.size() > (size_t)first_param && _parameters[first_param]._name == "self" && + if (_parameters.size() > first_param && _parameters[first_param]._name == "self" && TypeManager::is_pointer_to_PyObject(_parameters[first_param]._remap->get_orig_type())) { // Here's a special case. If the first parameter of a nonstatic method // is a PyObject * called "self", then we will automatically fill it in @@ -782,10 +782,10 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _flags |= F_explicit_self; } - if ((int)_parameters.size() == first_param) { + if (_parameters.size() == first_param) { _args_type = InterfaceMaker::AT_no_args; - } else if ((int)_parameters.size() == first_param + 1 && - _parameters[first_param]._remap->get_default_value() == NULL) { + } else if (_parameters.size() == first_param + 1 && + _parameters[first_param]._remap->get_default_value() == nullptr) { _args_type = InterfaceMaker::AT_single_arg; } else { _args_type = InterfaceMaker::AT_varargs; @@ -833,7 +833,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } } else if (fname == "size" || fname == "__len__") { - if ((int)_parameters.size() == first_param && + if (_parameters.size() == first_param && TypeManager::is_integer(_return_type->get_new_type())) { // It receives no parameters, and returns an integer. _flags |= F_size; @@ -847,7 +847,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } } else if (fname == "__iter__") { - if ((int)_parameters.size() == first_param && + if (_parameters.size() == first_param && TypeManager::is_pointer(_return_type->get_new_type())) { // It receives no parameters, and returns a pointer. _flags |= F_iter; @@ -870,7 +870,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak if (_args_type == InterfaceMaker::AT_varargs) { // Of course methods named "make" can still take kwargs, if they are // named. - for (int i = first_param; i < _parameters.size(); ++i) { + for (size_t i = first_param; i < _parameters.size(); ++i) { if (_parameters[i]._has_name) { _args_type = InterfaceMaker::AT_keyword_args; break; @@ -904,7 +904,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak if (_args_type == InterfaceMaker::AT_varargs) { // Every other method can take keyword arguments, if they take more // than one argument, and the arguments are named. - for (int i = first_param; i < _parameters.size(); ++i) { + for (size_t i = first_param; i < _parameters.size(); ++i) { if (_parameters[i]._has_name) { _args_type |= InterfaceMaker::AT_keyword_args; break; @@ -960,7 +960,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // Constructors always take varargs, and possibly keyword args. _args_type = InterfaceMaker::AT_varargs; - for (int i = first_param; i < _parameters.size(); ++i) { + for (size_t i = first_param; i < _parameters.size(); ++i) { if (_parameters[i]._has_name) { _args_type = InterfaceMaker::AT_keyword_args; break; diff --git a/dtool/src/interrogate/functionRemap.h b/dtool/src/interrogate/functionRemap.h index b4b8aea6dd..7c12f65c3d 100644 --- a/dtool/src/interrogate/functionRemap.h +++ b/dtool/src/interrogate/functionRemap.h @@ -103,7 +103,7 @@ public: F_explicit_args = 0x8000, }; - typedef vector Parameters; + typedef std::vector Parameters; Parameters _parameters; ParameterRemap *_return_type; diff --git a/dtool/src/interrogate/functionWriterPtrFromPython.cxx b/dtool/src/interrogate/functionWriterPtrFromPython.cxx index d39d5f47dd..c27ef1efe5 100644 --- a/dtool/src/interrogate/functionWriterPtrFromPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrFromPython.cxx @@ -64,13 +64,13 @@ write_code(ostream &out) { << _name << "(PyObject *obj, "; ppointer->output_instance(out, "addr", &parser); out << ") {\n" - << " if (obj != (PyObject *)NULL && PyInstance_Check(obj)) {\n" + << " if (obj != nullptr && PyInstance_Check(obj)) {\n" // << " PyClassObject *in_class = ((PyInstanceObject // *)obj)->in_class;\n" << " PyObject *in_dict = ((PyInstanceObject *)obj)->in_dict;\n" - << " if (in_dict != (PyObject *)NULL && PyDict_Check(in_dict)) {\n" + << " if (in_dict != nullptr && PyDict_Check(in_dict)) {\n" << " PyObject *thisobj = PyDict_GetItemString(in_dict, \"this\");\n" - << " if (thisobj != (PyObject *)NULL && PyLong_Check(thisobj)) {\n" + << " if (thisobj != nullptr && PyLong_Check(thisobj)) {\n" << " (*addr) = (" << _pointer_type->get_local_name(&parser) << ")PyLong_AsVoidPtr(thisobj);\n" << " return 1;\n" diff --git a/dtool/src/interrogate/functionWriterPtrToPython.cxx b/dtool/src/interrogate/functionWriterPtrToPython.cxx index 23a8304528..aac2984dbc 100644 --- a/dtool/src/interrogate/functionWriterPtrToPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrToPython.cxx @@ -62,8 +62,8 @@ write_code(ostream &out) { out << ", int caller_manages) {\n" << " PyObject *" << classobj_func << "();\n" << " PyObject *classobj = " << classobj_func << "();\n" - << " PyInstanceObject *instance = (PyInstanceObject *)PyInstance_New(classobj, (PyObject *)NULL, (PyObject *)NULL);\n" - << " if (instance != (PyInstanceObject *)NULL) {\n" + << " PyInstanceObject *instance = (PyInstanceObject *)PyInstance_New(classobj, nullptr, nullptr);\n" + << " if (instance != nullptr) {\n" << " PyObject *thisptr = PyLong_FromVoidPtr((void*)addr);\n" << " PyDict_SetItemString(instance->in_dict, \"this\", thisptr);\n" << " }\n" diff --git a/dtool/src/interrogate/functionWriters.h b/dtool/src/interrogate/functionWriters.h index 0db121de10..41943c47f7 100644 --- a/dtool/src/interrogate/functionWriters.h +++ b/dtool/src/interrogate/functionWriters.h @@ -42,7 +42,7 @@ protected: } }; - typedef set Writers; + typedef std::set Writers; Writers _writers; }; diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 218affd565..69ab181286 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -315,7 +315,7 @@ write_module(ostream &, ostream *out_h, InterrogateModuleDef *) { */ ParameterRemap *InterfaceMaker:: remap_parameter(CPPType *struct_type, CPPType *param_type) { - nassertr(param_type != NULL, NULL); + nassertr(param_type != nullptr, nullptr); if (convert_strings) { if (TypeManager::is_char_pointer(param_type)) { @@ -328,7 +328,7 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { // If we're exporting a method of basic_string itself, don't convert // basic_string's to atomic strings. - if (struct_type == (CPPType *)NULL || + if (struct_type == nullptr || !(TypeManager::is_basic_string_char(struct_type) || TypeManager::is_basic_string_wchar(struct_type))) { if (TypeManager::is_basic_string_char(param_type)) { @@ -359,11 +359,11 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { CPPType *pt_type = TypeManager::unwrap(param_type); if (TypeManager::is_basic_string_char(pt_type) || TypeManager::is_basic_string_wchar(pt_type)) { - return (ParameterRemap *)NULL; + return nullptr; } } } - if (struct_type == (CPPType *)NULL || + if (struct_type == nullptr || !TypeManager::is_vector_unsigned_char(struct_type)) { if (TypeManager::is_vector_unsigned_char(param_type)) { if (TypeManager::is_reference(param_type)) { @@ -385,7 +385,7 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { // Don't convert PointerTo<>'s to pointers for methods of the PointerTo // itself! - if (struct_type == (CPPType *)NULL || + if (struct_type == nullptr || !(pt_type->get_local_name(&parser) == struct_type->get_local_name(&parser))) { return new ParameterRemapPTToPointer(param_type); } @@ -417,7 +417,7 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { } else { // Here's something we have a problem with. - return (ParameterRemap *)NULL; + return nullptr; } } @@ -460,7 +460,7 @@ wrap_global_functions() { * added to the end. */ void InterfaceMaker:: -get_function_remaps(vector &remaps) { +get_function_remaps(std::vector &remaps) { FunctionsByIndex::iterator fi; for (fi = _functions.begin(); fi != _functions.end(); ++fi) { Function *func = (*fi).second; @@ -512,7 +512,7 @@ make_function_remap(const InterrogateType &itype, // No such FunctionRemap is valid. Return NULL. delete remap; - return (FunctionRemap *)NULL; + return nullptr; } /** @@ -576,7 +576,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { // printf(" Function Name = %s\n", ifunc.get_name().c_str()); // Now get all the valid FunctionRemaps for the function. - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); ++ii) { CPPInstance *cppfunc = (*ii).second; @@ -591,7 +591,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { pi != parameters->_parameters.rend(); ++pi) { CPPInstance *param = (*pi); - if (param->_initializer != (CPPExpression *)NULL) { + if (param->_initializer != nullptr) { // This parameter has a default value. max_default_parameters++; } else { @@ -610,7 +610,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { num_default_parameters++) { FunctionRemap *remap = make_function_remap(itype, ifunc, cppfunc, num_default_parameters); - if (remap != (FunctionRemap *)NULL) { + if (remap != nullptr) { func->_remaps.push_back(remap); @@ -654,7 +654,7 @@ InterfaceMaker::Object *InterfaceMaker:: record_object(TypeIndex type_index) { if (type_index == 0) { // An invalid type. - return (Object *)NULL; + return nullptr; } Objects::iterator oi = _objects.find(type_index); @@ -665,7 +665,6 @@ record_object(TypeIndex type_index) { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); const InterrogateType &itype = idb->get_type(type_index); - assert(&itype != NULL); Object *object = new Object(itype); bool inserted = _objects.insert(Objects::value_type(type_index, object)).second; @@ -756,8 +755,7 @@ manage_return_value(ostream &out, int indent_level, out << " = " << return_expr << ";\n"; indent(out, indent_level) - << "if (" << return_expr << " != (" - << remap->_return_type->get_new_type()->get_local_name(&parser) << ")NULL) {\n"; + << "if (" << return_expr << " != nullptr) {\n"; indent(out, indent_level + 2) << "(" << return_expr << ")->ref();\n"; indent(out, indent_level) @@ -814,8 +812,7 @@ output_ref(ostream &out, int indent_level, FunctionRemap *remap, // attempt to ref it. indent(out, indent_level) - << "if (" << varname << " != (" - << remap->_return_type->get_new_type()->get_local_name(&parser) << ")NULL) {\n"; + << "if (" << varname << " != nullptr) {\n"; indent(out, indent_level + 2) << varname << "->ref();\n"; indent(out, indent_level) @@ -848,8 +845,7 @@ output_unref(ostream &out, int indent_level, FunctionRemap *remap, // attempt to ref it. indent(out, indent_level) - << "if (" << varname << " != (" - << remap->_return_type->get_new_type()->get_local_name(&parser) << ")NULL) {\n"; + << "if (" << varname << " != nullptr) {\n"; if (TypeManager::is_pointer_to_base(remap->_return_type->get_temporary_type())) { // We're sure the reference count won't reach zero since we have it @@ -885,7 +881,7 @@ hash_function_signature(FunctionRemap *remap) { return; } - if ((*hi).second != (FunctionRemap *)NULL && + if ((*hi).second != nullptr && (*hi).second->_function_signature == remap->_function_signature) { // The same function signature has already appeared. This shouldn't // happen. @@ -897,9 +893,9 @@ hash_function_signature(FunctionRemap *remap) { } // We have a conflict. Extend both strings to resolve the ambiguity. - if ((*hi).second != (FunctionRemap *)NULL) { + if ((*hi).second != nullptr) { FunctionRemap *other_remap = (*hi).second; - (*hi).second = (FunctionRemap *)NULL; + (*hi).second = nullptr; other_remap->_hash += InterrogateBuilder::hash_string(other_remap->_function_signature, 11); bool inserted = _wrappers_by_hash.insert diff --git a/dtool/src/interrogate/interfaceMaker.h b/dtool/src/interrogate/interfaceMaker.h index f6b4730609..620f42d275 100644 --- a/dtool/src/interrogate/interfaceMaker.h +++ b/dtool/src/interrogate/interfaceMaker.h @@ -64,7 +64,7 @@ public: virtual bool separate_overloading(); virtual bool wrap_global_functions(); - void get_function_remaps(vector &remaps); + void get_function_remaps(std::vector &remaps); static ostream &indent(ostream &out, int indent_level); @@ -100,14 +100,14 @@ public: string _name; const InterrogateType &_itype; const InterrogateFunction &_ifunc; - typedef vector Remaps; + typedef std::vector Remaps; Remaps _remaps; bool _has_this; int _flags; ArgsType _args_type; }; - typedef map FunctionsByIndex; - typedef vector Functions; + typedef std::map FunctionsByIndex; + typedef std::vector Functions; FunctionsByIndex _functions; class MakeSeq { @@ -119,15 +119,15 @@ public: Function *_length_getter; Function *_element_getter; }; - typedef vector MakeSeqs; + typedef std::vector MakeSeqs; class Property { public: Property(const InterrogateElement &ielement); const InterrogateElement &_ielement; - vector _getter_remaps; - vector _setter_remaps; + std::vector _getter_remaps; + std::vector _setter_remaps; Function *_length_function; Function *_has_function; Function *_clear_function; @@ -136,7 +136,7 @@ public: Function *_getkey_function; bool _has_this; }; - typedef vector Properties; + typedef std::vector Properties; class Object { public: @@ -162,10 +162,10 @@ public: }; int _protocol_types; }; - typedef map Objects; + typedef std::map Objects; Objects _objects; - typedef map WrappersByHash; + typedef std::map WrappersByHash; WrappersByHash _wrappers_by_hash; virtual FunctionRemap * diff --git a/dtool/src/interrogate/interfaceMakerPython.cxx b/dtool/src/interrogate/interfaceMakerPython.cxx index 37125a7e64..31f59c0785 100644 --- a/dtool/src/interrogate/interfaceMakerPython.cxx +++ b/dtool/src/interrogate/interfaceMakerPython.cxx @@ -57,13 +57,13 @@ test_assert(ostream &out, int indent_level) const { indent(out, indent_level + 2) << "notify->clear_assert_failed();\n"; indent(out, indent_level + 2) - << "return (PyObject *)NULL;\n"; + << "return nullptr;\n"; indent(out, indent_level) << "}\n"; indent(out, indent_level) << "if (PyErr_Occurred()) {\n"; indent(out, indent_level + 2) - << "return (PyObject *)NULL;\n"; + << "return nullptr;\n"; indent(out, indent_level) << "}\n"; out << "#endif\n"; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 7542569d46..27151b8cbe 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -100,12 +100,12 @@ RenameSet methodRenameDictionary[] = { { "__deepcopy__" , "__deepcopy__", 0 }, { "print" , "Cprint", 0 }, { "CInterval.set_t", "_priv__cSetT", 0 }, - { NULL, NULL, -1 } + { nullptr, nullptr, -1 } }; RenameSet classRenameDictionary[] = { // No longer used, now empty. - { NULL, NULL, -1 } + { nullptr, nullptr, -1 } }; const char *pythonKeywords[] = { @@ -141,12 +141,12 @@ const char *pythonKeywords[] = { "while", "with", "yield", - NULL + nullptr }; std::string checkKeyword(std::string &cppName) { - for (int x = 0; pythonKeywords[x] != NULL; x++) { + for (int x = 0; pythonKeywords[x] != nullptr; x++) { if (cppName == pythonKeywords[x]) { return std::string("_") + cppName; } @@ -193,7 +193,7 @@ classNameFromCppName(const std::string &cppName, bool mangle) { } } - for (int x = 0; classRenameDictionary[x]._from != NULL; x++) { + for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { if (cppName == classRenameDictionary[x]._from) { className = classRenameDictionary[x]._to; } @@ -247,7 +247,7 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, } } - for (int x = 0; methodRenameDictionary[x]._from != NULL; x++) { + for (int x = 0; methodRenameDictionary[x]._from != nullptr; x++) { if (origName == methodRenameDictionary[x]._from) { methodName = methodRenameDictionary[x]._to; } @@ -255,7 +255,7 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, if (className.size() > 0) { string lookup_name = className + '.' + cppName; - for (int x = 0; classRenameDictionary[x]._from != NULL; x++) { + for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { if (lookup_name == methodRenameDictionary[x]._from) { methodName = methodRenameDictionary[x]._to; } @@ -296,7 +296,7 @@ std::string methodNameFromCppName(FunctionRemap *remap, const std::string &class bool InterfaceMakerPythonNative:: get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, SlottedFunctionDef &def) { - if (obj == NULL) { + if (obj == nullptr) { // Only methods may be slotted. return false; } @@ -679,7 +679,7 @@ write_function_slot(ostream &out, int indent_level, const SlottedFunctions &slot void InterfaceMakerPythonNative:: get_valid_child_classes(std::map &answer, CPPStructType *inclass, const std::string &upcast_seed, bool can_downcast) { - if (inclass == NULL) { + if (inclass == nullptr) { return; } @@ -691,7 +691,7 @@ get_valid_child_classes(std::map &answer, CPPStructTyp const CPPStructType::Base &base = (*bi); // if (base._vis <= V_public) can_downcast = false; CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); - if (base_type != NULL) { + if (base_type != nullptr) { std::string scoped_name = base_type->get_local_name(&parser); if (answer.find(scoped_name) == answer.end()) { @@ -738,7 +738,7 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, // will be grabbing the type index (which would obviously crash when // called on a NULL pointer), so we do it here. indent(out, indent_level) - << "if (" << return_expr << " == NULL) {\n"; + << "if (" << return_expr << " == nullptr) {\n"; indent(out, indent_level) << " Py_INCREF(Py_None);\n"; indent(out, indent_level) @@ -751,7 +751,7 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, indent(out, indent_level) << " ReferenceCount *rc = " << return_expr << "->as_reference_count();\n"; indent(out, indent_level) - << " bool is_refcount = (rc != (ReferenceCount *)NULL);\n"; + << " bool is_refcount = (rc != nullptr);\n"; indent(out, indent_level) << " if (is_refcount) {\n"; indent(out, indent_level) @@ -806,7 +806,7 @@ void InterfaceMakerPythonNative:: write_prototypes(ostream &out_code, ostream *out_h) { Functions::iterator fi; - if (out_h != NULL) { + if (out_h != nullptr) { *out_h << "#include \"py_panda.h\"\n\n"; } @@ -862,24 +862,24 @@ write_prototypes(ostream &out_code, ostream *out_h) { if (TypeManager::is_reference_count(type)) { out_code << "inline static bool Dtool_ConstCoerce_" << safe_name << "(PyObject *args, CPT(" << class_name << ") &coerced) {\n" - << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" - << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != nullptr, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce != nullptr, false);\n" << " return ((bool (*)(PyObject *, CPT(" << class_name << ") &))Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce)(args, coerced);\n" << "}\n"; if (has_coerce > 1) { out_code << "inline static bool Dtool_Coerce_" << safe_name << "(PyObject *args, PT(" << class_name << ") &coerced) {\n" - << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" - << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != nullptr, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != nullptr, false);\n" << " return ((bool (*)(PyObject *, PT(" << class_name << ") &))Dtool_Ptr_" << safe_name << "->_Dtool_Coerce)(args, coerced);\n" << "}\n"; } } else { out_code << "inline static " << class_name << " *Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " &coerced) {\n" - << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, NULL);\n" - << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != NULL, NULL);\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != nullptr, nullptr);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != nullptr, nullptr);\n" << " return ((" << class_name << " *(*)(PyObject *, " << class_name << " &))Dtool_Ptr_" << safe_name << "->_Dtool_Coerce)(args, coerced);\n" << "}\n"; } @@ -966,7 +966,7 @@ write_functions(ostream &out) { for (fi = _functions.begin(); fi != _functions.end(); ++fi) { Function *func = (*fi).second; if (!func->_itype.is_global() && is_function_legal(func)) { - write_function_for_top(out, NULL, func); + write_function_for_top(out, nullptr, func); } } @@ -1096,8 +1096,8 @@ write_class_details(ostream &out, Object *obj) { out << "static void *Dtool_UpcastInterface_" << ClassName << "(PyObject *self, Dtool_PyTypedObject *requested_type) {\n"; out << " Dtool_PyTypedObject *type = DtoolInstance_TYPE(self);\n"; out << " if (type != &Dtool_" << ClassName << ") {\n"; - out << " printf(\"" << ClassName << " ** Bad Source Type-- Requesting Conversion from %s to %s\\n\", Py_TYPE(self)->tp_name, requested_type->_PyType.tp_name); fflush(NULL);\n";; - out << " return NULL;\n"; + out << " printf(\"" << ClassName << " ** Bad Source Type-- Requesting Conversion from %s to %s\\n\", Py_TYPE(self)->tp_name, requested_type->_PyType.tp_name); fflush(nullptr);\n";; + out << " return nullptr;\n"; out << " }\n"; out << "\n"; out << " " << cClassName << " *local_this = (" << cClassName << " *)DtoolInstance_VOID_PTR(self);\n"; @@ -1113,12 +1113,12 @@ write_class_details(ostream &out, Object *obj) { } } - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; out << "static void *Dtool_DowncastInterface_" << ClassName << "(void *from_this, Dtool_PyTypedObject *from_type) {\n"; - out << " if (from_this == NULL || from_type == NULL) {\n"; - out << " return NULL;\n"; + out << " if (from_this == nullptr || from_type == nullptr) {\n"; + out << " return nullptr;\n"; out << " }\n"; out << " if (from_type == Dtool_Ptr_" << ClassName << ") {\n"; out << " return from_this;\n"; @@ -1131,7 +1131,7 @@ write_class_details(ostream &out, Object *obj) { out << " }\n"; } } - out << " return (void *) NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } } @@ -1187,7 +1187,7 @@ write_class_declarations(ostream &out, ostream *out_h, Object *obj) { out << "\n"; - if (out_h != NULL) { + if (out_h != nullptr) { *out_h << "extern \"C\" " << EXPORT_IMPORT_PREFIX << " struct Dtool_PyTypedObject Dtool_" << class_name << ";\n"; } } @@ -1225,7 +1225,7 @@ write_sub_module(ostream &out, Object *obj) { _external_imports.insert(TypeManager::resolve_type(wrapped_itype._cpptype)); class_ptr = "Dtool_Ptr_" + class_name; - out << " assert(" << class_ptr << " != NULL);\n"; + out << " assert(" << class_ptr << " != nullptr);\n"; } else { class_ptr = "&Dtool_" + class_name; @@ -1462,10 +1462,10 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " {\"Dtool_AddToDictionary\", &Dtool_AddToDictionary, METH_VARARGS, \"Used to add items into a tp_dict\"},\n"; } - out << " {NULL, NULL, 0, NULL}\n" << "};\n\n"; + out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n"; out << "struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs};\n"; - if (out_h != NULL) { + if (out_h != nullptr) { *out_h << "extern struct LibraryDef " << def->library_name << "_moddef;\n"; } } @@ -1486,10 +1486,10 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << "static struct PyModuleDef python_native_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << def->module_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" - << " NULL,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr,\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n" << "\n" << "#ifdef _WIN32\n" @@ -1501,7 +1501,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << "#endif\n" << "\n" << "PyObject *PyInit_" << def->module_name << "() {\n" - << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, NULL};\n" + << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n" << " PyObject *module = Dtool_PyModuleInitHelper(refs, &python_native_module);\n" << " Dtool_" << def->library_name << "_BuildInstants(module);\n" << " return module;\n" @@ -1518,7 +1518,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << "#endif\n" << "\n" << "void init" << def->module_name << "() {\n" - << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, NULL};\n" + << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n" << " PyObject *module = Dtool_PyModuleInitHelper(refs, \"" << def->module_name << "\");\n" << " Dtool_" << def->library_name << "_BuildInstants(module);\n" << "}\n" @@ -1546,7 +1546,7 @@ write_module_class(ostream &out, Object *obj) { } Object *nested_obj = _objects[nested_index]; - assert(nested_obj != (Object *)NULL); + assert(nested_obj != nullptr); if (nested_obj->_itype.is_class() || nested_obj->_itype.is_struct()) { write_module_class(out, nested_obj); @@ -1694,18 +1694,18 @@ write_module_class(ostream &out, Object *obj) { if (obj->_protocol_types & Object::PT_make_copy) { if (!got_copy) { - out << " {\"__copy__\", ©_from_make_copy, METH_NOARGS, NULL},\n"; + out << " {\"__copy__\", ©_from_make_copy, METH_NOARGS, nullptr},\n"; got_copy = true; } } else if (obj->_protocol_types & Object::PT_copy_constructor) { if (!got_copy) { - out << " {\"__copy__\", ©_from_copy_constructor, METH_NOARGS, NULL},\n"; + out << " {\"__copy__\", ©_from_copy_constructor, METH_NOARGS, nullptr},\n"; got_copy = true; } } if (got_copy && !got_deepcopy) { - out << " {\"__deepcopy__\", &map_deepcopy_to_copy, METH_VARARGS, NULL},\n"; + out << " {\"__deepcopy__\", &map_deepcopy_to_copy, METH_VARARGS, nullptr},\n"; } MakeSeqs::iterator msi; @@ -1727,14 +1727,14 @@ write_module_class(ostream &out, Object *obj) { string name1 = methodNameFromCppName(seq_name, export_class_name, false); string name2 = methodNameFromCppName(seq_name, export_class_name, true); out << " {\"" << name1 - << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", NULL},\n"; + << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", nullptr},\n"; if (name1 != name2) { out << " { \"" << name2 - << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", NULL},\n"; + << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", nullptr},\n"; } } - out << " {NULL, NULL, 0, NULL}\n" + out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n"; int num_derivations = obj->_itype.number_of_derivations(); @@ -1792,9 +1792,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; int return_flags = RF_pyobject | RF_err_null; @@ -1812,7 +1812,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -1833,19 +1833,19 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, PyObject *arg) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; if (rfi->second._wrapper_type != WT_one_param) { // WT_binary_operator means we must return NotImplemented, instead // of raising an exception, if the this pointer doesn't match. // This is for things like __sub__, which Python likes to call on // the wrong-type objects. out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **)&local_this);\n"; - out << " if (local_this == NULL) {\n"; + out << " if (local_this == nullptr) {\n"; out << " Py_INCREF(Py_NotImplemented);\n"; out << " return Py_NotImplemented;\n"; } else { out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; } out << " }\n"; @@ -1862,7 +1862,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; } out << "}\n\n"; } @@ -1876,7 +1876,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, PyObject *arg, PyObject *arg2) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -1899,7 +1899,7 @@ write_module_class(ostream &out, Object *obj) { } out << " // Determine whether to call __setattr__ or __delattr__.\n"; - out << " if (arg2 != (PyObject *)NULL) { // __setattr__\n"; + out << " if (arg2 != nullptr) { // __setattr__\n"; if (!setattr_remaps.empty()) { out << " PyObject *args = PyTuple_Pack(2, arg, arg2);\n"; @@ -1956,17 +1956,17 @@ write_module_class(ostream &out, Object *obj) { out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, PyObject *arg) {\n"; out << " PyObject *res = PyObject_GenericGetAttr(self, arg);\n"; - out << " if (res != NULL) {\n"; + out << " if (res != nullptr) {\n"; out << " return res;\n"; out << " }\n"; out << " if (_PyErr_OCCURRED() != PyExc_AttributeError) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; out << " PyErr_Clear();\n\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; string expected_params; @@ -1975,7 +1975,7 @@ write_module_class(ostream &out, Object *obj) { RF_pyobject | RF_err_null, true); // out << " PyErr_Clear();\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -1988,9 +1988,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, Py_ssize_t index) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; // This is a getitem or setitem of a sequence type. This means we @@ -1999,7 +1999,7 @@ write_module_class(ostream &out, Object *obj) { // assumption that Python makes). out << " if (index < 0 || index >= (Py_ssize_t) local_this->size()) {\n"; out << " PyErr_SetString(PyExc_IndexError, \"" << ClassName << " index out of range\");\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; string expected_params; @@ -2011,7 +2011,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -2024,7 +2024,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, Py_ssize_t index, PyObject *arg) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2052,7 +2052,7 @@ write_module_class(ostream &out, Object *obj) { } string expected_params; - out << " if (arg != (PyObject *)NULL) { // __setitem__\n"; + out << " if (arg != nullptr) { // __setitem__\n"; write_function_forset(out, setitem_remaps, 2, 2, expected_params, 4, true, true, AT_single_arg, RF_int, false, true, "index"); out << " } else { // __delitem__\n"; @@ -2078,7 +2078,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static Py_ssize_t " << def._wrapper_name << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2098,7 +2098,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, PyObject *arg, PyObject *arg2) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2121,7 +2121,7 @@ write_module_class(ostream &out, Object *obj) { } string expected_params; - out << " if (arg2 != (PyObject *)NULL) { // __setitem__\n"; + out << " if (arg2 != nullptr) { // __setitem__\n"; out << " PyObject *args = PyTuple_Pack(2, arg, arg2);\n"; write_function_forset(out, setitem_remaps, 2, 2, expected_params, 4, true, true, AT_varargs, RF_int | RF_decref_args, false); @@ -2155,7 +2155,7 @@ write_module_class(ostream &out, Object *obj) { const char *container = ""; if (remap->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2183,15 +2183,15 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, Py_buffer *buffer, int flags) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; vector_string params_const(1); vector_string params_nonconst(1); - FunctionRemap *remap_const = NULL; - FunctionRemap *remap_nonconst = NULL; + FunctionRemap *remap_const = nullptr; + FunctionRemap *remap_nonconst = nullptr; // Iterate through the remaps to find the one that matches our // parameters. @@ -2219,20 +2219,20 @@ write_module_class(ostream &out, Object *obj) { // because the function may depend on it to decide whether to // provide a writable buffer or a readonly buffer. const string const_this = "(const " + cClassName + " *)local_this"; - if (remap_const != NULL && remap_nonconst != NULL) { + if (remap_const != nullptr && remap_nonconst != nullptr) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; out << " return " << remap_nonconst->call_function(out, 4, false, "local_this", params_nonconst) << ";\n"; out << " } else {\n"; out << " return " << remap_const->call_function(out, 4, false, const_this, params_const) << ";\n"; out << " }\n"; - } else if (remap_nonconst != NULL) { + } else if (remap_nonconst != nullptr) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; out << " return " << remap_nonconst->call_function(out, 4, false, "local_this", params_nonconst) << ";\n"; out << " } else {\n"; out << " Dtool_Raise_TypeError(\"Cannot call " << ClassName << ".__getbuffer__() on a const object.\");\n"; out << " return -1;\n"; out << " }\n"; - } else if (remap_const != NULL) { + } else if (remap_const != nullptr) { out << " return " << remap_const->call_function(out, 4, false, const_this, params_const) << ";\n"; } else { nout << ClassName << "::__getbuffer__ does not match the required signature.\n"; @@ -2252,15 +2252,15 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static void " << def._wrapper_name << "(PyObject *self, Py_buffer *buffer) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return;\n"; out << " }\n\n"; vector_string params_const(1); vector_string params_nonconst(1); - FunctionRemap *remap_const = NULL; - FunctionRemap *remap_nonconst = NULL; + FunctionRemap *remap_const = nullptr; + FunctionRemap *remap_nonconst = nullptr; // Iterate through the remaps to find the one that matches our // parameters. @@ -2284,7 +2284,7 @@ write_module_class(ostream &out, Object *obj) { string return_expr; const string const_this = "(const " + cClassName + " *)local_this"; - if (remap_const != NULL && remap_nonconst != NULL) { + if (remap_const != nullptr && remap_nonconst != nullptr) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; return_expr = remap_nonconst->call_function(out, 4, false, "local_this", params_nonconst); if (!return_expr.empty()) { @@ -2298,7 +2298,7 @@ write_module_class(ostream &out, Object *obj) { } out << " }\n"; - } else if (remap_nonconst != NULL) { + } else if (remap_nonconst != nullptr) { // Doesn't matter if there's no const version. We *have* to call // it or else we could leak memory. return_expr = remap_nonconst->call_function(out, 2, false, "local_this", params_nonconst); @@ -2306,7 +2306,7 @@ write_module_class(ostream &out, Object *obj) { out << " " << return_expr << ";\n"; } - } else if (remap_const != NULL) { + } else if (remap_const != nullptr) { return_expr = remap_const->call_function(out, 2, false, const_this, params_const); if (!return_expr.empty()) { out << " " << return_expr << ";\n"; @@ -2336,9 +2336,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, PyObject *arg, PyObject *arg2) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **)&local_this);\n"; - out << " if (local_this == NULL) {\n"; + out << " if (local_this == nullptr) {\n"; // WT_ternary_operator means we must return NotImplemented, instead // of raising an exception, if the this pointer doesn't match. This // is for things like __pow__, which Python likes to call on the @@ -2364,7 +2364,7 @@ write_module_class(ostream &out, Object *obj) { string expected_params; - out << " if (arg2 != (PyObject *)NULL && arg2 != Py_None) {\n"; + out << " if (arg2 != nullptr && arg2 != Py_None) {\n"; out << " PyObject *args = PyTuple_Pack(2, arg, arg2);\n"; write_function_forset(out, two_param_remaps, 2, 2, expected_params, 4, true, true, AT_varargs, RF_pyobject | RF_err_null | RF_decref_args, true); @@ -2379,7 +2379,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -2399,9 +2399,9 @@ write_module_class(ostream &out, Object *obj) { const char *container = ""; if (remap->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **) &local_this);\n"; - out << " if (local_this == NULL) {\n"; + out << " if (local_this == nullptr) {\n"; out << " return 0;\n"; out << " }\n\n"; container = "local_this"; @@ -2424,7 +2424,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, PyObject *arg) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2451,7 +2451,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static Py_hash_t " << def._wrapper_name << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2489,9 +2489,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << "\n"; out << "//////////////////\n"; out << "static PyObject *Dtool_Repr_" << ClassName << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; out << " ostringstream os;\n"; if (need_repr == 3) { @@ -2519,9 +2519,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << "\n"; out << "//////////////////\n"; out << "static PyObject *Dtool_Str_" << ClassName << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; out << " ostringstream os;\n"; if (need_str == 2) { @@ -2542,9 +2542,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << "\n"; out << "//////////////////\n"; out << "static PyObject *Dtool_RichCompare_" << ClassName << "(PyObject *self, PyObject *arg, int op) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; out << " switch (op) {\n"; @@ -2607,7 +2607,7 @@ write_module_class(ostream &out, Object *obj) { out << " if (PyErr_ExceptionMatches(PyExc_TypeError)) {\n"; out << " PyErr_Clear();\n"; out << " } else {\n"; - out << " return (PyObject *)NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; out << " }\n"; out << " switch (op) {\n"; @@ -2636,8 +2636,6 @@ write_module_class(ostream &out, Object *obj) { if (obj->_properties.size() > 0) { // Write out the array of properties, telling Python which getter and // setter to call when they are assigned or queried in Python code. - out << "static PyGetSetDef Dtool_Properties_" << ClassName << "[] = {\n"; - Properties::const_iterator pit; for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { Property *property = (*pit); @@ -2646,13 +2644,17 @@ write_module_class(ostream &out, Object *obj) { continue; } + if (num_getset == 0) { + out << "static PyGetSetDef Dtool_Properties_" << ClassName << "[] = {\n"; + } + ++num_getset; string name1 = methodNameFromCppName(ielem.get_name(), "", false); // string name2 = methodNameFromCppName(ielem.get_name(), "", true); string getter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter"; - string setter = "NULL"; + string setter = "nullptr"; if (!ielem.is_sequence() && !ielem.is_mapping() && !property->_setter_remaps.empty()) { setter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter"; } @@ -2664,11 +2666,11 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 4, ielem.get_comment()); out << ",\n "; } else { - out << ", NULL, "; + out << ", nullptr, "; } // Extra void* argument; we don't make use of it. - out << "NULL},\n"; + out << "nullptr},\n"; /*if (name1 != name2 && name1 != "__dict__") { // Add alternative spelling. @@ -2679,8 +2681,10 @@ write_module_class(ostream &out, Object *obj) { }*/ } - out << " {NULL},\n"; - out << "};\n\n"; + if (num_getset != 0) { + out << " {nullptr},\n"; + out << "};\n\n"; + } } // These fields are inherited together. We should either write all of them @@ -2718,7 +2722,7 @@ write_module_class(ostream &out, Object *obj) { write_function_slot(out, 2, slots, "nb_coerce"); out << "#endif\n"; write_function_slot(out, 2, slots, "nb_int"); - out << " 0, // nb_long\n"; // removed in Python 3 + out << " nullptr, // nb_long\n"; // removed in Python 3 write_function_slot(out, 2, slots, "nb_float"); out << "#if PY_MAJOR_VERSION < 3\n"; write_function_slot(out, 2, slots, "nb_oct"); @@ -2765,9 +2769,9 @@ write_module_class(ostream &out, Object *obj) { write_function_slot(out, 2, slots, "sq_concat"); write_function_slot(out, 2, slots, "sq_repeat"); write_function_slot(out, 2, slots, "sq_item"); - out << " 0, // sq_slice\n"; // removed in Python 3 + out << " nullptr, // sq_slice\n"; // removed in Python 3 write_function_slot(out, 2, slots, "sq_ass_item"); - out << " 0, // sq_ass_slice\n"; // removed in Python 3 + out << " nullptr, // sq_ass_slice\n"; // removed in Python 3 write_function_slot(out, 2, slots, "sq_contains"); write_function_slot(out, 2, slots, "sq_inplace_concat"); @@ -2817,7 +2821,7 @@ write_module_class(ostream &out, Object *obj) { // Output the actual PyTypeObject definition. out << "struct Dtool_PyTypedObject Dtool_" << ClassName << " = {\n"; out << " {\n"; - out << " PyVarObject_HEAD_INIT(NULL, 0)\n"; + out << " PyVarObject_HEAD_INIT(nullptr, 0)\n"; // const char *tp_name; out << " \"" << _def->module_name << "." << export_class_name << "\",\n"; // Py_ssize_t tp_basicsize; @@ -2839,16 +2843,16 @@ write_module_class(ostream &out, Object *obj) { if (have_async) { out << " &Dtool_AsyncMethods_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_async\n"; + out << " nullptr, // tp_as_async\n"; } out << "#elif PY_MAJOR_VERSION >= 3\n"; - out << " 0, // tp_reserved\n"; + out << " nullptr, // tp_reserved\n"; out << "#else\n"; if (has_hash_compare) { write_function_slot(out, 4, slots, "tp_compare", "&DTOOL_PyObject_ComparePointers"); } else { - out << " 0, // tp_compare\n"; + out << " nullptr, // tp_compare\n"; } out << "#endif\n"; @@ -2865,20 +2869,20 @@ write_module_class(ostream &out, Object *obj) { if (has_parent_class || (obj->_protocol_types & Object::PT_sequence) != 0) { out << " &Dtool_SequenceMethods_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_sequence\n"; + out << " nullptr, // tp_as_sequence\n"; } // PyMappingMethods *tp_as_mapping; if (has_parent_class || (obj->_protocol_types & Object::PT_mapping) != 0) { out << " &Dtool_MappingMethods_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_mapping\n"; + out << " nullptr, // tp_as_mapping\n"; } // hashfunc tp_hash; if (has_hash_compare) { write_function_slot(out, 4, slots, "tp_hash", "&DTOOL_PyObject_HashPointer"); } else { - out << " 0, // tp_hash\n"; + out << " nullptr, // tp_hash\n"; } // ternaryfunc tp_call; @@ -2902,7 +2906,7 @@ write_module_class(ostream &out, Object *obj) { if (has_parent_class || has_local_getbuffer) { out << " &Dtool_BufferProcs_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_buffer\n"; + out << " nullptr, // tp_as_buffer\n"; } string gcflag; @@ -2930,15 +2934,15 @@ write_module_class(ostream &out, Object *obj) { out << ",\n"; out << "#endif\n"; } else { - out << " 0, // tp_doc\n"; + out << " nullptr, // tp_doc\n"; } // traverseproc tp_traverse; - out << " 0, // tp_traverse\n"; + out << " nullptr, // tp_traverse\n"; //write_function_slot(out, 4, slots, "tp_traverse"); // inquiry tp_clear; - out << " 0, // tp_clear\n"; + out << " nullptr, // tp_clear\n"; //write_function_slot(out, 4, slots, "tp_clear"); // richcmpfunc tp_richcompare; @@ -2949,10 +2953,10 @@ write_module_class(ostream &out, Object *obj) { out << "#if PY_MAJOR_VERSION >= 3\n"; out << " &DTOOL_PyObject_RichCompare,\n"; out << "#else\n"; - out << " 0, // tp_richcompare\n"; + out << " nullptr, // tp_richcompare\n"; out << "#endif\n"; } else { - out << " 0, // tp_richcompare\n"; + out << " nullptr, // tp_richcompare\n"; } // Py_ssize_t tp_weaklistoffset; @@ -2966,19 +2970,19 @@ write_module_class(ostream &out, Object *obj) { // struct PyMethodDef *tp_methods; out << " Dtool_Methods_" << ClassName << ",\n"; // struct PyMemberDef *tp_members; - out << " 0, // tp_members\n"; + out << " nullptr, // tp_members\n"; // struct PyGetSetDef *tp_getset; if (num_getset > 0) { out << " Dtool_Properties_" << ClassName << ",\n"; } else { - out << " 0, // tp_getset\n"; + out << " nullptr, // tp_getset\n"; } // struct _typeobject *tp_base; - out << " 0, // tp_base\n"; + out << " nullptr, // tp_base\n"; // PyObject *tp_dict; - out << " 0, // tp_dict\n"; + out << " nullptr, // tp_dict\n"; // descrgetfunc tp_descr_get; write_function_slot(out, 4, slots, "tp_descr_get"); // descrsetfunc tp_descr_set; @@ -2998,26 +3002,26 @@ write_module_class(ostream &out, Object *obj) { out << " PyObject_Del,\n"; } // inquiry tp_is_gc; - out << " 0, // tp_is_gc\n"; + out << " nullptr, // tp_is_gc\n"; // PyObject *tp_bases; - out << " 0, // tp_bases\n"; + out << " nullptr, // tp_bases\n"; // PyObject *tp_mro; - out << " 0, // tp_mro\n"; + out << " nullptr, // tp_mro\n"; // PyObject *tp_cache; - out << " 0, // tp_cache\n"; + out << " nullptr, // tp_cache\n"; // PyObject *tp_subclasses; - out << " 0, // tp_subclasses\n"; + out << " nullptr, // tp_subclasses\n"; // PyObject *tp_weaklist; - out << " 0, // tp_weaklist\n"; + out << " nullptr, // tp_weaklist\n"; // destructor tp_del; - out << " 0, // tp_del\n"; + out << " nullptr, // tp_del\n"; // unsigned int tp_version_tag out << "#if PY_VERSION_HEX >= 0x02060000\n"; out << " 0, // tp_version_tag\n"; out << "#endif\n"; // destructor tp_finalize out << "#if PY_VERSION_HEX >= 0x03040000\n"; - out << " 0, // tp_finalize\n"; + out << " nullptr, // tp_finalize\n"; out << "#endif\n"; out << " },\n"; @@ -3035,15 +3039,15 @@ write_module_class(ostream &out, Object *obj) { if (has_coerce > 1) { out << " (CoerceFunction)Dtool_Coerce_" << ClassName << ",\n"; } else { - out << " (CoerceFunction)0,\n"; + out << " nullptr,\n"; } } else { - out << " (CoerceFunction)0,\n"; + out << " nullptr,\n"; out << " (CoerceFunction)Dtool_Coerce_" << ClassName << ",\n"; } } else { - out << " (CoerceFunction)0,\n"; - out << " (CoerceFunction)0,\n"; + out << " nullptr,\n"; + out << " nullptr,\n"; } out << "};\n\n"; @@ -3063,14 +3067,14 @@ write_module_class(ostream &out, Object *obj) { if (isExportThisRun(*bi)) { baseargs += ", (PyTypeObject *)&Dtool_" + safe_name; - out << " Dtool_PyModuleClassInit_" << safe_name << "(NULL);\n"; + out << " Dtool_PyModuleClassInit_" << safe_name << "(nullptr);\n"; } else { baseargs += ", (PyTypeObject *)Dtool_Ptr_" + safe_name; - out << " assert(Dtool_Ptr_" << safe_name << " != NULL);\n" - << " assert(Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit != NULL);\n" - << " Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit(NULL);\n"; + out << " assert(Dtool_Ptr_" << safe_name << " != nullptr);\n" + << " assert(Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit != nullptr);\n" + << " Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit(nullptr);\n"; } } @@ -3089,7 +3093,7 @@ write_module_class(ostream &out, Object *obj) { continue; } Object *nested_obj = _objects[nested_index]; - assert(nested_obj != (Object *)NULL); + assert(nested_obj != nullptr); if (nested_obj->_itype.is_class() || nested_obj->_itype.is_struct()) { num_dict_items += 2; @@ -3121,13 +3125,13 @@ write_module_class(ostream &out, Object *obj) { } Object *nested_obj = _objects[nested_index]; - assert(nested_obj != (Object *)NULL); + assert(nested_obj != nullptr); if (nested_obj->_itype.is_class() || nested_obj->_itype.is_struct()) { std::string ClassName1 = make_safe_name(nested_obj->_itype.get_scoped_name()); std::string ClassName2 = make_safe_name(nested_obj->_itype.get_name()); out << " // Nested Object " << ClassName1 << ";\n"; - out << " Dtool_PyModuleClassInit_" << ClassName1 << "(NULL);\n"; + out << " Dtool_PyModuleClassInit_" << ClassName1 << "(nullptr);\n"; string name1 = classNameFromCppName(ClassName2, false); string name2 = classNameFromCppName(ClassName2, true); out << " PyDict_SetItemString(dict, \"" << name1 << "\", (PyObject *)&Dtool_" << ClassName1 << ");\n"; @@ -3217,7 +3221,7 @@ write_module_class(ostream &out, Object *obj) { // string name2 = methodNameFromCppName(ielem.get_name(), "", true); string getter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter"; - string setter = "NULL"; + string setter = "nullptr"; if (!ielem.is_sequence() && !ielem.is_mapping() && !property->_setter_remaps.empty()) { setter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter"; } @@ -3229,11 +3233,11 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 4, ielem.get_comment()); out << ",\n "; } else { - out << ", NULL, "; + out << ", nullptr, "; } // Extra void* argument; we don't make use of it. - out << "NULL};\n"; + out << "nullptr};\n"; out << " PyDict_SetItemString(dict, \"" << name1 << "\", Dtool_NewStaticProperty(&Dtool_" << ClassName << "._PyType, &def_" << name1 << "));\n"; /* Alternative spelling: @@ -3437,7 +3441,7 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker output_quoted(out, 2, comment.str()); out << ";\n"; out << "#else\n"; - out << "static const char *" << func->_name << "_comment = NULL;\n"; + out << "static const char *" << func->_name << "_comment = nullptr;\n"; out << "#endif\n\n"; } @@ -3458,7 +3462,7 @@ write_function_for_name(ostream &out, Object *obj, bool has_this = false; Function::Remaps::const_iterator ri; - FunctionRemap *remap = NULL; + FunctionRemap *remap = nullptr; int max_required_args = 0; bool all_nonconst = true; bool has_keywords = false; @@ -3510,7 +3514,7 @@ write_function_for_name(ostream &out, Object *obj, // string class_name = remap->_cpptype->get_simple_name(); // Extract pointer from 'self' parameter. - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; if (all_nonconst) { // All remaps are non-const. Also check that this object isn't const. @@ -3534,7 +3538,7 @@ write_function_for_name(ostream &out, Object *obj, if (args_type == AT_keyword_args && !has_keywords) { // We don't actually take keyword arguments. Make sure we didn't get any. - out << " if (kwds != NULL && PyDict_Size(kwds) > 0) {\n"; + out << " if (kwds != nullptr && PyDict_Size(kwds) > 0) {\n"; out << "#ifdef NDEBUG\n"; error_raise_return(out, 4, return_flags, "TypeError", "function takes no keyword arguments"); out << "#else\n"; @@ -3560,7 +3564,7 @@ write_function_for_name(ostream &out, Object *obj, switch (args_type) { case AT_keyword_args: indent(out, 2) << "int parameter_count = (int)PyTuple_Size(args);\n"; - indent(out, 2) << "if (kwds != NULL) {\n"; + indent(out, 2) << "if (kwds != nullptr) {\n"; indent(out, 2) << " parameter_count += (int)PyDict_Size(kwds);\n"; indent(out, 2) << "}\n"; break; @@ -3606,8 +3610,8 @@ write_function_for_name(ostream &out, Object *obj, std::set::iterator sii; for (sii = mii->second.begin(); sii != mii->second.end(); ++sii) { remap = (*sii); - int first_param = remap->_has_this ? 1 : 0; - for (int i = first_param; i < remap->_parameters.size(); ++i) { + size_t first_param = remap->_has_this ? 1u : 0u; + for (size_t i = first_param; i < remap->_parameters.size(); ++i) { if (remap->_parameters[i]._has_name) { strip_keyword_args = false; break; @@ -3619,7 +3623,7 @@ write_function_for_name(ostream &out, Object *obj, if (strip_keyword_args) { // None of the remaps take any keyword arguments, so let's check that // we take none. This saves some checks later on. - indent(out, 4) << "if (kwds == NULL || PyDict_GET_SIZE(kwds) == 0) {\n"; + indent(out, 4) << "if (kwds == nullptr || PyDict_GET_SIZE(kwds) == 0) {\n"; if (min_args == 1 && min_args == 1) { indent(out, 4) << " PyObject *arg = PyTuple_GET_ITEM(args, 0);\n"; write_function_forset(out, mii->second, min_args, max_args, expected_params, 6, @@ -3706,7 +3710,7 @@ write_function_for_name(ostream &out, Object *obj, case AT_keyword_args: out << " if (!Dtool_CheckNoArgs(args, kwds)) {\n"; out << " int parameter_count = (int)PyTuple_Size(args);\n"; - out << " if (kwds != NULL) {\n"; + out << " if (kwds != nullptr) {\n"; out << " parameter_count += (int)PyDict_Size(kwds);\n"; out << " }\n"; break; @@ -3738,7 +3742,7 @@ write_function_for_name(ostream &out, Object *obj, // Check this to be sure, as we handle the case of only 1 keyword arg in // write_function_forset (not using ParseTupleAndKeywords). out << " int parameter_count = (int)PyTuple_Size(args);\n" - " if (kwds != NULL) {\n" + " if (kwds != nullptr) {\n" " parameter_count += (int)PyDict_Size(kwds);\n" " }\n" " if (parameter_count != 1) {\n" @@ -4235,8 +4239,8 @@ int get_type_sort(CPPType *type) { // The Core sort function for remap calling orders.. bool RemapCompareLess(FunctionRemap *in1, FunctionRemap *in2) { - assert(in1 != NULL); - assert(in2 != NULL); + assert(in1 != nullptr); + assert(in2 != nullptr); if (in1->_const_method != in2->_const_method) { // Non-const methods should come first. @@ -4320,7 +4324,7 @@ write_function_forset(ostream &out, return; } - FunctionRemap *remap = NULL; + FunctionRemap *remap = nullptr; std::set::iterator sii; bool all_nonconst = false; @@ -4733,7 +4737,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_convert << "#if PY_VERSION_HEX >= 0x03030000\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", NULL);\n" + << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", nullptr);\n" << "#else" << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" @@ -4823,7 +4827,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, << default_value->_str.size() << ";\n"; } } else { - indent(out, indent_level) << "const char *" << param_name << "_str = NULL;\n"; + indent(out, indent_level) << "const char *" << param_name << "_str = nullptr;\n"; indent(out, indent_level) << "Py_ssize_t " << param_name << "_len;\n"; } @@ -4835,11 +4839,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, out << "#else\n"; // NB. PyString_AsStringAndSize also accepts a PyUnicode. indent(out, indent_level) << "if (PyString_AsStringAndSize(arg, (char **)&" << param_name << "_str, &" << param_name << "_len) == -1) {\n"; - indent(out, indent_level + 2) << param_name << "_str = NULL;\n"; + indent(out, indent_level + 2) << param_name << "_str = nullptr;\n"; indent(out, indent_level) << "}\n"; out << "#endif\n"; - extra_param_check << " && " << param_name << "_str != NULL"; + extra_param_check << " && " << param_name << "_str != nullptr"; } else { format_specifiers += "s#"; parameter_list += ", &" + param_name @@ -4858,7 +4862,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, only_pyobjects = false; } else if (TypeManager::is_vector_unsigned_char(type)) { - indent(out, indent_level) << "unsigned char *" << param_name << "_str = NULL;\n"; + indent(out, indent_level) << "unsigned char *" << param_name << "_str = nullptr;\n"; indent(out, indent_level) << "Py_ssize_t " << param_name << "_len;\n"; if (args_type == AT_single_arg) { @@ -5283,23 +5287,23 @@ write_function_instance(ostream &out, FunctionRemap *remap, // Unravel the type to determine its properties. int array_len = -1; bool is_const = true; - CPPSimpleType *simple = NULL; + CPPSimpleType *simple = nullptr; CPPType *unwrap = TypeManager::unwrap_const_reference(type); - if (unwrap != NULL) { + if (unwrap != nullptr) { CPPArrayType *array_type = unwrap->as_array_type(); CPPPointerType *pointer_type = unwrap->as_pointer_type(); - if (array_type != NULL) { - if (array_type->_bounds != NULL) { + if (array_type != nullptr) { + if (array_type->_bounds != nullptr) { array_len = array_type->_bounds->evaluate().as_integer(); } unwrap = array_type->_element_type; - } else if (pointer_type != NULL) { + } else if (pointer_type != nullptr) { unwrap = pointer_type->_pointing_at; } CPPConstType *const_type = unwrap->as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { unwrap = const_type->_wrapped_around; } else { is_const = false; @@ -5405,7 +5409,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { indent(out, indent_level) << "PyObject *" << param_name; if (is_optional) { - out << " = NULL"; + out << " = nullptr"; } out << ";\n"; format_specifiers += "O"; @@ -5447,6 +5451,9 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (TypeManager::is_reference_count(obj_type)) { // We use a PointerTo to handle the management here. It's cleaner // that way. + if (default_expr == " = 0" || default_expr == " = nullptr") { + default_expr.clear(); + } if (TypeManager::is_const_pointer_to_anything(type)) { extra_convert << "CPT(" << class_name << ") " << param_name << "_this" @@ -5477,16 +5484,16 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (is_optional && maybe_none) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL && " << param_name << " != Py_None) {\n" + << "if (" << param_name << " != nullptr && " << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } else if (is_optional) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL) {\n" + << "if (" << param_name << " != nullptr) {\n" << " " << param_name << "_this"; } else if (maybe_none) { extra_convert - << " = NULL;\n" + << " = nullptr;\n" << "if (" << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } @@ -5498,7 +5505,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_convert << "}\n"; } - coerce_call = "(" + param_name + "_this != NULL)"; + coerce_call = "(" + param_name + "_this != nullptr)"; pexpr_string = param_name + "_this"; } @@ -5506,9 +5513,9 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (report_errors) { // We were asked to report any errors. Let's do it. if (is_optional && maybe_none) { - extra_convert << "if (" << param_name << " != NULL && " << param_name << " != Py_None && !" << coerce_call << ") {\n"; + extra_convert << "if (" << param_name << " != nullptr && " << param_name << " != Py_None && !" << coerce_call << ") {\n"; } else if (is_optional) { - extra_convert << "if (" << param_name << " != NULL && !" << coerce_call << ") {\n"; + extra_convert << "if (" << param_name << " != nullptr && !" << coerce_call << ") {\n"; } else if (maybe_none) { extra_convert << "if (" << param_name << " != Py_None && !" << coerce_call << ") {\n"; } else { @@ -5534,10 +5541,10 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_convert << "}\n"; } else if (is_optional && maybe_none) { - extra_param_check << " && (" << param_name << " == NULL || " << param_name << " == Py_None || " << coerce_call << ")"; + extra_param_check << " && (" << param_name << " == nullptr || " << param_name << " == Py_None || " << coerce_call << ")"; } else if (is_optional) { - extra_param_check << " && (" << param_name << " == NULL || " << coerce_call << ")"; + extra_param_check << " && (" << param_name << " == nullptr || " << coerce_call << ")"; } else if (maybe_none) { extra_param_check << " && (" << param_name << " == Py_None || " << coerce_call << ")"; @@ -5551,16 +5558,16 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (is_optional && maybe_none) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL && " << param_name << " != Py_None) {\n" + << "if (" << param_name << " != nullptr && " << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } else if (is_optional) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL) {\n" + << "if (" << param_name << " != nullptr) {\n" << " " << param_name << "_this"; } else if (maybe_none) { extra_convert - << " = NULL;\n" + << " = nullptr;\n" << "if (" << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } @@ -5568,7 +5575,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // This function does the same thing in this case and is slightly // simpler. But maybe we should just reorganize these functions // entirely? - extra_convert << " = NULL;\n"; + extra_convert << " = nullptr;\n"; int indent_level = (is_optional || maybe_none) ? 2 : 0; indent(extra_convert, indent_level) << "DtoolInstance_GetPointer(" << param_name @@ -5587,15 +5594,15 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (is_optional && maybe_none) { extra_convert << "}\n"; - extra_param_check << " && (" << param_name << " == NULL || " << param_name << " == Py_None || " << param_name << "_this != NULL)"; + extra_param_check << " && (" << param_name << " == nullptr || " << param_name << " == Py_None || " << param_name << "_this != nullptr)"; } else if (is_optional) { extra_convert << "}\n"; - extra_param_check << " && (" << param_name << " == NULL || " << param_name << "_this != NULL)"; + extra_param_check << " && (" << param_name << " == nullptr || " << param_name << "_this != nullptr)"; } else if (maybe_none) { extra_convert << "}\n"; - extra_param_check << " && (" << param_name << " == Py_None || " << param_name << "_this != NULL)"; + extra_param_check << " && (" << param_name << " == Py_None || " << param_name << "_this != nullptr)"; } else { - extra_param_check << " && " << param_name << "_this != NULL"; + extra_param_check << " && " << param_name << "_this != nullptr"; } pexpr_string = param_name + "_this"; @@ -5655,7 +5662,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // We have to use the more expensive PyArg_ParseTupleAndKeywords. clear_error = true; indent(out, indent_level) - << "static const char *keyword_list[] = {" << keyword_list << ", NULL};\n"; + << "static const char *keyword_list[] = {" << keyword_list << ", nullptr};\n"; indent(out, indent_level) << "if (PyArg_ParseTupleAndKeywords(args, kwds, \"" << format_specifiers << ":" << method_name @@ -5679,7 +5686,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { clear_error = true; indent(out, indent_level) - << "if ((kwds == NULL || PyDict_Size(kwds) == 0) && PyArg_UnpackTuple(args, \"" + << "if ((kwds == nullptr || PyDict_Size(kwds) == 0) && PyArg_UnpackTuple(args, \"" << methodNameFromCppName(remap, "", false) << "\", " << min_num_args << ", " << max_num_args << parameter_list << ")) {\n"; @@ -5688,7 +5695,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { clear_error = true; indent(out, indent_level) - << "if ((kwds == NULL || PyDict_Size(kwds) == 0) && PyArg_ParseTuple(args, \"" + << "if ((kwds == nullptr || PyDict_Size(kwds) == 0) && PyArg_ParseTuple(args, \"" << format_specifiers << ":" << method_name << "\"" << parameter_list << ")) {\n"; } @@ -5785,14 +5792,14 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "PyObject *self = Dtool_new_" << make_safe_name(itype.get_scoped_name()) << "(&" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) - << "._PyType, NULL, NULL);\n"; + << "._PyType, nullptr, nullptr);\n"; extra_cleanup << "PyObject_Del(self);\n"; } else { // XXX rdb: this isn't needed, is it, because tp_new already initializes // the instance? indent(out, indent_level) - << "DTool_PyInit_Finalize(self, NULL, &" + << "DTool_PyInit_Finalize(self, nullptr, &" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) << ", false, false);\n"; } @@ -5885,7 +5892,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (manage_return) { // If a constructor returns NULL, that means allocation failed. if (remap->_return_type->return_value_needs_management()) { - indent(out, indent_level) << "if (return_value == NULL) {\n"; + indent(out, indent_level) << "if (return_value == nullptr) {\n"; if ((return_flags & ~RF_pyobject) == RF_err_null) { // PyErr_NoMemory returns NULL, so allow tail call elimination. indent(out, indent_level) << " return PyErr_NoMemory();\n"; @@ -5986,7 +5993,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << " // TypeError raised; continue to next overload type.\n"; indent(out, indent_level) - << "} else if (exception != (PyObject *)NULL) {\n"; + << "} else if (exception != nullptr) {\n"; } if (manage_return) { @@ -6087,8 +6094,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << "return Py_None;\n"; } else if (return_flags & RF_preserve_null) { - indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n"; - indent(out, indent_level) << " return NULL;\n"; + indent(out, indent_level) << "if (" << return_expr << " == nullptr) {\n"; + indent(out, indent_level) << " return nullptr;\n"; indent(out, indent_level) << "} else {\n"; pack_return_value(out, indent_level + 2, remap, return_expr, return_flags); indent(out, indent_level) << "}\n"; @@ -6200,7 +6207,7 @@ error_return(ostream &out, int indent_level, int return_flags) { indent(out, indent_level) << "return Py_NotImplemented;\n"; } else if (return_flags & RF_err_null) { - indent(out, indent_level) << "return NULL;\n"; + indent(out, indent_level) << "return nullptr;\n"; } else if (return_flags & RF_err_false) { indent(out, indent_level) << "return false;\n"; @@ -6300,7 +6307,7 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, indent(out, indent_level); type->output_instance(out, "return_ptr", &parser); out << " = " << return_expr << ";\n"; - indent(out, indent_level) << "return_value.cheat() = NULL;\n"; + indent(out, indent_level) << "return_value.cheat() = nullptr;\n"; return_expr = "return_ptr"; } @@ -6359,9 +6366,9 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, if (make_seq->_length_getter->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n" " Py_ssize_t count = (Py_ssize_t)" << remap->get_call_str("local_this", pexprs) << ";\n"; } else { @@ -6387,7 +6394,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, switch (elem_getter->_args_type) { case AT_keyword_args: out << " PyTuple_SET_ITEM(&args, 0, index);\n" - " PyObject *value = " << elem_getter->_name << "(self, (PyObject *)&args, NULL);\n"; + " PyObject *value = " << elem_getter->_name << "(self, (PyObject *)&args, nullptr);\n"; break; case AT_varargs: @@ -6400,7 +6407,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, break; default: - out << " PyObject *value = " << elem_getter->_name << "(self, NULL);\n"; + out << " PyObject *value = " << elem_getter->_name << "(self, nullptr);\n"; break; } @@ -6417,7 +6424,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, out << " if (Dtool_CheckErrorOccurred()) {\n" " Py_DECREF(tuple);\n" - " return NULL;\n" + " return nullptr;\n" " }\n" " return tuple;\n" "}\n" @@ -6450,7 +6457,7 @@ write_getset(ostream &out, Object *obj, Property *property) { "static Py_ssize_t Dtool_" + ClassName + "_" + ielem.get_name() + "_Len(PyObject *self) {\n"; if (property->_length_function->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" " return -1;\n" " }\n" @@ -6475,9 +6482,9 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n"; } @@ -6486,7 +6493,7 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " if (index < 0 || index >= (Py_ssize_t)" << len_remap->get_call_str("local_this", pexprs) << ") {\n"; out << " PyErr_SetString(PyExc_IndexError, \"" << ClassName << "." << ielem.get_name() << "[] index out of range\");\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; /*if (property->_has_function != NULL) { @@ -6527,7 +6534,7 @@ write_getset(ostream &out, Object *obj, Property *property) { if (!property->_setter_remaps.empty()) { out << "static int Dtool_" + ClassName + "_" + ielem.get_name() + "_Sequence_Setitem(PyObject *self, Py_ssize_t index, PyObject *arg) {\n"; if (property->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; out << " return -1;\n"; @@ -6540,8 +6547,8 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " return -1;\n"; out << " }\n"; - out << " if (arg == (PyObject *)NULL) {\n"; - if (property->_deleter != NULL) { + out << " if (arg == nullptr) {\n"; + if (property->_deleter != nullptr) { if (property->_deleter->_has_this) { out << " local_this->" << property->_deleter->_ifunc.get_name() << "(index);\n"; } else { @@ -6554,7 +6561,7 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " }\n"; - if (property->_clear_function != NULL) { + if (property->_clear_function != nullptr) { out << " if (arg == Py_None) {\n"; if (property->_clear_function->_has_this) { out << " local_this->" << property->_clear_function->_ifunc.get_name() << "(index);\n"; @@ -6599,10 +6606,10 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_inserter != nullptr) { out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Sequence_insert(PyObject *self, size_t index, PyObject *arg) {\n"; if (property->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; } @@ -6620,7 +6627,7 @@ write_getset(ostream &out, Object *obj, Property *property) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } } @@ -6649,13 +6656,13 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n"; } - if (property->_has_function != NULL) { + if (property->_has_function != nullptr) { std::set remaps; remaps.insert(property->_has_function->_remaps.begin(), property->_has_function->_remaps.end()); @@ -6692,7 +6699,7 @@ write_getset(ostream &out, Object *obj, Property *property) { output_quoted(out, 6, expected_params); out << ");\n" " }\n" - " return NULL;\n" + " return nullptr;\n" "}\n\n"; // Write out a setitem if this is not a read-only property. @@ -6705,18 +6712,18 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n" " return -1;\n" " }\n\n"; } - out << " if (value == (PyObject *)NULL) {\n"; - if (property->_deleter != NULL) { + out << " if (value == nullptr) {\n"; + if (property->_deleter != nullptr) { out << " PyObject *arg = key;\n"; - if (property->_has_function != NULL) { + if (property->_has_function != nullptr) { std::set remaps; remaps.insert(property->_has_function->_remaps.begin(), property->_has_function->_remaps.end()); @@ -6743,7 +6750,7 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " }\n"; - if (property->_clear_function != NULL) { + if (property->_clear_function != nullptr) { out << " if (value == Py_None) {\n" << " local_this->" << property->_clear_function->_ifunc.get_name() << "(key);\n" << " return 0;\n" @@ -6785,9 +6792,9 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n"; } @@ -6796,7 +6803,7 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " if (index < 0 || index >= (Py_ssize_t)" << len_remap->get_call_str("local_this", pexprs) << ") {\n"; out << " PyErr_SetString(PyExc_IndexError, \"" << ClassName << "." << ielem.get_name() << "[] index out of range\");\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; } @@ -6834,14 +6841,14 @@ write_getset(ostream &out, Object *obj, Property *property) { if (ielem.is_mapping()) { out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; if (property->_has_this) { - out << " nassertr(self != NULL, NULL);\n"; + out << " nassertr(self != nullptr, nullptr);\n"; } if (property->_setter_remaps.empty()) { out << " Dtool_MappingWrapper *wrap = Dtool_NewMappingWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n"; } else { out << " Dtool_MappingWrapper *wrap = Dtool_NewMutableMappingWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n"; } - out << " if (wrap != NULL) {\n" + out << " if (wrap != nullptr) {\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Mapping_Getitem;\n"; if (!property->_setter_remaps.empty()) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; @@ -6861,18 +6868,18 @@ write_getset(ostream &out, Object *obj, Property *property) { } else if (ielem.is_sequence()) { out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; if (property->_has_this) { - out << " nassertr(self != NULL, NULL);\n"; + out << " nassertr(self != nullptr, nullptr);\n"; } if (property->_setter_remaps.empty()) { out << " Dtool_SequenceWrapper *wrap = Dtool_NewSequenceWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n" - " if (wrap != NULL) {\n" + " if (wrap != nullptr) {\n" " wrap->_len_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Len;\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Sequence_Getitem;\n"; } else { out << " Dtool_MutableSequenceWrapper *wrap = Dtool_NewMutableSequenceWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n" - " if (wrap != NULL) {\n" + " if (wrap != nullptr) {\n" " wrap->_len_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Len;\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Sequence_Getitem;\n"; if (!property->_setter_remaps.empty()) { @@ -6895,18 +6902,18 @@ write_getset(ostream &out, Object *obj, Property *property) { if (remap->_has_this) { if (remap->_const_method) { - out << " const " << cClassName << " *local_this = NULL;\n"; + out << " const " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; } else { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; } - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; } - if (property->_has_function != NULL) { + if (property->_has_function != nullptr) { if (remap->_has_this) { out << " if (!local_this->" << property->_has_function->_ifunc.get_name() << "()) {\n"; } else { @@ -6930,18 +6937,18 @@ write_getset(ostream &out, Object *obj, Property *property) { if (!property->_setter_remaps.empty()) { out << "static int Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter(PyObject *self, PyObject *arg, void *) {\n"; if (remap->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; out << " return -1;\n"; out << " }\n\n"; } - out << " if (arg == (PyObject *)NULL) {\n"; - if (property->_deleter != NULL && remap->_has_this) { + out << " if (arg == nullptr) {\n"; + if (property->_deleter != nullptr && remap->_has_this) { out << " local_this->" << property->_deleter->_ifunc.get_name() << "();\n" << " return 0;\n"; - } else if (property->_deleter != NULL) { + } else if (property->_deleter != nullptr) { out << " " << cClassName << "::" << property->_deleter->_ifunc.get_name() << "();\n" << " return 0;\n"; } else { @@ -6950,7 +6957,7 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " }\n"; - if (property->_clear_function != NULL) { + if (property->_clear_function != nullptr) { out << " if (arg == Py_None) {\n"; if (remap->_has_this) { out << " local_this->" << property->_clear_function->_ifunc.get_name() << "();\n"; @@ -6999,7 +7006,7 @@ write_getset(ostream &out, Object *obj, Property *property) { InterfaceMaker::Object *InterfaceMakerPythonNative:: record_object(TypeIndex type_index) { if (type_index == 0) { - return (Object *)NULL; + return nullptr; } Objects::iterator oi = _objects.find(type_index); @@ -7011,7 +7018,7 @@ record_object(TypeIndex type_index) { const InterrogateType &itype = idb->get_type(type_index); if (!is_cpp_type_legal(itype._cpptype)) { - return (Object *)NULL; + return nullptr; } Object *object = new Object(itype); @@ -7077,9 +7084,8 @@ record_object(TypeIndex type_index) { int num_elements = itype.number_of_elements(); for (int ei = 0; ei < num_elements; ei++) { ElementIndex element_index = itype.get_element(ei); - const InterrogateElement &ielement = idb->get_element(element_index); - Property *property = record_property(itype, itype.get_element(ei)); + Property *property = record_property(itype, element_index); if (property != nullptr) { object->_properties.push_back(property); } else { @@ -7284,7 +7290,7 @@ generate_wrappers() { */ bool InterfaceMakerPythonNative:: is_cpp_type_legal(CPPType *in_ctype) { - if (in_ctype == NULL) { + if (in_ctype == nullptr) { return false; } @@ -7354,7 +7360,7 @@ isExportThisRun(CPPType *ctype) { */ bool InterfaceMakerPythonNative:: isExportThisRun(Function *func) { - if (func == NULL || !is_function_legal(func)) { + if (func == nullptr || !is_function_legal(func)) { return false; } @@ -7372,7 +7378,7 @@ isExportThisRun(Function *func) { */ bool InterfaceMakerPythonNative:: is_remap_legal(FunctionRemap *remap) { - if (remap == NULL) { + if (remap == nullptr) { return false; } @@ -7399,7 +7405,7 @@ is_remap_legal(FunctionRemap *remap) { for (size_t pn = 0; pn < remap->_parameters.size(); pn++) { ParameterRemap *param = remap->_parameters[pn]._remap; CPPType *orig_type = param->get_orig_type(); - if (param->get_default_value() == NULL && !is_cpp_type_legal(orig_type)) { + if (param->get_default_value() == nullptr && !is_cpp_type_legal(orig_type)) { return false; } } @@ -7413,7 +7419,7 @@ is_remap_legal(FunctionRemap *remap) { */ int InterfaceMakerPythonNative:: has_coerce_constructor(CPPStructType *type) { - if (type == NULL) { + if (type == nullptr) { return 0; } @@ -7426,7 +7432,7 @@ has_coerce_constructor(CPPStructType *type) { } CPPScope *scope = type->get_scope(); - if (scope == NULL) { + if (scope == nullptr) { return 0; } @@ -7440,7 +7446,7 @@ has_coerce_constructor(CPPStructType *type) { for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); CPPFunctionType *ftype = inst->_type->as_function_type(); - if (ftype == NULL) { + if (ftype == nullptr) { continue; } if (inst->_storage_class & CPPInstance::SC_explicit) { @@ -7486,7 +7492,7 @@ has_coerce_constructor(CPPStructType *type) { */ bool InterfaceMakerPythonNative:: is_remap_coercion_possible(FunctionRemap *remap) { - if (remap == NULL) { + if (remap == nullptr) { return false; } @@ -7562,7 +7568,7 @@ IsRunTimeTyped(const InterrogateType &itype) { */ bool InterfaceMakerPythonNative:: DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { - if (inclass == NULL) { + if (inclass == nullptr) { return false; } @@ -7579,7 +7585,7 @@ DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { const CPPStructType::Base &base = (*bi); CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); - if (base_type != NULL) { + if (base_type != nullptr) { if (DoesInheritFromIsClass(base_type, name)) { return true; } @@ -7598,7 +7604,7 @@ has_get_class_type_function(CPPType *type) { } CPPStructType *struct_type = type->as_struct_type(); - if (struct_type == NULL) { + if (struct_type == nullptr) { return false; } @@ -7617,7 +7623,7 @@ has_init_type_function(CPPType *type) { } CPPStructType *struct_type = type->as_struct_type(); - if (struct_type == NULL) { + if (struct_type == nullptr) { return false; } @@ -7633,8 +7639,8 @@ has_init_type_function(CPPType *type) { const CPPInstance *cppinst = *ii; const CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL && - cppfunc->_parameters != NULL && + if (cppfunc != nullptr && + cppfunc->_parameters != nullptr && cppfunc->_parameters->_parameters.size() == 0 && (cppinst->_storage_class & CPPInstance::SC_static) != 0) { return true; @@ -7666,7 +7672,7 @@ NeedsAStrFunction(const InterrogateType &itype_class) { FunctionIndex func_index = itype_class.get_method(mi); const InterrogateFunction &ifunc = idb->get_function(func_index); if (ifunc.get_name() == "write") { - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); @@ -7674,9 +7680,9 @@ NeedsAStrFunction(const InterrogateType &itype_class) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc != nullptr) { + if (cppfunc->_parameters != nullptr && + cppfunc->_return_type != nullptr && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 1) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -7690,7 +7696,7 @@ NeedsAStrFunction(const InterrogateType &itype_class) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; if (TypeManager::is_pointer_to_ostream(inst1->_type)) { inst1 = cppfunc->_parameters->_parameters[1]; - if (inst1->_initializer != NULL) { + if (inst1->_initializer != nullptr) { // write(ostream, int = 0) return 1; } @@ -7736,7 +7742,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { FunctionIndex func_index = itype_class.get_method(mi); const InterrogateFunction &ifunc = idb->get_function(func_index); if (ifunc.get_name() == "python_repr") { - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); @@ -7744,9 +7750,9 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc != nullptr) { + if (cppfunc->_parameters != nullptr && + cppfunc->_return_type != nullptr && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 2) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -7774,7 +7780,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { FunctionIndex func_index = itype_class.get_method(mi); const InterrogateFunction &ifunc = idb->get_function(func_index); if (ifunc.get_name() == "output") { - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); @@ -7782,9 +7788,9 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc != nullptr) { + if (cppfunc->_parameters != nullptr && + cppfunc->_return_type != nullptr && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 1) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -7798,7 +7804,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; if (TypeManager::is_pointer_to_ostream(inst1->_type)) { inst1 = cppfunc->_parameters->_parameters[1]; - if (inst1->_initializer != NULL) { + if (inst1->_initializer != nullptr) { // output(ostream, foo = bar, ...) return 2; } diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index 2c0195fdbf..72421f307a 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -132,7 +132,7 @@ private: static bool get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, SlottedFunctionDef &def); static void write_function_slot(ostream &out, int indent_level, const SlottedFunctions &slots, - const string &slot, const string &def = "0"); + const string &slot, const string &def = "nullptr"); void write_prototype_for_name(ostream &out, Function *func, const std::string &name); void write_prototype_for(ostream &out, Function *func); diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.cxx b/dtool/src/interrogate/interfaceMakerPythonObj.cxx index af48b2f016..3f11acb855 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonObj.cxx @@ -102,17 +102,17 @@ write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { << ", METH_VARARGS },\n"; } } - out << " { NULL, NULL }\n" + out << " { nullptr, nullptr }\n" << "};\n\n" << "#if PY_MAJOR_VERSION >= 3\n" << "static struct PyModuleDef python_obj_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << def->library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" << " python_obj_funcs,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n\n" << "#define INIT_FUNC PyObject *PyInit_" << def->library_name << "\n" @@ -171,7 +171,7 @@ get_wrapper_prefix() { void InterfaceMakerPythonObj:: write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { CPPType *struct_type = object->_itype._cpptype; - if (struct_type == (CPPType *)NULL) { + if (struct_type == nullptr) { return; } @@ -185,7 +185,7 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { << " */\n" << "PyObject *\n" << name << "() {\n" - << " static PyObject *wrapper = (PyObject *)NULL;\n" + << " static PyObject *wrapper = nullptr;\n" << " static PyMethodDef methods[] = {\n"; int methods_size = 0; @@ -216,7 +216,7 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { out << " };\n" << " static const int class_methods_size = " << class_methods_size << ";\n\n" - << " if (wrapper == (PyObject *)NULL) {\n" + << " if (wrapper == nullptr) {\n" << " int i;\n" << " PyObject *bases = PyTuple_New(0);\n" << " PyObject *dict = PyDict_New();\n" @@ -228,13 +228,13 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { << " wrapper = PyClass_New(bases, dict, name);\n" << " for (i = 0; i < methods_size; ++i) {\n" << " PyObject *function, *method;\n" - << " function = PyCFunction_New(&methods[i], (PyObject *)NULL);\n" - << " method = PyMethod_New(function, (PyObject *)NULL, wrapper);\n" + << " function = PyCFunction_New(&methods[i], nullptr);\n" + << " method = PyMethod_New(function, nullptr, wrapper);\n" << " PyDict_SetItemString(dict, methods[i].ml_name, method);\n" << " }\n" << " for (i = 0; i < class_methods_size; ++i) {\n" << " PyObject *function;\n" - << " function = PyCFunction_New(&class_methods[i], (PyObject *)NULL);\n" + << " function = PyCFunction_New(&class_methods[i], nullptr);\n" << " PyDict_SetItemString(dict, class_methods[i].ml_name, function);\n" << " }\n" << " }\n" @@ -287,7 +287,7 @@ write_function_for(ostream &out, InterfaceMaker::Function *func) { // different overloaded C++ function signatures. out << " PyErr_SetString(PyExc_TypeError, \"" << expected_params << "\");\n" - << " return (PyObject *)NULL;\n"; + << " return nullptr;\n"; out << "}\n\n"; } @@ -366,7 +366,7 @@ write_function_instance(ostream &out, int indent_level, format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsUnsignedLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; expected_params += "long"; @@ -376,7 +376,7 @@ write_function_instance(ostream &out, int indent_level, format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; expected_params += "long"; @@ -386,7 +386,7 @@ write_function_instance(ostream &out, int indent_level, format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_uint = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_uint == NULL)"; + extra_param_check += "|| (" + param_name + "_uint == nullptr)"; pexpr_string = "(unsigned int)PyLong_AsUnsignedLong(" + param_name + "_uint)"; extra_cleanup += " Py_XDECREF(" + param_name + "_uint);"; expected_params += "unsigned int"; @@ -452,7 +452,7 @@ write_function_instance(ostream &out, int indent_level, indent(out, indent_level + 6) << "PyErr_SetString(PyExc_TypeError, \"Invalid parameters.\");\n"; indent(out, indent_level + 6) - << "return (PyObject *)NULL;\n"; + << "return nullptr;\n"; indent(out, indent_level + 4) << "}\n"; } diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx index b7b5925a8c..8ee9552250 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx @@ -89,17 +89,17 @@ write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { << remap->_wrapper_name << ", METH_VARARGS },\n"; } } - out << " { NULL, NULL }\n" + out << " { nullptr, nullptr }\n" << "};\n\n" << "#if PY_MAJOR_VERSION >= 3\n" << "static struct PyModuleDef python_simple_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << def->library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" << " python_simple_funcs,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n\n" << "#define INIT_FUNC PyObject *PyInit_" << def->library_name << "\n" @@ -285,7 +285,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsUnsignedLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; @@ -294,7 +294,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; @@ -303,7 +303,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_uint = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_uint == NULL)"; + extra_param_check += "|| (" + param_name + "_uint == nullptr)"; pexpr_string = "(unsigned int)PyLong_AsUnsignedLong(" + param_name + "_uint)"; extra_cleanup += " Py_XDECREF(" + param_name + "_uint);"; @@ -361,7 +361,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface out << " " << extra_cleanup << "\n"; } out << " PyErr_SetString(PyExc_TypeError, \"Invalid parameters.\");\n" - << " return (PyObject *)NULL;\n" + << " return nullptr;\n" << " }\n"; } @@ -422,7 +422,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface out << " }\n"; - out << " return (PyObject *)NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 94175b9d2b..39b69e2c1d 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -83,32 +83,32 @@ enum CommandOptions { }; static struct option long_options[] = { - { "oc", required_argument, NULL, CO_oc }, - { "od", required_argument, NULL, CO_od }, - { "srcdir", required_argument, NULL, CO_srcdir }, - { "module", required_argument, NULL, CO_module }, - { "library", required_argument, NULL, CO_library }, - { "do-module", no_argument, NULL, CO_do_module }, - { "fptrs", no_argument, NULL, CO_fptrs }, - { "fnames", no_argument, NULL, CO_fnames }, - { "string", no_argument, NULL, CO_string }, - { "refcount", no_argument, NULL, CO_refcount }, - { "assert", no_argument, NULL, CO_assert }, - { "true-names", no_argument, NULL, CO_true_names }, - { "c", no_argument, NULL, CO_c }, - { "python", no_argument, NULL, CO_python }, - { "python-obj", no_argument, NULL, CO_python_obj }, - { "python-native", no_argument, NULL, CO_python_native }, - { "track-interpreter", no_argument, NULL, CO_track_interpreter }, - { "unique-names", no_argument, NULL, CO_unique_names }, - { "nodb", no_argument, NULL, CO_nodb }, - { "longlong", required_argument, NULL, CO_longlong }, - { "promiscuous", no_argument, NULL, CO_promiscuous }, - { "spam", no_argument, NULL, CO_spam }, - { "noangles", no_argument, NULL, CO_noangles }, - { "nomangle", no_argument, NULL, CO_nomangle }, - { "help", no_argument, NULL, CO_help }, - { NULL } + { "oc", required_argument, nullptr, CO_oc }, + { "od", required_argument, nullptr, CO_od }, + { "srcdir", required_argument, nullptr, CO_srcdir }, + { "module", required_argument, nullptr, CO_module }, + { "library", required_argument, nullptr, CO_library }, + { "do-module", no_argument, nullptr, CO_do_module }, + { "fptrs", no_argument, nullptr, CO_fptrs }, + { "fnames", no_argument, nullptr, CO_fnames }, + { "string", no_argument, nullptr, CO_string }, + { "refcount", no_argument, nullptr, CO_refcount }, + { "assert", no_argument, nullptr, CO_assert }, + { "true-names", no_argument, nullptr, CO_true_names }, + { "c", no_argument, nullptr, CO_c }, + { "python", no_argument, nullptr, CO_python }, + { "python-obj", no_argument, nullptr, CO_python_obj }, + { "python-native", no_argument, nullptr, CO_python_native }, + { "track-interpreter", no_argument, nullptr, CO_track_interpreter }, + { "unique-names", no_argument, nullptr, CO_unique_names }, + { "nodb", no_argument, nullptr, CO_nodb }, + { "longlong", required_argument, nullptr, CO_longlong }, + { "promiscuous", no_argument, nullptr, CO_promiscuous }, + { "spam", no_argument, nullptr, CO_spam }, + { "noangles", no_argument, nullptr, CO_noangles }, + { "nomangle", no_argument, nullptr, CO_nomangle }, + { "help", no_argument, nullptr, CO_help }, + { nullptr } }; void @@ -320,7 +320,7 @@ main(int argc, char **argv) { extern int optind; int flag; - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); while (flag != EOF) { switch (flag) { case 'I': @@ -458,7 +458,7 @@ main(int argc, char **argv) { default: exit(1); } - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); } argc -= (optind-1); @@ -541,10 +541,10 @@ main(int argc, char **argv) { // Make up a file identifier. This is just some bogus number that should be // the same in both the compiled-in code and in the database, so we can // check synchronicity at load time. - int file_identifier = time((time_t *)NULL); + int file_identifier = time(nullptr); InterrogateModuleDef *def = builder.make_module_def(file_identifier); - pofstream * the_output_include = NULL; + pofstream * the_output_include = nullptr; pofstream output_include; @@ -584,7 +584,7 @@ main(int argc, char **argv) { << " *\n" << " */\n\n"; - if(the_output_include != NULL) + if(the_output_include != nullptr) { output_code << "#include \""<resolve_type(&parser, &parser); @@ -132,7 +132,7 @@ do_command(const string &command, const string ¶ms) { } else if (command == "forcetype") { // forcetype explicitly exports the given type. CPPType *type = parser.parse_type(params); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: forcetype " << params << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -153,7 +153,7 @@ do_command(const string &command, const string ¶ms) { string new_name = params.substr(space + 1); CPPType *type = parser.parse_type(orig_name); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: renametype " << orig_name << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -164,7 +164,7 @@ do_command(const string &command, const string ¶ms) { } else if (command == "ignoretype") { // ignoretype explicitly ignores the given type. CPPType *type = parser.parse_type(params); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: ignoretype " << params << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -185,7 +185,7 @@ do_command(const string &command, const string ¶ms) { string constructor = params.substr(space + 1); CPPType *type = parser.parse_type(class_name); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: defconstruct " << class_name << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -254,10 +254,10 @@ build() { ci != _forcetype.end(); ++ci) { CPPType *type = parser.parse_type(*ci); - if (type == NULL) { + if (type == nullptr) { cerr << "Failure to parse forcetype " << *ci << "\n"; } - assert(type != (CPPType *)NULL); + assert(type != nullptr); get_type(type, true); } @@ -274,7 +274,7 @@ build() { scan_function(inst); } else { // Here's a data element declaration. - scan_element(inst, (CPPStructType *)NULL, &parser); + scan_element(inst, nullptr, &parser); } } else if ((*di)->get_subtype() == CPPDeclaration::ST_typedef) { @@ -323,7 +323,7 @@ build() { */ void InterrogateBuilder:: write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { - typedef vector InterfaceMakers; + typedef std::vector InterfaceMakers; InterfaceMakers makers; if (build_c_wrappers) { @@ -443,7 +443,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { } // Now collect all the function wrappers. - vector remaps; + std::vector remaps; for (mi = makers.begin(); mi != makers.end(); ++mi) { (*mi)->get_function_remaps(remaps); } @@ -457,7 +457,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { int num_wrappers = 0; map wrappers_by_index; - vector::iterator ri; + std::vector::iterator ri; for (ri = remaps.begin(); ri != remaps.end(); ++ri) { FunctionRemap *remap = (*ri); wrappers_by_index[remap->_wrapper_index] = remap; @@ -511,7 +511,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { << " \"" << def->library_name << "\", /* library_name */\n" << " \"" << def->library_hash_name << "\", /* library_hash_name */\n" << " \"" << def->module_name << "\", /* module_name */\n"; - if (def->database_filename != (const char *)NULL) { + if (def->database_filename != nullptr) { out_code << " \"" << def->database_filename << "\", /* database_filename */\n"; } else { @@ -522,7 +522,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { out_code << " _in_unique_names,\n" << " " << num_wrappers << ", /* num_unique_names */\n"; } else { - out_code << " (InterrogateUniqueNameDef *)0, /* unique_names */\n" + out_code << " nullptr, /* unique_names */\n" << " 0, /* num_unique_names */\n"; } @@ -530,7 +530,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { out_code << " _in_fptrs,\n" << " " << num_wrappers << ", /* num_fptrs */\n"; } else { - out_code << " (void **)0, /* fptrs */\n" + out_code << " nullptr, /* fptrs */\n" << " 0, /* num_fptrs */\n"; } @@ -921,17 +921,17 @@ bool InterrogateBuilder:: is_inherited_published(CPPInstance *function, CPPStructType *struct_type) { nassertr(struct_type->_derivation.size() == 1, false); CPPStructType *base = struct_type->_derivation[0]._base->as_struct_type(); - nassertr(base != (CPPStructType *)NULL, false); + nassertr(base != nullptr, false); CPPScope *base_scope = base->get_scope(); CPPDeclaration *symbol = base_scope->find_symbol(function->get_simple_name(), true); - if (symbol == (CPPDeclaration *)NULL) { + if (symbol == nullptr) { // Couldn't find the inherited function. return false; } CPPFunctionGroup *fgroup = symbol->as_function_group(); - if (fgroup == (CPPFunctionGroup *)NULL) { + if (fgroup == nullptr) { // Weird, it wasn't a function. return false; } @@ -960,7 +960,7 @@ is_inherited_published(CPPInstance *function, CPPStructType *struct_type) { * purpose of this function. */ void InterrogateBuilder:: -remap_indices(vector &remaps) { +remap_indices(std::vector &remaps) { IndexRemapper index_remap; InterrogateDatabase::get_ptr()->remap_indices(1, index_remap); @@ -976,7 +976,7 @@ remap_indices(vector &remaps) { (*fi).second = index_remap.map_from((*fi).second); } - vector::iterator ri; + std::vector::iterator ri; for (ri = remaps.begin(); ri != remaps.end(); ++ri) { FunctionRemap *remap = (*ri); remap->_wrapper_index = index_remap.map_from(remap->_wrapper_index); @@ -1000,22 +1000,22 @@ scan_function(CPPFunctionGroup *fgroup) { */ void InterrogateBuilder:: scan_function(CPPInstance *function) { - assert(function != (CPPInstance *)NULL); - assert(function->_type != (CPPType *)NULL && function->_type->as_function_type() != (CPPFunctionType *)NULL); + assert(function != nullptr); + assert(function->_type != nullptr && function->_type->as_function_type() != nullptr); CPPFunctionType *ftype = function->_type->resolve_type(&parser, &parser)->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); CPPScope *scope = &parser; if (function->is_scoped()) { scope = function->get_scope(&parser, &parser); - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { // Invalid scope. nout << "Invalid scope: " << *function->_ident << "\n"; return; } - if (scope->get_struct_type() != (CPPStructType *)NULL) { + if (scope->get_struct_type() != nullptr) { // Wait, this is a method, not a function. This must be the declaration // for the method (since it's appearing out-of-scope). We don't need to // define a new method for it, but we'd like to update the comment, if @@ -1070,7 +1070,7 @@ scan_function(CPPInstance *function) { } get_function(function, "", - (CPPStructType *)NULL, scope, + nullptr, scope, InterrogateFunction::F_global); } @@ -1079,7 +1079,7 @@ scan_function(CPPInstance *function) { */ void InterrogateBuilder:: scan_struct_type(CPPStructType *type) { - if (type == (CPPStructType *)NULL) { + if (type == nullptr) { return; } @@ -1129,7 +1129,7 @@ scan_struct_type(CPPStructType *type) { */ void InterrogateBuilder:: scan_enum_type(CPPEnumType *type) { - if (type == (CPPEnumType *)NULL) { + if (type == nullptr) { return; } @@ -1163,7 +1163,7 @@ scan_enum_type(CPPEnumType *type) { */ void InterrogateBuilder:: scan_typedef_type(CPPTypedefType *type) { - if (type == (CPPTypedefType *)NULL) { + if (type == nullptr) { return; } @@ -1202,7 +1202,7 @@ scan_typedef_type(CPPTypedefType *type) { } CPPStructType *struct_type = wrapped_type->as_struct_type(); - if (struct_type == (CPPStructType *)NULL) { + if (struct_type == nullptr) { // We only export typedefs to structs, for now. return; } @@ -1247,7 +1247,7 @@ scan_typedef_type(CPPTypedefType *type) { */ void InterrogateBuilder:: scan_manifest(CPPManifest *manifest) { - if (manifest == (CPPManifest *)NULL) { + if (manifest == nullptr) { return; } @@ -1278,7 +1278,7 @@ scan_manifest(CPPManifest *manifest) { imanifest._definition = manifest->expand(); CPPType *type = manifest->determine_type(); - if (type != (CPPType *)NULL) { + if (type != nullptr) { imanifest._flags |= InterrogateManifest::F_has_type; imanifest._type = get_type(type, false); @@ -1292,8 +1292,8 @@ scan_manifest(CPPManifest *manifest) { } else { // We have a more complex expression. Generate a getter function. FunctionIndex getter = - get_getter(type, manifest->_name, (CPPStructType *)NULL, &parser, - (CPPInstance *)NULL); + get_getter(type, manifest->_name, nullptr, &parser, + nullptr); if (getter != 0) { imanifest._flags |= InterrogateManifest::F_has_getter; @@ -1313,7 +1313,7 @@ scan_manifest(CPPManifest *manifest) { ElementIndex InterrogateBuilder:: scan_element(CPPInstance *element, CPPStructType *struct_type, CPPScope *scope) { - if (element == (CPPInstance *)NULL) { + if (element == nullptr) { return 0; } @@ -1336,7 +1336,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, return 0; } - if (struct_type == NULL && + if (struct_type == nullptr && (element->_file._source != CPPFile::S_local || in_ignorefile(element->_file._filename_as_referenced))) { // The element is defined in some other package or in an ignorable file. @@ -1368,7 +1368,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, ielement._scoped_name = descope(element->get_local_name(&parser)); // See if there happens to be a comment before the element. - if (element->_leading_comment != (CPPCommentBlock *)NULL) { + if (element->_leading_comment != nullptr) { ielement._comment = trim_blanks(element->_leading_comment->_comment); } @@ -1382,7 +1382,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, // We can only generate a getter and a setter if we can talk about the // type it is. - if (parameter_type->as_struct_type() != (CPPStructType *)NULL) { + if (parameter_type->as_struct_type() != nullptr) { // Wrap the type in a const reference. parameter_type = TypeManager::wrap_const_reference(parameter_type); } @@ -1407,7 +1407,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, } } - if (struct_type == (CPPStructType *)NULL) { + if (struct_type == nullptr) { // This is a global data element: not a data member. ielement._flags |= InterrogateElement::F_global; } @@ -1432,9 +1432,9 @@ get_getter(CPPType *expr_type, string expression, // Unroll the "const" from the expr_type, since that doesn't matter for a // return type. - while (expr_type->as_const_type() != (CPPConstType *)NULL) { + while (expr_type->as_const_type() != nullptr) { expr_type = expr_type->as_const_type()->_wrapped_around; - assert(expr_type != (CPPType *)NULL); + assert(expr_type != nullptr); } // We can't return an array from a function, but we can decay it into a @@ -1453,10 +1453,10 @@ get_getter(CPPType *expr_type, string expression, int getter_flags = InterrogateFunction::F_getter; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // This is a data member for some class. - assert(element != (CPPInstance *)NULL); - assert(scope != (CPPScope *)NULL); + assert(element != nullptr); + assert(scope != nullptr); if ((element->_storage_class & CPPInstance::SC_static) != 0) { // This is a static data member; therefore, the synthesized getter is @@ -1487,8 +1487,8 @@ get_getter(CPPType *expr_type, string expression, ostringstream desc; desc << "getter for "; - if (element != (CPPInstance *)NULL) { - element->_initializer = (CPPExpression *)NULL; + if (element != nullptr) { + element->_initializer = nullptr; element->output(desc, 0, &parser, false); desc << ";"; } else { @@ -1530,10 +1530,10 @@ get_setter(CPPType *expr_type, string expression, int setter_flags = InterrogateFunction::F_setter; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // This is a data member for some class. - assert(element != (CPPInstance *)NULL); - assert(scope != (CPPScope *)NULL); + assert(element != nullptr); + assert(scope != nullptr); if ((element->_storage_class & CPPInstance::SC_static) != 0) { // This is a static data member; therefore, the synthesized setter is @@ -1560,8 +1560,8 @@ get_setter(CPPType *expr_type, string expression, ostringstream desc; desc << "setter for "; - if (element != (CPPInstance *)NULL) { - element->_initializer = (CPPExpression *)NULL; + if (element != nullptr) { + element->_initializer = nullptr; element->output(desc, 0, &parser, false); desc << ";"; } else { @@ -1590,7 +1590,7 @@ get_cast_function(CPPType *to_type, CPPType *from_type, CPPStructType *struct_type = from_type->as_struct_type(); CPPScope *scope = &parser; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // We'll make this a method of the from type. scope = struct_type->get_scope(); @@ -1666,14 +1666,14 @@ get_function(CPPInstance *function, string description, function->_type = ftype; if ((ftype->_flags & CPPFunctionType::F_constructor) && - struct_type != (CPPStructType *)NULL && + struct_type != nullptr && struct_type->is_abstract()) { // This is a constructor for an abstract class; forget it. return 0; } TypeIndex class_index = 0; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { class_index = get_type(struct_type, false); } @@ -1696,8 +1696,6 @@ get_function(CPPInstance *function, string description, InterrogateFunction &ifunction = InterrogateDatabase::get_ptr()->update_function(index); - nassertr(&ifunction != NULL, 0); - ifunction._flags |= flags; // Also, make sure this particular signature is defined. @@ -1716,7 +1714,7 @@ get_function(CPPInstance *function, string description, } // Also set the comment. - if (function->_leading_comment != (CPPCommentBlock *)NULL) { + if (function->_leading_comment != nullptr) { string comment = trim_blanks(function->_leading_comment->_comment); if (!ifunction._comment.empty()) { ifunction._comment += "\n\n"; @@ -1724,7 +1722,7 @@ get_function(CPPInstance *function, string description, ifunction._comment += comment; // And update the particular wrapper comment. - if ((*ii).second->_leading_comment == NULL || + if ((*ii).second->_leading_comment == nullptr || function->_leading_comment->_comment.length() > (*ii).second->_leading_comment->_comment.length()) { (*ii).second->_leading_comment = function->_leading_comment; @@ -1744,7 +1742,7 @@ get_function(CPPInstance *function, string description, ifunction->_scoped_name = descope(function->get_local_name(&parser)); ifunction->_instances = new InterrogateFunction::Instances; - if (function->_leading_comment != (CPPCommentBlock *)NULL) { + if (function->_leading_comment != nullptr) { ifunction->_comment = trim_blanks(function->_leading_comment->_comment); } @@ -1753,7 +1751,7 @@ get_function(CPPInstance *function, string description, prototype << ";"; ifunction->_prototype = prototype.str(); - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // The function is a method. ifunction->_flags |= InterrogateFunction::F_method; ifunction->_class = class_index; @@ -1846,19 +1844,19 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // Find the getter so we can get its return type. - CPPInstance *getter = NULL; - CPPType *return_type = NULL; + CPPInstance *getter = nullptr; + CPPType *return_type = nullptr; // How many arguments we expect the getter to have. size_t num_args = (size_t)(make_property->_type != CPPMakeProperty::T_normal); fgroup = make_property->_get_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); CPPFunctionType *ftype = function->_type->as_function_type(); - if (ftype == NULL) { + if (ftype == nullptr) { continue; } @@ -1881,7 +1879,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP // The getter must either take no arguments, or all defaults. if (params.size() == expected_num_args || (params.size() > expected_num_args && - params[expected_num_args]->_initializer != NULL)) { + params[expected_num_args]->_initializer != nullptr)) { // If this is a sequence getter, it must take an index argument. if (make_property->_type == CPPMakeProperty::T_sequence && !TypeManager::is_integer(params[index_arg]->_type)) { @@ -1899,7 +1897,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } } - if (getter == NULL || return_type == NULL) { + if (getter == nullptr || return_type == nullptr) { cerr << "No instance of getter '" << fgroup->_name << "' is suitable!\n"; return 0; @@ -1907,10 +1905,10 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // Find the "hasser". - CPPInstance *hasser = NULL; + CPPInstance *hasser = nullptr; fgroup = make_property->_has_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -1931,10 +1929,10 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // And the "deleter". - CPPInstance *deleter = NULL; + CPPInstance *deleter = nullptr; fgroup = make_property->_del_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -2013,7 +2011,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP InterrogateElement &iproperty = idb->update_element(index); - if (return_type != NULL) { + if (return_type != nullptr) { TypeIndex return_index = get_type(TypeManager::unwrap_reference(return_type), false); if (iproperty._type != 0 && iproperty._type != return_index) { cerr << "Property " << property_name << " has inconsistent element type!\n"; @@ -2034,7 +2032,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } if (make_property->_type == CPPMakeProperty::T_normal) { - if (getter != NULL) { + if (getter != nullptr) { iproperty._flags |= InterrogateElement::F_has_getter; iproperty._getter = get_function(getter, "", struct_type, struct_type->get_scope(), 0); @@ -2062,28 +2060,28 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP ifunction._instances->insert(InterrogateFunction::Instances::value_type(signature, getter)); } - if (hasser != NULL) { + if (hasser != nullptr) { iproperty._flags |= InterrogateElement::F_has_has_function; iproperty._has_function = get_function(hasser, "", struct_type, struct_type->get_scope(), 0); nassertr(iproperty._has_function, 0); } - if (deleter != NULL) { + if (deleter != nullptr) { iproperty._flags |= InterrogateElement::F_has_del_function; iproperty._del_function = get_function(deleter, "", struct_type, struct_type->get_scope(), 0); nassertr(iproperty._del_function, 0); } - if (inserter != NULL) { + if (inserter != nullptr) { iproperty._flags |= InterrogateElement::F_has_insert_function; iproperty._insert_function = get_function(inserter, "", struct_type, struct_type->get_scope(), 0); nassertr(iproperty._insert_function, 0); } - if (getkey_function != NULL) { + if (getkey_function != nullptr) { iproperty._flags |= InterrogateElement::F_has_getkey_function; iproperty._getkey_function = get_function(getkey_function, "", struct_type, struct_type->get_scope(), 0); @@ -2091,17 +2089,17 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // See if there happens to be a comment before the MAKE_PROPERTY macro. - if (make_property->_leading_comment != (CPPCommentBlock *)NULL) { + if (make_property->_leading_comment != nullptr) { iproperty._comment = trim_blanks(make_property->_leading_comment->_comment); - } else if (getter->_leading_comment != (CPPCommentBlock *)NULL) { + } else if (getter->_leading_comment != nullptr) { // Take the comment from the getter. iproperty._comment = trim_blanks(getter->_leading_comment->_comment); } // Now look for setters. fgroup = make_property->_set_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -2114,7 +2112,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } fgroup = make_property->_clear_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -2150,12 +2148,12 @@ get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { CPPFunctionGroup::Instances::const_iterator fi; CPPFunctionGroup *fgroup = make_seq->_length_getter; - if (fgroup != NULL) { + if (fgroup != nullptr) { for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); CPPFunctionType *ftype = function->_type->as_function_type(); - if (ftype != NULL) { + if (ftype != nullptr) { length_getter = get_function(function, "", struct_type, struct_type->get_scope(), 0); if (length_getter != 0) { @@ -2174,12 +2172,12 @@ get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { } fgroup = make_seq->_element_getter; - if (fgroup != NULL) { + if (fgroup != nullptr) { for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); CPPFunctionType *ftype = function->_type->as_function_type(); - if (ftype != NULL && ftype->_parameters->_parameters.size() >= 1 && + if (ftype != nullptr && ftype->_parameters->_parameters.size() >= 1 && TypeManager::is_integer(ftype->_parameters->_parameters[0]->_type)) { // It really doesn't matter whether we grab the const or non-const // version, since they should all return the same function anyway. @@ -2213,7 +2211,7 @@ get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { imake_seq._element_getter = element_getter; // See if there happens to be a comment before the MAKE_SEQ macro. - if (make_seq->_leading_comment != (CPPCommentBlock *)NULL) { + if (make_seq->_leading_comment != nullptr) { imake_seq._comment = trim_blanks(make_seq->_leading_comment->_comment); } @@ -2269,6 +2267,10 @@ get_type(CPPType *type, bool global) { return 0; } + if (type->get_subtype() == CPPType::ST_tbd) { + type = type->resolve_type(&parser, &parser); + } + TypeIndex index = 0; // First, check to see if it's already there. @@ -2338,21 +2340,21 @@ get_type(CPPType *type, bool global) { itype._true_name = true_name; itype._cpptype = type; - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { // This type has a declaration; does the declaration have a comment? CPPTypeDeclaration *decl = type->_declaration; - if (decl->_leading_comment != (CPPCommentBlock *)NULL) { + if (decl->_leading_comment != nullptr) { itype._comment = trim_blanks(decl->_leading_comment->_comment); } } - CPPScope *scope = NULL; + CPPScope *scope = nullptr; // If it's an extension type or typedef, it might be scoped. if (CPPTypedefType *td_type = type->as_typedef_type()) { scope = td_type->_ident->get_scope(&parser, &parser); } else if (CPPExtensionType *ext_type = type->as_extension_type()) { - if (ext_type->_ident != (CPPIdentifier *)NULL) { + if (ext_type->_ident != nullptr) { scope = ext_type->_ident->get_scope(&parser, &parser); } else if (CPPEnumType *enum_type = ext_type->as_enum_type()) { @@ -2362,11 +2364,11 @@ get_type(CPPType *type, bool global) { } - if (scope != (CPPScope *)NULL) { - while (scope->as_template_scope() != (CPPTemplateScope *)NULL) { + if (scope != nullptr) { + while (scope->as_template_scope() != nullptr) { assert(scope->get_parent_scope() != scope); scope = scope->get_parent_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); } itype._cppscope = scope; @@ -2376,7 +2378,7 @@ get_type(CPPType *type, bool global) { descope(scope->get_local_name(&parser) + "::" + itype._name); CPPStructType *struct_type = scope->get_struct_type(); - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { itype._flags |= InterrogateType::F_nested; itype._outer_class = get_type(struct_type, false); } @@ -2386,28 +2388,28 @@ get_type(CPPType *type, bool global) { if (forced || !in_ignoretype(true_name)) { itype._flags |= InterrogateType::F_fully_defined; - if (type->as_simple_type() != (CPPSimpleType *)NULL) { + if (type->as_simple_type() != nullptr) { define_atomic_type(itype, type->as_simple_type()); - } else if (type->as_pointer_type() != (CPPPointerType *)NULL) { + } else if (type->as_pointer_type() != nullptr) { define_wrapped_type(itype, type->as_pointer_type()); - } else if (type->as_const_type() != (CPPConstType *)NULL) { + } else if (type->as_const_type() != nullptr) { define_wrapped_type(itype, type->as_const_type()); - } else if (type->as_struct_type() != (CPPStructType *)NULL) { + } else if (type->as_struct_type() != nullptr) { define_struct_type(itype, type->as_struct_type(), index, forced); - } else if (type->as_enum_type() != (CPPEnumType *)NULL) { + } else if (type->as_enum_type() != nullptr) { define_enum_type(itype, type->as_enum_type()); - } else if (type->as_extension_type() != (CPPExtensionType *)NULL) { + } else if (type->as_extension_type() != nullptr) { define_extension_type(itype, type->as_extension_type()); - } else if (type->as_typedef_type() != (CPPTypedefType *)NULL) { + } else if (type->as_typedef_type() != nullptr) { define_typedef_type(itype, type->as_typedef_type()); - } else if (type->as_array_type() != (CPPArrayType *)NULL) { + } else if (type->as_array_type() != nullptr) { define_array_type(itype, type->as_array_type()); } else { @@ -2534,7 +2536,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } cpptype = TypeManager::resolve_type(cpptype)->as_struct_type(); - assert(cpptype != (CPPStructType *)NULL); + assert(cpptype != nullptr); bool has_virt_methods = cpptype->is_polymorphic(); switch (cpptype->_type) { @@ -2606,7 +2608,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, TypeIndex base_index = get_type(base_type, false); if (base_index == 0) { - if (base_type != NULL) { + if (base_type != nullptr) { nout << *cpptype << " reports a derivation from invalid type " << *base_type << ".\n"; } else { nout << *cpptype << " reports a derivation from an invalid type.\n"; @@ -2639,7 +2641,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, // (For many compilers, this does not require a pointer change.) generate_casts = true; - } else if (has_virt_methods && (base_type->as_struct_type() == (CPPStructType *)NULL || !base_type->as_struct_type()->is_polymorphic())) { + } else if (has_virt_methods && (base_type->as_struct_type() == nullptr || !base_type->as_struct_type()->is_polymorphic())) { // Finally, if this class has virtual methods, but its parent // doesn't, then we have to upcast (because this class will require // space for a virtual function table pointer, while the parent @@ -2688,17 +2690,17 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, CPPType *type = (*di)->as_type_declaration()->_type; if ((*di)->_vis <= min_vis || in_forcetype(type->get_local_name(&parser))) { - if (type->as_struct_type() != (CPPStructType *)NULL || - type->as_enum_type() != (CPPEnumType *)NULL) { + if (type->as_struct_type() != nullptr || + type->as_enum_type() != nullptr) { // Here's a nested class or enum definition. type->_vis = (*di)->_vis; CPPExtensionType *nested_type = type->as_extension_type(); - assert(nested_type != (CPPExtensionType *)NULL); + assert(nested_type != nullptr); // For now, we don't allow anonymous structs. - if (nested_type->_ident != (CPPIdentifier *)NULL || - nested_type->as_enum_type() != (CPPEnumType *)NULL) { + if (nested_type->_ident != nullptr || + nested_type->as_enum_type() != nullptr) { TypeIndex nested_index = get_type(nested_type, false); itype._nested_types.push_back(nested_index); } @@ -2724,7 +2726,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } CPPStructType *struct_type = wrapped_type->as_struct_type(); - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // We only export typedefs to structs, for now. if (type->_vis <= min_vis) { @@ -2747,7 +2749,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, // See if we need to generate an implicit default constructor. CPPFunctionGroup *constructor = cpptype->get_constructor(); - if (constructor == (CPPFunctionGroup *)NULL && cpptype->is_default_constructible()) { + if (constructor == nullptr && cpptype->is_default_constructible()) { // Make a default constructor. CPPType *void_type = TypeManager::get_void_type(); CPPParameterList *params = new CPPParameterList; @@ -2767,11 +2769,11 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, // See if we need to generate an implicit copy constructor. CPPInstance *copy_constructor = cpptype->get_copy_constructor(); - if (copy_constructor == (CPPInstance *)NULL && + if (copy_constructor == nullptr && cpptype->is_copy_constructible()) { // Make an implicit copy constructor. CPPType *const_ref_type = TypeManager::wrap_const_reference(cpptype); - CPPInstance *param = new CPPInstance(const_ref_type, NULL); + CPPInstance *param = new CPPInstance(const_ref_type, nullptr); CPPType *void_type = TypeManager::get_void_type(); CPPParameterList *params = new CPPParameterList; @@ -2838,7 +2840,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, */ void InterrogateBuilder:: update_function_comment(CPPInstance *function, CPPScope *scope) { - if (function->_leading_comment == (CPPCommentBlock *)NULL) { + if (function->_leading_comment == nullptr) { // No comment anyway. Forget it. return; } @@ -2883,7 +2885,7 @@ update_function_comment(CPPInstance *function, CPPScope *scope) { InterrogateFunction::Instances::iterator ii = ifunction._instances->find(function_signature); if (ii != ifunction._instances->end()) { - if ((*ii).second->_leading_comment == NULL || + if ((*ii).second->_leading_comment == nullptr || function->_leading_comment->_comment.length() > (*ii).second->_leading_comment->_comment.length()) { (*ii).second->_leading_comment = function->_leading_comment; @@ -2912,9 +2914,9 @@ define_method(CPPFunctionGroup *fgroup, InterrogateType &itype, void InterrogateBuilder:: define_method(CPPInstance *function, InterrogateType &itype, CPPStructType *struct_type, CPPScope *scope) { - assert(function != (CPPInstance *)NULL); - assert(function->_type != (CPPType *)NULL && - function->_type->as_function_type() != (CPPFunctionType *)NULL); + assert(function != nullptr); + assert(function->_type != nullptr && + function->_type->as_function_type() != nullptr); CPPFunctionType *ftype = function->_type->resolve_type(scope, &parser)->as_function_type(); @@ -3035,7 +3037,7 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { itype._flags |= InterrogateType::F_enum; CPPScope *scope = cpptype->_parent_scope; - if (cpptype->_ident != (CPPIdentifier *)NULL) { + if (cpptype->_ident != nullptr) { scope = cpptype->_ident->get_scope(&parser, &parser); } @@ -3072,11 +3074,11 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { evalue._name = element->get_simple_name(); evalue._scoped_name = descope(element->get_local_name(&parser)); - if (element->_leading_comment != (CPPCommentBlock *)NULL) { + if (element->_leading_comment != nullptr) { evalue._comment = trim_blanks(element->_leading_comment->_comment); } - if (element->_initializer != (CPPExpression *)NULL) { + if (element->_initializer != nullptr) { CPPExpression::Result result = element->_initializer->evaluate(); if (result._type == CPPExpression::RT_error) { @@ -3112,7 +3114,7 @@ define_array_type(InterrogateType &itype, CPPArrayType *cpptype) { itype._flags |= InterrogateType::F_array; itype._wrapped_type = get_type(cpptype->_element_type, false); - if (cpptype->_bounds == NULL) { + if (cpptype->_bounds == nullptr) { // This indicates an unsized array. itype._array_size = -1; } else { diff --git a/dtool/src/interrogate/interrogateBuilder.h b/dtool/src/interrogate/interrogateBuilder.h index 41096a6f6a..68bcb4b131 100644 --- a/dtool/src/interrogate/interrogateBuilder.h +++ b/dtool/src/interrogate/interrogateBuilder.h @@ -68,8 +68,8 @@ public: TypeIndex get_type(CPPType *type, bool global); public: - typedef set Commands; - typedef map CommandParams; + typedef std::set Commands; + typedef std::map CommandParams; void insert_param_list(InterrogateBuilder::Commands &commands, const string ¶ms); @@ -86,7 +86,7 @@ public: bool is_inherited_published(CPPInstance *function, CPPStructType *struct_type); - void remap_indices(vector &remaps); + void remap_indices(std::vector &remaps); void scan_function(CPPFunctionGroup *fgroup); void scan_function(CPPInstance *function); void scan_struct_type(CPPStructType *type); @@ -135,17 +135,17 @@ public: static string trim_blanks(const string &str); - typedef map TypesByName; - typedef map FunctionsByName; - typedef map MakeSeqsByName; - typedef map PropertiesByName; + typedef std::map TypesByName; + typedef std::map FunctionsByName; + typedef std::map MakeSeqsByName; + typedef std::map PropertiesByName; TypesByName _types_by_name; FunctionsByName _functions_by_name; MakeSeqsByName _make_seqs_by_name; PropertiesByName _properties_by_name; - typedef map IncludeFiles; + typedef std::map IncludeFiles; IncludeFiles _include_files; Commands _forcetype; diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 8c843e9da1..0fe4534890 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -52,15 +52,15 @@ enum CommandOptions { }; static struct option long_options[] = { - { "oc", required_argument, NULL, CO_oc }, - { "module", required_argument, NULL, CO_module }, - { "library", required_argument, NULL, CO_library }, - { "c", no_argument, NULL, CO_c }, - { "python", no_argument, NULL, CO_python }, - { "python-native", no_argument, NULL, CO_python_native }, - { "track-interpreter", no_argument, NULL, CO_track_interpreter }, - { "import", required_argument, NULL, CO_import }, - { NULL } + { "oc", required_argument, nullptr, CO_oc }, + { "module", required_argument, nullptr, CO_module }, + { "library", required_argument, nullptr, CO_library }, + { "c", no_argument, nullptr, CO_c }, + { "python", no_argument, nullptr, CO_python }, + { "python-native", no_argument, nullptr, CO_python_native }, + { "track-interpreter", no_argument, nullptr, CO_track_interpreter }, + { "import", required_argument, nullptr, CO_import }, + { nullptr } }; /* @@ -80,10 +80,10 @@ upcase_string(const string &str) { * Finds a dependency cycle between the given dependency mapping, starting at * the node that is already placed in the given cycle vector. */ -static bool find_dependency_cycle(vector_string &cycle, map > &dependencies) { +static bool find_dependency_cycle(vector_string &cycle, std::map > &dependencies) { assert(!cycle.empty()); - const set &deps = dependencies[cycle.back()]; + const std::set &deps = dependencies[cycle.back()]; for (auto it = deps.begin(); it != deps.end(); ++it) { auto it2 = std::find(cycle.begin(), cycle.end(), *it); if (it2 != cycle.end()) { @@ -156,7 +156,7 @@ int write_python_table_native(ostream &out) { int count = 0; - map > dependencies; + std::map > dependencies; // out << "extern \"C\" {\n"; @@ -182,7 +182,7 @@ int write_python_table_native(ostream &out) { if (interrogate_type_has_module_name(thetype) && module_name == interrogate_type_module_name(thetype)) { if (interrogate_type_has_library_name(thetype)) { string library_name = interrogate_type_library_name(thetype); - set &deps = dependencies[library_name]; + std::set &deps = dependencies[library_name]; // Get the dependencies for this library. int num_derivations = interrogate_type_number_of_derivations(thetype); @@ -219,7 +219,7 @@ int write_python_table_native(ostream &out) { for (auto it = dependencies.begin(); it != dependencies.end(); ++it) { const string &library_name = it->first; - set &deps = dependencies[library_name]; + std::set &deps = dependencies[library_name]; // Remove the dependencies that have already been added from the deps. if (!deps.empty()) { @@ -243,7 +243,7 @@ int write_python_table_native(ostream &out) { cerr << "Circular dependency between libraries detected:\n"; for (auto it = dependencies.begin(); it != dependencies.end(); ++it) { const string &library_name = it->first; - set &deps = dependencies[library_name]; + std::set &deps = dependencies[library_name]; if (deps.empty()) { continue; } @@ -316,10 +316,10 @@ int write_python_table_native(ostream &out) { << "static struct PyModuleDef py_" << library_name << "_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" - << " NULL,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr,\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n" << "\n" << "PyObject *PyInit_" << library_name << "() {\n"; @@ -346,10 +346,10 @@ int write_python_table_native(ostream &out) { out << "&" << *ii << "_moddef, "; } - out << "NULL};\n" + out << "nullptr};\n" << "\n" << " PyObject *module = Dtool_PyModuleInitHelper(defs, &py_" << library_name << "_module);\n" - << " if (module != NULL) {\n"; + << " if (module != nullptr) {\n"; for (ii = libraries.begin(); ii != libraries.end(); ii++) { out << " Dtool_" << *ii << "_BuildInstants(module);\n"; @@ -393,10 +393,10 @@ int write_python_table_native(ostream &out) { out << "&" << *ii << "_moddef, "; } - out << "NULL};\n" + out << "nullptr};\n" << "\n" << " PyObject *module = Dtool_PyModuleInitHelper(defs, \"" << module_name << "\");\n" - << " if (module != NULL) {\n"; + << " if (module != nullptr) {\n"; for (ii = libraries.begin(); ii != libraries.end(); ii++) { out << " Dtool_" << *ii << "_BuildInstants(module);\n"; @@ -410,7 +410,7 @@ int write_python_table_native(ostream &out) { << " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was " << "compiled for Python \" PY_VERSION \", which is incompatible " << "with Python 3\");\n" - << " return (PyObject *)NULL;\n" + << " return nullptr;\n" << "}\n" << "#endif\n" << "#endif\n" @@ -497,17 +497,17 @@ int write_python_table(ostream &out) { library_name = module_name; } - out << " { NULL, NULL }\n" + out << " { nullptr, nullptr }\n" << "};\n\n" << "#if PY_MAJOR_VERSION >= 3\n" << "static struct PyModuleDef python_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" << " python_methods,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n\n" << "#define INIT_FUNC PyObject *PyInit_" << library_name << "\n" @@ -545,7 +545,7 @@ int main(int argc, char *argv[]) { pystub(); preprocess_argv(argc, argv); - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); while (flag != EOF) { switch (flag) { case CO_oc: @@ -583,7 +583,7 @@ int main(int argc, char *argv[]) { default: exit(1); } - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); } argc -= (optind-1); @@ -617,7 +617,7 @@ int main(int argc, char *argv[]) { pathname.set_type(Filename::T_dso); nout << "Loading " << pathname << "\n"; void *dl = load_dso(DSearchPath(), pathname); - if (dl == NULL) { + if (dl == nullptr) { nout << "Unable to load: " << load_dso_error() << "\n"; exit(1); } diff --git a/dtool/src/interrogate/parameterRemap.I b/dtool/src/interrogate/parameterRemap.I index 4b3040e514..dac104e87f 100644 --- a/dtool/src/interrogate/parameterRemap.I +++ b/dtool/src/interrogate/parameterRemap.I @@ -20,8 +20,8 @@ ParameterRemap(CPPType *orig_type) : _new_type(orig_type) { _is_valid = true; - _temporary_type = (CPPType *)NULL; - _default_value = (CPPExpression *)NULL; + _temporary_type = nullptr; + _default_value = nullptr; } /** @@ -57,7 +57,7 @@ get_new_type() const { */ INLINE CPPType *ParameterRemap:: get_temporary_type() const { - if (_temporary_type == (CPPType *)NULL) { + if (_temporary_type == nullptr) { return _new_type; } else { return _temporary_type; @@ -69,7 +69,7 @@ get_temporary_type() const { */ INLINE bool ParameterRemap:: has_default_value() const { - return (_default_value != (CPPExpression *)NULL); + return (_default_value != nullptr); } /** diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx index 8c9c247ac7..d2ea916fff 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx @@ -21,8 +21,8 @@ ParameterRemapBasicStringPtrToString:: ParameterRemapBasicStringPtrToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -54,8 +54,8 @@ ParameterRemapBasicWStringPtrToWString:: ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { - static CPPType *const_wchar_star_type = (CPPType *)NULL; - if (const_wchar_star_type == (CPPType *)NULL) { + static CPPType *const_wchar_star_type = nullptr; + if (const_wchar_star_type == nullptr) { const_wchar_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx index a94055f899..0e5bac31ff 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx @@ -21,8 +21,8 @@ ParameterRemapBasicStringRefToString:: ParameterRemapBasicStringRefToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -54,8 +54,8 @@ ParameterRemapBasicWStringRefToWString:: ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { - static CPPType *const_wchar_star_type = (CPPType *)NULL; - if (const_wchar_star_type == (CPPType *)NULL) { + static CPPType *const_wchar_star_type = nullptr; + if (const_wchar_star_type == nullptr) { const_wchar_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx index db031004c6..d2ed1f0406 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx @@ -22,8 +22,8 @@ ParameterRemapBasicStringToString:: ParameterRemapBasicStringToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -68,8 +68,8 @@ ParameterRemapBasicWStringToWString:: ParameterRemapBasicWStringToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { - static CPPType *const_wchar_star_type = (CPPType *)NULL; - if (const_wchar_star_type == (CPPType *)NULL) { + static CPPType *const_wchar_star_type = nullptr; + if (const_wchar_star_type == nullptr) { const_wchar_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parameterRemapPTToPointer.cxx b/dtool/src/interrogate/parameterRemapPTToPointer.cxx index 44f6a0d036..d4aefb71d2 100644 --- a/dtool/src/interrogate/parameterRemapPTToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapPTToPointer.cxx @@ -29,23 +29,23 @@ ParameterRemapPTToPointer(CPPType *orig_type) : ParameterRemap(orig_type) { CPPStructType *pt_type = TypeManager::unwrap(_orig_type)->as_struct_type(); - assert(pt_type != (CPPStructType *)NULL); + assert(pt_type != nullptr); // A horrible hack around a CPPParser bug. We don't trust the CPPStructType // pointer we were given; instead, we ask CPPParser to parse a new type of // the same name. This has a better chance of fully resolving templates. string name = pt_type->get_local_name(&parser); CPPType *new_type = parser.parse_type(name); - if (new_type == (CPPType *)NULL) { + if (new_type == nullptr) { nout << "Type " << name << " is unknown to parser.\n"; } else { new_type = new_type->resolve_type(&parser, &parser); pt_type = new_type->as_struct_type(); - assert(pt_type != (CPPStructType *)NULL); + assert(pt_type != nullptr); } _pointer_type = TypeManager::get_pointer_type(pt_type); - if (_pointer_type == (CPPType *)NULL) { + if (_pointer_type == nullptr) { // If we couldn't figure out the pointer type, forget it. nout << "Couldn't figure out pointer type for " << *pt_type << "\n"; _is_valid = false; diff --git a/dtool/src/interrogate/parameterRemapToString.cxx b/dtool/src/interrogate/parameterRemapToString.cxx index fe7c7a8253..0a3abe4559 100644 --- a/dtool/src/interrogate/parameterRemapToString.cxx +++ b/dtool/src/interrogate/parameterRemapToString.cxx @@ -22,13 +22,13 @@ ParameterRemapToString:: ParameterRemapToString(CPPType *orig_type) : ParameterRemap(orig_type) { - static CPPType *char_star_type = (CPPType *)NULL; - if (char_star_type == (CPPType *)NULL) { + static CPPType *char_star_type = nullptr; + if (char_star_type == nullptr) { char_star_type = parser.parse_type("char *"); } - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -75,8 +75,8 @@ ParameterRemapToWString:: ParameterRemapToWString(CPPType *orig_type) : ParameterRemap(orig_type) { - static CPPType *char_star_type = (CPPType *)NULL; - if (char_star_type == (CPPType *)NULL) { + static CPPType *char_star_type = nullptr; + if (char_star_type == nullptr) { char_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index 6670bcbe44..f7341b306e 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -48,10 +48,10 @@ predefine_macro(CPPParser &parser, const string &option) { void show_type_or_expression(const string &str) { CPPExpression *expr = parser.parse_expr(str); - if (expr != NULL) { + if (expr != nullptr) { cout << "\nExpression: " << *expr << "\n"; CPPType *type = expr->determine_type(); - if (type == NULL) { + if (type == nullptr) { cout << "type is unknown\n"; } else { cout << "type is " << *type << "\n"; @@ -60,13 +60,13 @@ show_type_or_expression(const string &str) { } else { CPPType *type = parser.parse_type(str); - if (type != NULL) { + if (type != nullptr) { cout << "\nType: " << *type << "\n" << "Defined in: " << type->_file << "\n" << "Subtype code is: " << (int)type->get_subtype() << "\n\n"; CPPStructType *stype = type->as_struct_type(); - if (stype != (CPPStructType *)NULL) { + if (stype != nullptr) { stype->check_virtual(); } @@ -84,7 +84,7 @@ show_type_or_expression(const string &str) { << "get_preferred_name = " << type->get_preferred_name() << "\n" << "is_incomplete = " << type->is_incomplete() << "\n"; - if (stype != (CPPStructType *)NULL) { + if (stype != nullptr) { cout << "scope = " << stype->get_scope()->get_fully_scoped_name() << "\n"; bool is_abstract = stype->is_abstract(); cout << "is_abstract = " << is_abstract << "\n"; @@ -109,19 +109,19 @@ show_type_or_expression(const string &str) { void show_methods(const string &str) { CPPType *type = parser.parse_type(str); - if (type == NULL) { + if (type == nullptr) { cerr << "Invalid type: " << str << "\n"; return; } CPPStructType *stype = type->as_struct_type(); - if (stype == NULL) { + if (stype == nullptr) { cerr << "Type is not a structure or class.\n"; return; } CPPScope *scope = stype->get_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); cerr << "Methods in " << *stype << ":\n"; @@ -142,19 +142,19 @@ show_methods(const string &str) { void show_data_members(const string &str) { CPPType *type = parser.parse_type(str); - if (type == NULL) { + if (type == nullptr) { cerr << "Invalid type: " << str << "\n"; return; } CPPStructType *stype = type->as_struct_type(); - if (stype == NULL) { + if (stype == nullptr) { cerr << "Type is not a structure or class.\n"; return; } CPPScope *scope = stype->get_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); cerr << "Data members in " << *stype << ":\n"; @@ -168,19 +168,19 @@ show_data_members(const string &str) { void show_nested_types(const string &str) { CPPType *type = parser.parse_type(str); - if (type == NULL) { + if (type == nullptr) { cerr << "Invalid type: " << str << "\n"; return; } CPPStructType *stype = type->as_struct_type(); - if (stype == NULL) { + if (stype == nullptr) { cerr << "Type is not a structure or class.\n"; return; } CPPScope *scope = stype->get_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); cerr << "Nested types in " << *stype << ":\n"; @@ -276,7 +276,7 @@ main(int argc, char **argv) { while (cin) { string str; cout << "Enter an expression or type name:\n"; - getline(cin, str); + std::getline(std::cin, str); if (!str.empty()) { size_t space = str.find(' '); diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index 1485c785ca..85161eb69e 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -37,7 +37,7 @@ */ CPPType *TypeManager:: resolve_type(CPPType *type, CPPScope *scope) { - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { scope = &parser; } @@ -550,7 +550,7 @@ is_char(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_char && simple_type->_flags == 0; @@ -581,7 +581,7 @@ is_unsigned_char(CPPType *type) { { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_char) && (simple_type->_flags & CPPSimpleType::F_unsigned) != 0; @@ -613,7 +613,7 @@ is_signed_char(CPPType *type) { { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_char) && (simple_type->_flags & CPPSimpleType::F_signed) != 0; @@ -717,7 +717,7 @@ is_const_unsigned_char_pointer(CPPType *type) { bool TypeManager:: is_basic_string_char(CPPType *type) { CPPType *string_type = get_basic_string_char_type(); - if (string_type != (CPPType *)NULL && + if (string_type != nullptr && string_type->get_local_name(&parser) == type->get_local_name(&parser)) { return true; } @@ -822,7 +822,7 @@ is_wchar(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_wchar_t; } } @@ -865,7 +865,7 @@ is_wchar_pointer(CPPType *type) { bool TypeManager:: is_basic_string_wchar(CPPType *type) { CPPType *string_type = get_basic_string_wchar_type(); - if (string_type != (CPPType *)NULL && + if (string_type != nullptr && string_type->get_local_name(&parser) == type->get_local_name(&parser)) { return true; } @@ -965,6 +965,7 @@ is_wstring(CPPType *type) { bool TypeManager:: is_vector_unsigned_char(CPPType *type) { if (type->get_local_name(&parser) == "vector< unsigned char >" || + type->get_local_name(&parser) == "std::vector< unsigned char >" || type->get_local_name(&parser) == "pvector< unsigned char >") { return true; } @@ -1030,7 +1031,7 @@ is_bool(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_bool; } @@ -1063,7 +1064,7 @@ is_integer(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_bool || simple_type->_type == CPPSimpleType::T_char || @@ -1098,7 +1099,7 @@ is_unsigned_integer(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return ((simple_type->_type == CPPSimpleType::T_bool || simple_type->_type == CPPSimpleType::T_char || @@ -1187,7 +1188,7 @@ is_long(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & CPPSimpleType::F_long) != 0); } @@ -1217,7 +1218,7 @@ is_short(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & CPPSimpleType::F_short) != 0); } @@ -1246,7 +1247,7 @@ is_unsigned_short(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & (CPPSimpleType::F_short | CPPSimpleType::F_unsigned)) == (CPPSimpleType::F_short | CPPSimpleType::F_unsigned)); } @@ -1276,7 +1277,7 @@ is_longlong(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & CPPSimpleType::F_longlong) != 0); } @@ -1306,7 +1307,7 @@ is_unsigned_longlong(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned)) == (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned)); } @@ -1335,7 +1336,7 @@ is_double(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_double); } } @@ -1364,7 +1365,7 @@ is_float(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_float || simple_type->_type == CPPSimpleType::T_double); @@ -1388,7 +1389,7 @@ is_float(CPPType *type) { bool TypeManager:: is_void(CPPType *type) { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_void && simple_type->_flags == 0; @@ -1404,7 +1405,7 @@ is_void(CPPType *type) { bool TypeManager:: is_reference_count(CPPType *type) { CPPType *refcount_type = get_reference_count_type(); - if (refcount_type != (CPPType *)NULL && + if (refcount_type != nullptr && refcount_type->get_local_name(&parser) == type->get_local_name(&parser)) { return true; } @@ -1804,7 +1805,9 @@ bool TypeManager::is_ostream(CPPType *type) { return is_ostream(type->as_const_type()->_wrapped_around); case CPPDeclaration::ST_struct: - return (type->get_local_name(&parser) == "ostream"); + return (type->get_local_name(&parser) == "std::ostream" || + type->get_local_name(&parser) == "ostream" || + type->get_local_name(&parser) == "std::basic_ostream< char >"); case CPPDeclaration::ST_typedef: return is_ostream(type->as_typedef_type()->_type); @@ -1859,7 +1862,7 @@ involves_unpublished(CPPType *type) { case CPPDeclaration::ST_struct: // A struct type is unpublished only if all of its members are // unpublished. - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { if (type->_declaration->_vis <= min_vis) { return false; } @@ -1881,7 +1884,7 @@ involves_unpublished(CPPType *type) { } case CPPDeclaration::ST_function: - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { if (type->_declaration->_vis <= min_vis) { return false; } @@ -1909,7 +1912,7 @@ involves_unpublished(CPPType *type) { return involves_unpublished(type->as_typedef_type()->_type); default: - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { return (type->_declaration->_vis > min_vis); } return false; @@ -1955,7 +1958,7 @@ involves_protected(CPPType *type) { return involves_protected(type->as_typedef_type()->_type); default: - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { return (type->_declaration->_vis > V_public); } return false; @@ -2073,7 +2076,7 @@ get_pointer_type(CPPStructType *pt_type) { ++ii) { CPPInstance *function = (*ii); CPPFunctionType *ftype = function->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if (ftype->_parameters->_parameters.empty()) { // Here's the function p(). What's its return type? return resolve_type(ftype->_return_type); @@ -2081,7 +2084,7 @@ get_pointer_type(CPPStructType *pt_type) { } } - return (CPPType *)NULL; + return nullptr; } /** @@ -2106,15 +2109,15 @@ get_template_parameter_type(CPPType *source_type, int i) { } CPPStructType *type = source_type->as_struct_type(); - if (type == NULL) { - return NULL; + if (type == nullptr) { + return nullptr; } // I'm not sure how reliable this is, but I don't know if there is a more // proper way to access this. CPPTemplateParameterList *templ = type->_ident->_names.back().get_templ(); - if (templ == NULL || i >= (int)templ->_parameters.size()) { - return NULL; + if (templ == nullptr || i >= (int)templ->_parameters.size()) { + return nullptr; } CPPDeclaration *decl = templ->_parameters[i]; @@ -2134,7 +2137,7 @@ wrap_pointer(CPPType *source_type) { */ CPPType *TypeManager:: wrap_const_pointer(CPPType *source_type) { - if (source_type->as_const_type() != (CPPConstType *)NULL) { + if (source_type->as_const_type() != nullptr) { // It's already const. return CPPType::new_type(new CPPPointerType(source_type)); @@ -2149,7 +2152,7 @@ wrap_const_pointer(CPPType *source_type) { */ CPPType *TypeManager:: wrap_const_reference(CPPType *source_type) { - if (source_type->as_const_type() != (CPPConstType *)NULL) { + if (source_type->as_const_type() != nullptr) { // It's already const. return CPPType::new_type(new CPPReferenceType(source_type)); @@ -2166,7 +2169,7 @@ wrap_const_reference(CPPType *source_type) { CPPType *TypeManager:: get_basic_string_char_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = parser.parse_type("std::basic_string"); got_type = true; @@ -2181,7 +2184,7 @@ get_basic_string_char_type() { CPPType *TypeManager:: get_basic_string_wchar_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = parser.parse_type("std::basic_string"); got_type = true; @@ -2196,7 +2199,7 @@ get_basic_string_wchar_type() { CPPType *TypeManager:: get_reference_count_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = parser.parse_type("ReferenceCount"); got_type = true; @@ -2210,7 +2213,7 @@ get_reference_count_type() { CPPType *TypeManager:: get_void_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_void)); got_type = true; @@ -2224,7 +2227,7 @@ get_void_type() { CPPType *TypeManager:: get_int_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int)); got_type = true; @@ -2246,7 +2249,7 @@ string TypeManager:: get_function_signature(CPPInstance *function, int num_default_parameters) { CPPFunctionType *ftype = function->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); ostringstream out; @@ -2315,7 +2318,7 @@ get_function_name(CPPInstance *function) { bool TypeManager:: has_protected_destructor(CPPType *type) { CPPStructType *struct_type = type->as_struct_type(); - if (struct_type == (CPPStructType *)NULL) { + if (struct_type == nullptr) { // It's not even a struct type! return false; } @@ -2332,7 +2335,7 @@ has_protected_destructor(CPPType *type) { if (inst->_type->get_subtype() == CPPDeclaration::ST_function) { // Here's a function declaration. CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { // Here's the destructor! Is it protected? return (inst->_vis > V_public); diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index 65f192edf7..6d259b01ff 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -39,7 +39,7 @@ class CPPManifest; class TypeManager { public: - static CPPType *resolve_type(CPPType *type, CPPScope *scope = (CPPScope *)NULL); + static CPPType *resolve_type(CPPType *type, CPPScope *scope = nullptr); static bool is_assignable(CPPType *type); diff --git a/dtool/src/interrogatedb/dtool_super_base.cxx b/dtool/src/interrogatedb/dtool_super_base.cxx index 26b57a157d..d5197b3c76 100644 --- a/dtool/src/interrogatedb/dtool_super_base.cxx +++ b/dtool/src/interrogatedb/dtool_super_base.cxx @@ -26,7 +26,7 @@ static PyObject *GetSuperBase(PyObject *self) { PyMethodDef Dtool_Methods_DTOOL_SUPER_BASE[] = { { "DtoolGetSuperBase", (PyCFunction) &GetSuperBase, METH_NOARGS, "Will Return SUPERbase Class"}, - { NULL, NULL } + { nullptr, nullptr, 0, nullptr } }; EXPCL_INTERROGATEDB void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module) { @@ -46,89 +46,89 @@ EXPCL_INTERROGATEDB void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *modu PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE._PyType.tp_dict, "DtoolGetSuperBase", PyCFunction_New(&Dtool_Methods_DTOOL_SUPER_BASE[0], (PyObject *)&Dtool_DTOOL_SUPER_BASE)); } - if (module != NULL) { + if (module != nullptr) { Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); PyModule_AddObject(module, "DTOOL_SUPER_BASE", (PyObject *)&Dtool_DTOOL_SUPER_BASE); } } inline void *Dtool_DowncastInterface_DTOOL_SUPER_BASE(void *from_this, Dtool_PyTypedObject *from_type) { - return (void *) NULL; + return nullptr; } inline void *Dtool_UpcastInterface_DTOOL_SUPER_BASE(PyObject *self, Dtool_PyTypedObject *requested_type) { - return NULL; + return nullptr; } int Dtool_Init_DTOOL_SUPER_BASE(PyObject *self, PyObject *args, PyObject *kwds) { - assert(self != NULL); + assert(self != nullptr); PyErr_Format(PyExc_TypeError, "cannot init constant class %s", Py_TYPE(self)->tp_name); return -1; } EXPORT_THIS Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE = { { - PyVarObject_HEAD_INIT(NULL, 0) + PyVarObject_HEAD_INIT(nullptr, 0) "dtoolconfig.DTOOL_SUPER_BASE", sizeof(Dtool_PyInstDef), - 0, + 0, // tp_itemsize &Dtool_FreeInstance_DTOOL_SUPER_BASE, - 0, - 0, - 0, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr #if PY_MAJOR_VERSION >= 3 - 0, + nullptr, // tp_compare #else &DTOOL_PyObject_ComparePointers, #endif - 0, - 0, - 0, - 0, + nullptr, // tp_repr + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping &DTOOL_PyObject_HashPointer, - 0, - 0, + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, + nullptr, // tp_as_buffer (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES), - 0, - 0, - 0, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear #if PY_MAJOR_VERSION >= 3 &DTOOL_PyObject_RichCompare, #else - 0, + nullptr, // tp_richcompare #endif - 0, - 0, - 0, + 0, // tp_weaklistoffset + nullptr, // tp_iter + nullptr, // tp_iternext Dtool_Methods_DTOOL_SUPER_BASE, standard_type_members, - 0, - 0, - 0, - 0, - 0, - 0, + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset Dtool_Init_DTOOL_SUPER_BASE, PyType_GenericAlloc, Dtool_new_DTOOL_SUPER_BASE, PyObject_Del, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }, TypeHandle::none(), Dtool_PyModuleClassInit_DTOOL_SUPER_BASE, Dtool_UpcastInterface_DTOOL_SUPER_BASE, Dtool_DowncastInterface_DTOOL_SUPER_BASE, - NULL, - NULL, + nullptr, + nullptr, }; #endif // HAVE_PYTHON diff --git a/dtool/src/interrogatedb/indexRemapper.cxx b/dtool/src/interrogatedb/indexRemapper.cxx index eee236cf08..7c606bec06 100644 --- a/dtool/src/interrogatedb/indexRemapper.cxx +++ b/dtool/src/interrogatedb/indexRemapper.cxx @@ -59,7 +59,7 @@ in_map(int from) const { */ int IndexRemapper:: map_from(int from) const { - map::const_iterator mi; + std::map::const_iterator mi; mi = _map_int.find(from); if (mi == _map_int.end()) { return from; diff --git a/dtool/src/interrogatedb/indexRemapper.h b/dtool/src/interrogatedb/indexRemapper.h index 9318777c94..c89a7a2988 100644 --- a/dtool/src/interrogatedb/indexRemapper.h +++ b/dtool/src/interrogatedb/indexRemapper.h @@ -38,7 +38,7 @@ public: int map_from(int from) const; private: - map _map_int; + std::map _map_int; }; #endif diff --git a/dtool/src/interrogatedb/interrogateComponent.I b/dtool/src/interrogatedb/interrogateComponent.I index 4617eee858..dc401c7945 100644 --- a/dtool/src/interrogatedb/interrogateComponent.I +++ b/dtool/src/interrogatedb/interrogateComponent.I @@ -46,7 +46,7 @@ operator = (const InterrogateComponent ©) { INLINE bool InterrogateComponent:: has_library_name() const { const char *name = get_library_name(); - return (name != (const char *)NULL && name[0] != '\0'); + return (name != nullptr && name[0] != '\0'); } /** @@ -57,10 +57,10 @@ has_library_name() const { */ INLINE const char *InterrogateComponent:: get_library_name() const { - if (_def != (InterrogateModuleDef *)NULL) { + if (_def != nullptr) { return _def->library_name; } - return (const char *)NULL; + return nullptr; } /** @@ -70,7 +70,7 @@ get_library_name() const { INLINE bool InterrogateComponent:: has_module_name() const { const char *name = get_module_name(); - return (name != (const char *)NULL && name[0] != '\0'); + return (name != nullptr && name[0] != '\0'); } /** @@ -81,10 +81,10 @@ has_module_name() const { */ INLINE const char *InterrogateComponent:: get_module_name() const { - if (_def != (InterrogateModuleDef *)NULL) { + if (_def != nullptr) { return _def->module_name; } - return (const char *)NULL; + return nullptr; } /** diff --git a/dtool/src/interrogatedb/interrogateComponent.h b/dtool/src/interrogatedb/interrogateComponent.h index c69dc26886..0d8a39595d 100644 --- a/dtool/src/interrogatedb/interrogateComponent.h +++ b/dtool/src/interrogatedb/interrogateComponent.h @@ -29,7 +29,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateComponent { public: - INLINE InterrogateComponent(InterrogateModuleDef *def = NULL); + INLINE InterrogateComponent(InterrogateModuleDef *def = nullptr); INLINE InterrogateComponent(const InterrogateComponent ©); INLINE void operator = (const InterrogateComponent ©); @@ -55,7 +55,7 @@ private: InterrogateModuleDef *_def; string _name; - typedef vector Strings; + typedef std::vector Strings; Strings _alt_names; friend class InterrogateBuilder; diff --git a/dtool/src/interrogatedb/interrogateDatabase.cxx b/dtool/src/interrogatedb/interrogateDatabase.cxx index c11675d352..8781e5c2bd 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.cxx +++ b/dtool/src/interrogatedb/interrogateDatabase.cxx @@ -16,7 +16,7 @@ #include "indexRemapper.h" #include "interrogate_datafile.h" -InterrogateDatabase *InterrogateDatabase::_global_ptr = NULL; +InterrogateDatabase *InterrogateDatabase::_global_ptr = nullptr; int InterrogateDatabase::_file_major_version = 0; int InterrogateDatabase::_file_minor_version = 0; int InterrogateDatabase::_current_major_version = 3; @@ -37,7 +37,7 @@ InterrogateDatabase() { */ InterrogateDatabase *InterrogateDatabase:: get_ptr() { - if (_global_ptr == (InterrogateDatabase *)NULL) { + if (_global_ptr == nullptr) { if (interrogatedb_cat->is_debug()) { interrogatedb_cat->debug() << "Creating interrogate database\n"; @@ -56,7 +56,7 @@ get_ptr() { void InterrogateDatabase:: request_module(InterrogateModuleDef *def) { if (interrogatedb_cat->is_debug()) { - if (def->library_name == (const char *)NULL) { + if (def->library_name == nullptr) { interrogatedb_cat->debug() << "Got interrogate data for anonymous module\n"; } else { @@ -78,13 +78,13 @@ request_module(InterrogateModuleDef *def) { _modules.push_back(def); } - if (def->num_unique_names > 0 && def->library_name != (const char *)NULL) { + if (def->num_unique_names > 0 && def->library_name != nullptr) { // Define a lookup by hash for this module, mainly so we can look up // functions by their unique names. _modules_by_hash[def->library_hash_name] = def; } - if (def->database_filename != (const char *)NULL) { + if (def->database_filename != nullptr) { _requests.push_back(def); } } @@ -361,7 +361,7 @@ get_fptr(FunctionWrapperIndex wrapper) { return def->fptrs[module_index]; } } - return (void *)NULL; + return nullptr; } /** @@ -830,7 +830,7 @@ load_latest() { for (ri = copy_requests.begin(); ri != copy_requests.end(); ++ri) { InterrogateModuleDef *def = (*ri); - if (def->database_filename != (char *)NULL) { + if (def->database_filename != nullptr) { Filename filename = def->database_filename; Filename pathname = filename; if (!pathname.empty() && pathname[0] != '/') { diff --git a/dtool/src/interrogatedb/interrogateDatabase.h b/dtool/src/interrogatedb/interrogateDatabase.h index 84fc55fbab..182e35798f 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.h +++ b/dtool/src/interrogatedb/interrogateDatabase.h @@ -124,41 +124,41 @@ private: const string &wrapper_hash_name); // This data is loaded from the various database files. - typedef map TypeMap; + typedef std::map TypeMap; TypeMap _type_map; - typedef map FunctionMap; + typedef std::map FunctionMap; FunctionMap _function_map; - typedef map FunctionWrapperMap; + typedef std::map FunctionWrapperMap; FunctionWrapperMap _wrapper_map; - typedef map ManifestMap; + typedef std::map ManifestMap; ManifestMap _manifest_map; - typedef map ElementMap; + typedef std::map ElementMap; ElementMap _element_map; - typedef map MakeSeqMap; + typedef std::map MakeSeqMap; MakeSeqMap _make_seq_map; - typedef vector GlobalTypes; + typedef std::vector GlobalTypes; GlobalTypes _global_types; GlobalTypes _all_types; - typedef vector GlobalFunctions; + typedef std::vector GlobalFunctions; GlobalFunctions _global_functions; GlobalFunctions _all_functions; - typedef vector GlobalManifests; + typedef std::vector GlobalManifests; GlobalManifests _global_manifests; - typedef vector GlobalElements; + typedef std::vector GlobalElements; GlobalElements _global_elements; // This data is compiled in directly to the shared libraries that we link // with. - typedef vector Modules; + typedef std::vector Modules; Modules _modules; - typedef map ModulesByHash; + typedef std::map ModulesByHash; ModulesByHash _modules_by_hash; // This records the set of database files that are still to be loaded. - typedef vector Requests; + typedef std::vector Requests; Requests _requests; bool _error_flag; @@ -174,7 +174,7 @@ private: }; int _lookups_fresh; - typedef map Lookup; + typedef std::map Lookup; Lookup _types_by_name; Lookup _types_by_scoped_name; Lookup _types_by_true_name; diff --git a/dtool/src/interrogatedb/interrogateElement.h b/dtool/src/interrogatedb/interrogateElement.h index f824b760cf..b3ba755fac 100644 --- a/dtool/src/interrogatedb/interrogateElement.h +++ b/dtool/src/interrogatedb/interrogateElement.h @@ -27,7 +27,7 @@ class CPPMakeProperty; */ class EXPCL_INTERROGATEDB InterrogateElement : public InterrogateComponent { public: - INLINE InterrogateElement(InterrogateModuleDef *def = NULL); + INLINE InterrogateElement(InterrogateModuleDef *def = nullptr); INLINE InterrogateElement(const InterrogateElement ©); INLINE void operator = (const InterrogateElement ©); diff --git a/dtool/src/interrogatedb/interrogateFunction.cxx b/dtool/src/interrogatedb/interrogateFunction.cxx index 6510f86fc9..a9a60264da 100644 --- a/dtool/src/interrogatedb/interrogateFunction.cxx +++ b/dtool/src/interrogatedb/interrogateFunction.cxx @@ -25,7 +25,7 @@ InterrogateFunction(InterrogateModuleDef *def) : { _flags = 0; _class = 0; - _instances = (Instances *)NULL; + _instances = nullptr; } /** diff --git a/dtool/src/interrogatedb/interrogateFunction.h b/dtool/src/interrogatedb/interrogateFunction.h index 312f69a97e..cf92aa15dc 100644 --- a/dtool/src/interrogatedb/interrogateFunction.h +++ b/dtool/src/interrogatedb/interrogateFunction.h @@ -29,7 +29,7 @@ class CPPInstance; */ class EXPCL_INTERROGATEDB InterrogateFunction : public InterrogateComponent { public: - InterrogateFunction(InterrogateModuleDef *def = NULL); + InterrogateFunction(InterrogateModuleDef *def = nullptr); InterrogateFunction(const InterrogateFunction ©); void operator = (const InterrogateFunction ©); @@ -78,7 +78,7 @@ private: string _prototype; TypeIndex _class; - typedef vector Wrappers; + typedef std::vector Wrappers; Wrappers _c_wrappers; Wrappers _python_wrappers; @@ -92,7 +92,7 @@ public: // This must be a pointer, rather than a concrete map, so we don't risk // trying to create a map in one DLL and access it in another. Silly // Windows. - typedef map Instances; + typedef std::map Instances; Instances *_instances; string _expression; diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index 511e8c6263..ff80d930b9 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -27,7 +27,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateFunctionWrapper : public InterrogateComponent { public: - INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL); + INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = nullptr); INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper ©); INLINE void operator = (const InterrogateFunctionWrapper ©); @@ -90,7 +90,7 @@ public: }; private: - typedef vector Parameters; + typedef std::vector Parameters; Parameters _parameters; friend class InterrogateBuilder; diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.h b/dtool/src/interrogatedb/interrogateMakeSeq.h index 6883e81126..b65a32b27e 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.h +++ b/dtool/src/interrogatedb/interrogateMakeSeq.h @@ -25,7 +25,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateMakeSeq : public InterrogateComponent { public: - INLINE InterrogateMakeSeq(InterrogateModuleDef *def = NULL); + INLINE InterrogateMakeSeq(InterrogateModuleDef *def = nullptr); INLINE InterrogateMakeSeq(const InterrogateMakeSeq ©); INLINE void operator = (const InterrogateMakeSeq ©); diff --git a/dtool/src/interrogatedb/interrogateManifest.h b/dtool/src/interrogatedb/interrogateManifest.h index 49323a75c0..37ec3696b4 100644 --- a/dtool/src/interrogatedb/interrogateManifest.h +++ b/dtool/src/interrogatedb/interrogateManifest.h @@ -25,7 +25,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateManifest : public InterrogateComponent { public: - INLINE InterrogateManifest(InterrogateModuleDef *def = NULL); + INLINE InterrogateManifest(InterrogateModuleDef *def = nullptr); INLINE InterrogateManifest(const InterrogateManifest ©); INLINE void operator = (const InterrogateManifest ©); diff --git a/dtool/src/interrogatedb/interrogateType.cxx b/dtool/src/interrogatedb/interrogateType.cxx index a6d6e45487..41839ffbf7 100644 --- a/dtool/src/interrogatedb/interrogateType.cxx +++ b/dtool/src/interrogatedb/interrogateType.cxx @@ -32,8 +32,8 @@ InterrogateType(InterrogateModuleDef *def) : _array_size = 1; _destructor = 0; - _cpptype = (CPPType *)NULL; - _cppscope = (CPPScope *)NULL; + _cpptype = nullptr; + _cppscope = nullptr; } /** diff --git a/dtool/src/interrogatedb/interrogateType.h b/dtool/src/interrogatedb/interrogateType.h index 176efb4fb9..f5b3b49065 100644 --- a/dtool/src/interrogatedb/interrogateType.h +++ b/dtool/src/interrogatedb/interrogateType.h @@ -29,7 +29,7 @@ class CPPScope; */ class EXPCL_INTERROGATEDB InterrogateType : public InterrogateComponent { public: - InterrogateType(InterrogateModuleDef *def = NULL); + InterrogateType(InterrogateModuleDef *def = nullptr); InterrogateType(const InterrogateType ©); void operator = (const InterrogateType ©); @@ -154,16 +154,16 @@ public: TypeIndex _wrapped_type; int _array_size; - typedef vector Functions; + typedef std::vector Functions; Functions _constructors; FunctionIndex _destructor; - typedef vector Elements; + typedef std::vector Elements; Elements _elements; Functions _methods; Functions _casts; - typedef vector MakeSeqs; + typedef std::vector MakeSeqs; MakeSeqs _make_seqs; enum DerivationFlags { @@ -188,7 +188,7 @@ public: }; private: - typedef vector Derivations; + typedef std::vector Derivations; Derivations _derivations; public: @@ -205,10 +205,10 @@ public: }; private: - typedef vector EnumValues; + typedef std::vector EnumValues; EnumValues _enum_values; - typedef vector Types; + typedef std::vector Types; Types _nested_types; public: diff --git a/dtool/src/interrogatedb/interrogate_datafile.I b/dtool/src/interrogatedb/interrogate_datafile.I index 9111260237..ee8d3f38a3 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.I +++ b/dtool/src/interrogatedb/interrogate_datafile.I @@ -17,9 +17,9 @@ */ template void -idf_output_vector(ostream &out, const vector &vec) { +idf_output_vector(ostream &out, const std::vector &vec) { out << vec.size() << " "; - TYPENAME vector::const_iterator vi; + typename std::vector::const_iterator vi; for (vi = vec.begin(); vi != vec.end(); ++vi) { out << (*vi) << " "; } @@ -33,7 +33,7 @@ idf_output_vector(ostream &out, const vector &vec) { */ template void -idf_input_vector(istream &in, vector &vec) { +idf_input_vector(istream &in, std::vector &vec) { int length; in >> length; if (in.fail()) { diff --git a/dtool/src/interrogatedb/interrogate_datafile.cxx b/dtool/src/interrogatedb/interrogate_datafile.cxx index eb5c0ca57f..65cc3f3fef 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.cxx +++ b/dtool/src/interrogatedb/interrogate_datafile.cxx @@ -53,7 +53,7 @@ idf_input_string(istream &in, string &str) { */ void idf_output_string(ostream &out, const char *str, char whitespace) { - if (str == (const char *)NULL) { + if (str == nullptr) { out << "0 "; } else { out << strlen(str) << whitespace; diff --git a/dtool/src/interrogatedb/interrogate_datafile.h b/dtool/src/interrogatedb/interrogate_datafile.h index ecd2acbce0..7442d8ce81 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.h +++ b/dtool/src/interrogatedb/interrogate_datafile.h @@ -27,10 +27,10 @@ void idf_output_string(ostream &out, const char *str, char whitespace = ' '); void idf_input_string(istream &in, const char *&str); template -void idf_output_vector(ostream &out, const vector &vec); +void idf_output_vector(ostream &out, const std::vector &vec); template -void idf_input_vector(istream &in, vector &vec); +void idf_input_vector(istream &in, std::vector &vec); #include "interrogate_datafile.I" diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index 6e948134d3..5f72f967e0 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -400,7 +400,7 @@ interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n) { bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper) { // cerr << "interrogate_wrapper_has_pointer(" << wrapper << ")\n"; - return (InterrogateDatabase::get_ptr()->get_fptr(wrapper) != (void *)NULL); + return (InterrogateDatabase::get_ptr()->get_fptr(wrapper) != nullptr); } void * diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 1986a128c5..7ddf8bec9b 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -68,28 +68,28 @@ DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &target_c template INLINE PyObject * DTool_CreatePyInstance(const T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, true); } template INLINE PyObject * DTool_CreatePyInstance(T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, false); } template INLINE PyObject * DTool_CreatePyInstanceTyped(const T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, true, obj->get_type().get_index()); } template INLINE PyObject * DTool_CreatePyInstanceTyped(T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, false, obj->get_type().get_index()); } @@ -180,7 +180,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(double value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const char *value) { - if (value == (const char *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -193,7 +193,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const char *value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const wchar_t *value) { - if (value == (const wchar_t *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -214,7 +214,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring &value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value) { - if (value == (const std::string *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -227,7 +227,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring *value) { - if (value == (const std::wstring *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -247,7 +247,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(wchar_t value) { return PyUnicode_FromWideChar(&value, 1); } -ALWAYS_INLINE PyObject *Dtool_WrapValue(nullptr_t) { +ALWAYS_INLINE PyObject *Dtool_WrapValue(std::nullptr_t) { Py_INCREF(Py_None); return Py_None; } @@ -266,7 +266,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const vector_uchar &value) { #if PY_MAJOR_VERSION >= 0x02060000 ALWAYS_INLINE PyObject *Dtool_WrapValue(Py_buffer *value) { - if (value == (Py_buffer *)NULL) { + if (value == nullptr) { return value; } else { return PyMemoryView_FromBuffer(value); diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 362f5ec6ca..236c9a5197 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -24,7 +24,7 @@ PyMemberDef standard_type_members[] = { // {(char *)"this_signature", T_INT, offsetof(Dtool_PyInstDef, _signature), // READONLY, (char *)"A type check signature"}, {(char *)"this_metatype", T_OBJECT, offsetof(Dtool_PyInstDef, _My_Type), READONLY, (char *)"The dtool meta object"}, - {NULL} /* Sentinel */ + {nullptr} /* Sentinel */ }; static RuntimeTypeMap runtime_type_map; @@ -183,9 +183,9 @@ PyObject *Dtool_Raise_AssertionError() { PyObject *message = PyString_FromString(notify->get_assert_error_message().c_str()); #endif Py_INCREF(PyExc_AssertionError); - PyErr_Restore(PyExc_AssertionError, message, (PyObject *)NULL); + PyErr_Restore(PyExc_AssertionError, message, nullptr); notify->clear_assert_failed(); - return NULL; + return nullptr; } /** @@ -196,11 +196,11 @@ PyObject *Dtool_Raise_TypeError(const char *message) { // eventually anyway, so we might as well just get to the point. Py_INCREF(PyExc_TypeError); #if PY_MAJOR_VERSION >= 3 - PyErr_Restore(PyExc_TypeError, PyUnicode_FromString(message), (PyObject *)NULL); + PyErr_Restore(PyExc_TypeError, PyUnicode_FromString(message), nullptr); #else - PyErr_Restore(PyExc_TypeError, PyString_FromString(message), (PyObject *)NULL); + PyErr_Restore(PyExc_TypeError, PyString_FromString(message), nullptr); #endif - return NULL; + return nullptr; } /** @@ -221,8 +221,8 @@ PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *functio Py_TYPE(obj)->tp_name); Py_INCREF(PyExc_TypeError); - PyErr_Restore(PyExc_TypeError, message, (PyObject *)NULL); - return NULL; + PyErr_Restore(PyExc_TypeError, message, nullptr); + return nullptr; } /** @@ -241,8 +241,8 @@ PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute) { Py_TYPE(obj)->tp_name, attribute); Py_INCREF(PyExc_TypeError); - PyErr_Restore(PyExc_TypeError, message, (PyObject *)NULL); - return NULL; + PyErr_Restore(PyExc_TypeError, message, nullptr); + return nullptr; } /** @@ -265,7 +265,7 @@ PyObject *_Dtool_Raise_BadArgumentsError() { */ PyObject *_Dtool_Return_None() { if (UNLIKELY(_PyErr_OCCURRED())) { - return NULL; + return nullptr; } #ifndef NDEBUG if (UNLIKELY(Notify::ptr()->has_assert_failed())) { @@ -282,7 +282,7 @@ PyObject *_Dtool_Return_None() { */ PyObject *Dtool_Return_Bool(bool value) { if (UNLIKELY(_PyErr_OCCURRED())) { - return NULL; + return nullptr; } #ifndef NDEBUG if (UNLIKELY(Notify::ptr()->has_assert_failed())) { @@ -301,7 +301,7 @@ PyObject *Dtool_Return_Bool(bool value) { */ PyObject *_Dtool_Return(PyObject *value) { if (UNLIKELY(_PyErr_OCCURRED())) { - return NULL; + return nullptr; } #ifndef NDEBUG if (UNLIKELY(Notify::ptr()->has_assert_failed())) { @@ -315,22 +315,22 @@ PyObject *_Dtool_Return(PyObject *value) { * Creates a Python 3.4-style enum type. Steals reference to 'names'. */ PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) { - static PyObject *enum_class = NULL; - static PyObject *enum_meta = NULL; - static PyObject *enum_create = NULL; - if (enum_meta == NULL) { + static PyObject *enum_class = nullptr; + static PyObject *enum_meta = nullptr; + static PyObject *enum_create = nullptr; + if (enum_meta == nullptr) { PyObject *enum_module = PyImport_ImportModule("enum"); - nassertr_always(enum_module != NULL, NULL); + nassertr_always(enum_module != nullptr, nullptr); enum_class = PyObject_GetAttrString(enum_module, "Enum"); enum_meta = PyObject_GetAttrString(enum_module, "EnumMeta"); enum_create = PyObject_GetAttrString(enum_meta, "_create_"); - nassertr(enum_meta != NULL, NULL); + nassertr(enum_meta != nullptr, nullptr); } PyObject *result = PyObject_CallFunction(enum_create, (char *)"OsN", enum_class, name, names); - nassertr(result != NULL, NULL); - if (module != NULL) { + nassertr(result != nullptr, nullptr); + if (module != nullptr) { PyObject *modstr = PyUnicode_FromString(module); PyObject_SetAttrString(result, "__module__", modstr); Py_DECREF(modstr); @@ -346,19 +346,19 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // caller will have to get the type index to pass to this function to begin // with. That code probably would have crashed by now if it was really NULL // for whatever reason. - nassertr(local_this_in != NULL, NULL); + nassertr(local_this_in != nullptr, nullptr); // IF the class is possibly a run time typed object if (type_index > 0) { // get best fit class... Dtool_PyTypedObject *target_class = Dtool_RuntimeTypeDtoolType(type_index); - if (target_class != NULL) { + if (target_class != nullptr) { // cast to the type... void *new_local_this = target_class->_Dtool_DowncastInterface(local_this_in, &known_class_type); - if (new_local_this != NULL) { + if (new_local_this != nullptr) { // ask class to allocate an instance.. - Dtool_PyInstDef *self = (Dtool_PyInstDef *) target_class->_PyType.tp_new(&target_class->_PyType, NULL, NULL); - if (self != NULL) { + Dtool_PyInstDef *self = (Dtool_PyInstDef *) target_class->_PyType.tp_new(&target_class->_PyType, nullptr, nullptr); + if (self != nullptr) { self->_ptr_to_object = new_local_this; self->_memory_rules = memory_rules; self->_is_const = is_const; @@ -372,8 +372,8 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // if we get this far .. just wrap the thing in the known type ?? better // than aborting...I guess.... - Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type._PyType.tp_new(&known_class_type._PyType, NULL, NULL); - if (self != NULL) { + Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type._PyType.tp_new(&known_class_type._PyType, nullptr, nullptr); + if (self != nullptr) { self->_ptr_to_object = local_this_in; self->_memory_rules = memory_rules; self->_is_const = is_const; @@ -386,7 +386,7 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // DTool_CreatePyInstance .. wrapper function to finalize the existance of a // general dtool py instance.. PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const) { - if (local_this == NULL) { + if (local_this == nullptr) { // This is actually a very common case, so let's allow this, but return // Py_None consistently. This eliminates code in the wrappers. Py_INCREF(Py_None); @@ -394,8 +394,8 @@ PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_class } Dtool_PyTypedObject *classdef = &in_classdef; - Dtool_PyInstDef *self = (Dtool_PyInstDef *) classdef->_PyType.tp_new(&classdef->_PyType, NULL, NULL); - if (self != NULL) { + Dtool_PyInstDef *self = (Dtool_PyInstDef *) classdef->_PyType.tp_new(&classdef->_PyType, nullptr, nullptr); + if (self != nullptr) { self->_ptr_to_object = local_this; self->_memory_rules = memory_rules; self->_is_const = is_const; @@ -420,7 +420,7 @@ int DTool_PyInit_Finalize(PyObject *self, void *local_this, Dtool_PyTypedObject // done at code generation time because of multiple generation passes in // interrogate.. void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { - for (; in->ml_name != NULL; in++) { + for (; in->ml_name != nullptr; in++) { if (themap.find(in->ml_name) == themap.end()) { themap[in->ml_name] = in; } @@ -492,7 +492,7 @@ LookupNamedClass(const string &name) { interrogatedb_cat.error() << "Attempt to use type " << name << " which has not yet been defined!\n"; - return NULL; + return nullptr; } else { return it->second; } @@ -506,7 +506,7 @@ LookupRuntimeTypedClass(TypeHandle handle) { if (it == runtime_type_map.end()) { interrogatedb_cat.error() << "Attempt to use type " << handle << " which has not yet been defined!\n"; - return NULL; + return nullptr; } else { return it->second; } @@ -523,7 +523,7 @@ Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type) { return di->second; } } - return NULL; + return nullptr; } #if PY_MAJOR_VERSION >= 3 @@ -544,7 +544,7 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { << "incompatible with Python " << version.substr(0, 3); string error = errs.str(); PyErr_SetString(PyExc_ImportError, error.c_str()); - return (PyObject *)NULL; + return nullptr; } // Initialize the types we define in py_panda. @@ -593,12 +593,12 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { #endif // Initialize the base class of everything. - Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(NULL); + Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(nullptr); } // the module level function inits.... MethodDefmap functions; - for (int xx = 0; defs[xx] != NULL; xx++) { + for (int xx = 0; defs[xx] != nullptr; xx++) { Dtool_Accum_MethDefs(defs[xx]->_methods, functions); } @@ -608,9 +608,9 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { for (mi = functions.begin(); mi != functions.end(); mi++, offset++) { newdef[offset] = *mi->second; } - newdef[offset].ml_doc = NULL; - newdef[offset].ml_name = NULL; - newdef[offset].ml_meth = NULL; + newdef[offset].ml_doc = nullptr; + newdef[offset].ml_name = nullptr; + newdef[offset].ml_meth = nullptr; newdef[offset].ml_flags = 0; #if PY_MAJOR_VERSION >= 3 @@ -620,7 +620,7 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { PyObject *module = Py_InitModule((char *)modulename, newdef); #endif - if (module == NULL) { + if (module == nullptr) { #if PY_MAJOR_VERSION >= 3 return Dtool_Raise_TypeError("PyModule_Create returned NULL"); #else @@ -640,21 +640,21 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { // Grab the __main__ module. PyObject *main_module = PyImport_ImportModule("__main__"); - if (main_module == NULL) { + if (main_module == nullptr) { interrogatedb_cat.warning() << "Unable to import __main__\n"; } // Extract the __file__ attribute, if present. Filename main_dir; PyObject *file_attr = PyObject_GetAttrString(main_module, "__file__"); - if (file_attr == NULL) { + if (file_attr == nullptr) { // Must be running in the interactive interpreter. Use the CWD. main_dir = ExecutionEnvironment::get_cwd(); } else { #if PY_MAJOR_VERSION >= 3 Py_ssize_t length; wchar_t *buffer = PyUnicode_AsWideCharString(file_attr, &length); - if (buffer != NULL) { + if (buffer != nullptr) { main_dir = Filename::from_os_specific_w(std::wstring(buffer, length)); main_dir.make_absolute(); main_dir = main_dir.get_dirname(); @@ -686,8 +686,8 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { // grab the "THIS" pointer from an object and use it Required to support // historical inheritance in the form of "is this instance of".. PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { - PyObject *from_in = NULL; - PyObject *to_in = NULL; + PyObject *from_in = nullptr; + PyObject *to_in = nullptr; if (PyArg_UnpackTuple(args, "Dtool_BorrowThisReference", 2, 2, &to_in, &from_in)) { if (DtoolInstance_Check(from_in) && DtoolInstance_Check(to_in)) { @@ -710,7 +710,7 @@ PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { return Dtool_Raise_TypeError("One of these does not appear to be DTOOL Instance ??"); } } - return (PyObject *) NULL; + return nullptr; } // We do expose a dictionay for dtool classes .. this should be removed at @@ -721,14 +721,14 @@ PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { PyObject *key; if (PyArg_ParseTuple(args, "OSO", &self, &key, &subject)) { PyObject *dict = ((PyTypeObject *)self)->tp_dict; - if (dict == NULL || !PyDict_Check(dict)) { + if (dict == nullptr || !PyDict_Check(dict)) { return Dtool_Raise_TypeError("No dictionary On Object"); } else { PyDict_SetItem(dict, key, subject); } } if (PyErr_Occurred()) { - return (PyObject *)NULL; + return nullptr; } Py_INCREF(Py_None); return Py_None; @@ -753,7 +753,7 @@ int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2) { // try this compare void *v1_this = DTOOL_Call_GetPointerThis(v1); void *v2_this = DTOOL_Call_GetPointerThis(v2); - if (v1_this != NULL && v2_this != NULL) { // both are our types... + if (v1_this != nullptr && v2_this != nullptr) { // both are our types... if (v1_this < v2_this) { return -1; } @@ -776,23 +776,23 @@ int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2) { int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2) { // First try compareTo function.. PyObject * func = PyObject_GetAttrString(v1, "compare_to"); - if (func == NULL) { + if (func == nullptr) { PyErr_Clear(); } else { #if PY_VERSION_HEX >= 0x03060000 PyObject *res = _PyObject_FastCall(func, &v2, 1); #else - PyObject *res = NULL; + PyObject *res = nullptr; PyObject *args = PyTuple_Pack(1, v2); - if (args != NULL) { - res = PyObject_Call(func, args, NULL); + if (args != nullptr) { + res = PyObject_Call(func, args, nullptr); Py_DECREF(args); } #endif Py_DECREF(func); PyErr_Clear(); // just in case the function threw an error // only use if the function returns an INT... hmm - if (res != NULL) { + if (res != nullptr) { if (PyLong_Check(res)) { long answer = PyLong_AsLong(res); Py_DECREF(res); @@ -861,8 +861,8 @@ PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op) { */ PyObject *copy_from_make_copy(PyObject *self, PyObject *noargs) { PyObject *callable = PyObject_GetAttrString(self, "make_copy"); - if (callable == NULL) { - return NULL; + if (callable == nullptr) { + return nullptr; } PyObject *result = _PyObject_CallNoArg(callable); Py_DECREF(callable); @@ -880,7 +880,7 @@ PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { PyObject *result = _PyObject_FastCall(callable, &self, 1); #else PyObject *args = PyTuple_Pack(1, self); - PyObject *result = PyObject_Call(callable, args, NULL); + PyObject *result = PyObject_Call(callable, args, nullptr); Py_DECREF(args); #endif return result; @@ -893,8 +893,8 @@ PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { */ PyObject *map_deepcopy_to_copy(PyObject *self, PyObject *args) { PyObject *callable = PyObject_GetAttrString(self, "__copy__"); - if (callable == NULL) { - return NULL; + if (callable == nullptr) { + return nullptr; } PyObject *result = _PyObject_CallNoArg(callable); Py_DECREF(callable); diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index f4edc8f4ad..ffa6de94c8 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -247,7 +247,7 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); * Wrapper around Python 3.4's enum library, which does not have a C API. */ EXPCL_INTERROGATEDB PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, - const char *module = NULL); + const char *module = nullptr); /** @@ -393,7 +393,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value); ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring *value); ALWAYS_INLINE PyObject *Dtool_WrapValue(char value); ALWAYS_INLINE PyObject *Dtool_WrapValue(wchar_t value); -ALWAYS_INLINE PyObject *Dtool_WrapValue(nullptr_t); +ALWAYS_INLINE PyObject *Dtool_WrapValue(std::nullptr_t); ALWAYS_INLINE PyObject *Dtool_WrapValue(PyObject *value); ALWAYS_INLINE PyObject *Dtool_WrapValue(const vector_uchar &value); diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index 4d56eee41a..f03d727bd3 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -517,7 +517,7 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) { _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Keys_Type, "MappingView"); } - PyObject_INIT(keys, &Dtool_MappingWrapper_Keys_Type); + (void)PyObject_INIT(keys, &Dtool_MappingWrapper_Keys_Type); Py_XINCREF(wrap->_base._self); keys->_base._self = wrap->_base._self; keys->_base._name = wrap->_base._name; @@ -552,7 +552,7 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) { _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Values_Type, "ValuesView"); } - PyObject_INIT(values, &Dtool_MappingWrapper_Values_Type); + (void)PyObject_INIT(values, &Dtool_MappingWrapper_Values_Type); Py_XINCREF(wrap->_base._self); values->_base._self = wrap->_base._self; values->_base._name = wrap->_base._name; @@ -588,7 +588,7 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) { _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Items_Type, "MappingView"); } - PyObject_INIT(items, &Dtool_MappingWrapper_Items_Type); + (void)PyObject_INIT(items, &Dtool_MappingWrapper_Items_Type); Py_XINCREF(wrap->_base._self); items->_base._self = wrap->_base._self; items->_base._name = wrap->_base._name; @@ -797,15 +797,15 @@ static PyObject *Dtool_MutableMappingWrapper_update(PyObject *self, PyObject *ar */ static PySequenceMethods Dtool_SequenceWrapper_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_SequenceWrapper_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_SequenceWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; static PyMethodDef Dtool_SequenceWrapper_Methods[] = { @@ -820,47 +820,47 @@ PyTypeObject Dtool_SequenceWrapper_Type = { sizeof(Dtool_SequenceWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_SequenceWrapper_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_SequenceWrapper_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_SequenceWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -868,15 +868,15 @@ PyTypeObject Dtool_SequenceWrapper_Type = { */ static PySequenceMethods Dtool_MutableSequenceWrapper_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_SequenceWrapper_getitem, - 0, // sq_slice + nullptr, // sq_slice Dtool_MutableSequenceWrapper_setitem, - 0, // sq_ass_slice + nullptr, // sq_ass_slice Dtool_SequenceWrapper_contains, Dtool_MutableSequenceWrapper_extend, - 0, // sq_inplace_repeat + nullptr, // sq_inplace_repeat }; static PyMethodDef Dtool_MutableSequenceWrapper_Methods[] = { @@ -897,47 +897,47 @@ PyTypeObject Dtool_MutableSequenceWrapper_Type = { sizeof(Dtool_MutableSequenceWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_SequenceWrapper_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MutableSequenceWrapper_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_MutableSequenceWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -945,21 +945,21 @@ PyTypeObject Dtool_MutableSequenceWrapper_Type = { */ static PySequenceMethods Dtool_MappingWrapper_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat - 0, // sq_item - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_concat + nullptr, // sq_repeat + nullptr, // sq_item + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; static PyMappingMethods Dtool_MappingWrapper_MappingMethods = { Dtool_SequenceWrapper_length, Dtool_MappingWrapper_getitem, - 0, // mp_ass_subscript + nullptr, // mp_ass_subscript }; static PyMethodDef Dtool_MappingWrapper_Methods[] = { @@ -976,47 +976,47 @@ PyTypeObject Dtool_MappingWrapper_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_WrapperBase_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_SequenceMethods, &Dtool_MappingWrapper_MappingMethods, - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset Dtool_MappingWrapper_iter, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_MappingWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1047,47 +1047,47 @@ PyTypeObject Dtool_MutableMappingWrapper_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_WrapperBase_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_SequenceMethods, &Dtool_MutableMappingWrapper_MappingMethods, - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset Dtool_MappingWrapper_iter, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_MutableMappingWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1131,15 +1131,15 @@ static PyObject *Dtool_MappingWrapper_Items_getitem(PyObject *self, Py_ssize_t i static PySequenceMethods Dtool_MappingWrapper_Items_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_MappingWrapper_Items_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; PyTypeObject Dtool_MappingWrapper_Items_Type = { @@ -1148,47 +1148,47 @@ PyTypeObject Dtool_MappingWrapper_Items_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_MappingWrapper_Items_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_Items_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1211,15 +1211,15 @@ static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) { static PySequenceMethods Dtool_MappingWrapper_Keys_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_MappingWrapper_Items_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; PyTypeObject Dtool_MappingWrapper_Keys_Type = { @@ -1228,47 +1228,47 @@ PyTypeObject Dtool_MappingWrapper_Keys_Type = { sizeof(Dtool_SequenceWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_MappingWrapper_Keys_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_SequenceWrapper_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1305,15 +1305,15 @@ static PyObject *Dtool_MappingWrapper_Values_getitem(PyObject *self, Py_ssize_t static PySequenceMethods Dtool_MappingWrapper_Values_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_MappingWrapper_Values_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; PyTypeObject Dtool_MappingWrapper_Values_Type = { @@ -1322,47 +1322,47 @@ PyTypeObject Dtool_MappingWrapper_Values_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_MappingWrapper_Values_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_Values_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1381,47 +1381,47 @@ PyTypeObject Dtool_GeneratorWrapper_Type = { sizeof(Dtool_GeneratorWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare - 0, // tp_repr - 0, // tp_as_number - 0, // tp_as_sequence - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + nullptr, // tp_repr + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PyObject_SelfIter, Dtool_GeneratorWrapper_iternext, - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1498,47 +1498,47 @@ PyTypeObject Dtool_StaticProperty_Type = { sizeof(PyGetSetDescrObject), 0, // tp_itemsize (destructor)Dtool_StaticProperty_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_reserved + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_reserved (reprfunc)Dtool_StaticProperty_repr, - 0, // tp_as_number - 0, // tp_as_sequence - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, - 0, // tp_setattro - 0, // tp_as_buffer + nullptr, // tp_setattro + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT, - 0, // tp_doc + nullptr, // tp_doc Dtool_StaticProperty_traverse, - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict + nullptr, // tp_iter + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict (descrgetfunc)Dtool_StaticProperty_get, (descrsetfunc)Dtool_StaticProperty_set, 0, // tp_dictoffset - 0, // tp_init - 0, // tp_alloc - 0, // tp_new - 0, // tp_del - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_init + nullptr, // tp_alloc + nullptr, // tp_new + nullptr, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1557,7 +1557,7 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name _register_collection((PyTypeObject *)&Dtool_MutableSequenceWrapper_Type, "Sequence"); } - PyObject_INIT(wrap, &Dtool_SequenceWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_SequenceWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1582,7 +1582,7 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co _register_collection((PyTypeObject *)&Dtool_MutableSequenceWrapper_Type, "MutableSequence"); } - PyObject_INIT(wrap, &Dtool_MutableSequenceWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_MutableSequenceWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1609,7 +1609,7 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name) _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Type, "Mapping"); } - PyObject_INIT(wrap, &Dtool_MappingWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_MappingWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1636,7 +1636,7 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char _register_collection((PyTypeObject *)&Dtool_MutableMappingWrapper_Type, "MutableMapping"); } - PyObject_INIT(wrap, &Dtool_MutableMappingWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_MutableMappingWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; diff --git a/dtool/src/parser-inc/algorithm b/dtool/src/parser-inc/algorithm index 6f409742c2..751a8ec2cb 100644 --- a/dtool/src/parser-inc/algorithm +++ b/dtool/src/parser-inc/algorithm @@ -20,5 +20,12 @@ #ifndef ALGORITHM_H #define ALGORITHM_H +namespace std { + template + constexpr const T &min(const T &a, const T &b); + template + constexpr const T &max(const T &a, const T &b); +} + #endif diff --git a/dtool/src/parser-inc/atomic b/dtool/src/parser-inc/atomic new file mode 100644 index 0000000000..a7e174937b --- /dev/null +++ b/dtool/src/parser-inc/atomic @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace std { + typedef enum memory_order { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst + } memory_order; + + template struct atomic; + template struct atomic; + + struct atomic_flag; +} diff --git a/dtool/src/parser-inc/clocale b/dtool/src/parser-inc/clocale new file mode 100644 index 0000000000..a889a57372 --- /dev/null +++ b/dtool/src/parser-inc/clocale @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstddef b/dtool/src/parser-inc/cstddef new file mode 100644 index 0000000000..78ed8af5a5 --- /dev/null +++ b/dtool/src/parser-inc/cstddef @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace std { + enum class byte : unsigned char {}; +} diff --git a/dtool/src/parser-inc/cstdint b/dtool/src/parser-inc/cstdint new file mode 100644 index 0000000000..9a6118bd85 --- /dev/null +++ b/dtool/src/parser-inc/cstdint @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstdio b/dtool/src/parser-inc/cstdio new file mode 100644 index 0000000000..53c5fdf179 --- /dev/null +++ b/dtool/src/parser-inc/cstdio @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstring b/dtool/src/parser-inc/cstring new file mode 100644 index 0000000000..3b2f590027 --- /dev/null +++ b/dtool/src/parser-inc/cstring @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/ctime b/dtool/src/parser-inc/ctime new file mode 100644 index 0000000000..91fd18715f --- /dev/null +++ b/dtool/src/parser-inc/ctime @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cwchar b/dtool/src/parser-inc/cwchar new file mode 100644 index 0000000000..598c31d9a3 --- /dev/null +++ b/dtool/src/parser-inc/cwchar @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace std { + struct mbstate_t; + typedef int wint_t; +} diff --git a/dtool/src/parser-inc/exception b/dtool/src/parser-inc/exception new file mode 100644 index 0000000000..d48d80620e --- /dev/null +++ b/dtool/src/parser-inc/exception @@ -0,0 +1,10 @@ +#pragma once + +namespace std { + class exception; + class bad_exception; + class nested_exception; + + typedef void (*unexpected_handler)(); + typedef void (*terminate_handler)(); +} diff --git a/dtool/src/parser-inc/initializer_list b/dtool/src/parser-inc/initializer_list index 57a3f7f6c1..289b0e4bf7 100644 --- a/dtool/src/parser-inc/initializer_list +++ b/dtool/src/parser-inc/initializer_list @@ -32,3 +32,5 @@ namespace std { typedef const E* const_iterator; }; } + +#endif diff --git a/dtool/src/parser-inc/iomanip b/dtool/src/parser-inc/iomanip new file mode 100644 index 0000000000..cc19f56b38 --- /dev/null +++ b/dtool/src/parser-inc/iomanip @@ -0,0 +1,6 @@ +#pragma once + +namespace std { + template void setfill(CharT c); + void setw(int); +} diff --git a/dtool/src/parser-inc/ios b/dtool/src/parser-inc/ios new file mode 100644 index 0000000000..4ea9143c4a --- /dev/null +++ b/dtool/src/parser-inc/ios @@ -0,0 +1,106 @@ +#pragma once + +#include + +// We actually want to wrap streampos as streamoff. +#define streampos streamoff + +namespace std { +#ifdef _WIN64 + typedef long long streamoff; + typedef long long streamsize; +#elif defined(_WIN32) + typedef long streamoff; + typedef int streamsize; +#else + typedef long long streamoff; + typedef ptrdiff_t streamsize; +#endif + + // We need to expose one method in each class to force it to publish. + // But we'd like to expose some of these methods anyway, so no + // problem. + class ios_base { + public: + class failure; + class Init; + enum event { + erase_event, + imbue_event, + copyfmt_event, + }; + + ios_base(const ios_base&) = delete; + ios_base &operator = (const ios_base&) = delete; + + __published: + enum seekdir { + beg = 0, + cur = 1, + end = 2, + }; + enum openmode { + }; + // Don't define these lest interrogate get tempted to actually + // substitute in the values, which are implementation-defined. + static const openmode app; + static const openmode binary; + static const openmode in; + static const openmode out; + static const openmode trunc; + protected: + // Force this to be a non-trivial type. + ios_base() {}; + }; + + template > + class basic_ios : public ios_base { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + __published: + typedef long fmtflags; + + bool good() const; + bool eof() const; + bool fail() const; + bool bad() const; + void clear(); + + protected: + basic_ios(); + }; + + ios_base &boolalpha(ios_base &str); + ios_base &noboolalpha(ios_base &str); + ios_base &showbase(ios_base &str); + ios_base &noshowbase(ios_base &str); + ios_base &showpoint(ios_base &str); + ios_base &noshowpoint(ios_base &str); + ios_base &showpos(ios_base &str); + ios_base &noshowpos(ios_base &str); + ios_base &skipws(ios_base &str); + ios_base &noskipws(ios_base &str); + ios_base &uppercase(ios_base &str); + ios_base &nouppercase(ios_base &str); + ios_base &unitbuf(ios_base &str); + ios_base &nounitbuf(ios_base &str); + ios_base &internal(ios_base &str); + ios_base &left(ios_base &str); + ios_base &right(ios_base &str); + ios_base &dec(ios_base &str); + ios_base &hex(ios_base &str); + ios_base &oct(ios_base &str); + ios_base &fixed(ios_base &str); + ios_base &scientific(ios_base &str); + ios_base &hexfloat(ios_base &str); + ios_base &defaultfloat(ios_base &str); + + enum class io_errc { + stream = 1 + }; +} diff --git a/dtool/src/parser-inc/iosfwd b/dtool/src/parser-inc/iosfwd new file mode 100644 index 0000000000..abf62821ea --- /dev/null +++ b/dtool/src/parser-inc/iosfwd @@ -0,0 +1,77 @@ +#pragma once + +#include +#include +#include + +namespace std { + template class allocator; + + template > class basic_ios; + template > class basic_istream; + template > class basic_ostream; + template > class basic_iostream; + template, class Allocator = allocator > class basic_stringbuf; + + template, class Allocator = allocator > class basic_istringstream; + template, class Allocator = allocator > class basic_ostringstream; + template, class Allocator = allocator > class basic_stringstream; + + template > class basic_filebuf; + template > class basic_ifstream; + template > class basic_ofstream; + template > class basic_fstream; + + template, class Allocator = allocator > class basic_syncbuf; + template, class Allocator = allocator > class basic_osyncstream; + + template > class istreambuf_iterator; + template > class ostreambuf_iterator; + + typedef basic_ios ios; + typedef basic_ios wios; + + //typedef basic_istream istream; + //typedef basic_ostream ostream; + //typedef basic_iostream iostream; + class istream; + class ostream; + class iostream; + + typedef basic_stringbuf stringbuf; + typedef basic_istringstream istringstream; + typedef basic_ostringstream ostringstream; + typedef basic_stringstream stringstream; + + typedef basic_filebuf filebuf; + //typedef basic_ifstream ifstream; + //typedef basic_ofstream ofstream; + //typedef basic_fstream fstream; + class ifstream; + class ofstream; + class fstream; + + typedef basic_syncbuf syncbuf; + typedef basic_osyncstream osyncstream; + + typedef basic_istream wistream; + typedef basic_ostream wostream; + typedef basic_iostream wiostream; + + typedef basic_stringbuf wstringbuf; + typedef basic_istringstream wistringstream; + typedef basic_ostringstream wostringstream; + typedef basic_stringstream wstringstream; + + typedef basic_filebuf wfilebuf; + typedef basic_ifstream wifstream; + typedef basic_ofstream wofstream; + typedef basic_fstream wfstream; + + typedef basic_syncbuf wsyncbuf; + typedef basic_osyncstream wosyncstream; + + template class fpos; + typedef fpos streampos; + typedef fpos wstreampos; +} diff --git a/dtool/src/parser-inc/iostream b/dtool/src/parser-inc/iostream index 170d1d03f9..8bfe91d0aa 100644 --- a/dtool/src/parser-inc/iostream +++ b/dtool/src/parser-inc/iostream @@ -21,122 +21,69 @@ #define IOSTREAM_H #include - -#ifdef _WIN64 -typedef long long streamoff; -typedef long long streamsize; -#elif defined(_WIN32) -typedef long streamoff; -typedef int streamsize; -#else -typedef long long streamoff; -typedef ptrdiff_t streamsize; -#endif +#include +#include +#include // We don't care (much) about the actual definition of the various // iostream classes, but we do need to know the classnames that are // available. -// We need to expose one method in each class to force it to publish. -// But we'd like to expose some of these methods anyway, so no -// problem. -class ios_base { -__published: - enum seekdir { - beg = 0, - cur = 1, - end = 2, +namespace std { + class ostream : virtual public ios { + __published: + ostream(const ostream&) = delete; + + void put(char c); + void flush(); + streampos tellp(); + void seekp(streampos pos); + void seekp(streamoff off, ios_base::seekdir dir); + + protected: + ostream(ostream &&); }; - enum openmode { + class istream : virtual public ios { + __published: + istream(const istream&) = delete; + + int get(); + streampos tellg(); + void seekg(streampos pos); + void seekg(streamoff off, ios_base::seekdir dir); + + protected: + istream(istream &&); }; - // Don't define these lest interrogate get tempted to actually - // substitute in the values, which are implementation-defined. - static const openmode app; - static const openmode binary; - static const openmode in; - static const openmode out; - static const openmode trunc; -protected: - // Force this to be a non-trivial type. - ios_base() {}; -private: - ios_base(const ios_base &); -}; -class ios : public ios_base { -__published: - typedef long fmtflags; + class iostream : public istream, public ostream { + __published: + iostream(const iostream&) = delete; - bool good() const; - bool eof() const; - bool fail() const; - bool bad() const; - void clear(); + void flush(); -protected: - ios(); -}; + protected: + iostream(iostream &&); + }; -// We actually want to wrap streampos as streamoff. -#define streampos streamoff + class ofstream : public ostream { + __published: + ofstream(); + void close(); + }; + class ifstream : public istream { + __published: + ifstream(); + void close(); + }; + class fstream : public iostream { + __published: + fstream(); + void close(); + }; -class ostream : virtual public ios { -__published: - ostream(const ostream&) = delete; - - void put(char c); - void flush(); - streampos tellp(); - void seekp(streampos pos); - void seekp(streamoff off, ios_base::seekdir dir); - -protected: - ostream(ostream &&); -}; -class istream : virtual public ios { -__published: - istream(const istream&) = delete; - - int get(); - streampos tellg(); - void seekg(streampos pos); - void seekg(streamoff off, ios_base::seekdir dir); - -protected: - istream(istream &&); -}; -class iostream : public istream, public ostream { -__published: - iostream(const iostream&) = delete; - - void flush(); - -protected: - iostream(iostream &&); -}; - -class ofstream : public ostream { -__published: - ofstream(); - void close(); -}; -class ifstream : public istream { -__published: - ifstream(); - void close(); -}; -class fstream : public iostream { -__published: - fstream(); - void close(); -}; - -class ostringstream : public ostream {}; -class istringstream : public istream {}; -class stringstream : public iostream {}; -class streambuf {}; - -extern istream cin; -extern ostream cout; -extern ostream cerr; + extern istream cin; + extern ostream cout; + extern ostream cerr; +} #endif diff --git a/dtool/src/parser-inc/mutex b/dtool/src/parser-inc/mutex new file mode 100644 index 0000000000..b05214e512 --- /dev/null +++ b/dtool/src/parser-inc/mutex @@ -0,0 +1,28 @@ +#pragma once + +namespace std { + class mutex; + class recursive_mutex; + class timed_mutex; + class recursive_timed_mutex; + + struct defer_lock_t { + explicit defer_lock_t() = default; + }; + inline constexpr defer_lock_t defer_lock {}; + + struct try_to_lock_t { + explicit try_to_lock_t() = default; + }; + inline constexpr try_to_lock_t try_to_lock {}; + + struct adopt_lock_t { + explicit adopt_lock_t() = default; + }; + inline constexpr adopt_lock_t adopt_lock {}; + + template class lock_guard; + template class unique_lock; + + struct once_flag; +} diff --git a/dtool/src/parser-inc/ostream b/dtool/src/parser-inc/ostream new file mode 100644 index 0000000000..fb7f7ea51e --- /dev/null +++ b/dtool/src/parser-inc/ostream @@ -0,0 +1,12 @@ +#pragma once + +namespace std { + template + std::basic_ostream &ends(std::basic_ostream &os); + + template + std::basic_ostream &flush(std::basic_ostream &os); + + template + std::basic_ostream &endl(std::basic_ostream &os); +} diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index f971d7e1f2..873ba9425d 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -46,7 +46,9 @@ struct timeval; #else #define NULL ((void *)0) #endif -typedef decltype(nullptr) nullptr_t; +namespace std { + typedef decltype(nullptr) nullptr_t; +} // One day, we might extend interrogate to be able to parse this, // but we currently don't need it. diff --git a/dtool/src/parser-inc/streambuf b/dtool/src/parser-inc/streambuf new file mode 100644 index 0000000000..b46f0faef3 --- /dev/null +++ b/dtool/src/parser-inc/streambuf @@ -0,0 +1,14 @@ +#pragma once + +namespace std { + template class char_traits; + template<> class char_traits; + template<> class char_traits; + template<> class char_traits; + template<> class char_traits; + + template > class basic_streambuf; + + typedef basic_streambuf streambuf; + typedef basic_streambuf wstreambuf; +} diff --git a/dtool/src/parser-inc/string b/dtool/src/parser-inc/string index 4ca8f3fa12..841e6fd7c6 100644 --- a/dtool/src/parser-inc/string +++ b/dtool/src/parser-inc/string @@ -21,10 +21,35 @@ #define STRING_H #include +#include +#include namespace std { - template - class char_traits; + template struct char_traits; + + template<> struct char_traits { + using char_type = char; + using int_type = int; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = char16_t; + using int_type = uint_least16_t; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = char32_t; + using int_type = uint_least32_t; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = wchar_t; + using int_type = wint_t; + using state_type = mbstate_t; + }; template class basic_string { diff --git a/dtool/src/parser-inc/utility b/dtool/src/parser-inc/utility new file mode 100644 index 0000000000..119814b5c3 --- /dev/null +++ b/dtool/src/parser-inc/utility @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace std { + template void swap(T &a, T &b); + template void swap(T (&a)[N], T (&b)[N]); + + template struct remove_reference {typedef T type;}; + template struct remove_reference {typedef T type;}; + template struct remove_reference {typedef T type;}; + + template constexpr remove_reference::type &&move(T &&) noexcept; + + template struct pair; +} diff --git a/dtool/src/parser-inc/vector b/dtool/src/parser-inc/vector index fb27a78c0d..e83a5ff911 100644 --- a/dtool/src/parser-inc/vector +++ b/dtool/src/parser-inc/vector @@ -22,6 +22,8 @@ #include +inline namespace std { + template class vector { public: @@ -40,4 +42,6 @@ public: typedef size_t size_type; }; +} + #endif diff --git a/dtool/src/prc/androidLogStream.cxx b/dtool/src/prc/androidLogStream.cxx index 6427b9163a..2dd32f7c5b 100644 --- a/dtool/src/prc/androidLogStream.cxx +++ b/dtool/src/prc/androidLogStream.cxx @@ -124,9 +124,9 @@ AndroidLogStream:: */ ostream &AndroidLogStream:: out(NotifySeverity severity) { - static AndroidLogStream* streams[NS_fatal + 1] = {NULL}; + static AndroidLogStream* streams[NS_fatal + 1] = {nullptr}; - if (streams[severity] == NULL) { + if (streams[severity] == nullptr) { int priority = ANDROID_LOG_UNKNOWN; if (severity != NS_unspecified) { priority = ((int)severity) + 1; diff --git a/dtool/src/prc/configDeclaration.h b/dtool/src/prc/configDeclaration.h index 9a74acd8d2..1e6c50ee12 100644 --- a/dtool/src/prc/configDeclaration.h +++ b/dtool/src/prc/configDeclaration.h @@ -111,7 +111,7 @@ private: short _flags; }; - typedef vector Words; + typedef std::vector Words; Words _words; bool _got_words; diff --git a/dtool/src/prc/configPage.cxx b/dtool/src/prc/configPage.cxx index 981caadf87..ce515529c2 100644 --- a/dtool/src/prc/configPage.cxx +++ b/dtool/src/prc/configPage.cxx @@ -25,8 +25,8 @@ #include "openssl/evp.h" #endif -ConfigPage *ConfigPage::_default_page = NULL; -ConfigPage *ConfigPage::_local_page = NULL; +ConfigPage *ConfigPage::_default_page = nullptr; +ConfigPage *ConfigPage::_local_page = nullptr; /** * The constructor is private because a ConfigPage should be constructed via @@ -58,7 +58,7 @@ ConfigPage:: */ ConfigPage *ConfigPage:: get_default_page() { - if (_default_page == (ConfigPage *)NULL) { + if (_default_page == nullptr) { _default_page = new ConfigPage("default", false, 0); } return _default_page; @@ -71,7 +71,7 @@ get_default_page() { */ ConfigPage *ConfigPage:: get_local_page() { - if (_local_page == (ConfigPage *)NULL) { + if (_local_page == nullptr) { _local_page = new ConfigPage("local", false, 0); } return _local_page; @@ -142,7 +142,7 @@ read_prc(istream &in) { // Look for the first line in the buffer.. char *newline = (char *)memchr((void *)buffer, '\n', count); - if (newline == (char *)NULL) { + if (newline == nullptr) { // The buffer was one long line. Huh. prev_line += string(buffer, count); @@ -154,7 +154,7 @@ read_prc(istream &in) { // Now look for the next line, etc. char *start = newline + 1; newline = (char *)memchr((void *)start, '\n', buffer_end - start); - while (newline != (char *)NULL) { + while (newline != nullptr) { length = newline - start; read_prc_line(string(start, length + 1)); start = newline + 1; @@ -189,7 +189,7 @@ read_prc(istream &in) { int num_keys = pkr->get_num_keys(); for (int i = 1; i < num_keys && _trust_level == 0; i++) { EVP_PKEY *pkey = pkr->get_key(i); - if (pkey != (EVP_PKEY *)NULL) { + if (pkey != nullptr) { int verify_result = EVP_VerifyFinal((EVP_MD_CTX *)_md_ctx, (unsigned char *)_signature.data(), @@ -283,7 +283,7 @@ get_num_declarations() const { */ const ConfigDeclaration *ConfigPage:: get_declaration(size_t n) const { - nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _declarations.size(), nullptr); return _declarations[n]; } @@ -294,7 +294,7 @@ get_declaration(size_t n) const { */ ConfigDeclaration *ConfigPage:: modify_declaration(size_t n) { - nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _declarations.size(), nullptr); return _declarations[n]; } diff --git a/dtool/src/prc/configPage.h b/dtool/src/prc/configPage.h index 72659fe096..e6cdb9ed0d 100644 --- a/dtool/src/prc/configPage.h +++ b/dtool/src/prc/configPage.h @@ -92,7 +92,7 @@ private: int _next_decl_seq; int _trust_level; - typedef vector Declarations; + typedef std::vector Declarations; Declarations _declarations; string _signature; diff --git a/dtool/src/prc/configPageManager.I b/dtool/src/prc/configPageManager.I index 16dbeb3e6c..cd95cce50f 100644 --- a/dtool/src/prc/configPageManager.I +++ b/dtool/src/prc/configPageManager.I @@ -123,7 +123,7 @@ get_num_implicit_pages() const { INLINE ConfigPage *ConfigPageManager:: get_implicit_page(size_t n) const { check_sort_pages(); - nassertr(n < _implicit_pages.size(), (ConfigPage *)NULL); + nassertr(n < _implicit_pages.size(), nullptr); return _implicit_pages[n]; } @@ -144,7 +144,7 @@ get_num_explicit_pages() const { INLINE ConfigPage *ConfigPageManager:: get_explicit_page(size_t n) const { check_sort_pages(); - nassertr(n < _explicit_pages.size(), (ConfigPage *)NULL); + nassertr(n < _explicit_pages.size(), nullptr); return _explicit_pages[n]; } diff --git a/dtool/src/prc/configPageManager.cxx b/dtool/src/prc/configPageManager.cxx index f7868aa394..8065ac3261 100644 --- a/dtool/src/prc/configPageManager.cxx +++ b/dtool/src/prc/configPageManager.cxx @@ -37,7 +37,7 @@ #include #include -ConfigPageManager *ConfigPageManager::_global_ptr = NULL; +ConfigPageManager *ConfigPageManager::_global_ptr = nullptr; /** * The constructor is private (actually, just protected, but only to avoid a @@ -500,7 +500,7 @@ write(ostream &out) const { */ ConfigPageManager *ConfigPageManager:: get_global_ptr() { - if (_global_ptr == (ConfigPageManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ConfigPageManager; } return _global_ptr; diff --git a/dtool/src/prc/configPageManager.h b/dtool/src/prc/configPageManager.h index 1ad8f6c3bd..dd6acc3f99 100644 --- a/dtool/src/prc/configPageManager.h +++ b/dtool/src/prc/configPageManager.h @@ -76,7 +76,7 @@ private: void config_initialized(); - typedef vector Pages; + typedef std::vector Pages; Pages _implicit_pages; Pages _explicit_pages; bool _pages_sorted; @@ -87,7 +87,7 @@ private: DSearchPath _search_path; - typedef vector Globs; + typedef std::vector Globs; Globs _prc_patterns; Globs _prc_encrypted_patterns; Globs _prc_executable_patterns; @@ -105,7 +105,7 @@ private: int _file_flags; Filename _filename; }; - typedef vector ConfigFiles; + typedef std::vector ConfigFiles; static ConfigPageManager *_global_ptr; }; diff --git a/dtool/src/prc/configVariable.I b/dtool/src/prc/configVariable.I index b46bc63529..92842ab0dd 100644 --- a/dtool/src/prc/configVariable.I +++ b/dtool/src/prc/configVariable.I @@ -57,7 +57,7 @@ INLINE ConfigVariable:: */ INLINE const ConfigDeclaration *ConfigVariable:: get_default_value() const { - nassertr(is_constructed(), (ConfigDeclaration *)NULL); + nassertr(is_constructed(), nullptr); return _core->get_default_value(); } @@ -273,7 +273,7 @@ set_double_word(size_t n, double value) { INLINE bool ConfigVariable:: is_constructed() const { #ifndef NDEBUG - if (_core == (ConfigVariableCore *)NULL) { + if (_core == nullptr) { report_unconstructed(); return false; } diff --git a/dtool/src/prc/configVariableBase.I b/dtool/src/prc/configVariableBase.I index 09db1c4088..29bf58f72a 100644 --- a/dtool/src/prc/configVariableBase.I +++ b/dtool/src/prc/configVariableBase.I @@ -37,7 +37,7 @@ INLINE ConfigVariableBase:: */ INLINE const string &ConfigVariableBase:: get_name() const { - nassertr(_core != (ConfigVariableCore *)NULL, *new string()); + nassertr(_core != nullptr, *new string()); return _core->get_name(); } @@ -47,7 +47,7 @@ get_name() const { */ INLINE ConfigVariableBase::ValueType ConfigVariableBase:: get_value_type() const { - nassertr(_core != (ConfigVariableCore *)NULL, VT_undefined); + nassertr(_core != nullptr, VT_undefined); return _core->get_value_type(); } @@ -56,7 +56,7 @@ get_value_type() const { */ INLINE const string &ConfigVariableBase:: get_description() const { - nassertr(_core != (ConfigVariableCore *)NULL, *new string()); + nassertr(_core != nullptr, *new string()); return _core->get_description(); } @@ -68,7 +68,7 @@ get_description() const { */ INLINE int ConfigVariableBase:: get_flags() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_flags(); } @@ -83,7 +83,7 @@ get_flags() const { */ INLINE bool ConfigVariableBase:: is_closed() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->is_closed(); } @@ -99,7 +99,7 @@ is_closed() const { */ INLINE int ConfigVariableBase:: get_trust_level() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_trust_level(); } @@ -110,7 +110,7 @@ get_trust_level() const { */ INLINE bool ConfigVariableBase:: is_dynamic() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->is_dynamic(); } @@ -123,7 +123,7 @@ is_dynamic() const { */ INLINE bool ConfigVariableBase:: clear_local_value() { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->clear_local_value(); } @@ -133,7 +133,7 @@ clear_local_value() { */ INLINE bool ConfigVariableBase:: has_local_value() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->has_local_value(); } @@ -143,7 +143,7 @@ has_local_value() const { */ INLINE bool ConfigVariableBase:: has_value() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->has_value(); } @@ -152,7 +152,7 @@ has_value() const { */ INLINE void ConfigVariableBase:: output(ostream &out) const { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); _core->output(out); } @@ -161,7 +161,7 @@ output(ostream &out) const { */ INLINE void ConfigVariableBase:: write(ostream &out) const { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); _core->write(out); } diff --git a/dtool/src/prc/configVariableBase.cxx b/dtool/src/prc/configVariableBase.cxx index 52b113b79a..55643704b7 100644 --- a/dtool/src/prc/configVariableBase.cxx +++ b/dtool/src/prc/configVariableBase.cxx @@ -55,7 +55,7 @@ ConfigVariableBase(const string &name, void ConfigVariableBase:: record_unconstructed() const { #ifndef NDEBUG - if (_unconstructed == (Unconstructed *)NULL) { + if (_unconstructed == nullptr) { _unconstructed = new Unconstructed; } _unconstructed->insert(this); @@ -69,7 +69,7 @@ record_unconstructed() const { bool ConfigVariableBase:: was_unconstructed() const { #ifndef NDEBUG - if (_unconstructed != (Unconstructed *)NULL) { + if (_unconstructed != nullptr) { Unconstructed::const_iterator ui = _unconstructed->find(this); if (ui != _unconstructed->end()) { return true; diff --git a/dtool/src/prc/configVariableBool.I b/dtool/src/prc/configVariableBool.I index 7eba0820d0..25c9e833f1 100644 --- a/dtool/src/prc/configVariableBool.I +++ b/dtool/src/prc/configVariableBool.I @@ -115,7 +115,7 @@ get_value() const { INLINE bool ConfigVariableBool:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_bool_word(0); } return false; diff --git a/dtool/src/prc/configVariableCore.I b/dtool/src/prc/configVariableCore.I index 057beb0449..95f8829a2a 100644 --- a/dtool/src/prc/configVariableCore.I +++ b/dtool/src/prc/configVariableCore.I @@ -118,7 +118,7 @@ set_used() { */ INLINE bool ConfigVariableCore:: has_local_value() const { - return _local_value != (ConfigDeclaration *)NULL; + return _local_value != nullptr; } /** @@ -141,7 +141,7 @@ get_num_references() const { INLINE const ConfigDeclaration *ConfigVariableCore:: get_reference(size_t n) const { check_sort_declarations(); - nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _declarations.size(), nullptr); return _declarations[n]; } @@ -167,7 +167,7 @@ get_num_trusted_references() const { INLINE const ConfigDeclaration *ConfigVariableCore:: get_trusted_reference(size_t n) const { check_sort_declarations(); - nassertr(n < _trusted_declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _trusted_declarations.size(), nullptr); return _trusted_declarations[n]; } @@ -188,7 +188,7 @@ get_num_unique_references() const { INLINE const ConfigDeclaration *ConfigVariableCore:: get_unique_reference(size_t n) const { check_sort_declarations(); - nassertr(n < _unique_declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _unique_declarations.size(), nullptr); return _unique_declarations[n]; } diff --git a/dtool/src/prc/configVariableCore.cxx b/dtool/src/prc/configVariableCore.cxx index 7bf355ba3c..b2ab7d277a 100644 --- a/dtool/src/prc/configVariableCore.cxx +++ b/dtool/src/prc/configVariableCore.cxx @@ -34,8 +34,8 @@ ConfigVariableCore(const string &name) : _is_used(false), _value_type(VT_undefined), _flags(0), - _default_value(NULL), - _local_value(NULL), + _default_value(nullptr), + _local_value(nullptr), _declarations_sorted(true), _value_queried(false) { @@ -56,12 +56,12 @@ ConfigVariableCore(const ConfigVariableCore &templ, const string &name) : _value_type(templ._value_type), _description(templ._description), _flags(templ._flags), - _default_value(NULL), - _local_value(NULL), + _default_value(nullptr), + _local_value(nullptr), _declarations_sorted(false), _value_queried(false) { - if (templ._default_value != (ConfigDeclaration *)NULL) { + if (templ._default_value != nullptr) { set_default_value(templ._default_value->get_string_value()); } } @@ -187,7 +187,7 @@ set_description(const string &description) { */ void ConfigVariableCore:: set_default_value(const string &default_value) { - if (_default_value == (ConfigDeclaration *)NULL) { + if (_default_value == nullptr) { // Defining the default value for the first time. ConfigPage *default_page = ConfigPage::get_default_page(); _default_value = default_page->make_declaration(this, default_value); @@ -228,7 +228,7 @@ set_default_value(const string &default_value) { */ ConfigDeclaration *ConfigVariableCore:: make_local_value() { - if (_local_value == (ConfigDeclaration *)NULL) { + if (_local_value == nullptr) { ConfigPage *local_page = ConfigPage::get_local_page(); string string_value = get_declaration(0)->get_string_value(); _local_value = local_page->make_declaration(this, string_value); @@ -253,9 +253,9 @@ make_local_value() { */ bool ConfigVariableCore:: clear_local_value() { - if (_local_value != (ConfigDeclaration *)NULL) { + if (_local_value != nullptr) { ConfigPage::get_local_page()->delete_declaration(_local_value); - _local_value = (ConfigDeclaration *)NULL; + _local_value = nullptr; invalidate_cache(); return true; } @@ -304,7 +304,7 @@ get_num_declarations() const { const ConfigDeclaration *ConfigVariableCore:: get_declaration(size_t n) const { ((ConfigVariableCore *)this)->_value_queried = true; - if (_default_value == (ConfigDeclaration *)NULL) { + if (_default_value == nullptr) { prc_cat->warning() << "value queried before default value set for " << get_name() << ".\n"; @@ -350,7 +350,7 @@ write(ostream &out) const { << " (from " << (*di)->get_page()->get_name() << ")\n"; } - if (_default_value != (ConfigDeclaration *)NULL) { + if (_default_value != nullptr) { out << " " << *_default_value << " (default value)\n"; } diff --git a/dtool/src/prc/configVariableCore.h b/dtool/src/prc/configVariableCore.h index 19e03436d2..6e8ce7ace9 100644 --- a/dtool/src/prc/configVariableCore.h +++ b/dtool/src/prc/configVariableCore.h @@ -110,7 +110,7 @@ private: ConfigDeclaration *_default_value; ConfigDeclaration *_local_value; - typedef vector Declarations; + typedef std::vector Declarations; Declarations _declarations; Declarations _trusted_declarations; Declarations _untrusted_declarations; diff --git a/dtool/src/prc/configVariableDouble.I b/dtool/src/prc/configVariableDouble.I index 8cd2cd1e91..e93f39830e 100644 --- a/dtool/src/prc/configVariableDouble.I +++ b/dtool/src/prc/configVariableDouble.I @@ -116,7 +116,7 @@ get_value() const { INLINE double ConfigVariableDouble:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_double_word(0); } return 0.0; diff --git a/dtool/src/prc/configVariableEnum.I b/dtool/src/prc/configVariableEnum.I index 04464fcc41..6ae9327119 100644 --- a/dtool/src/prc/configVariableEnum.I +++ b/dtool/src/prc/configVariableEnum.I @@ -126,7 +126,7 @@ INLINE EnumType ConfigVariableEnum:: get_default_value() const { if (!_got_default_value) { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { ((ConfigVariableEnum *)this)->_default_value = (EnumType)parse_string(decl->get_string_value()); ((ConfigVariableEnum *)this)->_got_default_value = true; } diff --git a/dtool/src/prc/configVariableFilename.I b/dtool/src/prc/configVariableFilename.I index d84d92dcb0..8e6ca228b3 100644 --- a/dtool/src/prc/configVariableFilename.I +++ b/dtool/src/prc/configVariableFilename.I @@ -195,7 +195,7 @@ get_value() const { INLINE Filename ConfigVariableFilename:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return Filename::expand_from(decl->get_string_value()); } return Filename(); diff --git a/dtool/src/prc/configVariableFilename.cxx b/dtool/src/prc/configVariableFilename.cxx index 1679082ef5..4c8941babd 100644 --- a/dtool/src/prc/configVariableFilename.cxx +++ b/dtool/src/prc/configVariableFilename.cxx @@ -28,7 +28,7 @@ reload_cache() { // We check again for cache validity since another thread may have beaten // us to the punch while we were waiting for the lock. if (!is_cache_valid(_local_modified)) { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); const ConfigDeclaration *decl = _core->get_declaration(0); const ConfigPage *page = decl->get_page(); diff --git a/dtool/src/prc/configVariableInt.I b/dtool/src/prc/configVariableInt.I index 7c91ce1d6a..bdafa4b817 100644 --- a/dtool/src/prc/configVariableInt.I +++ b/dtool/src/prc/configVariableInt.I @@ -116,7 +116,7 @@ get_value() const { INLINE int ConfigVariableInt:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_int_word(0); } return 0; diff --git a/dtool/src/prc/configVariableInt64.I b/dtool/src/prc/configVariableInt64.I index f7c1c5d66b..534905b0e8 100644 --- a/dtool/src/prc/configVariableInt64.I +++ b/dtool/src/prc/configVariableInt64.I @@ -116,7 +116,7 @@ get_value() const { INLINE int64_t ConfigVariableInt64:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_int64_word(0); } return 0; diff --git a/dtool/src/prc/configVariableList.I b/dtool/src/prc/configVariableList.I index 4429e31fb9..a3e96c5a17 100644 --- a/dtool/src/prc/configVariableList.I +++ b/dtool/src/prc/configVariableList.I @@ -33,7 +33,7 @@ ConfigVariableList(const string &name, // A list variable implicitly defines a default value of the empty string. // This is just to prevent the core variable from complaining should anyone // ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -44,7 +44,7 @@ ConfigVariableList(const string &name, */ INLINE size_t ConfigVariableList:: get_num_values() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_num_trusted_references(); } @@ -53,9 +53,9 @@ get_num_values() const { */ INLINE string ConfigVariableList:: get_string_value(size_t n) const { - nassertr(_core != (ConfigVariableCore *)NULL, string()); + nassertr(_core != nullptr, string()); const ConfigDeclaration *decl = _core->get_trusted_reference(n); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_string_value(); } return string(); @@ -66,7 +66,7 @@ get_string_value(size_t n) const { */ INLINE size_t ConfigVariableList:: get_num_unique_values() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_num_unique_references(); } @@ -75,9 +75,9 @@ get_num_unique_values() const { */ INLINE string ConfigVariableList:: get_unique_value(size_t n) const { - nassertr(_core != (ConfigVariableCore *)NULL, string()); + nassertr(_core != nullptr, string()); const ConfigDeclaration *decl = _core->get_unique_reference(n); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_string_value(); } return string(); diff --git a/dtool/src/prc/configVariableManager.I b/dtool/src/prc/configVariableManager.I index 4ca5363bde..6c92874e9c 100644 --- a/dtool/src/prc/configVariableManager.I +++ b/dtool/src/prc/configVariableManager.I @@ -24,7 +24,7 @@ get_num_variables() const { */ INLINE ConfigVariableCore *ConfigVariableManager:: get_variable(size_t n) const { - nassertr(n < _variables.size(), (ConfigVariableCore *)NULL); + nassertr(n < _variables.size(), nullptr); return _variables[n]; } diff --git a/dtool/src/prc/configVariableManager.cxx b/dtool/src/prc/configVariableManager.cxx index 4231abbbaa..52f7269f6b 100644 --- a/dtool/src/prc/configVariableManager.cxx +++ b/dtool/src/prc/configVariableManager.cxx @@ -17,7 +17,7 @@ #include "configPage.h" #include "config_prc.h" -ConfigVariableManager *ConfigVariableManager::_global_ptr = NULL; +ConfigVariableManager *ConfigVariableManager::_global_ptr = nullptr; /** * The constructor is private (actually, just protected, but only to avoid a @@ -52,12 +52,12 @@ make_variable(const string &name) { return (*ni).second; } - ConfigVariableCore *variable = NULL; + ConfigVariableCore *variable = nullptr; // See if there's a template that matches this name. VariableTemplates::const_iterator ti; for (ti = _variable_templates.begin(); - ti != _variable_templates.end() && variable == (ConfigVariableCore *)NULL; + ti != _variable_templates.end() && variable == nullptr; ++ti) { const GlobPattern &pattern = (*ti).first; ConfigVariableCore *templ = (*ti).second; @@ -66,7 +66,7 @@ make_variable(const string &name) { } } - if (variable == (ConfigVariableCore *)NULL) { + if (variable == nullptr) { variable = new ConfigVariableCore(name); } @@ -116,7 +116,7 @@ make_variable_template(const string &pattern, core->set_value_type(value_type); } if (!default_value.empty() || - core->get_default_value() == (ConfigDeclaration *)NULL) { + core->get_default_value() == nullptr) { core->set_default_value(default_value); } if (!description.empty()) { @@ -137,7 +137,7 @@ make_variable_template(const string &pattern, variable->set_value_type(value_type); } if (!default_value.empty() || - variable->get_default_value() == (ConfigDeclaration *)NULL) { + variable->get_default_value() == nullptr) { variable->set_default_value(default_value); } if (!description.empty()) { @@ -300,7 +300,7 @@ list_dynamic_variables() const { */ ConfigVariableManager *ConfigVariableManager:: get_global_ptr() { - if (_global_ptr == (ConfigVariableManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ConfigVariableManager; } return _global_ptr; @@ -357,7 +357,7 @@ list_variable(const ConfigVariableCore *variable, } decl = variable->get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { nout << " default value = " << decl->get_string_value() << "\n"; } } diff --git a/dtool/src/prc/configVariableManager.h b/dtool/src/prc/configVariableManager.h index 713e1bc5d2..818c5a8f3d 100644 --- a/dtool/src/prc/configVariableManager.h +++ b/dtool/src/prc/configVariableManager.h @@ -67,13 +67,13 @@ private: // We have to avoid pmap and pvector, due to the very low-level nature of // this stuff. - typedef vector Variables; + typedef std::vector Variables; Variables _variables; - typedef map VariablesByName; + typedef std::map VariablesByName; VariablesByName _variables_by_name; - typedef map VariableTemplates; + typedef std::map VariableTemplates; VariableTemplates _variable_templates; static ConfigVariableManager *_global_ptr; diff --git a/dtool/src/prc/configVariableSearchPath.I b/dtool/src/prc/configVariableSearchPath.I index 9017d1cf0a..c9294f119e 100644 --- a/dtool/src/prc/configVariableSearchPath.I +++ b/dtool/src/prc/configVariableSearchPath.I @@ -28,7 +28,7 @@ ConfigVariableSearchPath(const string &name, // A SearchPath variable implicitly defines a default value of the empty // string. This is just to prevent the core variable from complaining // should anyone ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -52,7 +52,7 @@ ConfigVariableSearchPath(const string &name, // A SearchPath variable implicitly defines a default value of the empty // string. This is just to prevent the core variable from complaining // should anyone ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -76,7 +76,7 @@ ConfigVariableSearchPath(const string &name, // A SearchPath variable implicitly defines a default value of the empty // string. This is just to prevent the core variable from complaining // should anyone ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -123,7 +123,7 @@ get_default_value() const { */ INLINE bool ConfigVariableSearchPath:: clear_local_value() { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); bool any_to_clear = !_prefix.is_empty() || _postfix.is_empty(); _prefix.clear(); diff --git a/dtool/src/prc/configVariableSearchPath.cxx b/dtool/src/prc/configVariableSearchPath.cxx index 2ae4d87d16..984ba435c7 100644 --- a/dtool/src/prc/configVariableSearchPath.cxx +++ b/dtool/src/prc/configVariableSearchPath.cxx @@ -19,7 +19,7 @@ */ void ConfigVariableSearchPath:: reload_search_path() { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); mark_cache_valid(_local_modified); _cache.clear(); diff --git a/dtool/src/prc/configVariableString.I b/dtool/src/prc/configVariableString.I index 1adbbe6797..fcdb301e2a 100644 --- a/dtool/src/prc/configVariableString.I +++ b/dtool/src/prc/configVariableString.I @@ -138,7 +138,7 @@ get_value() const { INLINE string ConfigVariableString:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_string_value(); } return string(); diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index dc38ac5894..1fd5cc72b5 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -23,11 +23,6 @@ #include "openssl/rand.h" #include "openssl/evp.h" -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - // The iteration count is scaled by this factor for writing to the stream. static const int iteration_count_factor = 1000; @@ -36,9 +31,9 @@ static const int iteration_count_factor = 1000; */ EncryptStreamBuf:: EncryptStreamBuf() { - _source = (istream *)NULL; + _source = nullptr; _owns_source = false; - _dest = (ostream *)NULL; + _dest = nullptr; _owns_dest = false; ConfigVariableString encryption_algorithm @@ -74,10 +69,10 @@ EncryptStreamBuf() { _key_length = encryption_key_length; _iteration_count = encryption_iteration_count; - _read_ctx = NULL; - _write_ctx = NULL; + _read_ctx = nullptr; + _write_ctx = nullptr; - _read_overflow_buffer = NULL; + _read_overflow_buffer = nullptr; _in_read_overflow_buffer = 0; #ifdef PHAVE_IOSTREAM @@ -112,9 +107,9 @@ open_read(istream *source, bool owns_source, const string &password) { _source = source; _owns_source = owns_source; - if (_read_ctx != NULL) { + if (_read_ctx != nullptr) { EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } // Now read the header information. @@ -125,7 +120,7 @@ open_read(istream *source, bool owns_source, const string &password) { const EVP_CIPHER *cipher = EVP_get_cipherbynid(nid); - if (cipher == NULL) { + if (cipher == nullptr) { prc_cat.error() << "Unknown encryption algorithm in stream.\n"; return; @@ -150,11 +145,11 @@ open_read(istream *source, bool owns_source, const string &password) { iv_length = (int)sr.extract_bytes(iv, iv_length); _read_ctx = EVP_CIPHER_CTX_new(); - nassertv(_read_ctx != NULL); + nassertv(_read_ctx != nullptr); // Initialize the context int result; - result = EVP_DecryptInit(_read_ctx, cipher, NULL, (unsigned char *)iv); + result = EVP_DecryptInit(_read_ctx, cipher, nullptr, (unsigned char *)iv); nassertv(result > 0); result = EVP_CIPHER_CTX_set_key_length(_read_ctx, key_length); @@ -163,7 +158,7 @@ open_read(istream *source, bool owns_source, const string &password) { << "Invalid key length " << key_length * 8 << " bits for algorithm " << OBJ_nid2sn(nid) << "\n"; EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; return; } @@ -177,7 +172,7 @@ open_read(istream *source, bool owns_source, const string &password) { nassertv(result > 0); // Store the key within the context. - result = EVP_DecryptInit(_read_ctx, NULL, key, NULL); + result = EVP_DecryptInit(_read_ctx, nullptr, key, nullptr); nassertv(result > 0); _read_overflow_buffer = new unsigned char[_read_block_size]; @@ -190,22 +185,22 @@ open_read(istream *source, bool owns_source, const string &password) { */ void EncryptStreamBuf:: close_read() { - if (_read_ctx != NULL) { + if (_read_ctx != nullptr) { EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } - if (_read_overflow_buffer != (unsigned char *)NULL) { + if (_read_overflow_buffer != nullptr) { delete[] _read_overflow_buffer; - _read_overflow_buffer = NULL; + _read_overflow_buffer = nullptr; } - if (_source != (istream *)NULL) { + if (_source != nullptr) { if (_owns_source) { delete _source; _owns_source = false; } - _source = (istream *)NULL; + _source = nullptr; } } @@ -223,7 +218,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) { const EVP_CIPHER *cipher = EVP_get_cipherbyname(_algorithm.c_str()); - if (cipher == NULL) { + if (cipher == nullptr) { prc_cat.error() << "Unknown encryption algorithm: " << _algorithm << "\n"; return; @@ -240,10 +235,10 @@ open_write(ostream *dest, bool owns_dest, const string &password) { RAND_bytes(iv, iv_length); _write_ctx = EVP_CIPHER_CTX_new(); - nassertv(_write_ctx != NULL); + nassertv(_write_ctx != nullptr); int result; - result = EVP_EncryptInit(_write_ctx, cipher, NULL, iv); + result = EVP_EncryptInit(_write_ctx, cipher, nullptr, iv); nassertv(result > 0); // Store the appropriate key length in the context. @@ -257,7 +252,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) { << "Invalid key length " << key_length * 8 << " bits for algorithm " << OBJ_nid2sn(nid) << "\n"; EVP_CIPHER_CTX_free(_write_ctx); - _write_ctx = NULL; + _write_ctx = nullptr; return; } @@ -281,7 +276,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) { nassertv(result > 0); // Store the key in the context. - result = EVP_EncryptInit(_write_ctx, NULL, key, NULL); + result = EVP_EncryptInit(_write_ctx, nullptr, key, nullptr); nassertv(result > 0); // Now write the header information to the stream. @@ -302,12 +297,12 @@ open_write(ostream *dest, bool owns_dest, const string &password) { */ void EncryptStreamBuf:: close_write() { - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n); pbump(-(int)n); - if (_write_ctx != NULL) { + if (_write_ctx != nullptr) { unsigned char *write_buffer = (unsigned char *)alloca(_write_block_size); int bytes_written = 0; EVP_EncryptFinal(_write_ctx, write_buffer, &bytes_written); @@ -316,14 +311,14 @@ close_write() { _dest->write((const char *)write_buffer, bytes_written); EVP_CIPHER_CTX_free(_write_ctx); - _write_ctx = NULL; + _write_ctx = nullptr; } if (_owns_dest) { delete _dest; _owns_dest = false; } - _dest = (ostream *)NULL; + _dest = nullptr; } } @@ -354,12 +349,12 @@ overflow(int ch) { */ int EncryptStreamBuf:: sync() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { size_t n = egptr() - gptr(); gbump((int)n); } - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n); pbump(-(int)n); @@ -428,7 +423,7 @@ read_chars(char *start, size_t length) { do { // Get more bytes from the stream. - if (_read_ctx == NULL) { + if (_read_ctx == nullptr) { return 0; } @@ -445,15 +440,15 @@ read_chars(char *start, size_t length) { result = EVP_DecryptFinal(_read_ctx, read_buffer, &bytes_read); EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } if (result <= 0) { prc_cat.error() << "Error decrypting stream.\n"; - if (_read_ctx != NULL) { + if (_read_ctx != nullptr) { EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } } thread_consider_yield(); @@ -483,7 +478,7 @@ read_chars(char *start, size_t length) { */ void EncryptStreamBuf:: write_chars(const char *start, size_t length) { - if (_write_ctx != NULL && length != 0) { + if (_write_ctx != nullptr && length != 0) { size_t max_write_buffer = length + _write_block_size; unsigned char *write_buffer = (unsigned char *)alloca(max_write_buffer); diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index f74f55e596..0d91f5b444 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -29,18 +29,18 @@ #include #endif -Notify *Notify::_global_ptr = (Notify *)NULL; +Notify *Notify::_global_ptr = nullptr; /** * */ Notify:: Notify() { - _ostream_ptr = &cerr; + _ostream_ptr = &std::cerr; _owns_ostream_ptr = false; - _null_ostream_ptr = new fstream; + _null_ostream_ptr = new std::fstream; - _assert_handler = (AssertHandler *)NULL; + _assert_handler = nullptr; _assert_failed = false; } @@ -67,7 +67,7 @@ set_ostream_ptr(ostream *ostream_ptr, bool delete_later) { delete _ostream_ptr; } - if (ostream_ptr == (ostream *)NULL) { + if (ostream_ptr == nullptr) { _ostream_ptr = &cerr; _owns_ostream_ptr = false; } else { @@ -135,7 +135,7 @@ set_assert_handler(Notify::AssertHandler *assert_handler) { */ void Notify:: clear_assert_handler() { - _assert_handler = (AssertHandler *)NULL; + _assert_handler = nullptr; } /** @@ -143,7 +143,7 @@ clear_assert_handler() { */ bool Notify:: has_assert_handler() const { - return (_assert_handler != (AssertHandler *)NULL); + return (_assert_handler != nullptr); } /** @@ -172,10 +172,10 @@ get_top_category() { NotifyCategory *Notify:: get_category(const string &basename, NotifyCategory *parent_category) { // The string should not contain colons. - nassertr(basename.find(':') == string::npos, (NotifyCategory *)NULL); + nassertr(basename.find(':') == string::npos, nullptr); string fullname; - if (parent_category != (NotifyCategory *)NULL) { + if (parent_category != nullptr) { fullname = parent_category->get_fullname() + ":" + basename; } else { // The parent_category is NULL. If basename is empty, that means we refer @@ -188,7 +188,7 @@ get_category(const string &basename, NotifyCategory *parent_category) { } pair result = - _categories.insert(Categories::value_type(fullname, (NotifyCategory *)NULL)); + _categories.insert(Categories::value_type(fullname, nullptr)); bool inserted = result.second; NotifyCategory *&category = (*result.first).second; @@ -230,7 +230,7 @@ get_category(const string &fullname) { // No such Category; create one. First identify the parent name, based on // the rightmost colon. - NotifyCategory *parent_category = (NotifyCategory *)NULL; + NotifyCategory *parent_category = nullptr; string basename = fullname; size_t colon = fullname.rfind(':'); @@ -281,7 +281,7 @@ write_string(const string &str) { */ Notify *Notify:: ptr() { - if (_global_ptr == (Notify *)NULL) { + if (_global_ptr == nullptr) { init_memory_hook(); _global_ptr = new Notify; } @@ -360,7 +360,7 @@ assert_failure(const char *expression, int line, // debugger otherwise. // So we'll force a segfault, which works every time. - int *ptr = (int *)NULL; + int *ptr = nullptr; *ptr = 1; #else // WIN32 diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index 432dfca159..8faa89bdd0 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -41,12 +41,12 @@ NotifyCategory(const string &fullname, const string &basename, ConfigVariable::F_dynamic), _local_modified(initial_invalid_cache()) { - if (_parent != (NotifyCategory *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } // Only the unnamed top category is allowed not to have a parent. - nassertv(_parent != (NotifyCategory *)NULL || _fullname.empty()); + nassertv(_parent != nullptr || _fullname.empty()); } /** @@ -77,7 +77,7 @@ out(NotifySeverity severity, bool prefix) const { if (prefix) { if (get_notify_timestamp()) { // Format a timestamp to include as a prefix as well. - time_t now = time(NULL) + _server_delta; + time_t now = time(nullptr) + _server_delta; struct tm atm; #ifdef _WIN32 localtime_s(&atm, &now); @@ -175,7 +175,7 @@ update_severity_cache() { nout << "Invalid severity name for " << _severity.get_name() << ": " << _severity.get_string_value() << "\n"; } - if (_parent != (NotifyCategory *)NULL) { + if (_parent != nullptr) { _severity_cache = _parent->get_severity(); } else { @@ -195,8 +195,8 @@ update_severity_cache() { */ bool NotifyCategory:: get_notify_timestamp() { - static ConfigVariableBool *notify_timestamp = NULL; - if (notify_timestamp == (ConfigVariableBool *)NULL) { + static ConfigVariableBool *notify_timestamp = nullptr; + if (notify_timestamp == nullptr) { notify_timestamp = new ConfigVariableBool ("notify-timestamp", false, "Set true to output the date & time with each notify message."); @@ -211,8 +211,8 @@ get_notify_timestamp() { */ bool NotifyCategory:: get_check_debug_notify_protect() { - static ConfigVariableBool *check_debug_notify_protect = NULL; - if (check_debug_notify_protect == (ConfigVariableBool *)NULL) { + static ConfigVariableBool *check_debug_notify_protect = nullptr; + if (check_debug_notify_protect == nullptr) { check_debug_notify_protect = new ConfigVariableBool ("check-debug-notify-protect", false, "Set true to issue a warning message if a debug or spam " diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index ee25b56268..5ef3712208 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -88,7 +88,7 @@ private: string _basename; NotifyCategory *_parent; ConfigVariableEnum _severity; - typedef vector Children; + typedef std::vector Children; Children _children; static long _server_delta; // not a time_t because server delta may be signed. diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index 8c0a5dc47d..501090a6d4 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -18,7 +18,7 @@ template NotifyCategory *NotifyCategoryProxy:: init() { - if (_ptr == (NotifyCategory *)NULL) { + if (_ptr == nullptr) { _ptr = GetCategory::get_category(); } return _ptr; @@ -33,7 +33,7 @@ init() { template INLINE NotifyCategory *NotifyCategoryProxy:: get_unsafe_ptr() { - nassertd(_ptr != (NotifyCategory *)NULL) { + nassertd(_ptr != nullptr) { init(); nout << "Uninitialized notify proxy: " << _ptr->get_fullname() << "\n"; } diff --git a/dtool/src/prc/pnotify.h b/dtool/src/prc/pnotify.h index 27a346d0d9..90cdb24a5d 100644 --- a/dtool/src/prc/pnotify.h +++ b/dtool/src/prc/pnotify.h @@ -85,7 +85,7 @@ private: // This shouldn't be a pmap, since it might be invoked before we initialize // the global malloc pointers. - typedef map Categories; + typedef std::map Categories; Categories _categories; static Notify *_global_ptr; diff --git a/dtool/src/prc/prcKeyRegistry.cxx b/dtool/src/prc/prcKeyRegistry.cxx index 6329a8abbd..e505b96ecc 100644 --- a/dtool/src/prc/prcKeyRegistry.cxx +++ b/dtool/src/prc/prcKeyRegistry.cxx @@ -25,7 +25,7 @@ // Some versions of OpenSSL appear to define this as a macro. Yucky. #undef set_key -PrcKeyRegistry *PrcKeyRegistry::_global_ptr = NULL; +PrcKeyRegistry *PrcKeyRegistry::_global_ptr = nullptr; /** * There is only one PrcKeyRegistry in the world; use get_global_ptr() to get @@ -56,19 +56,19 @@ void PrcKeyRegistry:: record_keys(const KeyDef *key_def, size_t num_keys) { for (size_t i = 0; i < num_keys; i++) { const KeyDef *def = &key_def[i]; - if (def->_data != (char *)NULL) { + if (def->_data != nullptr) { // Clear the ith key. while (_keys.size() <= i) { Key key; - key._def = NULL; - key._pkey = NULL; + key._def = nullptr; + key._pkey = nullptr; key._generated_time = 0; _keys.push_back(key); } if (_keys[i]._def != def) { - if (_keys[i]._pkey != (EVP_PKEY *)NULL) { + if (_keys[i]._pkey != nullptr) { EVP_PKEY_free(_keys[i]._pkey); - _keys[i]._pkey = NULL; + _keys[i]._pkey = nullptr; } _keys[i]._def = def; _keys[i]._generated_time = def->_generated_time; @@ -88,15 +88,15 @@ set_key(size_t n, EVP_PKEY *pkey, time_t generated_time) { // Clear the nth key. while (_keys.size() <= n) { Key key; - key._def = NULL; - key._pkey = NULL; + key._def = nullptr; + key._pkey = nullptr; key._generated_time = 0; _keys.push_back(key); } - _keys[n]._def = NULL; - if (_keys[n]._pkey != (EVP_PKEY *)NULL) { + _keys[n]._def = nullptr; + if (_keys[n]._pkey != nullptr) { EVP_PKEY_free(_keys[n]._pkey); - _keys[n]._pkey = NULL; + _keys[n]._pkey = nullptr; } _keys[n]._pkey = pkey; _keys[n]._generated_time = generated_time; @@ -117,20 +117,20 @@ get_num_keys() const { */ EVP_PKEY *PrcKeyRegistry:: get_key(size_t n) const { - nassertr(n < _keys.size(), (EVP_PKEY *)NULL); + nassertr(n < _keys.size(), nullptr); - if (_keys[n]._def != (KeyDef *)NULL) { - if (_keys[n]._pkey == (EVP_PKEY *)NULL) { + if (_keys[n]._def != nullptr) { + if (_keys[n]._pkey == nullptr) { // Convert the def to a EVP_PKEY structure. const KeyDef *def = _keys[n]._def; BIO *mbio = BIO_new_mem_buf((void *)def->_data, def->_length); - EVP_PKEY *pkey = PEM_read_bio_PUBKEY(mbio, NULL, NULL, NULL); + EVP_PKEY *pkey = PEM_read_bio_PUBKEY(mbio, nullptr, nullptr, nullptr); ((PrcKeyRegistry *)this)->_keys[n]._pkey = pkey; BIO_free(mbio); - if (pkey == (EVP_PKEY *)NULL) { + if (pkey == nullptr) { // Couldn't read the bio for some reason. - ((PrcKeyRegistry *)this)->_keys[n]._def = NULL; + ((PrcKeyRegistry *)this)->_keys[n]._def = nullptr; } } } @@ -154,7 +154,7 @@ get_generated_time(size_t n) const { */ PrcKeyRegistry *PrcKeyRegistry:: get_global_ptr() { - if (_global_ptr == (PrcKeyRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PrcKeyRegistry; } return _global_ptr; diff --git a/dtool/src/prc/prcKeyRegistry.h b/dtool/src/prc/prcKeyRegistry.h index 0a21d182ad..c05e69a445 100644 --- a/dtool/src/prc/prcKeyRegistry.h +++ b/dtool/src/prc/prcKeyRegistry.h @@ -63,7 +63,7 @@ private: time_t _generated_time; }; - typedef vector Keys; + typedef std::vector Keys; Keys _keys; static PrcKeyRegistry *_global_ptr; diff --git a/dtool/src/prc/streamReader_ext.cxx b/dtool/src/prc/streamReader_ext.cxx index 2876f82faa..53a4570872 100644 --- a/dtool/src/prc/streamReader_ext.cxx +++ b/dtool/src/prc/streamReader_ext.cxx @@ -68,8 +68,8 @@ readline() { PyObject *Extension:: readlines() { PyObject *lst = PyList_New(0); - if (lst == NULL) { - return NULL; + if (lst == nullptr) { + return nullptr; } PyObject *py_line = readline(); diff --git a/dtool/src/prckeys/makePrcKey.cxx b/dtool/src/prckeys/makePrcKey.cxx index 6832860540..48b8f62d9c 100644 --- a/dtool/src/prckeys/makePrcKey.cxx +++ b/dtool/src/prckeys/makePrcKey.cxx @@ -163,7 +163,7 @@ write_public_keys(Filename outfile) { for (i = 0; i < num_keys; i++) { EVP_PKEY *pkey = pkr->get_key(i); - if (pkey != (EVP_PKEY *)NULL) { + if (pkey != nullptr) { if (!PEM_write_bio_PUBKEY(mbio, pkey)) { output_ssl_errors(); exit(1); @@ -184,11 +184,11 @@ write_public_keys(Filename outfile) { EVP_PKEY *pkey = pkr->get_key(i); time_t generated_time = pkr->get_generated_time(i); - if (pkey != (EVP_PKEY *)NULL) { + if (pkey != nullptr) { out << " { prc_pubkey" << i << "_data, prc_pubkey" << i << "_length, " << generated_time << " },\n"; } else { - out << " { NULL, 0, 0 },\n"; + out << " { nullptr, 0, 0 },\n"; } }; @@ -220,17 +220,17 @@ write_private_key(EVP_PKEY *pkey, Filename outfile, int n, time_t now, BIO *mbio = BIO_new(BIO_s_mem()); int write_result; - if (pp != NULL && *pp == '\0') { + if (pp != nullptr && *pp == '\0') { // The supplied password was the empty string. This means not to encrypt // the private key. write_result = - PEM_write_bio_PKCS8PrivateKey(mbio, pkey, NULL, NULL, 0, NULL, NULL); + PEM_write_bio_PKCS8PrivateKey(mbio, pkey, nullptr, nullptr, 0, nullptr, nullptr); } else { // Otherwise, the default is to encrypt it. write_result = PEM_write_bio_PKCS8PrivateKey(mbio, pkey, EVP_des_ede3_cbc(), - NULL, 0, NULL, (void *)pp); + nullptr, 0, nullptr, (void *)pp); } if (!write_result) { @@ -427,7 +427,7 @@ main(int argc, char **argv) { // Load the OpenSSL algorithms. OpenSSL_add_all_algorithms(); - time_t now = time(NULL); + time_t now = time(nullptr); string name = priv_outfile.get_fullpath_wo_extension(); string prefix, suffix; @@ -448,7 +448,7 @@ main(int argc, char **argv) { KeyNumbers::iterator ki; for (ki = key_numbers.begin(); ki != key_numbers.end(); ++ki) { int n = (*ki)._number; - const char *pp = NULL; + const char *pp = nullptr; if ((*ki)._got_pass_phrase) { pp = (*ki)._pass_phrase.c_str(); } diff --git a/dtool/src/prckeys/signPrcFile_src.cxx b/dtool/src/prckeys/signPrcFile_src.cxx index 0d9f58cfa4..f122283c55 100644 --- a/dtool/src/prckeys/signPrcFile_src.cxx +++ b/dtool/src/prckeys/signPrcFile_src.cxx @@ -92,7 +92,7 @@ read_file(istream &in, string &data) { // Look for the first line in the buffer.. char *newline = (char *)memchr((void *)buffer, '\n', count); - if (newline == NULL) { + if (newline == nullptr) { // The buffer was one long line. Huh. prev_line += string(buffer, count); @@ -104,7 +104,7 @@ read_file(istream &in, string &data) { // Now look for the next line, etc. char *start = newline + 1; newline = (char *)memchr((void *)start, '\n', buffer_end - start); - while (newline != NULL) { + while (newline != nullptr) { length = newline - start; read_prc_line(string(start, length + 1), data); start = newline + 1; @@ -158,7 +158,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { ostringstream strm; strm << "##!\n"; if (!no_comments) { - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *t = localtime(&now); char formatted[128]; strftime(formatted, 128, "%I:%M %p %B %d, %Y", t); @@ -265,7 +265,7 @@ usage() { int main(int argc, char **argv) { preprocess_argv(argc, argv); - if (argv[0] != NULL && *argv[0]) { + if (argv[0] != nullptr && *argv[0]) { // Get the program name from the command-line arguments, if the OS // provides it. Filename progfile = Filename::from_os_specific(argv[0]); @@ -318,16 +318,16 @@ main(int argc, char **argv) { OpenSSL_add_all_algorithms(); // Convert the compiled-in data to an EVP_PKEY. - const char *pp = NULL; + const char *pp = nullptr; if (got_pass_phrase) { pp = pass_phrase.c_str(); } BIO *mbio = BIO_new_mem_buf((void *)KEY_DATA, KEY_LENGTH); - EVP_PKEY *pkey = PEM_read_bio_PrivateKey(mbio, NULL, NULL, (void *)pp); + EVP_PKEY *pkey = PEM_read_bio_PrivateKey(mbio, nullptr, nullptr, (void *)pp); BIO_free(mbio); - if (pkey == (EVP_PKEY *)NULL) { + if (pkey == nullptr) { // Actually, we're not 100% sure this was the problem, but we can't really // tell why it failed, and we're 99% sure anyway. cerr << "Invalid pass phrase.\n"; diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index f9a30e74bf..91cad58115 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -449,31 +449,31 @@ void PyEval_InitThreads() { } -void *PyExc_AssertionError = (void *)NULL; -void *PyExc_AttributeError = (void *)NULL; -void *PyExc_BufferError = (void *)NULL; -void *PyExc_ConnectionError = (void *)NULL; -void *PyExc_Exception = (void *)NULL; -void *PyExc_FutureWarning = (void *)NULL; -void *PyExc_ImportError = (void *)NULL; -void *PyExc_IndexError = (void *)NULL; -void *PyExc_KeyError = (void *)NULL; -void *PyExc_OSError = (void *)NULL; -void *PyExc_OverflowError = (void *)NULL; -void *PyExc_RuntimeError = (void *)NULL; -void *PyExc_StandardError = (void *)NULL; -void *PyExc_StopIteration = (void *)NULL; -void *PyExc_SystemExit = (void *)NULL; -void *PyExc_TypeError = (void *)NULL; -void *PyExc_ValueError = (void *)NULL; -void *PyTuple_Type = (void *)NULL; -void *PyType_Type = (void *)NULL; -void *_PyThreadState_Current = (void *)NULL; -void *_Py_FalseStruct = (void *)NULL; -void *_Py_NoneStruct = (void *)NULL; -void *_Py_NotImplementedStruct = (void *)NULL; -void *_Py_TrueStruct = (void *)NULL; -void *_Py_ZeroStruct = (void *)NULL; +void *PyExc_AssertionError = nullptr; +void *PyExc_AttributeError = nullptr; +void *PyExc_BufferError = nullptr; +void *PyExc_ConnectionError = nullptr; +void *PyExc_Exception = nullptr; +void *PyExc_FutureWarning = nullptr; +void *PyExc_ImportError = nullptr; +void *PyExc_IndexError = nullptr; +void *PyExc_KeyError = nullptr; +void *PyExc_OSError = nullptr; +void *PyExc_OverflowError = nullptr; +void *PyExc_RuntimeError = nullptr; +void *PyExc_StandardError = nullptr; +void *PyExc_StopIteration = nullptr; +void *PyExc_SystemExit = nullptr; +void *PyExc_TypeError = nullptr; +void *PyExc_ValueError = nullptr; +void *PyTuple_Type = nullptr; +void *PyType_Type = nullptr; +void *_PyThreadState_Current = nullptr; +void *_Py_FalseStruct = nullptr; +void *_Py_NoneStruct = nullptr; +void *_Py_NotImplementedStruct = nullptr; +void *_Py_TrueStruct = nullptr; +void *_Py_ZeroStruct = nullptr; void diff --git a/dtool/src/test_interrogate/test_interrogate.cxx b/dtool/src/test_interrogate/test_interrogate.cxx index 6c2b961ff3..9a5c6dfc16 100644 --- a/dtool/src/test_interrogate/test_interrogate.cxx +++ b/dtool/src/test_interrogate/test_interrogate.cxx @@ -586,7 +586,7 @@ main(int argc, char **argv) { #endif void *dl = load_dso(DSearchPath(), pathname); - if (dl == NULL) { + if (dl == nullptr) { cerr << "Unable to load: " << load_dso_error() << "\n"; return_status++; } diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index a810da13af..4a369a6f72 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1354,6 +1354,16 @@ def CompileCxx(obj,src,opts): if (optlevel==3): cmd += " -O2" if (optlevel==4): cmd += " -O3 -DNDEBUG" + # Enable more warnings. + cmd += " -Wall -Wno-unused-function" + + if not src.endswith(".c"): + cmd += " -Wno-reorder" + + # Ignore unused variables in NDEBUG builds, often used in asserts. + if optlevel == 4: + cmd += " -Wno-unused-variable" + if src.endswith(".c"): cmd += ' ' + CFLAGS else: @@ -2267,10 +2277,7 @@ DTOOL_CONFIG=[ ("DO_PIPELINING", '1', '1'), ("DEFAULT_PATHSEP", '";"', '":"'), ("WORDS_BIGENDIAN", 'UNDEF', 'UNDEF'), - ("HAVE_OPEN_MASK", 'UNDEF', 'UNDEF'), - ("PHAVE_LOCKF", '1', '1'), - ("HAVE_WCHAR_T", '1', '1'), - ("HAVE_WSTRING", '1', '1'), + ("PHAVE_LOCKF", '1', '1'), ("SIMPLE_STRUCT_POINTERS", '1', 'UNDEF'), ("HAVE_DINKUM", 'UNDEF', 'UNDEF'), ("HAVE_STL_HASH", 'UNDEF', 'UNDEF'), @@ -2280,7 +2287,6 @@ DTOOL_CONFIG=[ ("PHAVE_GETOPT_H", 'UNDEF', '1'), ("PHAVE_LINUX_INPUT_H", 'UNDEF', '1'), ("IOCTL_TERMINAL_WIDTH", 'UNDEF', '1'), - ("HAVE_STREAMSIZE", '1', '1'), ("HAVE_IOS_TYPEDEFS", '1', '1'), ("HAVE_IOS_BINARY", '1', '1'), ("STATIC_INIT_GETENV", '1', 'UNDEF'), @@ -2313,7 +2319,6 @@ DTOOL_CONFIG=[ ("PHAVE_UTIME_H", 'UNDEF', '1'), ("PHAVE_GLOB_H", 'UNDEF', '1'), ("PHAVE_DIRENT_H", 'UNDEF', '1'), - ("PHAVE_SYS_SOUNDCARD_H", 'UNDEF', '1'), ("PHAVE_UCONTEXT_H", 'UNDEF', '1'), ("PHAVE_STDINT_H", '1', '1'), ("HAVE_RTTI", '1', '1'), @@ -2326,7 +2331,6 @@ DTOOL_CONFIG=[ ("HAVE_ZLIB", 'UNDEF', 'UNDEF'), ("HAVE_PNG", 'UNDEF', 'UNDEF'), ("HAVE_JPEG", 'UNDEF', 'UNDEF'), - ("PHAVE_JPEGINT_H", '1', '1'), ("HAVE_VIDEO4LINUX", 'UNDEF', '1'), ("HAVE_TIFF", 'UNDEF', 'UNDEF'), ("HAVE_OPENEXR", 'UNDEF', 'UNDEF'), diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index afbaf243ff..aa527cefc3 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -19,7 +19,7 @@ NotifyCategoryDef(android, ""); -struct android_app *panda_android_app = NULL; +struct android_app *panda_android_app = nullptr; jclass jni_PandaActivity; jmethodID jni_PandaActivity_readBitmapSize; diff --git a/panda/src/android/jni_NativeIStream.cxx b/panda/src/android/jni_NativeIStream.cxx index 56e0c8c8bc..8bb60dfe8c 100644 --- a/panda/src/android/jni_NativeIStream.cxx +++ b/panda/src/android/jni_NativeIStream.cxx @@ -39,8 +39,8 @@ Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlon EXPORT_JNI jint Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlong ptr, jbyteArray byte_array, jint offset, jint length) { std::istream *stream = (std::istream *) ptr; - jbyte *buffer = (jbyte *) env->GetPrimitiveArrayCritical(byte_array, NULL); - if (buffer == NULL) { + jbyte *buffer = (jbyte *) env->GetPrimitiveArrayCritical(byte_array, nullptr); + if (buffer == nullptr) { return -1; } diff --git a/panda/src/android/pnmFileTypeAndroid.h b/panda/src/android/pnmFileTypeAndroid.h index f27cc4f23d..d872c58578 100644 --- a/panda/src/android/pnmFileTypeAndroid.h +++ b/panda/src/android/pnmFileTypeAndroid.h @@ -28,7 +28,7 @@ * Wrapper class around the Android Bitmap mechanism to allow loading images * on Android without needing libpng or libjpeg. */ -class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeAndroid : public PNMFileType { +class PNMFileTypeAndroid : public PNMFileType { public: enum CompressFormat : jint { CF_jpeg = 0, diff --git a/panda/src/android/pnmFileTypeAndroidReader.cxx b/panda/src/android/pnmFileTypeAndroidReader.cxx index e18ebcbaea..797571a311 100644 --- a/panda/src/android/pnmFileTypeAndroidReader.cxx +++ b/panda/src/android/pnmFileTypeAndroidReader.cxx @@ -61,7 +61,7 @@ static void conv_rgba4444(uint16_t in, xel &rgb, xelval &alpha) { */ PNMFileTypeAndroid::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : - PNMReader(type, file, owns_file), _bitmap(NULL) + PNMReader(type, file, owns_file), _bitmap(nullptr) { // Hope we can putback() more than one character. for (string::reverse_iterator mi = magic_number.rbegin(); @@ -120,7 +120,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : */ PNMFileTypeAndroid::Reader:: ~Reader() { - if (_bitmap != NULL) { + if (_bitmap != nullptr) { _env->DeleteGlobalRef(_bitmap); } } @@ -150,7 +150,7 @@ prepare_read() { jni_PandaActivity_readBitmap, (jlong) _file, _sample_size); - if (_bitmap == NULL) { + if (_bitmap == nullptr) { android_cat.error() << "Failed to read " << *this << "\n"; _is_valid = false; diff --git a/panda/src/android/pview.cxx b/panda/src/android/pview.cxx index 6683b6206b..5df6f7465b 100644 --- a/panda/src/android/pview.cxx +++ b/panda/src/android/pview.cxx @@ -30,7 +30,7 @@ int main(int argc, char **argv) { PartGroup::HMF_ok_anim_extra; WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. NodePath loading_np; diff --git a/panda/src/androiddisplay/androidGraphicsPipe.cxx b/panda/src/androiddisplay/androidGraphicsPipe.cxx index 00ff6f924f..673a03e5a2 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.cxx +++ b/panda/src/androiddisplay/androidGraphicsPipe.cxx @@ -28,13 +28,13 @@ AndroidGraphicsPipe:: AndroidGraphicsPipe() { _is_valid = false; _supported_types = OT_window | OT_buffer | OT_texture_buffer; - _egl_display = NULL; + _egl_display = nullptr; _display_width = 0; _display_height = 0; _egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (!eglInitialize(_egl_display, NULL, NULL)) { + if (!eglInitialize(_egl_display, nullptr, nullptr)) { androiddisplay_cat.error() << "Couldn't initialize the EGL display: " << get_egl_error_string(eglGetError()) << "\n"; @@ -110,12 +110,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } AndroidGraphicsStateGuardian *androidgsg = 0; if (gsg != 0) { - DCAST_INTO_R(androidgsg, gsg, NULL); + DCAST_INTO_R(androidgsg, gsg, nullptr); } // First thing to try: an eglGraphicsWindow @@ -128,7 +128,7 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new AndroidGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -212,5 +212,5 @@ make_output(const string &name, }*/ // Nothing else left to try. - return NULL; + return nullptr; } diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx index 409baa0a96..3d5b949633 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx @@ -37,7 +37,7 @@ AndroidGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _fbconfig = 0; _format = 0; - if (share_with != (AndroidGraphicsStateGuardian *)NULL) { + if (share_with != nullptr) { _prepared_objects = share_with->get_prepared_objects(); _share_context = share_with->_context; } @@ -48,12 +48,12 @@ AndroidGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ AndroidGraphicsStateGuardian:: ~AndroidGraphicsStateGuardian() { - if (_context != (EGLContext)NULL) { + if (_context != (EGLContext)nullptr) { if (!eglDestroyContext(_egl_display, _context)) { androiddisplay_cat.error() << "Failed to destroy EGL context: " << get_egl_error_string(eglGetError()) << "\n"; } - _context = (EGLContext)NULL; + _context = (EGLContext)nullptr; } } @@ -145,7 +145,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // First get the number of matching configurations, so we know how much // memory to allocate. int num_configs = 0, returned_configs; - if (!eglChooseConfig(_egl_display, attrib_list, NULL, num_configs, &returned_configs) || returned_configs <= 0) { + if (!eglChooseConfig(_egl_display, attrib_list, nullptr, num_configs, &returned_configs) || returned_configs <= 0) { androiddisplay_cat.error() << "eglChooseConfig failed: " << get_egl_error_string(eglGetError()) << "\n"; return; @@ -228,7 +228,7 @@ create_context() { EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; _context = eglCreateContext(_egl_display, _fbconfig, _share_context, context_attribs); #else - _context = eglCreateContext(_egl_display, _fbconfig, _share_context, NULL); + _context = eglCreateContext(_egl_display, _fbconfig, _share_context, nullptr); #endif int err = eglGetError(); diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 1a91f21186..62755cdd2c 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -79,7 +79,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -129,7 +129,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void AndroidGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -153,7 +153,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void AndroidGraphicsWindow:: end_flip() { - if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { + if (_gsg != nullptr && _flip_ready) { // It doesn't appear to be necessary to ensure the graphics context is // current before flipping the windows, and insisting on doing so can be a @@ -185,9 +185,9 @@ process_events() { struct android_poll_source* source; // Loop until all events are read. - while ((looper_id = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) { + while ((looper_id = ALooper_pollAll(0, nullptr, &events, (void**)&source)) >= 0) { // Process this event. - if (source != NULL) { + if (source != nullptr) { source->process(_app, source); } } @@ -207,7 +207,7 @@ process_events() { */ void AndroidGraphicsWindow:: set_properties_now(WindowProperties &properties) { - if (_pipe == (GraphicsPipe *)NULL) { + if (_pipe == nullptr) { // If the pipe is null, we're probably closing down. GraphicsWindow::set_properties_now(properties); return; @@ -242,7 +242,7 @@ void AndroidGraphicsWindow:: close_window() { destroy_surface(); - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { _gsg.clear(); } @@ -266,7 +266,7 @@ open_window() { AndroidGraphicsStateGuardian *androidgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - androidgsg = new AndroidGraphicsStateGuardian(_engine, _pipe, NULL); + androidgsg = new AndroidGraphicsStateGuardian(_engine, _pipe, nullptr); androidgsg->choose_pixel_format(_fb_properties, false, false); _gsg = androidgsg; } else { @@ -281,13 +281,13 @@ open_window() { } // Register the callbacks - assert(_app != NULL); + assert(_app != nullptr); _app->userData = this; _app->onAppCmd = handle_command; _app->onInputEvent = handle_input_event; // Wait until Android has opened the window. - while (_app->window == NULL) { + while (_app->window == nullptr) { process_events(); } @@ -326,7 +326,7 @@ destroy_surface() { } // Destroy the current context. - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { AndroidGraphicsStateGuardian *androidgsg; DCAST_INTO_V(androidgsg, _gsg); androidgsg->destroy_context(); @@ -355,7 +355,7 @@ create_surface() { ANativeActivity_setWindowFlags(_app->activity, add_flags, del_flags); // Create the EGL surface. - _egl_surface = eglCreateWindowSurface(_egl_display, androidgsg->_fbconfig, _app->window, NULL); + _egl_surface = eglCreateWindowSurface(_egl_display, androidgsg->_fbconfig, _app->window, nullptr); if (eglGetError() != EGL_SUCCESS) { androiddisplay_cat.error() << "Failed to create window surface.\n"; @@ -415,7 +415,7 @@ ns_handle_command(int32_t command) { break; case APP_CMD_INIT_WINDOW: // The window is being shown, get it ready. - if (_app->window != NULL) { + if (_app->window != nullptr) { create_surface(); properties.set_size(ANativeWindow_getWidth(_app->window), ANativeWindow_getHeight(_app->window)); diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index b52ceb50e5..77d4c1a076 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -36,11 +36,11 @@ namespace { } } -Create_AudioManager_proc *AudioManager::_create_AudioManager = NULL; +Create_AudioManager_proc *AudioManager::_create_AudioManager = nullptr; void AudioManager:: register_AudioManager_creator(Create_AudioManager_proc* proc) { - nassertv(_create_AudioManager == NULL || _create_AudioManager == proc); + nassertv(_create_AudioManager == nullptr || _create_AudioManager == proc); _create_AudioManager = proc; } @@ -48,7 +48,7 @@ register_AudioManager_creator(Create_AudioManager_proc* proc) { PT(AudioManager) AudioManager::create_AudioManager() { audio_debug("create_AudioManager()\n audio_library_name=\""<ref(); - void *result = AtomicAdjust::compare_and_exchange_ptr(_null_sound, (void *)NULL, (void *)new_sound); - if (result != NULL) { + void *result = AtomicAdjust::compare_and_exchange_ptr(_null_sound, nullptr, (void *)new_sound); + if (result != nullptr) { // Someone else must have assigned the AudioSound first. OK. - nassertr(_null_sound != new_sound, NULL); + nassertr(_null_sound != new_sound, nullptr); unref_delete(new_sound); } - nassertr(_null_sound != NULL, NULL); + nassertr(_null_sound != nullptr, nullptr); } return (AudioSound *)_null_sound; diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index c957581534..3d69b26519 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -179,7 +179,7 @@ PUBLISHED: virtual void write(ostream &out) const; // set_speaker_configuration is a Miles only method. - virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=NULL, LVecBase3 *speaker3=NULL, LVecBase3 *speaker4=NULL, LVecBase3 *speaker5=NULL, LVecBase3 *speaker6=NULL, LVecBase3 *speaker7=NULL, LVecBase3 *speaker8=NULL, LVecBase3 *speaker9=NULL); + virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=nullptr, LVecBase3 *speaker3=nullptr, LVecBase3 *speaker4=nullptr, LVecBase3 *speaker5=nullptr, LVecBase3 *speaker6=nullptr, LVecBase3 *speaker7=nullptr, LVecBase3 *speaker8=nullptr, LVecBase3 *speaker9=nullptr); public: static void register_AudioManager_creator(Create_AudioManager_proc* proc); diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 012fd103cd..529f6facb0 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -98,7 +98,7 @@ FmodAudioManager() { _saved_outputtype = FMOD_OUTPUTTYPE_AUTODETECT; - if (_system == (FMOD::System *)NULL) { + if (_system == nullptr) { // Create the global FMOD System object. This one object must be shared // by all FmodAudioManagers (this is particularly true on OSX, but the // FMOD documentation is unclear as to whether this is the intended design @@ -196,7 +196,7 @@ FmodAudioManager:: if (_all_managers.empty()) { result = _system->release(); fmod_audio_errcheck("_system->release()", result); - _system = NULL; + _system = nullptr; _system_is_valid = false; } } @@ -232,13 +232,13 @@ make_dsp(const FilterProperties::FilterConfig &conf) { case FilterProperties::FT_compress: dsptype = FMOD_DSP_TYPE_COMPRESSOR; break; default: audio_error("Garbage in DSP configuration data"); - return NULL; + return nullptr; } result = _system->createDSPByType( dsptype, &dsp); if (result != 0) { audio_error("Could not create DSP object"); - return NULL; + return nullptr; } FMOD_RESULT res1 = FMOD_OK; @@ -334,7 +334,7 @@ make_dsp(const FilterProperties::FilterConfig &conf) { (res13!=FMOD_OK)||(res14!=FMOD_OK)) { audio_error("Could not configure DSP"); dsp->release(); - return NULL; + return nullptr; } dsp->setUserData(USER_DSP_MAGIC); @@ -364,7 +364,7 @@ update_dsp_chain(FMOD::DSP *head, FilterProperties *config) { break; } FMOD::DSP *prev; - result = head->getInput(0, &prev, NULL); + result = head->getInput(0, &prev, nullptr); fmod_audio_errcheck("head->getInput()", result); void *userdata; result = prev->getUserData(&userdata); @@ -380,7 +380,7 @@ update_dsp_chain(FMOD::DSP *head, FilterProperties *config) { for (int i=0; i<(int)(conf.size()); i++) { FMOD::DSP *dsp = make_dsp(conf[i]); - result = _channelgroup->addDSP(dsp, NULL); + result = _channelgroup->addDSP(dsp, nullptr); fmod_audio_errcheck("_channelgroup->addDSP()", result); } } @@ -436,7 +436,7 @@ get_sound(const string &file_name, bool positional, int) { PT(AudioSound) FmodAudioManager:: get_sound(MovieAudio *source, bool positional, int) { nassert_raise("FMOD audio manager does not support MovieAudio sources"); - return NULL; + return nullptr; } /** diff --git a/panda/src/audiotraits/fmodAudioSound.cxx b/panda/src/audiotraits/fmodAudioSound.cxx index f10750ade3..9d9399bf4f 100644 --- a/panda/src/audiotraits/fmodAudioSound.cxx +++ b/panda/src/audiotraits/fmodAudioSound.cxx @@ -82,7 +82,7 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) file = vfs->get_file(_file_name); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // File not found. We will display the appropriate error message below. result = FMOD_ERR_FILE_NOTFOUND; @@ -99,7 +99,7 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { if (ext == "mid") { // Get the MIDI parameters. memcpy(&sound_info, &_manager->_midi_info, sizeof(sound_info)); - if (sound_info.dlsname != NULL) { + if (sound_info.dlsname != nullptr) { audio_debug("Using DLS file " << sound_info.dlsname); } } @@ -880,7 +880,7 @@ sound_end_callback(FMOD_CHANNEL * channel, // have to worry about thread-related issues here. if (type == FMOD_CHANNEL_CALLBACKTYPE_END) { FMOD::Channel *fc = (FMOD::Channel *)channel; - void *userdata = NULL; + void *userdata = nullptr; FMOD_RESULT result = fc->getUserData(&userdata); fmod_audio_errcheck("channel->getUserData()", result); FmodAudioSound *fsound = (FmodAudioSound*)userdata; @@ -897,7 +897,7 @@ open_callback(const char *name, int, unsigned int *file_size, void **handle, void **user_data) { // We actually pass in the VirtualFile pointer as the "name". VirtualFile *file = (VirtualFile *)name; - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { return FMOD_ERR_FILE_NOTFOUND; } if (fmodAudio_cat.is_spam()) { diff --git a/panda/src/audiotraits/globalMilesManager.cxx b/panda/src/audiotraits/globalMilesManager.cxx index 163147c75e..1795384b66 100644 --- a/panda/src/audiotraits/globalMilesManager.cxx +++ b/panda/src/audiotraits/globalMilesManager.cxx @@ -100,7 +100,7 @@ get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { for (size_t i = 0; i < _samples.size(); ++i) { SampleData &smp = _samples[i]; if (AIL_sample_status(smp._sample) == SMP_DONE) { - if (smp._sound != NULL) { + if (smp._sound != nullptr) { // Tell the last sound that was using this sample that it's done now. smp._sound->internal_stop(); } @@ -137,7 +137,7 @@ release_sample(size_t index, MilesAudioSample *sound) { SampleData &smp = _samples[index]; if (smp._sound == sound) { - smp._sound = NULL; + smp._sound = nullptr; } } @@ -159,7 +159,7 @@ get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { for (size_t i = 0; i < _sequences.size(); ++i) { SequenceData &seq = _sequences[i]; if (AIL_sequence_status(seq._sequence) == SEQ_DONE) { - if (seq._sound != NULL) { + if (seq._sound != nullptr) { // Tell the last sound that was using this sequence that it's done // now. seq._sound->internal_stop(); @@ -196,7 +196,7 @@ release_sequence(size_t index, MilesAudioSequence *sound) { SequenceData &seq = _sequences[index]; if (seq._sound == sound) { - seq._sound = NULL; + seq._sound = nullptr; } } @@ -214,7 +214,7 @@ force_midi_reset() { audio_debug("MilesAudioManager::force_midi_reset"); #ifdef WIN32 - if ((_midi_driver!=NULL) && (_midi_driver->deviceid != MIDI_NULL_DRIVER) && (_midi_driver->hMidiOut != NULL)) { + if ((_midi_driver!=nullptr) && (_midi_driver->deviceid != MIDI_nullptr_DRIVER) && (_midi_driver->hMidiOut != nullptr)) { audio_debug("MilesAudioManager::calling midiOutReset"); midiOutReset(_midi_driver->hMidiOut); } @@ -226,7 +226,7 @@ force_midi_reset() { */ GlobalMilesManager *GlobalMilesManager:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GlobalMilesManager; } return _global_ptr; @@ -282,7 +282,7 @@ open_api() { _midi_driver = AIL_open_XMIDI_driver(AIL_OPEN_XMIDI_NULL_DRIVER); // Load the downloadable sounds file: - _dls_device = AIL_DLS_open(_midi_driver, _digital_driver, NULL, 0, + _dls_device = AIL_DLS_open(_midi_driver, _digital_driver, nullptr, 0, audio_output_rate, audio_output_bits, audio_output_channels); @@ -293,7 +293,7 @@ open_api() { _dls_data.clear(); PT(VirtualFile) file = vfs->get_file(dls_pathname); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { milesAudio_cat.warning() << "DLS file does not exist: " << dls_pathname << "\n"; @@ -384,7 +384,7 @@ U32 AILCALLBACK GlobalMilesManager:: open_callback(char const *filename, UINTa *file_handle) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *strm = vfs->open_read_file(Filename::binary_filename(string(filename)), true); - if (strm == NULL) { + if (strm == nullptr) { // Failure. return 0; } diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index c20ebd1a9a..24ed73d448 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -147,7 +147,7 @@ get_sound(const string &file_name, bool, int) { } else { // ...the sound was not found in the cachepool. sd = load(path); - if (sd != (SoundData *)NULL) { + if (sd != nullptr) { while (_sounds.size() >= (unsigned int)_cache_limit) { uncache_a_sound(); } @@ -158,7 +158,7 @@ get_sound(const string &file_name, bool, int) { if (!ib.second) { // The insert failed. audio_debug(" failed map insert of "<_file_type == AILFILETYPE_MIDI || sd->_file_type == AILFILETYPE_XMIDI || @@ -199,7 +199,7 @@ get_sound(const string &file_name, bool, int) { } audio_debug(" returning 0x" << (void*)audioSound); - nassertr(do_is_valid(), NULL); + nassertr(do_is_valid(), nullptr); return audioSound; } @@ -209,7 +209,7 @@ get_sound(const string &file_name, bool, int) { PT(AudioSound) MilesAudioManager:: get_sound(MovieAudio *sound, bool, int) { nassert_raise("Miles audio manager does not support MovieAudio sources."); - return NULL; + return nullptr; } /** @@ -505,69 +505,69 @@ set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2, LVecBase3 *s MSSVECTOR3D speakers[9]; - if(speaker1 != NULL) { + if(speaker1 != nullptr) { speakers[0].x = speaker1->get_x(); speakers[0].y = speaker1->get_z(); speakers[0].z = speaker1->get_y(); } - if(speaker2 != NULL) { + if(speaker2 != nullptr) { speakers[1].x = speaker2->get_x(); speakers[1].y = speaker2->get_z(); speakers[1].z = speaker2->get_y(); } - if(speaker3 != NULL) { + if(speaker3 != nullptr) { speakers[2].x = speaker3->get_x(); speakers[2].y = speaker3->get_z(); speakers[2].z = speaker3->get_y(); } - if(speaker4 != NULL) { + if(speaker4 != nullptr) { speakers[3].x = speaker4->get_x(); speakers[3].y = speaker4->get_z(); speakers[3].z = speaker4->get_y(); } - if(speaker5 != NULL) { + if(speaker5 != nullptr) { speakers[4].x = speaker5->get_x(); speakers[4].y = speaker5->get_z(); speakers[4].z = speaker5->get_y(); } - if(speaker6 != NULL) { + if(speaker6 != nullptr) { speakers[5].x = speaker6->get_x(); speakers[5].y = speaker6->get_z(); speakers[5].z = speaker6->get_y(); } - if(speaker7 != NULL) { + if(speaker7 != nullptr) { speakers[6].x = speaker7->get_x(); speakers[6].y = speaker7->get_z(); speakers[6].z = speaker7->get_y(); } - if(speaker8 != NULL) { + if(speaker8 != nullptr) { speakers[7].x = speaker8->get_x(); speakers[7].y = speaker8->get_z(); speakers[7].z = speaker8->get_y(); } - if(speaker9 != NULL) { + if(speaker9 != nullptr) { speakers[8].x = speaker9->get_x(); speakers[8].y = speaker9->get_z(); speakers[8].z = speaker9->get_y(); } - if(speaker1 == NULL) { + if(speaker1 == nullptr) { audio_error("No valid speaker positions specified in MilesAudioManager::set_speaker_configuration()."); - } else if(speaker2 == NULL) { + } else if(speaker2 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 1, 1.0); - } else if(speaker3 == NULL) { + } else if(speaker3 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 2, 1.0); - } else if(speaker4 == NULL) { + } else if(speaker4 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 3, 1.0); - } else if(speaker5 == NULL) { + } else if(speaker5 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 4, 1.0); - } else if(speaker6 == NULL) { + } else if(speaker6 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 5, 1.0); - } else if(speaker7 == NULL) { + } else if(speaker7 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 6, 1.0); - } else if(speaker8 == NULL) { + } else if(speaker8 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 7, 1.0); - } else if(speaker9 == NULL) { + } else if(speaker9 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 8, 1.0); } else { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 9, 1.0); @@ -878,16 +878,16 @@ load(const Filename &file_name) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) file = vfs->get_file(file_name); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { milesAudio_cat.warning() << "No such file: " << file_name << "\n"; - return NULL; + return nullptr; } if (file->get_file_size() == 0) { milesAudio_cat.warning() << "File " << file_name << " is empty\n"; - return NULL; + return nullptr; } sd->_basename = file_name.get_basename(); @@ -908,7 +908,7 @@ load(const Filename &file_name) { if (!file->read_file(sd->_raw_data, true)) { milesAudio_cat.warning() << "Unable to read " << file_name << "\n"; - return NULL; + return nullptr; } sd->_file_type = @@ -955,7 +955,7 @@ load(const Filename &file_name) { U32 wav_data_size; if (AIL_decompress_ASI(&sd->_raw_data[0], sd->_raw_data.size(), sd->_basename.c_str(), &wav_data, &wav_data_size, - NULL)) { + nullptr)) { audio_debug("expanded " << sd->_basename << " from " << sd->_raw_data.size() << " bytes to " << wav_data_size << " bytes."); diff --git a/panda/src/audiotraits/milesAudioManager.h b/panda/src/audiotraits/milesAudioManager.h index ead813b679..51fb16b527 100644 --- a/panda/src/audiotraits/milesAudioManager.h +++ b/panda/src/audiotraits/milesAudioManager.h @@ -81,7 +81,7 @@ public: virtual PN_stdfloat audio_3d_get_doppler_factor() const; virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_drop_off_factor() const; - virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=NULL, LVecBase3 *speaker3=NULL, LVecBase3 *speaker4=NULL, LVecBase3 *speaker5=NULL, LVecBase3 *speaker6=NULL, LVecBase3 *speaker7=NULL, LVecBase3 *speaker8=NULL, LVecBase3 *speaker9=NULL); + virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=nullptr, LVecBase3 *speaker3=nullptr, LVecBase3 *speaker4=nullptr, LVecBase3 *speaker5=nullptr, LVecBase3 *speaker6=nullptr, LVecBase3 *speaker7=nullptr, LVecBase3 *speaker8=nullptr, LVecBase3 *speaker9=nullptr); virtual void output(ostream &out) const; virtual void write(ostream &out) const; diff --git a/panda/src/audiotraits/milesAudioSample.cxx b/panda/src/audiotraits/milesAudioSample.cxx index c89addb1a5..e953e77dad 100644 --- a/panda/src/audiotraits/milesAudioSample.cxx +++ b/panda/src/audiotraits/milesAudioSample.cxx @@ -38,7 +38,7 @@ MilesAudioSample(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, MilesAudioSound(manager, file_name), _sd(sd) { - nassertv(sd != NULL); + nassertv(sd != nullptr); audio_debug("MilesAudioSample(manager=0x"<<(void*)&manager <<", sd=0x"<<(void*)sd<<", file_name="<release_sound(this); - _manager = NULL; + _manager = nullptr; } } @@ -325,7 +325,7 @@ void MilesAudioSample::set_3d_min_distance(PN_stdfloat dist) { // distances in a single operation. float max_dist; int auto_3D_wet_atten; - AIL_sample_3D_distances(_sample, &max_dist, NULL, &auto_3D_wet_atten); + AIL_sample_3D_distances(_sample, &max_dist, nullptr, &auto_3D_wet_atten); AIL_set_sample_3D_distances(_sample, max_dist, dist, auto_3D_wet_atten); } else { @@ -341,7 +341,7 @@ PN_stdfloat MilesAudioSample::get_3d_min_distance() const { if(_sample != 0) { float min_dist; - AIL_sample_3D_distances(_sample, NULL, &min_dist, NULL); + AIL_sample_3D_distances(_sample, nullptr, &min_dist, nullptr); return (PN_stdfloat)min_dist; } else { audio_warning("_sample == 0 in MilesAudioSample::get_3d_min_distance()."); @@ -362,7 +362,7 @@ void MilesAudioSample::set_3d_max_distance(PN_stdfloat dist) { // distances in a single operation. float min_dist; int auto_3D_wet_atten; - AIL_sample_3D_distances(_sample, NULL, &min_dist, &auto_3D_wet_atten); + AIL_sample_3D_distances(_sample, nullptr, &min_dist, &auto_3D_wet_atten); AIL_set_sample_3D_distances(_sample, dist, min_dist, auto_3D_wet_atten); } else { @@ -378,7 +378,7 @@ PN_stdfloat MilesAudioSample::get_3d_max_distance() const { if(_sample != 0) { float max_dist; - AIL_sample_3D_distances(_sample, &max_dist, NULL, NULL); + AIL_sample_3D_distances(_sample, &max_dist, nullptr, nullptr); return (PN_stdfloat)max_dist; } else { audio_warning("_sample == 0 in MilesAudioSample::get_3d_max_distance()."); @@ -500,7 +500,7 @@ finish_callback(HSAMPLE sample) { milesAudio_cat.debug() << "finished " << *self << "\n"; } - if (self->_manager == (MilesAudioManager *)NULL) { + if (self->_manager == nullptr) { return; } self->_manager->_sounds_finished = true; diff --git a/panda/src/audiotraits/milesAudioSequence.cxx b/panda/src/audiotraits/milesAudioSequence.cxx index 3b79099db8..9f16c0dd3d 100644 --- a/panda/src/audiotraits/milesAudioSequence.cxx +++ b/panda/src/audiotraits/milesAudioSequence.cxx @@ -38,7 +38,7 @@ MilesAudioSequence(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, MilesAudioSound(manager, file_name), _sd(sd) { - nassertv(sd != NULL); + nassertv(sd != nullptr); audio_debug("MilesAudioSequence(manager=0x"<<(void*)&manager <<", sd=0x"<<(void*)sd<<", file_name="<_raw_data[0], 0); S32 length_ms; - AIL_sequence_ms_position(_sequence, &length_ms, NULL); + AIL_sequence_ms_position(_sequence, &length_ms, nullptr); PN_stdfloat time = (PN_stdfloat)length_ms * 0.001f; mgr->release_sequence(_sequence_index, this); _sequence = 0; diff --git a/panda/src/audiotraits/milesAudioSound.cxx b/panda/src/audiotraits/milesAudioSound.cxx index 0988eaf48e..de9d0edcff 100644 --- a/panda/src/audiotraits/milesAudioSound.cxx +++ b/panda/src/audiotraits/milesAudioSound.cxx @@ -130,7 +130,7 @@ set_time(PN_stdfloat time) { */ void MilesAudioSound:: set_active(bool active) { - if (_manager == (MilesAudioManager *)NULL) { + if (_manager == nullptr) { return; } diff --git a/panda/src/audiotraits/milesAudioStream.cxx b/panda/src/audiotraits/milesAudioStream.cxx index c8b9251cbd..debf8dd08a 100644 --- a/panda/src/audiotraits/milesAudioStream.cxx +++ b/panda/src/audiotraits/milesAudioStream.cxx @@ -118,7 +118,7 @@ play() { */ void MilesAudioStream:: stop() { - if (_manager == (MilesAudioManager *)NULL) { + if (_manager == nullptr) { return; } miles_audio_debug("stop()"); @@ -152,7 +152,7 @@ get_time() const { } S32 current_ms; - AIL_stream_ms_position(_stream, NULL, ¤t_ms); + AIL_stream_ms_position(_stream, nullptr, ¤t_ms); PN_stdfloat time = PN_stdfloat(current_ms * 0.001f); return time; @@ -226,7 +226,7 @@ length() const { } S32 length_ms; - AIL_stream_ms_position(_stream, &length_ms, NULL); + AIL_stream_ms_position(_stream, &length_ms, nullptr); _length = (PN_stdfloat)length_ms * 0.001f; _got_length = true; } @@ -266,9 +266,9 @@ cleanup() { set_active(false); nassertv(_stream == 0); - if (_manager != (MilesAudioManager *)NULL) { + if (_manager != nullptr) { _manager->release_sound(this); - _manager = NULL; + _manager = nullptr; } } @@ -283,7 +283,7 @@ finish_callback(HSTREAM stream) { milesAudio_cat.debug() << "finished " << *self << "\n"; } - if (self->_manager == (MilesAudioManager *)NULL) { + if (self->_manager == nullptr) { return; } self->_manager->_sounds_finished = true; @@ -300,7 +300,7 @@ do_set_time(PN_stdfloat time) { // Ensure we don't inadvertently run off the end of the sound. S32 length_ms; - AIL_stream_ms_position(_stream, &length_ms, NULL); + AIL_stream_ms_position(_stream, &length_ms, nullptr); time_ms = min(time_ms, length_ms); AIL_set_stream_ms_position(_stream, time_ms); diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 1a91185ecf..f6b7caa22b 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -38,15 +38,15 @@ TypeHandle OpenALAudioManager::_type_handle; ReMutex OpenALAudioManager::_lock; int OpenALAudioManager::_active_managers = 0; bool OpenALAudioManager::_openal_active = false; -ALCdevice* OpenALAudioManager::_device = NULL; -ALCcontext* OpenALAudioManager::_context = NULL; +ALCdevice* OpenALAudioManager::_device = nullptr; +ALCcontext* OpenALAudioManager::_context = nullptr; // This is the list of all OpenALAudioManager objects in the world. It must // be a pointer rather than a concrete object, so it won't be destructed at // exit time before we're done removing things from it. -OpenALAudioManager::Managers *OpenALAudioManager::_managers = NULL; +OpenALAudioManager::Managers *OpenALAudioManager::_managers = nullptr; -OpenALAudioManager::SourceCache *OpenALAudioManager::_al_sources = NULL; +OpenALAudioManager::SourceCache *OpenALAudioManager::_al_sources = nullptr; // Central dispatcher for audio errors. @@ -79,7 +79,7 @@ AudioManager *Create_OpenALAudioManager() { OpenALAudioManager:: OpenALAudioManager() { ReMutexHolder holder(_lock); - if (_managers == (Managers *)NULL) { + if (_managers == nullptr) { _managers = new Managers; _al_sources = new SourceCache; } @@ -118,7 +118,7 @@ OpenALAudioManager() { // Initialization audio_cat.init(); if (_active_managers == 0 || !_openal_active) { - _device = NULL; + _device = nullptr; string dev_name = select_audio_device(); if (!dev_name.empty()) { @@ -126,7 +126,7 @@ OpenALAudioManager() { audio_cat.info() << "Using OpenAL device " << dev_name << "\n"; _device = alcOpenDevice(dev_name.c_str()); - if (_device == NULL) { + if (_device == nullptr) { audio_cat.error() << "Couldn't open OpenAL device \"" << dev_name << "\", falling back to default device\n"; } @@ -134,27 +134,27 @@ OpenALAudioManager() { audio_cat.info() << "Using default OpenAL device\n"; } - if (_device == NULL) { + if (_device == nullptr) { // Open the default device. - _device = alcOpenDevice(NULL); + _device = alcOpenDevice(nullptr); - if (_device == NULL && dev_name != "OpenAL Soft") { + if (_device == nullptr && dev_name != "OpenAL Soft") { // Try the OpenAL Soft driver instead, which is fairly reliable. _device = alcOpenDevice("OpenAL Soft"); - if (_device == NULL) { + if (_device == nullptr) { audio_cat.error() << "Couldn't open default OpenAL device\n"; } } } - if (_device != NULL) { + if (_device != nullptr) { // We managed to get a device open. alcGetError(_device); // clear errors - _context = alcCreateContext(_device, NULL); + _context = alcCreateContext(_device, nullptr); alc_audio_errcheck("alcCreateContext(_device, NULL)", _device); - if (_context != NULL) { + if (_context != nullptr) { _openal_active = true; } } @@ -197,7 +197,7 @@ OpenALAudioManager() { OpenALAudioManager:: ~OpenALAudioManager() { ReMutexHolder holder(_lock); - nassertv(_managers != (Managers *)NULL); + nassertv(_managers != nullptr); Managers::iterator mi = _managers->find(this); nassertv(mi != _managers->end()); _managers->erase(mi); @@ -213,7 +213,7 @@ OpenALAudioManager:: void OpenALAudioManager:: shutdown() { ReMutexHolder holder(_lock); - if (_managers != (Managers *)NULL) { + if (_managers != nullptr) { Managers::iterator mi; for (mi = _managers->begin(); mi != _managers->end(); ++mi) { (*mi)->cleanup(); @@ -241,12 +241,12 @@ string OpenALAudioManager:: select_audio_device() { string selected_device = openal_device; - const char *devices = NULL; + const char *devices = nullptr; // This extension gives us all audio paths on all drivers. - if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE) { - string default_device = alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); - devices = (const char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); + if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE) { + string default_device = alcGetString(nullptr, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); + devices = (const char *)alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER); if (devices) { audio_cat.debug() << "All OpenAL devices:\n"; @@ -272,9 +272,9 @@ select_audio_device() { // This extension just gives us generic driver names, like "OpenAL Soft" and // "Generic Software", rather than individual outputs. - if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE) { - string default_device = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); - devices = (const char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER); + if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT") == AL_TRUE) { + string default_device = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER); + devices = (const char *)alcGetString(nullptr, ALC_DEVICE_SPECIFIER); if (devices) { audio_cat.debug() << "OpenAL drivers:\n"; @@ -402,14 +402,14 @@ get_sound_data(MovieAudio *movie, int mode) { } PT(MovieAudioCursor) stream = movie->open(); - if (stream == 0) { + if (stream == nullptr) { audio_error("Cannot open file: "<_sample == 0) { audio_error("Could not create an OpenAL buffer object"); delete sd; - return NULL; + return nullptr; } int channels = stream->audio_channels(); int samples = (int)(stream->length() * stream->audio_rate()); @@ -448,7 +448,7 @@ get_sound_data(MovieAudio *movie, int mode) { if (err != AL_NO_ERROR) { audio_error("could not fill OpenAL buffer object with data"); delete sd; - return NULL; + return nullptr; } _sample_cache.insert(SampleCache::value_type(path, sd)); } else { @@ -498,7 +498,7 @@ get_sound(const string &file_name, bool positional, int mode) { if (path.empty()) { audio_error("get_sound - invalid filename"); - return NULL; + return nullptr; } PT(MovieAudio) mva = MovieAudio::get(path); @@ -1007,18 +1007,18 @@ cleanup() { // make sure that the context is not current when it is destroyed alcGetError(_device); // clear errors - alcMakeContextCurrent(NULL); + alcMakeContextCurrent(nullptr); alc_audio_errcheck("alcMakeContextCurrent(NULL)",_device); alcDestroyContext(_context); alc_audio_errcheck("alcDestroyContext(_context)",_device); - _context = NULL; + _context = nullptr; if (_device) { audio_debug("Going to try to close openAL"); alcCloseDevice(_device); // alc_audio_errcheck("alcCloseDevice(_device)",_device); - _device = NULL; + _device = nullptr; audio_debug("openAL Closed"); } @@ -1033,9 +1033,9 @@ cleanup() { */ OpenALAudioManager::SoundData:: SoundData() : - _manager(0), + _manager(nullptr), _sample(0), - _stream(NULL), + _stream(nullptr), _length(0.0), _rate(0), _channels(0), diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index 9a090adc3d..5bbf56e871 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -76,7 +76,7 @@ release_sound_data(bool force) { */ INLINE bool OpenALAudioSound:: is_valid() const { - return _manager != NULL; + return _manager != nullptr; } /** @@ -98,5 +98,5 @@ is_playing() const { */ INLINE bool OpenALAudioSound:: has_sound_data() const { - return _sd != NULL; + return _sd != nullptr; } diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index faa9df5717..2a697a642b 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -38,7 +38,7 @@ OpenALAudioSound(OpenALAudioManager* manager, bool positional, int mode) : _movie(movie), - _sd(NULL), + _sd(nullptr), _playing_loops(0), _playing_rate(0.0), _loops_completed(0), @@ -109,7 +109,7 @@ cleanup() { release_sound_data(true); } _manager->release_sound(this); - _manager = 0; + _manager = nullptr; } /** diff --git a/panda/src/awesomium/WebBrowserTexture.cxx b/panda/src/awesomium/WebBrowserTexture.cxx index 7872574b9d..04908f4abc 100644 --- a/panda/src/awesomium/WebBrowserTexture.cxx +++ b/panda/src/awesomium/WebBrowserTexture.cxx @@ -149,7 +149,7 @@ bool WebBrowserTexture::get_flip_texture_active() const { bool WebBrowserTexture::cull_callback(CullTraverser *trav, const CullTraverserData &data) const{ // see if we are in a state where udpates can happen. else just return if( !_update_active ) return true; - if( _aw_web_view == NULL ) return true; + if( _aw_web_view == nullptr ) return true; // do we even need to update? if( !_aw_web_view->is_dirty() ) return true; diff --git a/panda/src/awesomium/WebBrowserTexture.h b/panda/src/awesomium/WebBrowserTexture.h index e9ae392d10..112f8399da 100644 --- a/panda/src/awesomium/WebBrowserTexture.h +++ b/panda/src/awesomium/WebBrowserTexture.h @@ -37,7 +37,7 @@ protected: private: WebBrowserTexture(const WebBrowserTexture ©); PUBLISHED: - WebBrowserTexture(const string &name, AwWebView* aw_web_view = NULL); + WebBrowserTexture(const string &name, AwWebView* aw_web_view = nullptr); virtual ~WebBrowserTexture(); diff --git a/panda/src/bullet/bulletAllHitsRayResult.cxx b/panda/src/bullet/bulletAllHitsRayResult.cxx index 12c6abacc4..1b638efcf9 100644 --- a/panda/src/bullet/bulletAllHitsRayResult.cxx +++ b/panda/src/bullet/bulletAllHitsRayResult.cxx @@ -136,7 +136,7 @@ get_hit_fraction() const { PandaNode *BulletRayHit:: get_node() const { - return (_object) ? (PandaNode *)_object->getUserPointer() : NULL; + return (_object) ? (PandaNode *)_object->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index f02641cd96..565cfa35a2 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -310,7 +310,7 @@ BulletShape *BulletBodyNode:: get_shape(int idx) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL); + nassertr(idx >= 0 && idx < (int)_shapes.size(), nullptr); return _shapes[idx]; } @@ -334,7 +334,7 @@ do_add_shape(BulletShape *bullet_shape, const TransformState *ts) { nassertv(ts); btCollisionShape *shape = bullet_shape->ptr(); - nassertv(shape != NULL); + nassertv(shape != nullptr); nassertv(!(shape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE && ((btConvexHullShape *)shape)->getNumVertices() == 0)); @@ -782,7 +782,7 @@ void BulletBodyNode:: add_shapes_from_collision_solids(CollisionNode *cnode) { LightMutexHolder holder(BulletWorld::get_global_lock()); - PT(BulletTriangleMesh) mesh = NULL; + PT(BulletTriangleMesh) mesh = nullptr; for (int j=0; jget_num_solids(); j++) { CPT(CollisionSolid) solid = cnode->get_solid(j); @@ -864,7 +864,7 @@ cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << */ btVector3 center; - btScalar radius; + btScalar radius = 0; if (_shape) { _shape->getBoundingSphere(center, radius); @@ -914,7 +914,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { } // Write NULL pointer to indicate the end of the list. - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); } /** @@ -927,7 +927,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { PT(BulletShape) shape = DCAST(BulletShape, p_list[pi++]); - while (shape != (BulletShape *)NULL) { + while (shape != nullptr) { const TransformState *trans = DCAST(TransformState, p_list[pi++]); add_shape(shape, trans); diff --git a/panda/src/bullet/bulletClosestHitRayResult.cxx b/panda/src/bullet/bulletClosestHitRayResult.cxx index 2e831c9308..094d404a6e 100644 --- a/panda/src/bullet/bulletClosestHitRayResult.cxx +++ b/panda/src/bullet/bulletClosestHitRayResult.cxx @@ -78,7 +78,7 @@ PandaNode *BulletClosestHitRayResult:: get_node() const { const btCollisionObject *objectPtr = m_collisionObject; - return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; + return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletClosestHitSweepResult.cxx b/panda/src/bullet/bulletClosestHitSweepResult.cxx index f86bc0456a..0e3d08ffc4 100644 --- a/panda/src/bullet/bulletClosestHitSweepResult.cxx +++ b/panda/src/bullet/bulletClosestHitSweepResult.cxx @@ -60,7 +60,7 @@ PandaNode *BulletClosestHitSweepResult:: get_node() const { const btCollisionObject *objectPtr = m_hitCollisionObject; - return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; + return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletContactCallbacks.h b/panda/src/bullet/bulletContactCallbacks.h index 27e8093e55..e368e6ee0c 100644 --- a/panda/src/bullet/bulletContactCallbacks.h +++ b/panda/src/bullet/bulletContactCallbacks.h @@ -51,7 +51,7 @@ contact_added_callback(btManifoldPoint &cp, int id1, int index1) { - if (cp.m_userPersistentData == NULL) { + if (cp.m_userPersistentData == nullptr) { #if BT_BULLET_VERSION >= 281 PT(PandaNode) node0 = (PandaNode *)wrap0->getCollisionObject()->getUserPointer(); diff --git a/panda/src/bullet/bulletContactResult.cxx b/panda/src/bullet/bulletContactResult.cxx index 4d9e2588bd..ad4e5b8801 100644 --- a/panda/src/bullet/bulletContactResult.cxx +++ b/panda/src/bullet/bulletContactResult.cxx @@ -22,8 +22,8 @@ BulletContact BulletContactResult::_empty; BulletContact:: BulletContact() : _mp(_empty) { - _node0 = NULL; - _node1 = NULL; + _node0 = nullptr; + _node1 = nullptr; } /** @@ -47,8 +47,8 @@ BulletContactResult:: BulletContactResult() : btCollisionWorld::ContactResultCallback() { #if BT_BULLET_VERSION >= 281 - _filter_cb = NULL; - _filter_proxy = NULL; + _filter_cb = nullptr; + _filter_proxy = nullptr; _filter_set = false; #endif } @@ -96,8 +96,8 @@ addSingleResult(btManifoldPoint &mp, BulletContact contact; contact._mp = BulletManifoldPoint(mp); - contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : NULL; - contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : NULL; + contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr; + contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr; contact._part_id0 = part_id0; contact._part_id1 = part_id1; contact._idx0 = idx0; @@ -119,8 +119,8 @@ addSingleResult(btManifoldPoint &mp, BulletContact contact; contact._mp = BulletManifoldPoint(mp); - contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : NULL; - contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : NULL; + contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr; + contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr; contact._part_id0 = part_id0; contact._part_id1 = part_id1; contact._idx0 = idx0; diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 07d559c2fd..487219c7fd 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -25,7 +25,7 @@ TypeHandle BulletConvexHullShape::_type_handle; BulletConvexHullShape:: BulletConvexHullShape() { - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); } @@ -36,7 +36,7 @@ BulletConvexHullShape:: BulletConvexHullShape(const BulletConvexHullShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); #if BT_BULLET_VERSION >= 282 @@ -80,7 +80,7 @@ add_array(const PTA_LVecBase3 &points) { if (_shape) delete _shape; - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); PTA_LVecBase3::const_iterator it; @@ -123,20 +123,18 @@ add_geom(const Geom *geom, const TransformState *ts) { delete _shape; // Create shape - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); pvector::const_iterator it; #if BT_BULLET_VERSION >= 282 for (it = points.begin(); it != points.end(); ++it) { - LVecBase3 v = *it; _shape->addPoint(LVecBase3_to_btVector3(*it), false); } _shape->recalcLocalAabb(); #else for (it = points.begin(); it != points.end(); ++it) { - LVecBase3 v = *it; _shape->addPoint(LVecBase3_to_btVector3(*it)); } #endif diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index 14b693bda6..fad9e8141a 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -133,10 +133,10 @@ PandaNode *BulletGhostNode:: get_overlapping_node(int idx) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), NULL); + nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), nullptr); btCollisionObject *object = _ghost->getOverlappingObject(idx); - return (object) ? (PandaNode *)object->getUserPointer() : NULL; + return (object) ? (PandaNode *)object->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletHelper.I b/panda/src/bullet/bulletHelper.I index 51c4f4b830..85e168eb70 100644 --- a/panda/src/bullet/bulletHelper.I +++ b/panda/src/bullet/bulletHelper.I @@ -17,7 +17,7 @@ INLINE PT(InternalName) BulletHelper:: get_sb_index() { - if (_sb_index == (InternalName *)NULL) { + if (_sb_index == nullptr) { _sb_index = InternalName::make("sb_index"); } return _sb_index; @@ -29,7 +29,7 @@ get_sb_index() { INLINE PT(InternalName) BulletHelper:: get_sb_flip() { - if (_sb_flip == (InternalName *)NULL) { + if (_sb_flip == nullptr) { _sb_flip = InternalName::make("sb_flip"); } return _sb_flip; diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index a12a773740..d5e3f503b4 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -37,7 +37,7 @@ from_collision_solids(NodePath &np, bool clear) { NodePath cnp = npc.get_path(i); CollisionNode *cnode = DCAST(CollisionNode, cnp.node()); - PT(PandaNode) bnode = NULL; + PT(PandaNode) bnode = nullptr; // Create a either a new rigid body or a new ghost for each CollisionNode, // and add one shape per CollisionSolid contained in the CollisionNode @@ -179,8 +179,8 @@ make_geom(BulletSoftBodyNode *node, const GeomVertexFormat *format, bool two_sid CPT(GeomVertexFormat) fmt = (format) ? format : GeomVertexFormat::get_v3n3t2(); fmt = BulletHelper::add_sb_flip_column(fmt); - nassertr(fmt->has_column(InternalName::get_vertex()), NULL); - nassertr(fmt->has_column(InternalName::get_normal()), NULL); + nassertr(fmt->has_column(InternalName::get_vertex()), nullptr); + nassertr(fmt->has_column(InternalName::get_normal()), nullptr); btSoftBody::tNodeArray &nodes(body->m_nodes); diff --git a/panda/src/bullet/bulletHelper.h b/panda/src/bullet/bulletHelper.h index c63f70f111..f2195d4d92 100644 --- a/panda/src/bullet/bulletHelper.h +++ b/panda/src/bullet/bulletHelper.h @@ -43,11 +43,11 @@ PUBLISHED: // Geom utils static PT(Geom) make_geom_from_faces(BulletSoftBodyNode *node, - const GeomVertexFormat *format=NULL, + const GeomVertexFormat *format=nullptr, bool two_sided=false); static PT(Geom) make_geom_from_links(BulletSoftBodyNode *node, - const GeomVertexFormat *format=NULL); + const GeomVertexFormat *format=nullptr); static void make_texcoords_for_patch(Geom *geom, int resx, int resy); diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index e42ea3c6f8..67d760e8df 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -65,7 +65,7 @@ get_node0() { const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody0(); #endif - return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; + return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr; } /** @@ -81,7 +81,7 @@ get_node1() { const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody1(); #endif - return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; + return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr; } /** @@ -101,7 +101,7 @@ BulletManifoldPoint *BulletPersistentManifold:: get_manifold_point(int idx) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx < _manifold->getNumContacts(), NULL) + nassertr(idx < _manifold->getNumContacts(), nullptr) return new BulletManifoldPoint(_manifold->getContactPoint(idx)); } diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index dfee91f12c..95aa16d9ef 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -29,7 +29,7 @@ class EXPCL_PANDABULLET BulletPlaneShape : public BulletShape { private: // Only used by make_from_bam - INLINE BulletPlaneShape() : _shape(NULL) {}; + INLINE BulletPlaneShape() : _shape(nullptr) {}; PUBLISHED: explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 8321c610f1..546a73f311 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -41,15 +41,15 @@ BulletSoftBodyNode(btSoftBody *body, const char *name) : BulletBodyNode(name) { // Shape btCollisionShape *shape_ptr = _soft->getCollisionShape(); - nassertv(shape_ptr != NULL); + nassertv(shape_ptr != nullptr); nassertv(shape_ptr->getShapeType() == SOFTBODY_SHAPE_PROXYTYPE); _shapes.push_back(new BulletSoftBodyShape((btSoftBodyCollisionShape *)shape_ptr)); // Rendering - _geom = NULL; - _curve = NULL; - _surface = NULL; + _geom = nullptr; + _curve = nullptr; + _surface = nullptr; } /** @@ -385,7 +385,7 @@ void BulletSoftBodyNode:: unlink_geom() { LightMutexHolder holder(BulletWorld::get_global_lock()); - _geom = NULL; + _geom = nullptr; } /** @@ -407,7 +407,7 @@ void BulletSoftBodyNode:: unlink_curve() { LightMutexHolder holder(BulletWorld::get_global_lock()); - _curve = NULL; + _curve = nullptr; } /** @@ -429,7 +429,7 @@ void BulletSoftBodyNode:: unlink_surface() { LightMutexHolder holder(BulletWorld::get_global_lock()); - _surface = NULL; + _surface = nullptr; } /** @@ -851,7 +851,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indic num_triangles, randomizeConstraints); - nassertr(body, NULL); + nassertr(body, nullptr); delete[] vertices; delete[] triangles; @@ -873,7 +873,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeCon CPT(GeomVertexData) vdata = geom->get_vertex_data(); - nassertr(vdata->has_column(InternalName::get_vertex()), NULL); + nassertr(vdata->has_column(InternalName::get_vertex()), nullptr); GeomVertexReader vreader(vdata, InternalName::get_vertex()); @@ -953,7 +953,7 @@ make_tet_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indic PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_tet_mesh(BulletSoftBodyWorldInfo &info, const char *ele, const char *face, const char *node) { - nassertr(node && node[0], NULL); + nassertr(node && node[0], nullptr); // Nodes btAlignedObjectArray pos; diff --git a/panda/src/bullet/bulletSoftBodyNode.h b/panda/src/bullet/bulletSoftBodyNode.h index 600e185fac..26d7cc6fce 100644 --- a/panda/src/bullet/bulletSoftBodyNode.h +++ b/panda/src/bullet/bulletSoftBodyNode.h @@ -78,7 +78,7 @@ PUBLISHED: BulletSoftBodyConfig get_cfg(); BulletSoftBodyWorldInfo get_world_info(); - void generate_bending_constraints(int distance, BulletSoftBodyMaterial *material=NULL); + void generate_bending_constraints(int distance, BulletSoftBodyMaterial *material=nullptr); void randomize_constraints(); // Mass, volume, density @@ -146,7 +146,7 @@ PUBLISHED: PN_stdfloat erp=1.0, PN_stdfloat cfm=1.0, PN_stdfloat split=1.0, - BulletSoftBodyControl *control=NULL); + BulletSoftBodyControl *control=nullptr); // Materials int get_num_materials() const; diff --git a/panda/src/bullet/bulletSoftBodyShape.cxx b/panda/src/bullet/bulletSoftBodyShape.cxx index 9e6aa2929b..c6df128687 100644 --- a/panda/src/bullet/bulletSoftBodyShape.cxx +++ b/panda/src/bullet/bulletSoftBodyShape.cxx @@ -47,6 +47,6 @@ get_body() const { } else { - return NULL; + return nullptr; } } diff --git a/panda/src/bullet/bulletSphereShape.h b/panda/src/bullet/bulletSphereShape.h index aad49a145c..e0634d50c2 100644 --- a/panda/src/bullet/bulletSphereShape.h +++ b/panda/src/bullet/bulletSphereShape.h @@ -28,7 +28,7 @@ class EXPCL_PANDABULLET BulletSphereShape : public BulletShape { private: // Only used by make_from_bam - INLINE BulletSphereShape() : _shape(NULL) {}; + INLINE BulletSphereShape() : _shape(nullptr) {}; PUBLISHED: explicit BulletSphereShape(PN_stdfloat radius); diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index e2d3e0b242..9286a2d010 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -423,7 +423,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // Add the vertices. const unsigned char *vptr = mesh.m_vertexBase; - nassertv(vptr != NULL || mesh.m_numVertices == 0); + nassertv(vptr != nullptr || mesh.m_numVertices == 0); for (int i = 0; i < mesh.m_numVertices; ++i) { const btVector3 &vertex = *((btVector3 *)vptr); @@ -435,7 +435,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // Now add the triangle indices. const unsigned char *iptr = mesh.m_triangleIndexBase; - nassertv(iptr != NULL || mesh.m_numTriangles == 0); + nassertv(iptr != nullptr || mesh.m_numTriangles == 0); for (int i = 0; i < mesh.m_numTriangles; ++i) { int *triangle = (int *)iptr; diff --git a/panda/src/bullet/bulletTriangleMeshShape.I b/panda/src/bullet/bulletTriangleMeshShape.I index f178723ebc..f1263cbed6 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.I +++ b/panda/src/bullet/bulletTriangleMeshShape.I @@ -32,7 +32,7 @@ INLINE BulletTriangleMeshShape:: INLINE bool BulletTriangleMeshShape:: is_static() const { - return (_bvh_shape != NULL); + return (_bvh_shape != nullptr); } /** @@ -41,5 +41,5 @@ is_static() const { INLINE bool BulletTriangleMeshShape:: is_dynamic() const { - return (_gimpact_shape != NULL); + return (_gimpact_shape != nullptr); } diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index ced374a3fc..ca9f7288cc 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -25,9 +25,9 @@ TypeHandle BulletTriangleMeshShape::_type_handle; */ BulletTriangleMeshShape:: BulletTriangleMeshShape() : - _mesh(NULL), - _gimpact_shape(NULL), - _bvh_shape(NULL), + _mesh(nullptr), + _gimpact_shape(nullptr), + _bvh_shape(nullptr), _dynamic(false), _compress(false), _bvh(false) { @@ -66,7 +66,7 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b _gimpact_shape->updateBound(); _gimpact_shape->setUserPointer(this); - _bvh_shape = NULL; + _bvh_shape = nullptr; } // Static will create a Bvh mesh shape @@ -75,7 +75,7 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b _bvh_shape = new btBvhTriangleMeshShape(mesh->ptr(), compress, bvh); _bvh_shape->setUserPointer(this); - _gimpact_shape = NULL; + _gimpact_shape = nullptr; } } @@ -95,11 +95,11 @@ BulletTriangleMeshShape(const BulletTriangleMeshShape ©) { _gimpact_shape = new btGImpactMeshShape(_mesh->ptr()); _gimpact_shape->updateBound(); _gimpact_shape->setUserPointer(this); - _bvh_shape = NULL; + _bvh_shape = nullptr; } else { _bvh_shape = new btBvhTriangleMeshShape(_mesh->ptr(), _compress, _bvh); _bvh_shape->setUserPointer(this); - _gimpact_shape = NULL; + _gimpact_shape = nullptr; } } @@ -117,7 +117,7 @@ ptr() const { return _gimpact_shape; } - return NULL; + return nullptr; } /** @@ -174,7 +174,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { _mesh = DCAST(BulletTriangleMesh, p_list[pi++]); btStridingMeshInterface *mesh_ptr = _mesh->ptr(); - nassertr(mesh_ptr != NULL, pi); + nassertr(mesh_ptr != nullptr, pi); if (_dynamic) { _gimpact_shape = new btGImpactMeshShape(mesh_ptr); diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index e2d74c131d..8d0f479dee 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -76,7 +76,7 @@ BulletRigidBodyNode *BulletVehicle:: do_get_chassis() { btRigidBody *bodyPtr = _vehicle->getRigidBody(); - return (bodyPtr) ? (BulletRigidBodyNode *)bodyPtr->getUserPointer() : NULL; + return (bodyPtr) ? (BulletRigidBodyNode *)bodyPtr->getUserPointer() : nullptr; } /** @@ -180,7 +180,7 @@ create_wheel() { btWheelInfo &info = _vehicle->addWheel(pos, direction, axle, suspension, radius, _tuning._, false); - info.m_clientInfo = NULL; + info.m_clientInfo = nullptr; return BulletWheel(info); } diff --git a/panda/src/bullet/bulletWheel.cxx b/panda/src/bullet/bulletWheel.cxx index 149dbd8bf5..c24369546b 100644 --- a/panda/src/bullet/bulletWheel.cxx +++ b/panda/src/bullet/bulletWheel.cxx @@ -517,7 +517,7 @@ PandaNode *BulletWheel:: get_node() const { LightMutexHolder holder(BulletWorld::get_global_lock()); - return (_info.m_clientInfo == NULL) ? NULL : (PandaNode *)_info.m_clientInfo; + return (_info.m_clientInfo == nullptr) ? nullptr : (PandaNode *)_info.m_clientInfo; } /** @@ -597,5 +597,5 @@ PandaNode *BulletWheelRaycastInfo:: get_ground_object() const { LightMutexHolder holder(BulletWorld::get_global_lock()); - return _info.m_groundObject ? (PandaNode *)_info.m_groundObject : NULL; + return _info.m_groundObject ? (PandaNode *)_info.m_groundObject : nullptr; } diff --git a/panda/src/bullet/bulletWorld.I b/panda/src/bullet/bulletWorld.I index 61893a1531..d79534c865 100644 --- a/panda/src/bullet/bulletWorld.I +++ b/panda/src/bullet/bulletWorld.I @@ -65,7 +65,7 @@ get_debug_node() const { INLINE bool BulletWorld:: has_debug_node() const { - return _debug != NULL; + return _debug != nullptr; } /** diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 6098759581..6827140e93 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -95,13 +95,13 @@ BulletWorld() { break; default: bullet_cat.error() << "no proper filter algorithm!" << endl; - _filter_cb = NULL; + _filter_cb = nullptr; } _world->getPairCache()->setOverlapFilterCallback(_filter_cb); // Tick callback - _tick_callback_obj = NULL; + _tick_callback_obj = nullptr; // SoftBodyWorldInfo _info.m_dispatcher = _dispatcher; @@ -786,7 +786,7 @@ BulletRigidBodyNode *BulletWorld:: get_rigid_body(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_bodies.size(), NULL); + nassertr(idx >= 0 && idx < (int)_bodies.size(), nullptr); return _bodies[idx]; } @@ -807,7 +807,7 @@ BulletSoftBodyNode *BulletWorld:: get_soft_body(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_softbodies.size(), NULL); + nassertr(idx >= 0 && idx < (int)_softbodies.size(), nullptr); return _softbodies[idx]; } @@ -828,7 +828,7 @@ BulletGhostNode *BulletWorld:: get_ghost(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_ghosts.size(), NULL); + nassertr(idx >= 0 && idx < (int)_ghosts.size(), nullptr); return _ghosts[idx]; } @@ -849,7 +849,7 @@ BulletBaseCharacterControllerNode *BulletWorld:: get_character(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_characters.size(), NULL); + nassertr(idx >= 0 && idx < (int)_characters.size(), nullptr); return _characters[idx]; } @@ -870,7 +870,7 @@ BulletVehicle *BulletWorld:: get_vehicle(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_vehicles.size(), NULL); + nassertr(idx >= 0 && idx < (int)_vehicles.size(), nullptr); return _vehicles[idx]; } @@ -891,7 +891,7 @@ BulletConstraint *BulletWorld:: get_constraint(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_constraints.size(), NULL); + nassertr(idx >= 0 && idx < (int)_constraints.size(), nullptr); return _constraints[idx]; } @@ -1052,10 +1052,10 @@ BulletPersistentManifold *BulletWorld:: get_manifold(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx < _dispatcher->getNumManifolds(), NULL); + nassertr(idx < _dispatcher->getNumManifolds(), nullptr); btPersistentManifold *ptr = _dispatcher->getManifoldByIndexInternal(idx); - return (ptr) ? new BulletPersistentManifold(ptr) : NULL; + return (ptr) ? new BulletPersistentManifold(ptr) : nullptr; } /** @@ -1077,7 +1077,7 @@ get_collision_object(PandaNode *node) { return ((BulletSoftBodyNode *)node)->get_object(); } - return NULL; + return nullptr; } /** @@ -1148,7 +1148,7 @@ clear_contact_added_callback() { _world->getSolverInfo().m_solverMode &= ~SOLVER_USE_2_FRICTION_DIRECTIONS; _world->getSolverInfo().m_solverMode &= ~SOLVER_ENABLE_FRICTION_DIRECTION_CACHING; - bullet_contact_added_callback = NULL; + bullet_contact_added_callback = nullptr; } /** @@ -1158,7 +1158,7 @@ void BulletWorld:: set_tick_callback(CallbackObject *obj, bool is_pretick) { LightMutexHolder holder(get_global_lock()); - nassertv(obj != NULL); + nassertv(obj != nullptr); _tick_callback_obj = obj; _world->setInternalTickCallback(&BulletWorld::tick_callback, this, is_pretick); } @@ -1170,8 +1170,8 @@ void BulletWorld:: clear_tick_callback() { LightMutexHolder holder(get_global_lock()); - _tick_callback_obj = NULL; - _world->setInternalTickCallback(NULL); + _tick_callback_obj = nullptr; + _world->setInternalTickCallback(nullptr); } /** @@ -1202,7 +1202,7 @@ void BulletWorld:: set_filter_callback(CallbackObject *obj) { LightMutexHolder holder(get_global_lock()); - nassertv(obj != NULL); + nassertv(obj != nullptr); if (_filter_algorithm != FA_callback) { bullet_cat.warning() << "filter algorithm is not 'callback'" << endl; @@ -1218,7 +1218,7 @@ void BulletWorld:: clear_filter_callback() { LightMutexHolder holder(get_global_lock()); - _filter_cb3._filter_callback_obj = NULL; + _filter_cb3._filter_callback_obj = nullptr; } /** diff --git a/panda/src/chan/animBundle.cxx b/panda/src/chan/animBundle.cxx index ad67124966..312483b3be 100644 --- a/panda/src/chan/animBundle.cxx +++ b/panda/src/chan/animBundle.cxx @@ -32,7 +32,7 @@ AnimBundle(AnimGroup *parent, const AnimBundle ©) : _fps(copy._fps), _num_frames(copy._num_frames) { - nassertv(_root == (AnimBundle *)NULL); + nassertv(_root == nullptr); _root = this; } @@ -43,7 +43,7 @@ AnimBundle(AnimGroup *parent, const AnimBundle ©) : */ PT(AnimBundle) AnimBundle:: copy_bundle() const { - PT(AnimGroup) group = copy_subtree((AnimGroup *)NULL); + PT(AnimGroup) group = copy_subtree(nullptr); return DCAST(AnimBundle, group.p()); } diff --git a/panda/src/chan/animBundleNode.cxx b/panda/src/chan/animBundleNode.cxx index b3e49ca6a7..f6fab7a110 100644 --- a/panda/src/chan/animBundleNode.cxx +++ b/panda/src/chan/animBundleNode.cxx @@ -46,12 +46,12 @@ safe_to_flatten() const { */ AnimBundle *AnimBundleNode:: find_anim_bundle(PandaNode *root) { - nassertr(root != (PandaNode *)NULL, NULL); + nassertr(root != nullptr, nullptr); if (root->is_of_type(AnimBundleNode::get_class_type())) { AnimBundleNode *anode = DCAST(AnimBundleNode, root); AnimBundle *anim = anode->get_bundle(); - if (anim != (AnimBundle *)NULL) { + if (anim != nullptr) { return anim; } } @@ -60,12 +60,12 @@ find_anim_bundle(PandaNode *root) { int num_children = cr.get_num_children(); for (int i = 0; i < num_children; i++) { AnimBundle *anim = find_anim_bundle(cr.get_child(i)); - if (anim != (AnimBundle *)NULL) { + if (anim != nullptr) { return anim; } } - return NULL; + return nullptr; } /** diff --git a/panda/src/chan/animChannel.I b/panda/src/chan/animChannel.I index 6dd73d5240..d776b938e5 100644 --- a/panda/src/chan/animChannel.I +++ b/panda/src/chan/animChannel.I @@ -71,7 +71,7 @@ INLINE AnimChannel:: */ template void AnimChannel:: -get_value(int, TYPENAME AnimChannel::ValueType &) { +get_value(int, typename AnimChannel::ValueType &) { } #endif diff --git a/panda/src/chan/animChannel.h b/panda/src/chan/animChannel.h index 4137196f52..531511660e 100644 --- a/panda/src/chan/animChannel.h +++ b/panda/src/chan/animChannel.h @@ -33,7 +33,7 @@ protected: INLINE AnimChannel(const string &name = ""); INLINE AnimChannel(AnimGroup *parent, const AnimChannel ©); public: - typedef TYPENAME SwitchType::ValueType ValueType; + typedef typename SwitchType::ValueType ValueType; INLINE AnimChannel(AnimGroup *parent, const string &name); INLINE ~AnimChannel(); diff --git a/panda/src/chan/animChannelFixed.h b/panda/src/chan/animChannelFixed.h index 9940f5bdcf..0ad0ff5696 100644 --- a/panda/src/chan/animChannelFixed.h +++ b/panda/src/chan/animChannelFixed.h @@ -28,7 +28,7 @@ template class AnimChannelFixed : public AnimChannel { public: - typedef TYPENAME AnimChannel::ValueType ValueType; + typedef typename AnimChannel::ValueType ValueType; protected: INLINE AnimChannelFixed(AnimGroup *parent, const AnimChannelFixed ©); diff --git a/panda/src/chan/animChannelMatrixDynamic.cxx b/panda/src/chan/animChannelMatrixDynamic.cxx index fb60451bc3..1fa762e782 100644 --- a/panda/src/chan/animChannelMatrixDynamic.cxx +++ b/panda/src/chan/animChannelMatrixDynamic.cxx @@ -41,7 +41,7 @@ AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic © AnimChannelMatrix(parent, copy), _value_node(copy._value_node), _value(copy._value), - _last_value(NULL) + _last_value(nullptr) { } @@ -53,7 +53,7 @@ AnimChannelMatrixDynamic(const string &name) : AnimChannelMatrix(name) { _value = TransformState::make_identity(); - _last_value = NULL; // This is impossible; thus, has_changed() will + _last_value = nullptr; // This is impossible; thus, has_changed() will // always return true the first time. } @@ -64,7 +64,7 @@ AnimChannelMatrixDynamic(const string &name) */ bool AnimChannelMatrixDynamic:: has_changed(int, double, int, double) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } bool has_changed = (_value != _last_value); @@ -77,7 +77,7 @@ has_changed(int, double, int, double) { */ void AnimChannelMatrixDynamic:: get_value(int, LMatrix4 &mat) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } mat = _value->get_mat(); @@ -89,7 +89,7 @@ get_value(int, LMatrix4 &mat) { */ void AnimChannelMatrixDynamic:: get_value_no_scale_shear(int, LMatrix4 &mat) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } if (_value->has_scale() || _value->has_shear()) { @@ -105,7 +105,7 @@ get_value_no_scale_shear(int, LMatrix4 &mat) { */ void AnimChannelMatrixDynamic:: get_scale(int, LVecBase3 &scale) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } scale = _value->get_scale(); @@ -117,7 +117,7 @@ get_scale(int, LVecBase3 &scale) { */ void AnimChannelMatrixDynamic:: get_hpr(int, LVecBase3 &hpr) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } hpr = _value->get_hpr(); @@ -130,7 +130,7 @@ get_hpr(int, LVecBase3 &hpr) { */ void AnimChannelMatrixDynamic:: get_quat(int, LQuaternion &quat) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } quat = _value->get_quat(); @@ -142,7 +142,7 @@ get_quat(int, LQuaternion &quat) { */ void AnimChannelMatrixDynamic:: get_pos(int, LVecBase3 &pos) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } pos = _value->get_pos(); @@ -154,7 +154,7 @@ get_pos(int, LVecBase3 &pos) { */ void AnimChannelMatrixDynamic:: get_shear(int, LVecBase3 &shear) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } shear = _value->get_shear(); @@ -186,7 +186,7 @@ set_value(const TransformState *value) { void AnimChannelMatrixDynamic:: set_value_node(PandaNode *value_node) { _value_node = value_node; - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } } diff --git a/panda/src/chan/animChannelMatrixXfmTable.I b/panda/src/chan/animChannelMatrixXfmTable.I index 93fceb143c..e86bc56658 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.I +++ b/panda/src/chan/animChannelMatrixXfmTable.I @@ -41,7 +41,7 @@ has_table(char table_id) const { if (table_index < 0) { return false; } - return !(_tables[table_index] == (const PN_stdfloat *)NULL); + return !(_tables[table_index] == nullptr); } /** @@ -51,7 +51,7 @@ INLINE void AnimChannelMatrixXfmTable:: clear_table(char table_id) { int table_index = get_table_index(table_id); if (table_index >= 0) { - _tables[table_index] = NULL; + _tables[table_index] = nullptr; } } diff --git a/panda/src/chan/animChannelMatrixXfmTable.cxx b/panda/src/chan/animChannelMatrixXfmTable.cxx index 6c404d06fe..ec9564ee88 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.cxx +++ b/panda/src/chan/animChannelMatrixXfmTable.cxx @@ -377,7 +377,7 @@ write_datagram(BamWriter *manager, Datagram &me) { PN_stdfloat r = _tables[8].empty() ? 0.0f : _tables[8][i % _tables[8].size()]; hprs.push_back(LVecBase3(h, p, r)); } - const LVecBase3 *hprs_array = NULL; + const LVecBase3 *hprs_array = nullptr; if (hprs_length != 0) { hprs_array = &hprs[0]; } diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index ead0d539a6..a5597110ba 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -41,7 +41,7 @@ AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic © AnimChannelScalar(parent, copy), _value_node(copy._value_node), _value(copy._value), - _last_value(NULL), + _last_value(nullptr), _value_changed(true), _float_value(copy._float_value) { @@ -66,7 +66,7 @@ AnimChannelScalarDynamic(const string &name) */ bool AnimChannelScalarDynamic:: has_changed(int, double, int, double) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); bool has_changed = (_value != _last_value); _last_value = _value; @@ -84,7 +84,7 @@ has_changed(int, double, int, double) { */ void AnimChannelScalarDynamic:: get_value(int, PN_stdfloat &value) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { value = _value->get_pos()[0]; } else { @@ -108,13 +108,13 @@ set_value(PN_stdfloat value) { */ void AnimChannelScalarDynamic:: set_value_node(PandaNode *value_node) { - if (_value_node == (PandaNode *)NULL) { + if (_value_node == nullptr) { _last_value = TransformState::make_pos(LVecBase3(_float_value, 0.0f, 0.0f)); } _value_node = value_node; - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } } diff --git a/panda/src/chan/animChannelScalarTable.I b/panda/src/chan/animChannelScalarTable.I index 1a41648490..b9dda3154c 100644 --- a/panda/src/chan/animChannelScalarTable.I +++ b/panda/src/chan/animChannelScalarTable.I @@ -25,7 +25,7 @@ get_table() const { */ INLINE bool AnimChannelScalarTable:: has_table() const { - return _table != (const PN_stdfloat *)NULL; + return _table != nullptr; } @@ -34,5 +34,5 @@ has_table() const { */ INLINE void AnimChannelScalarTable:: clear_table() { - _table = NULL; + _table = nullptr; } diff --git a/panda/src/chan/animControl.I b/panda/src/chan/animControl.I index 3b79891fc4..4c493dd943 100644 --- a/panda/src/chan/animControl.I +++ b/panda/src/chan/animControl.I @@ -28,7 +28,7 @@ is_pending() const { */ INLINE bool AnimControl:: has_anim() const { - return (_anim != (AnimBundle *)NULL); + return (_anim != nullptr); } /** diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index 35e56374f7..34fd94646e 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -40,7 +40,7 @@ AnimControl(const string &name, PartBundle *part, _pending = true; _part = part; - _anim = NULL; + _anim = nullptr; _channel_index = -1; set_frame_rate(frame_rate); set_num_frames(num_frames); @@ -57,7 +57,7 @@ setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints) { MutexHolder holder(_pending_lock); nassertv(_pending && part == _part); - nassertv(_anim == (AnimBundle *)NULL); + nassertv(_anim == nullptr); _anim = anim; _channel_index = channel_index; _bound_joints = bound_joints; diff --git a/panda/src/chan/animControlCollection.I b/panda/src/chan/animControlCollection.I index fd4b7251b1..2492c3ad03 100644 --- a/panda/src/chan/animControlCollection.I +++ b/panda/src/chan/animControlCollection.I @@ -17,7 +17,7 @@ INLINE bool AnimControlCollection:: play(const string &anim_name) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -31,7 +31,7 @@ play(const string &anim_name) { INLINE bool AnimControlCollection:: play(const string &anim_name, double from, double to) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -45,7 +45,7 @@ play(const string &anim_name, double from, double to) { INLINE bool AnimControlCollection:: loop(const string &anim_name, bool restart) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -59,7 +59,7 @@ loop(const string &anim_name, bool restart) { INLINE bool AnimControlCollection:: loop(const string &anim_name, bool restart, double from, double to) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -73,7 +73,7 @@ loop(const string &anim_name, bool restart, double from, double to) { INLINE bool AnimControlCollection:: stop(const string &anim_name) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } control->stop(); @@ -87,7 +87,7 @@ stop(const string &anim_name) { INLINE bool AnimControlCollection:: pose(const string &anim_name, double frame) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -102,7 +102,7 @@ pose(const string &anim_name, double frame) { INLINE int AnimControlCollection:: get_frame(const string &anim_name) const { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return 0; } return control->get_frame(); @@ -113,7 +113,7 @@ get_frame(const string &anim_name) const { */ INLINE int AnimControlCollection:: get_frame() const { - if (_last_started_control == (AnimControl *)NULL) { + if (_last_started_control == nullptr) { return 0; } return _last_started_control->get_frame(); @@ -125,7 +125,7 @@ get_frame() const { INLINE bool AnimControlCollection:: is_playing(const string &anim_name) const { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } return control->is_playing(); @@ -137,7 +137,7 @@ is_playing(const string &anim_name) const { */ INLINE bool AnimControlCollection:: is_playing() const { - if (_last_started_control == (AnimControl *)NULL) { + if (_last_started_control == nullptr) { return false; } return _last_started_control->is_playing(); @@ -150,7 +150,7 @@ is_playing() const { INLINE int AnimControlCollection:: get_num_frames(const string &anim_name) const { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return 0; } return control->get_num_frames(); @@ -161,7 +161,7 @@ get_num_frames(const string &anim_name) const { */ INLINE int AnimControlCollection:: get_num_frames() const { - if (_last_started_control == (AnimControl *)NULL) { + if (_last_started_control == nullptr) { return 0; } return _last_started_control->get_num_frames(); diff --git a/panda/src/chan/animControlCollection.cxx b/panda/src/chan/animControlCollection.cxx index 2a46ebb88f..50783b5305 100644 --- a/panda/src/chan/animControlCollection.cxx +++ b/panda/src/chan/animControlCollection.cxx @@ -20,7 +20,7 @@ */ AnimControlCollection:: AnimControlCollection() { - _last_started_control = (AnimControl *)NULL; + _last_started_control = nullptr; } /** @@ -55,7 +55,7 @@ store_anim(AnimControl *control, const string &name) { nassertv(index < _controls.size()); nassertv(_controls[index]._name == name); if (_last_started_control == _controls[index]._control) { - _last_started_control = (AnimControl *)NULL; + _last_started_control = nullptr; } _controls[index]._control = control; } @@ -69,11 +69,11 @@ AnimControl *AnimControlCollection:: find_anim(const string &name) const { ControlsByName::const_iterator ci = _controls_by_name.find(name); if (ci == _controls_by_name.end()) { - return (AnimControl *)NULL; + return nullptr; } size_t index = (*ci).second; - nassertr(index < _controls.size(), NULL); - nassertr(_controls[index]._name == name, NULL); + nassertr(index < _controls.size(), nullptr); + nassertr(_controls[index]._name == name, nullptr); return _controls[index]._control; } @@ -93,7 +93,7 @@ unbind_anim(const string &name) { nassertr(_controls[index]._name == name, false); if (_last_started_control == _controls[index]._control) { - _last_started_control = (AnimControl *)NULL; + _last_started_control = nullptr; } _controls_by_name.erase(ci); @@ -124,7 +124,7 @@ get_num_anims() const { */ AnimControl *AnimControlCollection:: get_anim(int n) const { - nassertr(n >= 0 && n < (int)_controls.size(), NULL); + nassertr(n >= 0 && n < (int)_controls.size(), nullptr); return _controls[n]._control; } diff --git a/panda/src/chan/animGroup.cxx b/panda/src/chan/animGroup.cxx index 364da1bd58..4c23b36110 100644 --- a/panda/src/chan/animGroup.cxx +++ b/panda/src/chan/animGroup.cxx @@ -36,7 +36,7 @@ AnimGroup:: AnimGroup(const string &name) : Namable(name), _children(get_class_type()), - _root(NULL) + _root(nullptr) { } @@ -50,11 +50,11 @@ AnimGroup(AnimGroup *parent, const AnimGroup ©) : Namable(copy), _children(get_class_type()) { - if (parent != (AnimGroup *)NULL) { + if (parent != nullptr) { parent->_children.push_back(this); _root = parent->_root; } else { - _root = NULL; + _root = nullptr; } } @@ -67,7 +67,7 @@ AnimGroup(AnimGroup *parent, const string &name) : Namable(name), _children(get_class_type()) { - nassertv(parent != NULL); + nassertv(parent != nullptr); parent->_children.push_back(this); _root = parent->_root; @@ -95,7 +95,7 @@ get_num_children() const { */ AnimGroup *AnimGroup:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -115,7 +115,7 @@ get_child_named(const string &name) const { } } - return (AnimGroup *)NULL; + return nullptr; } /** @@ -132,12 +132,12 @@ find_child(const string &name) const { return child; } AnimGroup *result = child->find_child(name); - if (result != (AnimGroup *)NULL) { + if (result != nullptr) { return result; } } - return (AnimGroup *)NULL; + return nullptr; } // An STL object to sort a list of children into alphabetical order. diff --git a/panda/src/chan/auto_bind.cxx b/panda/src/chan/auto_bind.cxx index 912b199ac8..e9e827b319 100644 --- a/panda/src/chan/auto_bind.cxx +++ b/panda/src/chan/auto_bind.cxx @@ -52,15 +52,15 @@ bind_anims(const PartBundles &parts, const AnimBundles &anims, if (name.empty()) { name = anim->get_name(); } - if (control != (AnimControl *)NULL) { - if (controls.find_anim(name) != (AnimControl *)NULL) { + if (control != nullptr) { + if (controls.find_anim(name) != nullptr) { // That name's already used; synthesize another one. int index = 0; string new_name; do { index++; new_name = name + '.' + format_string(index); - } while (controls.find_anim(new_name) != (AnimControl *)NULL); + } while (controls.find_anim(new_name) != nullptr); name = new_name; } @@ -68,7 +68,7 @@ bind_anims(const PartBundles &parts, const AnimBundles &anims, } if (chan_cat.is_info()) { - if (control == (AnimControl *)NULL) { + if (control == nullptr) { chan_cat.info() << "Bind failed.\n"; } else { diff --git a/panda/src/chan/bindAnimRequest.cxx b/panda/src/chan/bindAnimRequest.cxx index b1315044b9..c1b34038ff 100644 --- a/panda/src/chan/bindAnimRequest.cxx +++ b/panda/src/chan/bindAnimRequest.cxx @@ -51,7 +51,7 @@ do_task() { } PT(PandaNode) model = get_model(); - if (model == (PandaNode *)NULL) { + if (model == nullptr) { // Couldn't load the file. _control->fail_anim(part); return DS_done; @@ -59,7 +59,7 @@ do_task() { _control->set_anim_model(model); AnimBundle *anim = AnimBundleNode::find_anim_bundle(model); - if (anim == (AnimBundle *)NULL) { + if (anim == nullptr) { // No anim bundle. _control->fail_anim(part); return DS_done; diff --git a/panda/src/chan/bindAnimRequest.h b/panda/src/chan/bindAnimRequest.h index fed5e5d596..1c555de10a 100644 --- a/panda/src/chan/bindAnimRequest.h +++ b/panda/src/chan/bindAnimRequest.h @@ -25,7 +25,7 @@ class AnimControl; * This class object manages an asynchronous load-and-bind animation request, * as issued through PartBundle::load_bind_anim(). */ -class EXPCL_PANDA_PGRAPH BindAnimRequest : public ModelLoadRequest { +class EXPCL_PANDA_CHAN BindAnimRequest : public ModelLoadRequest { public: ALLOC_DELETED_CHAIN(BindAnimRequest); diff --git a/panda/src/chan/movingPart.h b/panda/src/chan/movingPart.h index 7b3640b981..dd6dc7540b 100644 --- a/panda/src/chan/movingPart.h +++ b/panda/src/chan/movingPart.h @@ -26,7 +26,7 @@ template class MovingPart : public MovingPartBase { public: - typedef TYPENAME SwitchType::ValueType ValueType; + typedef typename SwitchType::ValueType ValueType; typedef AnimChannel ChannelType; protected: diff --git a/panda/src/chan/movingPartBase.I b/panda/src/chan/movingPartBase.I index 2c18cb7584..182f597b67 100644 --- a/panda/src/chan/movingPartBase.I +++ b/panda/src/chan/movingPartBase.I @@ -18,7 +18,7 @@ INLINE MovingPartBase:: MovingPartBase(const MovingPartBase ©) : PartGroup(copy), _num_effective_channels(0), - _effective_control(NULL), + _effective_control(nullptr), _forced_channel(copy._forced_channel) { // We don't copy the bound channels. We do copy the forced_channel, though @@ -47,6 +47,6 @@ get_max_bound() const { */ INLINE AnimChannelBase *MovingPartBase:: get_bound(int n) const { - nassertr(n >= 0 && n < (int)_channels.size(), NULL); + nassertr(n >= 0 && n < (int)_channels.size(), nullptr); return _channels[n]; } diff --git a/panda/src/chan/movingPartBase.cxx b/panda/src/chan/movingPartBase.cxx index b623e7f689..cc60dabe3c 100644 --- a/panda/src/chan/movingPartBase.cxx +++ b/panda/src/chan/movingPartBase.cxx @@ -29,7 +29,7 @@ MovingPartBase:: MovingPartBase(PartGroup *parent, const string &name) : PartGroup(parent, name), _num_effective_channels(0), - _effective_control(NULL) + _effective_control(nullptr) { } @@ -39,7 +39,7 @@ MovingPartBase(PartGroup *parent, const string &name) : MovingPartBase:: MovingPartBase() : _num_effective_channels(0), - _effective_control(NULL) + _effective_control(nullptr) { } @@ -49,7 +49,7 @@ MovingPartBase() : */ bool MovingPartBase:: clear_forced_channel() { - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { _forced_channel.clear(); return true; } @@ -117,10 +117,10 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, // See if any of the channel values have changed since last time. if (!needs_update) { - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { needs_update = _forced_channel->has_changed(0, 0.0, 0, 0.0); - } else if (_effective_control != (AnimControl *)NULL) { + } else if (_effective_control != nullptr) { const PartBundle::CData *cdata = (const PartBundle::CData *)root_cdata; needs_update = _effective_control->channel_has_changed(_effective_channel, cdata->_frame_blend_flag); @@ -132,12 +132,12 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, ++bci) { AnimControl *control = (*bci).first; - AnimChannelBase *channel = NULL; + AnimChannelBase *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = _channels[channel_index]; } - if (channel != (AnimChannelBase*)NULL) { + if (channel != nullptr) { needs_update = control->channel_has_changed(channel, cdata->_frame_blend_flag); } } @@ -199,7 +199,7 @@ pick_channel_index(plist &holes, int &next) const { int hole = (*ii); nassertv(hole >= 0 && hole < next); if (hole < (int)_channels.size() || - _channels[hole] != (AnimChannelBase *)NULL) { + _channels[hole] != nullptr) { // We can't accept this hole; we're using it! holes.erase(ii); } @@ -210,7 +210,7 @@ pick_channel_index(plist &holes, int &next) const { if (next < (int)_channels.size()) { int i; for (i = next; i < (int)_channels.size(); i++) { - if (_channels[i] == (AnimChannelBase*)NULL) { + if (_channels[i] == nullptr) { // Here's a hole we do have. holes.push_back(i); } @@ -238,7 +238,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, } if (chan_cat.is_debug()) { - if (anim == (AnimGroup *)NULL) { + if (anim == nullptr) { chan_cat.debug() << "binding " << *this << " to NULL, is_included = " << is_included << "\n"; @@ -249,13 +249,13 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, } } while ((int)_channels.size() <= channel_index) { - _channels.push_back((AnimChannelBase*)NULL); + _channels.push_back(nullptr); } - nassertv(_channels[channel_index] == (AnimChannelBase*)NULL); + nassertv(_channels[channel_index] == nullptr); if (is_included) { - if (anim == (AnimGroup*)NULL) { + if (anim == nullptr) { // If we're binding to the NULL anim, it means actually to create a // default AnimChannel that just returns the part's initial value. _channels[channel_index] = make_default_channel(); @@ -303,12 +303,12 @@ find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, */ void MovingPartBase:: determine_effective_channels(const CycleData *root_cdata) { - _effective_control = NULL; - _effective_channel = NULL; + _effective_control = nullptr; + _effective_channel = nullptr; _num_effective_channels = 0; - AnimControl *effective_control = NULL; - AnimChannelBase *effective_channel = NULL; + AnimControl *effective_control = nullptr; + AnimChannelBase *effective_channel = nullptr; int num_effective_channels = 0; const PartBundle::CData *cdata = (const PartBundle::CData *)root_cdata; @@ -319,7 +319,7 @@ determine_effective_channels(const CycleData *root_cdata) { AnimControl *control = (*cbi).first; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { - if (_channels[channel_index] != (AnimChannelBase *)NULL) { + if (_channels[channel_index] != nullptr) { effective_control = control; effective_channel = _channels[channel_index]; ++num_effective_channels; diff --git a/panda/src/chan/movingPartMatrix.cxx b/panda/src/chan/movingPartMatrix.cxx index 6477728e0d..0c8c7bc7bd 100644 --- a/panda/src/chan/movingPartMatrix.cxx +++ b/panda/src/chan/movingPartMatrix.cxx @@ -53,7 +53,7 @@ get_blend_value(const PartBundle *root) { // If a forced channel is set on this particular joint, we always return // that value instead of performing the blend. Furthermore, the frame // number is always 0 for the forced channel. - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { ChannelType *channel = DCAST(ChannelType, _forced_channel); channel->get_value(0, _value); return; @@ -67,7 +67,7 @@ get_blend_value(const PartBundle *root) { _value = _default_value; } - } else if (_effective_control != (AnimControl *)NULL && + } else if (_effective_control != nullptr && !cdata->_frame_blend_flag) { // A single value, the normal case. ChannelType *channel = DCAST(ChannelType, _effective_channel); @@ -93,7 +93,7 @@ get_blend_value(const PartBundle *root) { int channel_index = control->get_channel_index(); nassertv(channel_index >= 0 && channel_index < (int)_channels.size()); ChannelType *channel = DCAST(ChannelType, _channels[channel_index]); - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { ValueType v; channel->get_value(control->get_frame(), v); @@ -140,12 +140,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { int frame = control->get_frame(); ValueType v; LVecBase3 iscale, ishear; @@ -213,12 +213,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { int frame = control->get_frame(); LVecBase3 iscale, ihpr, ipos, ishear; channel->get_scale(frame, iscale); @@ -289,12 +289,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { int frame = control->get_frame(); LVecBase3 iscale, ipos, ishear; LQuaternion iquat; diff --git a/panda/src/chan/movingPartScalar.cxx b/panda/src/chan/movingPartScalar.cxx index abebb49a32..d0d03b4152 100644 --- a/panda/src/chan/movingPartScalar.cxx +++ b/panda/src/chan/movingPartScalar.cxx @@ -39,7 +39,7 @@ get_blend_value(const PartBundle *root) { // If a forced channel is set on this particular scalar, we always return // that value instead of performing the blend. Furthermore, the frame // number is always 0 for the forced channel. - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { ChannelType *channel = DCAST(ChannelType, _forced_channel); channel->get_value(0, _value); return; @@ -53,7 +53,7 @@ get_blend_value(const PartBundle *root) { _value = _default_value; } - } else if (_effective_control != (AnimControl *)NULL && + } else if (_effective_control != nullptr && !cdata->_frame_blend_flag) { // A single value, the normal case. ChannelType *channel = DCAST(ChannelType, _effective_channel); @@ -70,12 +70,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != NULL) { + if (channel != nullptr) { ValueType v; channel->get_value(control->get_frame(), v); diff --git a/panda/src/chan/partBundle.I b/panda/src/chan/partBundle.I index ca6ec4c7cf..ca4ffdaad4 100644 --- a/panda/src/chan/partBundle.I +++ b/panda/src/chan/partBundle.I @@ -43,7 +43,7 @@ set_anim_preload(AnimPreloadTable *anim_preload) { */ INLINE void PartBundle:: clear_anim_preload() { - _anim_preload = NULL; + _anim_preload = nullptr; } /** @@ -165,7 +165,7 @@ get_num_nodes() const { */ INLINE PartBundleNode *PartBundle:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index 3806f812a5..d2aa343774 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -85,13 +85,13 @@ make_copy() const { */ void PartBundle:: merge_anim_preloads(const PartBundle *other) { - if (other->_anim_preload == (AnimPreloadTable *)NULL || + if (other->_anim_preload == nullptr || _anim_preload == other->_anim_preload) { // No-op. return; } - if (_anim_preload == (AnimPreloadTable *)NULL) { + if (_anim_preload == nullptr) { // Trivial case. _anim_preload = other->_anim_preload; return; @@ -128,7 +128,7 @@ set_anim_blend_flag(bool anim_blend_flag) { // eliminate all the AnimControls other than the most-recently-added // one. - nassertv(cdataw->_last_control_set != NULL); + nassertv(cdataw->_last_control_set != nullptr); clear_and_stop_intersecting(cdataw->_last_control_set, cdataw); } @@ -247,7 +247,7 @@ bind_anim(AnimBundle *anim, int hierarchy_match_flags, return control; } - return NULL; + return nullptr; } /** @@ -275,7 +275,7 @@ PT(AnimControl) PartBundle:: load_bind_anim(Loader *loader, const Filename &filename, int hierarchy_match_flags, const PartSubset &subset, bool allow_async) { - nassertr(loader != (Loader *)NULL, NULL); + nassertr(loader != nullptr, nullptr); LoaderOptions anim_options(LoaderOptions::LF_search | LoaderOptions::LF_report_errors | @@ -284,7 +284,7 @@ load_bind_anim(Loader *loader, const Filename &filename, int anim_index = -1; CPT(AnimPreloadTable) anim_preload = _anim_preload.get_read_pointer(); - if (anim_preload != (AnimPreloadTable *)NULL) { + if (anim_preload != nullptr) { anim_index = anim_preload->find_anim(basename); } @@ -293,19 +293,19 @@ load_bind_anim(Loader *loader, const Filename &filename, // Therefore, perform an ordinary synchronous load-and-bind. PT(PandaNode) model = loader->load_sync(filename, anim_options); - if (model == (PandaNode *)NULL) { + if (model == nullptr) { // Couldn't load the file. - return NULL; + return nullptr; } AnimBundle *anim = AnimBundleNode::find_anim_bundle(model); - if (anim == (AnimBundle *)NULL) { + if (anim == nullptr) { // No anim bundle. - return NULL; + return nullptr; } PT(AnimControl) control = bind_anim(anim, hierarchy_match_flags, subset); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { // Couldn't bind. - return NULL; + return nullptr; } control->set_anim_model(model); return control; @@ -366,7 +366,7 @@ wait_pending() { bool PartBundle:: freeze_joint(const string &joint_name, const TransformState *transform) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -387,7 +387,7 @@ freeze_joint(const string &joint_name, const TransformState *transform) { bool PartBundle:: freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -408,7 +408,7 @@ freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hp bool PartBundle:: freeze_joint(const string &joint_name, PN_stdfloat value) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -430,7 +430,7 @@ freeze_joint(const string &joint_name, PN_stdfloat value) { bool PartBundle:: control_joint(const string &joint_name, PandaNode *node) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -451,7 +451,7 @@ control_joint(const string &joint_name, PandaNode *node) { bool PartBundle:: release_joint(const string &joint_name) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -479,7 +479,7 @@ update() { bool anim_changed = cdata->_anim_changed; bool frame_blend_flag = cdata->_frame_blend_flag; - any_changed = do_update(this, cdata, NULL, false, anim_changed, + any_changed = do_update(this, cdata, nullptr, false, anim_changed, current_thread); // Now update all the controls for next time. @@ -504,7 +504,7 @@ bool PartBundle:: force_update() { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, false, current_thread); - bool any_changed = do_update(this, cdata, NULL, true, true, current_thread); + bool any_changed = do_update(this, cdata, nullptr, true, true, current_thread); // Now update all the controls for next time. ChannelBlend::const_iterator cbi; @@ -585,7 +585,7 @@ do_bind_anim(AnimControl *control, AnimBundle *anim, } } - if (!check_hierarchy(anim, NULL, hierarchy_match_flags)) { + if (!check_hierarchy(anim, nullptr, hierarchy_match_flags)) { return false; } @@ -747,7 +747,7 @@ void PartBundle:: finalize(BamReader *) { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true); - do_update(this, cdata, NULL, true, true, current_thread); + do_update(this, cdata, nullptr, true, true, current_thread); } /** @@ -827,7 +827,7 @@ CData() { _anim_blend_flag = false; _frame_blend_flag = interpolate_frames; _root_xform = LMatrix4::ident_mat(); - _last_control_set = NULL; + _last_control_set = nullptr; _net_blend = 0.0f; _anim_changed = false; _last_update = 0.0; diff --git a/panda/src/chan/partBundleNode.I b/panda/src/chan/partBundleNode.I index c1251b7eac..721e930bd9 100644 --- a/panda/src/chan/partBundleNode.I +++ b/panda/src/chan/partBundleNode.I @@ -54,7 +54,7 @@ get_num_bundles() const { */ INLINE PartBundle *PartBundleNode:: get_bundle(int n) const { - nassertr(n >= 0 && n < (int)_bundles.size(), NULL); + nassertr(n >= 0 && n < (int)_bundles.size(), nullptr); return _bundles[n]->get_bundle(); } @@ -65,6 +65,6 @@ get_bundle(int n) const { */ INLINE PartBundleHandle *PartBundleNode:: get_bundle_handle(int n) const { - nassertr(n >= 0 && n < (int)_bundles.size(), NULL); + nassertr(n >= 0 && n < (int)_bundles.size(), nullptr); return _bundles[n]; } diff --git a/panda/src/chan/partBundleNode.cxx b/panda/src/chan/partBundleNode.cxx index e0a726fd39..9fe5473fe0 100644 --- a/panda/src/chan/partBundleNode.cxx +++ b/panda/src/chan/partBundleNode.cxx @@ -192,6 +192,6 @@ fillin(DatagramIterator &scan, BamReader* manager) { // Remaining bundles. Push a new slot for each one. for (int i = 1; i < num_bundles; ++i) { manager->read_pointer(scan); - _bundles.push_back(NULL); + _bundles.push_back(nullptr); } } diff --git a/panda/src/chan/partGroup.cxx b/panda/src/chan/partGroup.cxx index 20fe582ae9..ad501ca24c 100644 --- a/panda/src/chan/partGroup.cxx +++ b/panda/src/chan/partGroup.cxx @@ -36,7 +36,7 @@ PartGroup(PartGroup *parent, const string &name) : Namable(name), _children(get_class_type()) { - nassertv(parent != NULL); + nassertv(parent != nullptr); parent->_children.push_back(this); } @@ -102,7 +102,7 @@ get_num_children() const { */ PartGroup *PartGroup:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -122,7 +122,7 @@ get_child_named(const string &name) const { } } - return (PartGroup *)NULL; + return nullptr; } /** @@ -139,12 +139,12 @@ find_child(const string &name) const { return child; } PartGroup *result = child->find_child(name); - if (result != (PartGroup *)NULL) { + if (result != nullptr) { return result; } } - return (PartGroup *)NULL; + return nullptr; } // An STL object to sort a list of children into alphabetical order. @@ -163,7 +163,7 @@ public: */ void PartGroup:: sort_descendants() { - stable_sort(_children.begin(), _children.end(), PartGroupAlphabeticalOrder()); + std::stable_sort(_children.begin(), _children.end(), PartGroupAlphabeticalOrder()); Children::iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -243,7 +243,7 @@ clear_forced_channel() { */ AnimChannelBase *PartGroup:: get_forced_channel() const { - return NULL; + return nullptr; } @@ -314,14 +314,14 @@ check_hierarchy(const AnimGroup *anim, const PartGroup *, // to differ meaninglessly here. Any differences here remain // unreported. if (anim->get_num_children() == get_num_children() + 1 && - anim->get_child_named("morph") != NULL && - get_child_named("morph") == NULL) { + anim->get_child_named("morph") != nullptr && + get_child_named("morph") == nullptr) { // Anim has "morph" and model does not, but there are no other // differences. } else if (get_num_children() == anim->get_num_children() + 1 && - get_child_named("morph") != NULL && - anim->get_child_named("morph") == NULL) { + get_child_named("morph") != nullptr && + anim->get_child_named("morph") == nullptr) { // Model has "morph" and anim does not, but there are no other // differences. @@ -562,7 +562,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, int i = 0, j = 0; int part_num_children = get_num_children(); - int anim_num_children = (anim == NULL) ? 0 : anim->get_num_children(); + int anim_num_children = (anim == nullptr) ? 0 : anim->get_num_children(); while (i < part_num_children && j < anim_num_children) { PartGroup *pc = get_child(i); @@ -570,7 +570,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, if (pc->get_name() < ac->get_name()) { // Here's a part, not in the anim. Bind it to the special NULL anim. - pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, + pc->bind_hierarchy(nullptr, channel_index, joint_index, is_included, bound_joints, subset); i++; @@ -590,7 +590,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, // Now pick up any more parts, not in the anim. while (i < part_num_children) { PartGroup *pc = get_child(i); - pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, + pc->bind_hierarchy(nullptr, channel_index, joint_index, is_included, bound_joints, subset); i++; } @@ -652,7 +652,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _children.reserve(num_children); for (int i = 0; i < num_children; i++) { manager->read_pointer(scan); - _children.push_back(NULL); + _children.push_back(nullptr); } } diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index ed28ac491e..8b5bac116a 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -359,12 +359,12 @@ find_joint(const string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); - if (part != (PartGroup *)NULL && part->is_character_joint()) { + if (part != nullptr && part->is_character_joint()) { return DCAST(CharacterJoint, part); } } - return NULL; + return nullptr; } /** @@ -377,13 +377,13 @@ find_slider(const string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); - if (part != (PartGroup *)NULL && + if (part != nullptr && part->is_of_type(CharacterSlider::get_class_type())) { return DCAST(CharacterSlider, part); } } - return NULL; + return nullptr; } /** @@ -644,7 +644,7 @@ r_merge_bundles(Character::JointMap &joint_map, // Since the old_joint will be getting dropped, reset its character // reference. - old_joint->_character = NULL; + old_joint->_character = nullptr; // Copy any _net_transform and _local_transform operations to the new // joint. @@ -929,8 +929,8 @@ CPT(TransformTable) Character:: redirect_transform_table(const TransformTable *source, const Character::JointMap &joint_map, Character::GeomJointMap &gjmap) { - if (source == (TransformTable *)NULL) { - return NULL; + if (source == nullptr) { + return nullptr; } PT(TransformTable) dest = new TransformTable(*source); @@ -939,7 +939,7 @@ redirect_transform_table(const TransformTable *source, for (int i = 0; i < num_transforms; ++i) { const VertexTransform *vt = dest->get_transform(i); PT(JointVertexTransform) new_jvt = redirect_joint(vt, joint_map, gjmap); - if (new_jvt != (JointVertexTransform *)NULL) { + if (new_jvt != nullptr) { dest->set_transform(i, new_jvt); } } @@ -955,8 +955,8 @@ CPT(TransformBlendTable) Character:: redirect_transform_blend_table(const TransformBlendTable *source, const Character::JointMap &joint_map, Character::GeomJointMap &gjmap) { - if (source == (TransformBlendTable *)NULL) { - return NULL; + if (source == nullptr) { + return nullptr; } PT(TransformBlendTable) dest = new TransformBlendTable(*source); @@ -968,7 +968,7 @@ redirect_transform_blend_table(const TransformBlendTable *source, for (int j = 0; j < num_transforms; ++j) { const VertexTransform *vt = blend.get_transform(j); PT(JointVertexTransform) new_jvt = redirect_joint(vt, joint_map, gjmap); - if (new_jvt != (JointVertexTransform *)NULL) { + if (new_jvt != nullptr) { blend.set_transform(j, new_jvt); } } @@ -985,8 +985,8 @@ redirect_transform_blend_table(const TransformBlendTable *source, CPT(SliderTable) Character:: redirect_slider_table(const SliderTable *source, Character::GeomSliderMap &gsmap) { - if (source == (SliderTable *)NULL) { - return NULL; + if (source == nullptr) { + return nullptr; } PT(SliderTable) dest = new SliderTable(*source); @@ -995,7 +995,7 @@ redirect_slider_table(const SliderTable *source, for (int i = 0; i < num_sliders; ++i) { const VertexSlider *vs = dest->get_slider(i); PT(CharacterVertexSlider) new_cvs = redirect_slider(vs, gsmap); - if (new_cvs != (CharacterVertexSlider *)NULL) { + if (new_cvs != nullptr) { dest->set_slider(i, new_cvs); } } @@ -1057,7 +1057,7 @@ redirect_slider(const VertexSlider *vs, Character::GeomSliderMap &gsmap) { if (vs->is_of_type(CharacterVertexSlider::get_class_type())) { const CharacterVertexSlider *cvs = DCAST(CharacterVertexSlider, vs); CharacterSlider *slider = find_slider(cvs->get_char_slider()->get_name()); - if (slider != (CharacterSlider *)NULL) { + if (slider != nullptr) { new_cvs = new CharacterVertexSlider(slider); } } @@ -1081,7 +1081,7 @@ r_clear_joint_characters(PartGroup *part) { // listed within more than one Character node, but it can only point back // to one of them. if (joint->get_character() == this) { - joint->set_character(NULL); + joint->set_character(nullptr); } } diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index fee1a90f76..8a424d91c1 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -27,7 +27,7 @@ TypeHandle CharacterJoint::_type_handle; */ CharacterJoint:: CharacterJoint() : - _character(NULL) + _character(nullptr) { } @@ -37,7 +37,7 @@ CharacterJoint() : CharacterJoint:: CharacterJoint(const CharacterJoint ©) : MovingPartMatrix(copy), - _character(NULL), + _character(nullptr), _net_transform(copy._net_transform), _initial_net_transform_inverse(copy._initial_net_transform_inverse), _skinning_matrix(copy._skinning_matrix) @@ -75,7 +75,7 @@ CharacterJoint(Character *character, CharacterJoint:: ~CharacterJoint() { nassertv(_vertex_transforms.empty()); - nassertv(_character == (Character *)NULL); + nassertv(_character == nullptr); } /** @@ -110,7 +110,7 @@ make_copy() const { bool CharacterJoint:: update_internals(PartBundle *root, PartGroup *parent, bool self_changed, bool parent_changed, Thread *current_thread) { - nassertr(parent != (PartGroup *)NULL, false); + nassertr(parent != nullptr, false); bool net_changed = false; if (parent->is_character_joint()) { @@ -194,7 +194,7 @@ do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { */ bool CharacterJoint:: add_net_transform(PandaNode *node) { - if (_character != (Character *)NULL) { + if (_character != nullptr) { node->set_effect(CharacterJointEffect::make(_character)); } CPT(TransformState) t = TransformState::make_mat(_net_transform); @@ -213,7 +213,7 @@ add_net_transform(PandaNode *node) { bool CharacterJoint:: remove_net_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -243,7 +243,7 @@ clear_net_transforms() { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -286,7 +286,7 @@ get_net_transforms() { */ bool CharacterJoint:: add_local_transform(PandaNode *node) { - if (_character != (Character *)NULL) { + if (_character != nullptr) { node->set_effect(CharacterJointEffect::make(_character)); } CPT(TransformState) t = TransformState::make_mat(_value); @@ -305,7 +305,7 @@ add_local_transform(PandaNode *node) { bool CharacterJoint:: remove_local_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -335,7 +335,7 @@ clear_local_transforms() { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -401,7 +401,7 @@ void CharacterJoint:: set_character(Character *character) { if (character != _character) { - if (character != (Character *)NULL) { + if (character != nullptr) { // Change or set a _character pointer on each joint's exposed node. NodeList::iterator ai; for (ai = _net_transform_nodes.begin(); @@ -426,7 +426,7 @@ set_character(Character *character) { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -437,7 +437,7 @@ set_character(Character *character) { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -514,7 +514,7 @@ complete_pointers(TypedWritable **p_list, BamReader* manager) { if (manager->get_file_minor_ver() >= 4) { _character = DCAST(Character, p_list[pi++]); } else { - _character = NULL; + _character = nullptr; } int i; diff --git a/panda/src/char/characterJointBundle.cxx b/panda/src/char/characterJointBundle.cxx index e6bf4061a7..980e9058dc 100644 --- a/panda/src/char/characterJointBundle.cxx +++ b/panda/src/char/characterJointBundle.cxx @@ -78,7 +78,7 @@ remove_node(PartBundleNode *node) { */ void CharacterJointBundle:: r_set_character(PartGroup *group, Character *character) { - if (group == (PartGroup *)NULL) { + if (group == nullptr) { // This might happen if we are in the middle of reading the Character's // hierarchy from the bam file. return; diff --git a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm index ea6fb61e4e..07f44b6c94 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm @@ -105,6 +105,12 @@ open_buffer() { } } + if (cocoagsg->_context == nil) { + // Could not obtain a proper context. + _gsg.clear(); + return false; + } + FrameBufferProperties desired_props(_fb_properties); // Lock the context, so we can safely operate on it. diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index 5430373c55..dd554e2a77 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -37,7 +37,7 @@ CocoaGraphicsPipe(CGDirectDisplayID display) : _display(display) { _supported_types = OT_window | OT_buffer | OT_texture_buffer; _is_valid = true; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSAutoreleasePool alloc] init]; // Put Cocoa into thread-safe mode by spawning a thread which immediately // exits. diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 72c9d57c0f..df12a69985 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -362,6 +362,13 @@ open_window() { } } + if (cocoagsg->_context == nil) { + // Could not obtain a proper context. + _gsg.clear(); + close_window(); + return false; + } + // Fill in the blanks. if (!_properties.has_origin()) { _properties.set_origin(-2, -2); @@ -405,7 +412,7 @@ open_window() { cocoadisplay_cat.info() << "os_handle type " << os_handle->get_type() << "\n"; - void *ptr_handle; + void *ptr_handle = nullptr; // Depending on whether the window handle comes from a Carbon or a Cocoa // application, it could be either a HIViewRef or an NSView or NSWindow. diff --git a/panda/src/collada/colladaBindMaterial.cxx b/panda/src/collada/colladaBindMaterial.cxx index 768e31a46d..2ef46e4a99 100644 --- a/panda/src/collada/colladaBindMaterial.cxx +++ b/panda/src/collada/colladaBindMaterial.cxx @@ -37,8 +37,8 @@ */ CPT(RenderState) ColladaBindMaterial:: get_material(const ColladaPrimitive *prim) const { - if (prim == NULL || _states.count(prim->get_material()) == 0) { - return NULL; + if (prim == nullptr || _states.count(prim->get_material()) == 0) { + return nullptr; } return _states.find(prim->get_material())->second; } @@ -50,7 +50,7 @@ get_material(const ColladaPrimitive *prim) const { CPT(RenderState) ColladaBindMaterial:: get_material(const string &symbol) const { if (_states.count(symbol) == 0) { - return NULL; + return nullptr; } return _states.find(symbol)->second; } @@ -74,10 +74,10 @@ load_bind_material(domBind_material &bind_mat) { void ColladaBindMaterial:: load_instance_material(domInstance_material &inst) { domMaterialRef mat = daeSafeCast (inst.getTarget().getElement()); - nassertv(mat != NULL); + nassertv(mat != nullptr); domInstance_effectRef einst = mat->getInstance_effect(); - nassertv(einst != NULL); + nassertv(einst != nullptr); domInstance_effect::domSetparam_Array &setparams = einst->getSetparam_array(); diff --git a/panda/src/collada/colladaInput.cxx b/panda/src/collada/colladaInput.cxx index b0f77ccd4e..be6522b23f 100644 --- a/panda/src/collada/colladaInput.cxx +++ b/panda/src/collada/colladaInput.cxx @@ -38,7 +38,7 @@ */ ColladaInput:: ColladaInput(const string &semantic) : - _column_name (NULL), + _column_name (nullptr), _semantic (semantic), _offset (0), _have_set (false), @@ -70,7 +70,7 @@ ColladaInput(const string &semantic) : */ ColladaInput:: ColladaInput(const string &semantic, unsigned int set) : - _column_name (NULL), + _column_name (nullptr), _semantic (semantic), _offset (0), _have_set (true), @@ -107,7 +107,7 @@ ColladaInput(const string &semantic, unsigned int set) : ColladaInput *ColladaInput:: from_dom(domInput_local_offset &input) { // If we already loaded it before, use that. - if (input.getUserData() != NULL) { + if (input.getUserData() != nullptr) { return (ColladaInput *) input.getUserData(); } @@ -117,7 +117,7 @@ from_dom(domInput_local_offset &input) { // If this has the VERTEX semantic, it points to a element. if (new_input->is_vertex_source()) { domVertices *verts = daeSafeCast (input.getSource().getElement()); - nassertr(verts != NULL, NULL); + nassertr(verts != nullptr, nullptr); daeTArray &inputs = verts->getInput_array(); // Iterate over the elements in . @@ -127,7 +127,7 @@ from_dom(domInput_local_offset &input) { } } else { domSource *source = daeSafeCast (input.getSource().getElement()); - nassertr(source != NULL, NULL); + nassertr(source != nullptr, nullptr); new_input->read_data(*source); } @@ -141,17 +141,17 @@ from_dom(domInput_local_offset &input) { ColladaInput *ColladaInput:: from_dom(domInput_local &input) { // If we already loaded it before, use that. - if (input.getUserData() != NULL) { + if (input.getUserData() != nullptr) { return (ColladaInput *) input.getUserData(); } ColladaInput *new_input = new ColladaInput(input.getSemantic()); new_input->_offset = 0; - nassertr (!new_input->is_vertex_source(), NULL); + nassertr (!new_input->is_vertex_source(), nullptr); domSource *source = daeSafeCast (input.getSource().getElement()); - nassertr(source != NULL, NULL); + nassertr(source != nullptr, nullptr); new_input->read_data(*source); return new_input; @@ -174,7 +174,7 @@ make_vertex_columns(GeomVertexArrayFormat *format) const { return counter; } - nassertr(_column_name != NULL, 0); + nassertr(_column_name != nullptr, 0); format->add_column(_column_name, _num_bound_params, GeomEnums::NT_stdfloat, _column_contents); return 1; @@ -189,7 +189,7 @@ read_data(domSource &source) { // Get this, get that domFloat_array* float_array = source.getFloat_array(); - if (float_array == NULL) { + if (float_array == nullptr) { return false; } @@ -246,7 +246,7 @@ write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride) c */ void ColladaInput:: write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride, unsigned int offset) const { - nassertv(_column_name != NULL); + nassertv(_column_name != nullptr); GeomVertexWriter writer (vdata, _column_name); writer.set_row_unsafe(start_row); diff --git a/panda/src/collada/colladaLoader.cxx b/panda/src/collada/colladaLoader.cxx index 93749b30b6..7414af0a7f 100644 --- a/panda/src/collada/colladaLoader.cxx +++ b/panda/src/collada/colladaLoader.cxx @@ -45,18 +45,18 @@ #define domTargetable_floatRef domTargetableFloatRef #endif -#define TOSTRING(x) (x == NULL ? "" : x) +#define TOSTRING(x) (x == nullptr ? "" : x) /** * */ ColladaLoader:: ColladaLoader() : - _record (NULL), + _record (nullptr), _cs (CS_default), _error (false), - _root (NULL), - _collada (NULL) { + _root (nullptr), + _collada (nullptr) { _dae = new DAE; } @@ -87,7 +87,7 @@ read(const Filename &filename) { } _collada = _dae->openFromMemory(_filename.to_os_specific(), data.c_str()); - _error = (_collada == NULL); + _error = (_collada == nullptr); return !_error; } @@ -116,7 +116,7 @@ build_graph() { void ColladaLoader:: load_visual_scene(domVisual_scene& scene, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (scene.getUserData() != NULL) { + if (scene.getUserData() != nullptr) { parent->add_child((PandaNode *) scene.getUserData()); return; } @@ -156,7 +156,7 @@ load_visual_scene(domVisual_scene& scene, PandaNode *parent) { void ColladaLoader:: load_node(domNode& node, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (node.getUserData() != NULL) { + if (node.getUserData() != nullptr) { parent->add_child((PandaNode *) node.getUserData()); return; } @@ -243,7 +243,7 @@ load_node(domNode& node, PandaNode *parent) { for (size_t i = 0; i < ctrlinst.getCount(); ++i) { domController* target = daeSafeCast (ctrlinst[i]->getUrl().getElement()); // TODO: implement controllers. For now, let's just read the geometry - if (target->getSkin() != NULL) { + if (target->getSkin() != nullptr) { domGeometry* geom = daeSafeCast (target->getSkin()->getSource().getElement()); // TODO load_geometry(*geom, ctrlinst[i]->getBind_material(), pnode); } @@ -321,7 +321,7 @@ load_tags(domExtra &extra, PandaNode *node) { void ColladaLoader:: load_camera(domCamera &cam, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (cam.getUserData() != NULL) { + if (cam.getUserData() != nullptr) { parent->add_child((PandaNode *) cam.getUserData()); return; } @@ -335,13 +335,13 @@ load_camera(domCamera &cam, PandaNode *parent) { void ColladaLoader:: load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (inst.getUserData() != NULL) { + if (inst.getUserData() != nullptr) { parent->add_child((PandaNode *) inst.getUserData()); return; } domGeometry* geom = daeSafeCast (inst.getUrl().getElement()); - nassertv(geom != NULL); + nassertv(geom != nullptr); // Create the node. PT(GeomNode) gnode = new GeomNode(TOSTRING(geom->getName())); @@ -350,7 +350,7 @@ load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { domBind_materialRef bind_mat = inst.getBind_material(); ColladaBindMaterial cbm; - if (bind_mat != NULL) { + if (bind_mat != nullptr) { cbm.load_bind_material(*bind_mat); } @@ -370,7 +370,7 @@ load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { void ColladaLoader:: load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) { domMesh* mesh = geom.getMesh(); - if (mesh == NULL) { + if (mesh == nullptr) { // TODO: support non-mesh geometry. return; } @@ -379,7 +379,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domLines_Array &lines_array = mesh->getLines_array(); for (size_t i = 0; i < lines_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*lines_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -387,7 +387,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domLinestrips_Array &linestrips_array = mesh->getLinestrips_array(); for (size_t i = 0; i < linestrips_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*linestrips_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -395,7 +395,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domPolygons_Array &polygons_array = mesh->getPolygons_array(); for (size_t i = 0; i < polygons_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*polygons_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -403,7 +403,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domPolylist_Array &polylist_array = mesh->getPolylist_array(); for (size_t i = 0; i < polylist_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*polylist_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -411,7 +411,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domTriangles_Array &triangles_array = mesh->getTriangles_array(); for (size_t i = 0; i < triangles_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*triangles_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -419,7 +419,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domTrifans_Array &trifans_array = mesh->getTrifans_array(); for (size_t i = 0; i < trifans_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*trifans_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -427,7 +427,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domTristrips_Array &tristrips_array = mesh->getTristrips_array(); for (size_t i = 0; i < tristrips_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*tristrips_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -439,7 +439,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) void ColladaLoader:: load_light(domLight &light, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (light.getUserData() != NULL) { + if (light.getUserData() != nullptr) { parent->add_child((PandaNode *) light.getUserData()); return; } @@ -449,7 +449,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for an ambient light. domLight::domTechnique_common::domAmbientRef ambient = tc.getAmbient(); - if (ambient != NULL) { + if (ambient != nullptr) { PT(AmbientLight) alight = new AmbientLight(TOSTRING(light.getName())); lnode = DCAST(LightNode, alight); @@ -459,7 +459,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for a directional light. domLight::domTechnique_common::domDirectionalRef directional = tc.getDirectional(); - if (directional != NULL) { + if (directional != nullptr) { PT(DirectionalLight) dlight = new DirectionalLight(TOSTRING(light.getName())); lnode = DCAST(LightNode, dlight); @@ -470,7 +470,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for a point light. domLight::domTechnique_common::domPointRef point = tc.getPoint(); - if (point != NULL) { + if (point != nullptr) { PT(PointLight) plight = new PointLight(TOSTRING(light.getName())); lnode = DCAST(LightNode, plight); @@ -479,15 +479,15 @@ load_light(domLight &light, PandaNode *parent) { LVecBase3f atten (1.0f, 0.0f, 0.0f); domTargetable_floatRef fval = point->getConstant_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[0] = fval->getValue(); } fval = point->getLinear_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[1] = fval->getValue(); } fval = point->getQuadratic_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[2] = fval->getValue(); } @@ -496,7 +496,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for a spot light. domLight::domTechnique_common::domSpotRef spot = tc.getSpot(); - if (spot != NULL) { + if (spot != nullptr) { PT(Spotlight) slight = new Spotlight(TOSTRING(light.getName())); lnode = DCAST(LightNode, slight); @@ -505,36 +505,36 @@ load_light(domLight &light, PandaNode *parent) { LVecBase3f atten (1.0f, 0.0f, 0.0f); domTargetable_floatRef fval = spot->getConstant_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[0] = fval->getValue(); } fval = spot->getLinear_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[1] = fval->getValue(); } fval = spot->getQuadratic_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[2] = fval->getValue(); } slight->set_attenuation(atten); fval = spot->getFalloff_angle(); - if (fval != NULL) { + if (fval != nullptr) { slight->get_lens()->set_fov(fval->getValue()); } else { slight->get_lens()->set_fov(180.0f); } fval = spot->getFalloff_exponent(); - if (fval != NULL) { + if (fval != nullptr) { slight->set_exponent(fval->getValue()); } else { slight->set_exponent(0.0f); } } - if (lnode == NULL) { + if (lnode == nullptr) { return; } parent->add_child(lnode); diff --git a/panda/src/collada/colladaPrimitive.cxx b/panda/src/collada/colladaPrimitive.cxx index f1c627cb00..04433b72e4 100644 --- a/panda/src/collada/colladaPrimitive.cxx +++ b/panda/src/collada/colladaPrimitive.cxx @@ -65,7 +65,7 @@ ColladaPrimitive(GeomPrimitive *prim, daeTArray &input ColladaPrimitive *ColladaPrimitive:: from_dom(domLines &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -77,7 +77,7 @@ from_dom(domLines &prim) { prim.setUserData(new_prim); domPRef p = prim.getP(); - if (p != NULL) { + if (p != nullptr) { new_prim->load_primitive(*p); } @@ -91,7 +91,7 @@ from_dom(domLines &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domLinestrips &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -114,7 +114,7 @@ from_dom(domLinestrips &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domPolygons &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -145,7 +145,7 @@ from_dom(domPolygons &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domPolylist &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -162,7 +162,7 @@ from_dom(domPolylist &prim) { domPRef p = prim.getP(); domPolylist::domVcountRef vcounts = prim.getVcount(); - if (p == NULL || vcounts == NULL) { + if (p == nullptr || vcounts == nullptr) { return new_prim; } @@ -185,7 +185,7 @@ from_dom(domPolylist &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domTriangles &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -197,7 +197,7 @@ from_dom(domTriangles &prim) { prim.setUserData(new_prim); domPRef p = prim.getP(); - if (p != NULL) { + if (p != nullptr) { new_prim->load_primitive(*p); } @@ -211,7 +211,7 @@ from_dom(domTriangles &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domTrifans &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -234,7 +234,7 @@ from_dom(domTrifans &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domTristrips &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } diff --git a/panda/src/collada/load_collada_file.cxx b/panda/src/collada/load_collada_file.cxx index 1d849f0f79..2ebdd2c340 100644 --- a/panda/src/collada/load_collada_file.cxx +++ b/panda/src/collada/load_collada_file.cxx @@ -26,10 +26,10 @@ load_from_loader(ColladaLoader &loader) { if (loader._error && !collada_accept_errors) { collada_cat.error() << "Errors in collada file.\n"; - return NULL; + return nullptr; } - if (loader._root != NULL && collada_flatten) { + if (loader._root != nullptr && collada_flatten) { SceneGraphReducer gr; int combine_siblings_bits = 0; @@ -72,7 +72,7 @@ load_collada_file(const Filename &filename, CoordinateSystem cs, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(filename); } @@ -85,7 +85,7 @@ load_collada_file(const Filename &filename, CoordinateSystem cs, << "Reading " << filename << "\n"; if (!loader.read(filename)) { - return NULL; + return nullptr; } return load_from_loader(loader); diff --git a/panda/src/collada/load_collada_file.h b/panda/src/collada/load_collada_file.h index 9dea0e72f9..8217b11063 100644 --- a/panda/src/collada/load_collada_file.h +++ b/panda/src/collada/load_collada_file.h @@ -30,7 +30,7 @@ BEGIN_PUBLISH */ EXPCL_COLLADA PT(PandaNode) load_collada_file(const Filename &filename, CoordinateSystem cs = CS_default, - BamCacheRecord *record = NULL); + BamCacheRecord *record = nullptr); END_PUBLISH #endif diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index b55988c352..ad025f8682 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -199,7 +199,7 @@ PT(CollisionEntry) CollisionBox:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); @@ -310,7 +310,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat edge_dist = 0.0f; const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform(),ip)) { @@ -361,7 +361,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { intersect = true; } if( !intersect ) - return NULL; + return nullptr; if (collide_cat.is_debug()) { collide_cat.debug() @@ -402,7 +402,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionBox:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); LPoint3 from_origin = ray->get_origin() * wrt_mat; @@ -453,7 +453,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { if(!intersect) { // No intersection with ANY of the box's planes has been detected - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -483,7 +483,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionBox:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *seg; - DCAST_INTO_R(seg, entry.get_from(), NULL); + DCAST_INTO_R(seg, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); LPoint3 from_origin = seg->get_point_a() * wrt_mat; @@ -535,7 +535,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { if(!intersect) { // No intersection with ANY of the box's planes has been detected - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -564,7 +564,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionBox:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -603,7 +603,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { cabs(box_z[0] * from_extents[2]); pen = r1 + r2 - cabs(diff[0]); if (pen < 0) { - return NULL; + return nullptr; } min_pen = pen; @@ -613,7 +613,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { cabs(box_z[1] * from_extents[2]); pen = r1 + r2 - cabs(diff[1]); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -626,7 +626,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { cabs(box_z[2] * from_extents[2]); pen = r1 + r2 - cabs(diff[2]); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -640,7 +640,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r2 = from_extents[0]; pen = r1 + r2 - cabs(diff.dot(box_x)); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -652,7 +652,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r2 = from_extents[1]; pen = r1 + r2 - cabs(diff.dot(box_y)); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -664,7 +664,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r2 = from_extents[2]; pen = r1 + r2 - cabs(diff.dot(box_z)); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -674,55 +674,55 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = into_extents[1] * cabs(box_x[2]) + into_extents[2] * cabs(box_x[1]); r2 = from_extents[1] * cabs(box_z[0]) + from_extents[2] * cabs(box_y[0]); if (cabs(diff[2] * box_x[1] - diff[1] * box_x[2]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[1] * cabs(box_y[2]) + into_extents[2] * cabs(box_y[1]); r2 = from_extents[0] * cabs(box_z[0]) + from_extents[2] * cabs(box_x[0]); if (cabs(diff[2] * box_y[1] - diff[1] * box_y[2]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[1] * cabs(box_z[2]) + into_extents[2] * cabs(box_z[1]); r2 = from_extents[0] * cabs(box_y[0]) + from_extents[1] * cabs(box_x[0]); if (cabs(diff[2] * box_z[1] - diff[1] * box_z[2]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_x[2]) + into_extents[2] * cabs(box_x[0]); r2 = from_extents[1] * cabs(box_z[1]) + from_extents[2] * cabs(box_y[1]); if (cabs(diff[0] * box_x[2] - diff[2] * box_x[0]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_y[2]) + into_extents[2] * cabs(box_y[0]); r2 = from_extents[0] * cabs(box_z[1]) + from_extents[2] * cabs(box_x[1]); if (cabs(diff[0] * box_y[2] - diff[2] * box_y[0]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_z[2]) + into_extents[2] * cabs(box_z[0]); r2 = from_extents[0] * cabs(box_y[1]) + from_extents[1] * cabs(box_x[1]); if (cabs(diff[0] * box_z[2] - diff[2] * box_z[0]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_x[1]) + into_extents[1] * cabs(box_x[0]); r2 = from_extents[1] * cabs(box_z[2]) + from_extents[2] * cabs(box_y[2]); if (cabs(diff[1] * box_x[0] - diff[0] * box_x[1]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_y[1]) + into_extents[1] * cabs(box_y[0]); r2 = from_extents[0] * cabs(box_z[2]) + from_extents[2] * cabs(box_x[2]); if (cabs(diff[1] * box_y[0] - diff[0] * box_y[1]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_z[1]) + into_extents[1] * cabs(box_z[0]); r2 = from_extents[0] * cabs(box_y[2]) + from_extents[1] * cabs(box_x[2]); if (cabs(diff[1] * box_z[0] - diff[0] * box_z[1]) > r1 + r2) { - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionEntry.I b/panda/src/collide/collisionEntry.I index 9b535d17ce..8187ca7a9c 100644 --- a/panda/src/collide/collisionEntry.I +++ b/panda/src/collide/collisionEntry.I @@ -38,7 +38,7 @@ get_from() const { */ INLINE bool CollisionEntry:: has_into() const { - return (_into != (CollisionSolid *)NULL); + return (_into != nullptr); } /** @@ -338,7 +338,7 @@ test_intersection(CollisionHandler *record, PT(CollisionEntry) result = get_from()->test_intersection(*this); #ifdef DO_COLLISION_RECORDING if (trav->has_recorder()) { - if (result != (CollisionEntry *)NULL) { + if (result != nullptr) { trav->get_recorder()->collision_tested(*result, true); } else { trav->get_recorder()->collision_tested(*this, false); @@ -351,11 +351,11 @@ test_intersection(CollisionHandler *record, // if there was no collision detected but the handler wants to know about // all potential collisions, create a "didn't collide" collision entry for // it - if (record->wants_all_potential_collidees() && result == (CollisionEntry *)NULL) { + if (record->wants_all_potential_collidees() && result == nullptr) { result = new CollisionEntry(*this); result->reset_collided(); } - if (result != (CollisionEntry *)NULL) { + if (result != nullptr) { record->add_entry(result); } } diff --git a/panda/src/collide/collisionEntry.cxx b/panda/src/collide/collisionEntry.cxx index 81814eea48..237c725579 100644 --- a/panda/src/collide/collisionEntry.cxx +++ b/panda/src/collide/collisionEntry.cxx @@ -239,7 +239,7 @@ write(ostream &out, int indent_level) const { out << "]"; const ClipPlaneAttrib *cpa = get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { out << " (clipped)"; } out << "\n"; diff --git a/panda/src/collide/collisionFloorMesh.cxx b/panda/src/collide/collisionFloorMesh.cxx index d523875727..fa7ac93949 100644 --- a/panda/src/collide/collisionFloorMesh.cxx +++ b/panda/src/collide/collisionFloorMesh.cxx @@ -125,7 +125,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); LPoint3 from_origin = ray->get_origin() * entry.get_wrt_mat(); double fx = from_origin[0]; @@ -180,7 +180,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { new_entry->set_surface_point(LPoint3(fx, fy, finalz)); return new_entry; } - return NULL; + return nullptr; } @@ -190,7 +190,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); LPoint3 from_origin = sphere->get_center() * entry.get_wrt_mat(); double fx = from_origin[0]; @@ -243,14 +243,14 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat finalz = p0z+vz+(((uz - vz) *u)/(u+v)); PN_stdfloat dz = fz - finalz; if(dz > rad) - return NULL; + return nullptr; PT(CollisionEntry) new_entry = new CollisionEntry(entry); new_entry->set_surface_normal(LPoint3(0, 0, 1)); new_entry->set_surface_point(LPoint3(fx, fy, finalz)); return new_entry; } - return NULL; + return nullptr; } diff --git a/panda/src/collide/collisionHandlerEvent.cxx b/panda/src/collide/collisionHandlerEvent.cxx index c43a3c2ee4..872044bb22 100644 --- a/panda/src/collide/collisionHandlerEvent.cxx +++ b/panda/src/collide/collisionHandlerEvent.cxx @@ -50,7 +50,7 @@ begin_group() { */ void CollisionHandlerEvent:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); // Record this particular entry for later. This will keep track of all the // unique pairs of nodenode intersections. diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index e8f697fb5f..3c8c8e80bf 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/panda/src/collide/collisionHandlerFloor.cxx @@ -62,13 +62,13 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod bool got_min = false; PN_stdfloat max_height = 0.0f; PN_stdfloat min_height = 0.0f; - CollisionEntry *highest = NULL; - CollisionEntry *lowest = NULL; + CollisionEntry *highest = nullptr; + CollisionEntry *lowest = nullptr; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, 0.0f); + nassertr(entry != nullptr, 0.0f); nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { @@ -159,12 +159,12 @@ handle_entries() { // Get the maximum height for all collisions with this node. bool got_max = false; PN_stdfloat max_height = 0.0f; - CollisionEntry *max_entry = NULL; + CollisionEntry *max_entry = nullptr; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, false); + nassertr(entry != nullptr, false); nassertr(from_node_path == entry->get_from_node_path(), false); if (entry->has_surface_point()) { diff --git a/panda/src/collide/collisionHandlerFluidPusher.cxx b/panda/src/collide/collisionHandlerFluidPusher.cxx index 0a48381d01..df15e8bacc 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.cxx +++ b/panda/src/collide/collisionHandlerFluidPusher.cxx @@ -35,7 +35,7 @@ CollisionHandlerFluidPusher() { */ void CollisionHandlerFluidPusher:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); // skip over CollisionHandlerPhysical::add_entry, since it filters out // collidees by orientation; our collider can change direction mid-frame, so // it may collide with something that would have been filtered out @@ -154,24 +154,24 @@ handle_entries() { // unit vector pointing out to the right relative to the direction of // motion, looking into the direction of motion - const LVector3 right_unit(LVector3::up().cross(reverse_vec)); + //const LVector3 right_unit(LVector3::up().cross(reverse_vec)); // iterate until the mover runs out of movement or gets stuck while (true) { - const CollisionEntry *C = 0; + const CollisionEntry *C = nullptr; // find the first (earliest) collision Entries::const_iterator cei; for (cei = entries.begin(); cei != entries.end(); ++cei) { const CollisionEntry *entry = (*cei); - nassertr(entry != (CollisionEntry *)NULL, false); - if (entry->collided() && ((C == 0) || (entry->get_t() < C->get_t()))) { + nassertr(entry != nullptr, false); + if (entry->collided() && ((C == nullptr) || (entry->get_t() < C->get_t()))) { nassertr(from_node_path == entry->get_from_node_path(), false); C = entry; } } // if no collisions, we're done - if (C == 0) { + if (C == nullptr) { break; } @@ -213,11 +213,11 @@ handle_entries() { prev_trans = prev_trans->set_pos(contact_pos); from_node_path.set_prev_transform(wrt_node, prev_trans); - { + /*{ const LPoint3 new_pos(from_node_path.get_pos(wrt_node)); CPT(TransformState) new_prev_trans(from_node_path.get_prev_transform(wrt_node)); const LPoint3 new_prev_pos(new_prev_trans->get_pos()); - } + }*/ // recalculate the position delta N = from_node_path.get_pos_delta(wrt_node); @@ -227,13 +227,13 @@ handle_entries() { Entries new_entries; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, false); + nassertr(entry != nullptr, false); // skip the one we just collided against if (entry != C) { entry->_from_node_path = from_node_path; entry->reset_collided(); PT(CollisionEntry) result = entry->get_from()->test_intersection(**ei); - if (result != (CollisionEntry *)NULL && result != (CollisionEntry *)0) { + if (result != nullptr && result != nullptr) { new_entries.push_back(result); } } diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index a09b70a0a6..42a52a54b6 100644 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -53,12 +53,12 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod // Get the maximum height for all collisions with this node. bool got_max = false; PN_stdfloat max_height = 0.0f; - CollisionEntry *highest = NULL; + CollisionEntry *highest = nullptr; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, 0.0f); + nassertr(entry != nullptr, 0.0f); nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { @@ -109,15 +109,15 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod bool got_min = false; PN_stdfloat max_height = 0.0f; PN_stdfloat min_height = 0.0f; - CollisionEntry *highest = NULL; - CollisionEntry *lowest = NULL; + CollisionEntry *highest = nullptr; + CollisionEntry *lowest = nullptr; pvector valid_entries; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, 0.0f); + nassertr(entry != nullptr, 0.0f); nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { diff --git a/panda/src/collide/collisionHandlerHighestEvent.cxx b/panda/src/collide/collisionHandlerHighestEvent.cxx index f72023153d..55eb58b221 100644 --- a/panda/src/collide/collisionHandlerHighestEvent.cxx +++ b/panda/src/collide/collisionHandlerHighestEvent.cxx @@ -46,7 +46,7 @@ begin_group() { } _current_colliding.clear(); _collider_distance = 0; - _closest_collider = NULL; + _closest_collider = nullptr; } /** @@ -55,12 +55,12 @@ begin_group() { */ void CollisionHandlerHighestEvent:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); LVector3 vec = entry->get_surface_point(entry->get_from_node_path()) - entry->get_from()->get_collision_origin(); double dist = vec.length_squared(); - if (_closest_collider == NULL || dist < _collider_distance) { + if (_closest_collider == nullptr || dist < _collider_distance) { _collider_distance = dist; _closest_collider = entry; } diff --git a/panda/src/collide/collisionHandlerPhysical.I b/panda/src/collide/collisionHandlerPhysical.I index d0f45fd495..5000ec3f59 100644 --- a/panda/src/collide/collisionHandlerPhysical.I +++ b/panda/src/collide/collisionHandlerPhysical.I @@ -74,7 +74,7 @@ set_target(const NodePath &target, DriveInterface *drive_interface) { */ INLINE void CollisionHandlerPhysical::ColliderDef:: updated_transform() { - if (_drive_interface != (DriveInterface *)NULL) { + if (_drive_interface != nullptr) { _drive_interface->set_mat(_target.get_mat()); _drive_interface->force_dgraph(); } diff --git a/panda/src/collide/collisionHandlerPhysical.cxx b/panda/src/collide/collisionHandlerPhysical.cxx index 4b356235a3..3e65e41bfc 100644 --- a/panda/src/collide/collisionHandlerPhysical.cxx +++ b/panda/src/collide/collisionHandlerPhysical.cxx @@ -52,7 +52,7 @@ begin_group() { */ void CollisionHandlerPhysical:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); CollisionHandlerEvent::add_entry(entry); if (entry->get_from()->is_tangible() && diff --git a/panda/src/collide/collisionHandlerPhysical.h b/panda/src/collide/collisionHandlerPhysical.h index cb3a340cdc..9a9225b6b8 100644 --- a/panda/src/collide/collisionHandlerPhysical.h +++ b/panda/src/collide/collisionHandlerPhysical.h @@ -62,7 +62,7 @@ protected: class ColliderDef { public: INLINE void set_target(const NodePath &target, - DriveInterface *drive_interface = NULL); + DriveInterface *drive_interface = nullptr); INLINE void updated_transform(); NodePath _target; diff --git a/panda/src/collide/collisionHandlerPusher.cxx b/panda/src/collide/collisionHandlerPusher.cxx index 4b1b60482a..5881b7e177 100644 --- a/panda/src/collide/collisionHandlerPusher.cxx +++ b/panda/src/collide/collisionHandlerPusher.cxx @@ -91,7 +91,7 @@ handle_entries() { Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, false); + nassertr(entry != nullptr, false); nassertr(from_node_path == entry->get_from_node_path(), false); LPoint3 surface_point; @@ -171,8 +171,8 @@ handle_entries() { // concave). const CollisionSolid *s1 = sd._entry->get_into(); const CollisionSolid *s2 = sd2._entry->get_into(); - if (s1 != (CollisionSolid *)NULL && - s2 != (CollisionSolid *)NULL && + if (s1 != nullptr && + s2 != nullptr && s1->is_exact_type(CollisionPolygon::get_class_type()) && s2->is_exact_type(CollisionPolygon::get_class_type()) && sd._entry->get_into_node_path() == diff --git a/panda/src/collide/collisionHandlerQueue.cxx b/panda/src/collide/collisionHandlerQueue.cxx index 9c8909f3bc..7a2fefd271 100644 --- a/panda/src/collide/collisionHandlerQueue.cxx +++ b/panda/src/collide/collisionHandlerQueue.cxx @@ -58,7 +58,7 @@ begin_group() { */ void CollisionHandlerQueue:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); _entries.push_back(entry); } @@ -118,7 +118,7 @@ get_num_entries() const { */ CollisionEntry *CollisionHandlerQueue:: get_entry(int n) const { - nassertr(n >= 0 && n < (int)_entries.size(), NULL); + nassertr(n >= 0 && n < (int)_entries.size(), nullptr); return _entries[n]; } diff --git a/panda/src/collide/collisionInvSphere.cxx b/panda/src/collide/collisionInvSphere.cxx index 35a73225dd..2074fb9522 100644 --- a/panda/src/collide/collisionInvSphere.cxx +++ b/panda/src/collide/collisionInvSphere.cxx @@ -47,7 +47,7 @@ make_copy() { PT(CollisionEntry) CollisionInvSphere:: test_intersection(const CollisionEntry &) const { report_undefined_from_intersection(get_type()); - return NULL; + return nullptr; } /** @@ -92,7 +92,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -108,7 +108,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat dist2 = dot(vec, vec); if (dist2 < (into_radius - from_radius) * (into_radius - from_radius)) { // No intersection--the sphere is within the hollow. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -144,7 +144,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -185,7 +185,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -228,7 +228,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -264,7 +264,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { // Neither edge of the segment intersects the shell. It follows that both // intersection points are within the hollow center of the sphere; // therefore, there is no intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionLevelState.I b/panda/src/collide/collisionLevelState.I index 5dc74aa691..db618f99e7 100644 --- a/panda/src/collide/collisionLevelState.I +++ b/panda/src/collide/collisionLevelState.I @@ -147,7 +147,7 @@ any_in_bounds() { is_in = true; // If there's no bounding volume, we're implicitly in. - if (col_gbv != (GeometricBoundingVolume *)NULL) { + if (col_gbv != nullptr) { is_in = (node_gbv->contains(col_gbv) != 0); _node_volume_pcollector.add_level(1); @@ -231,7 +231,7 @@ apply_transform() { int num_colliders = get_num_colliders(); new_bounds.reserve(num_colliders); for (int c = 0; c < num_colliders; c++) { - new_bounds.push_back((GeometricBoundingVolume *)NULL); + new_bounds.push_back(nullptr); } _local_bounds = new_bounds; @@ -257,8 +257,8 @@ apply_transform() { new_bounds.reserve(num_colliders); for (int c = 0; c < num_colliders; c++) { if (!has_collider(c) || - get_local_bound(c) == (GeometricBoundingVolume *)NULL) { - new_bounds.push_back((GeometricBoundingVolume *)NULL); + get_local_bound(c) == nullptr) { + new_bounds.push_back(nullptr); } else { const GeometricBoundingVolume *old_bound = get_local_bound(c); GeometricBoundingVolume *new_bound = diff --git a/panda/src/collide/collisionLevelStateBase.I b/panda/src/collide/collisionLevelStateBase.I index 2f2b366fb9..20923a9c22 100644 --- a/panda/src/collide/collisionLevelStateBase.I +++ b/panda/src/collide/collisionLevelStateBase.I @@ -88,7 +88,7 @@ get_num_colliders() const { */ INLINE const CollisionSolid *CollisionLevelStateBase:: get_collider(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); return _colliders[n]._collider; } @@ -98,7 +98,7 @@ get_collider(int n) const { */ INLINE CollisionNode *CollisionLevelStateBase:: get_collider_node(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); return _colliders[n]._node; } @@ -119,8 +119,8 @@ get_collider_node_path(int n) const { */ INLINE const GeometricBoundingVolume *CollisionLevelStateBase:: get_local_bound(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); - nassertr(n >= 0 && n < (int)_local_bounds.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); + nassertr(n >= 0 && n < (int)_local_bounds.size(), nullptr); // For whatever reason, the Intel compiler can't figure this line out. // return _local_bounds[n]; @@ -137,8 +137,8 @@ get_local_bound(int n) const { */ INLINE const GeometricBoundingVolume *CollisionLevelStateBase:: get_parent_bound(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); - nassertr(n >= 0 && n < (int)_parent_bounds.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); + nassertr(n >= 0 && n < (int)_parent_bounds.size(), nullptr); // But it can figure out this equivalent line. return *(_parent_bounds + n); diff --git a/panda/src/collide/collisionLevelStateBase.cxx b/panda/src/collide/collisionLevelStateBase.cxx index c66f58e8fc..02d7cc2fd2 100644 --- a/panda/src/collide/collisionLevelStateBase.cxx +++ b/panda/src/collide/collisionLevelStateBase.cxx @@ -52,7 +52,7 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { const CollisionSolid *collider = def._collider; CPT(BoundingVolume) bv = collider->get_bounds(); if (!bv->is_of_type(GeometricBoundingVolume::get_class_type())) { - _local_bounds.push_back((GeometricBoundingVolume *)NULL); + _local_bounds.push_back(nullptr); } else { // We can use a plain pointer, rather than a PT() here, because we know we // are going to save the volume in the vector, below. diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index 9de94617b3..803a5f058d 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -142,7 +142,7 @@ combine_with(PandaNode *other) { } } - return NULL; + return nullptr; } /** @@ -184,7 +184,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { for (si = _solids.begin(); si != _solids.end(); ++si) { CPT(CollisionSolid) solid = (*si).get_read_pointer(); PT(PandaNode) node = solid->get_viz(trav, data, false); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { CullTraverserData next_data(data, node); // We don't want to inherit the render state from above for these guys. @@ -206,7 +206,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { for (si = _solids.begin(); si != _solids.end(); ++si) { CPT(CollisionSolid) solid = (*si).get_read_pointer(); PT(PandaNode) node = solid->get_viz(trav, data, false); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { CullTraverserData next_data(data, node); next_data._net_transform = @@ -331,8 +331,8 @@ CPT(RenderState) CollisionNode:: get_last_pos_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha)); @@ -422,7 +422,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for(int i = 0; i < num_solids; i++) { manager->read_pointer(scan); // Push back a NULL for each solid, for now. We'll fill them in later. - _solids.push_back((CollisionSolid *)NULL); + _solids.push_back(nullptr); } _from_collide_mask.set_word(scan.get_uint32()); diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index d722adde7b..f869f6c2d1 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -107,7 +107,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -119,7 +119,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat dist = dist_to_plane(from_center); if (dist > from_radius) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -146,7 +146,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -159,7 +159,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { if (_plane.dist_to_plane(from_origin) > 0.0f) { // The line is entirely in front of the plane. - return NULL; + return nullptr; } // The line is entirely behind the plane. @@ -191,7 +191,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -208,13 +208,13 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } else { if (!_plane.intersects_line(t, from_origin, from_direction)) { // No intersection. The ray is parallel to the plane. - return NULL; + return nullptr; } if (t < 0.0f) { // The intersection point is before the start of the ray, and so the ray // is entirely in front of the plane. - return NULL; + return nullptr; } } @@ -243,7 +243,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -255,7 +255,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { if (dist_a >= 0.0f && dist_b >= 0.0f) { // Entirely in front of the plane means no intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -300,7 +300,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_tube(const CollisionEntry &entry) const { const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), NULL); + DCAST_INTO_R(tube, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -315,7 +315,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { if (dist_a >= from_radius && dist_b >= from_radius) { // Entirely in front of the plane means no intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -371,7 +371,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -390,7 +390,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { if (!get_plane().intersects_parabola(t1, t2, local_p)) { // No intersection. The infinite parabola is entirely in front of the // plane. - return NULL; + return nullptr; } if (t1 >= parabola->get_t1() && t1 <= parabola->get_t2()) { @@ -409,7 +409,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } else { // Neither intersection point is within our segment. - return NULL; + return nullptr; } } @@ -437,7 +437,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -459,7 +459,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { if (depth > 0) { // No collision. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index 646a7b9439..2e907c0695 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -235,7 +235,7 @@ PT(PandaNode) CollisionPolygon:: get_viz(const CullTraverser *trav, const CullTraverserData &data, bool bounds_only) const { const ClipPlaneAttrib *cpa = DCAST(ClipPlaneAttrib, data._state->get_attrib(ClipPlaneAttrib::get_class_slot())); - if (cpa == (const ClipPlaneAttrib *)NULL) { + if (cpa == nullptr) { // Fortunately, the polygon is not clipped. This is the normal, easy // case. return CollisionSolid::get_viz(trav, data, bounds_only); @@ -259,7 +259,7 @@ get_viz(const CullTraverser *trav, const CullTraverserData &data, if (new_points.empty()) { // All points are in front of the clip plane; draw nothing. - return NULL; + return nullptr; } // Draw the clipped polygon. @@ -360,11 +360,11 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_sphere(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); @@ -395,7 +395,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // in the same direction as the plane's normal. PN_stdfloat dot = delta.dot(get_normal()); if (dot > 0.1f) { - return NULL; + return nullptr; } if (IS_NEARLY_ZERO(dot)) { @@ -451,19 +451,19 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { if (!get_plane().intersects_line(dist, from_center, -get_normal())) { // No intersection with plane? This means the plane's effective normal // was within the plane itself. A useless polygon. - return NULL; + return nullptr; } if (dist > from_radius || dist < -from_radius) { // No intersection with the plane. - return NULL; + return nullptr; } LPoint2 p = to_2d(from_center - dist * get_normal()); PN_stdfloat edge_dist = 0.0f; const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { @@ -472,7 +472,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } else if (new_points.empty()) { // The polygon is completely clipped. - return NULL; + return nullptr; } else { // Test against the clipped polygon. @@ -489,7 +489,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { if (edge_dist > from_radius) { // No intersection; the circle is outside the polygon. - return NULL; + return nullptr; } // The sphere appears to intersect the polygon. If the edge is less than @@ -505,7 +505,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { if (dist > max_dist) { // There's no intersection: the sphere is hanging off the edge. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -541,11 +541,11 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_line(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -555,35 +555,35 @@ test_intersection_from_line(const CollisionEntry &entry) const { PN_stdfloat t; if (!get_plane().intersects_line(t, from_origin, from_direction)) { // No intersection. - return NULL; + return nullptr; } LPoint3 plane_point = from_origin + t * from_direction; LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -609,11 +609,11 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_ray(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -623,40 +623,40 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PN_stdfloat t; if (!get_plane().intersects_line(t, from_origin, from_direction)) { // No intersection. - return NULL; + return nullptr; } if (t < 0.0f) { // The intersection point is before the start of the ray. - return NULL; + return nullptr; } LPoint3 plane_point = from_origin + t * from_direction; LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -682,11 +682,11 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_segment(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -697,41 +697,41 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PN_stdfloat t; if (!get_plane().intersects_line(t, from_a, from_direction)) { // No intersection. - return NULL; + return nullptr; } if (t < 0.0f || t > 1.0f) { // The intersection point is before the start of the segment or after the // end of the segment. - return NULL; + return nullptr; } LPoint3 plane_point = from_a + t * from_direction; LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -757,11 +757,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_parabola(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -772,7 +772,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PN_stdfloat t1, t2; if (!get_plane().intersects_parabola(t1, t2, local_p)) { // No intersection. - return NULL; + return nullptr; } PN_stdfloat t; @@ -792,35 +792,35 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } else { // Neither intersection point is within our segment. - return NULL; + return nullptr; } LPoint3 plane_point = local_p.calc_point(t); LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -846,7 +846,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); // To make things easier, transform the box into the coordinate space of the // plane. @@ -864,7 +864,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { // Is there a separating axis between the plane and the box? if (cabs(from_center[1]) > cabs(box_x[1]) + cabs(box_y[1]) + cabs(box_z[1])) { // There is one. No collision. - return NULL; + return nullptr; } // Now do the same for each of the box' primary axes. @@ -873,19 +873,19 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(box_x)) + cabs(box_y.dot(box_x)) + cabs(box_z.dot(box_x)); project(box_x, center, r2); if (cabs(from_center.dot(box_x) - center) > r1 + r2) { - return NULL; + return nullptr; } r1 = cabs(box_x.dot(box_y)) + cabs(box_y.dot(box_y)) + cabs(box_z.dot(box_y)); project(box_y, center, r2); if (cabs(from_center.dot(box_y) - center) > r1 + r2) { - return NULL; + return nullptr; } r1 = cabs(box_x.dot(box_z)) + cabs(box_y.dot(box_z)) + cabs(box_z.dot(box_z)); project(box_z, center, r2); if (cabs(from_center.dot(box_z) - center) > r1 + r2) { - return NULL; + return nullptr; } // Now do the same check for the cross products between the box axes and the @@ -901,7 +901,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(axis)) + cabs(box_y.dot(axis)) + cabs(box_z.dot(axis)); project(axis, center, r2); if (cabs(from_center.dot(axis) - center) > r1 + r2) { - return NULL; + return nullptr; } axis.set(-box_y[1] * pd._v[1], @@ -910,7 +910,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(axis)) + cabs(box_y.dot(axis)) + cabs(box_z.dot(axis)); project(axis, center, r2); if (cabs(from_center.dot(axis) - center) > r1 + r2) { - return NULL; + return nullptr; } axis.set(-box_z[1] * pd._v[1], @@ -919,7 +919,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(axis)) + cabs(box_y.dot(axis)) + cabs(box_z.dot(axis)); project(axis, center, r2); if (cabs(from_center.dot(axis) - center) > r1 + r2) { - return NULL; + return nullptr; } } @@ -958,7 +958,7 @@ fill_viz_geom() { collide_cat.debug() << "Recomputing viz for " << *this << "\n"; } - nassertv(_viz_geom != (GeomNode *)NULL && _bounds_viz_geom != (GeomNode *)NULL); + nassertv(_viz_geom != nullptr && _bounds_viz_geom != nullptr); draw_polygon(_viz_geom, _bounds_viz_geom, _points); } diff --git a/panda/src/collide/collisionRecorder.cxx b/panda/src/collide/collisionRecorder.cxx index 09d87a9971..45580e97f1 100644 --- a/panda/src/collide/collisionRecorder.cxx +++ b/panda/src/collide/collisionRecorder.cxx @@ -25,7 +25,7 @@ CollisionRecorder:: CollisionRecorder() { _num_missed = 0; _num_detected = 0; - _trav = (CollisionTraverser *)NULL; + _trav = nullptr; } /** @@ -33,7 +33,7 @@ CollisionRecorder() { */ CollisionRecorder:: ~CollisionRecorder() { - if (_trav != (CollisionTraverser *)NULL) { + if (_trav != nullptr) { _trav->clear_recorder(); } } diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index 5f27903b45..f812c836f2 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -108,7 +108,7 @@ set_bounds(const BoundingVolume &bounding_volume) { PT(CollisionEntry) CollisionSolid:: test_intersection(const CollisionEntry &) const { report_undefined_from_intersection(get_type()); - return NULL; + return nullptr; } /** @@ -134,7 +134,7 @@ PT(PandaNode) CollisionSolid:: get_viz(const CullTraverser *, const CullTraverserData &, bool bounds_only) const { LightMutexHolder holder(_lock); if ((_flags & F_viz_geom_stale) != 0) { - if (_viz_geom == (GeomNode *)NULL) { + if (_viz_geom == nullptr) { ((CollisionSolid *)this)->_viz_geom = new GeomNode("viz"); ((CollisionSolid *)this)->_bounds_viz_geom = new GeomNode("bounds_viz"); } else { @@ -202,7 +202,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_sphere(const CollisionEntry &) const { report_undefined_intersection_test(CollisionSphere::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -213,7 +213,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_line(const CollisionEntry &) const { report_undefined_intersection_test(CollisionLine::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -224,7 +224,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_ray(const CollisionEntry &) const { report_undefined_intersection_test(CollisionRay::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -235,7 +235,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_segment(const CollisionEntry &) const { report_undefined_intersection_test(CollisionSegment::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -246,7 +246,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_tube(const CollisionEntry &) const { report_undefined_intersection_test(CollisionTube::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -257,7 +257,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_parabola(const CollisionEntry &) const { report_undefined_intersection_test(CollisionParabola::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -268,7 +268,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_box(const CollisionEntry &) const { report_undefined_intersection_test(CollisionBox::get_class_type(), get_type()); - return NULL; + return nullptr; } @@ -389,8 +389,8 @@ CPT(RenderState) CollisionSolid:: get_solid_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), @@ -398,24 +398,24 @@ get_solid_viz_state() { } if (!do_is_tangible()) { - static CPT(RenderState) intangible_state = (const RenderState *)NULL; - if (intangible_state == (const RenderState *)NULL) { + static CPT(RenderState) intangible_state = nullptr; + if (intangible_state == nullptr) { intangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 0.3, 0.5f, 0.5f))); } return intangible_state; } else if (do_has_effective_normal()) { - static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; - if (fakenormal_state == (const RenderState *)NULL) { + static CPT(RenderState) fakenormal_state = nullptr; + if (fakenormal_state == nullptr) { fakenormal_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.5f, 0.5f, 1.0f, 0.5f))); } return fakenormal_state; } else { - static CPT(RenderState) tangible_state = (const RenderState *)NULL; - if (tangible_state == (const RenderState *)NULL) { + static CPT(RenderState) tangible_state = nullptr; + if (tangible_state == nullptr) { tangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 1.0f, 0.5f))); } @@ -435,8 +435,8 @@ CPT(RenderState) CollisionSolid:: get_wireframe_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_none), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -444,24 +444,24 @@ get_wireframe_viz_state() { } if (!do_is_tangible()) { - static CPT(RenderState) intangible_state = (const RenderState *)NULL; - if (intangible_state == (const RenderState *)NULL) { + static CPT(RenderState) intangible_state = nullptr; + if (intangible_state == nullptr) { intangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.0f, 1.0f))); } return intangible_state; } else if (do_has_effective_normal()) { - static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; - if (fakenormal_state == (const RenderState *)NULL) { + static CPT(RenderState) fakenormal_state = nullptr; + if (fakenormal_state == nullptr) { fakenormal_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.0f, 0.0f, 1.0f, 1.0f))); } return fakenormal_state; } else { - static CPT(RenderState) tangible_state = (const RenderState *)NULL; - if (tangible_state == (const RenderState *)NULL) { + static CPT(RenderState) tangible_state = nullptr; + if (tangible_state == nullptr) { tangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.0f, 0.0f, 1.0f, 1.0f))); } @@ -480,8 +480,8 @@ CPT(RenderState) CollisionSolid:: get_other_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), @@ -504,8 +504,8 @@ CPT(RenderState) CollisionSolid:: get_solid_bounds_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), @@ -513,24 +513,24 @@ get_solid_bounds_viz_state() { } if (!do_is_tangible()) { - static CPT(RenderState) intangible_state = (const RenderState *)NULL; - if (intangible_state == (const RenderState *)NULL) { + static CPT(RenderState) intangible_state = nullptr; + if (intangible_state == nullptr) { intangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.5f, 0.3))); } return intangible_state; } else if (do_has_effective_normal()) { - static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; - if (fakenormal_state == (const RenderState *)NULL) { + static CPT(RenderState) fakenormal_state = nullptr; + if (fakenormal_state == nullptr) { fakenormal_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.5f, 0.5f, 1.0f, 0.3))); } return fakenormal_state; } else { - static CPT(RenderState) tangible_state = (const RenderState *)NULL; - if (tangible_state == (const RenderState *)NULL) { + static CPT(RenderState) tangible_state = nullptr; + if (tangible_state == nullptr) { tangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.5f, 0.3))); } @@ -550,8 +550,8 @@ CPT(RenderState) CollisionSolid:: get_wireframe_bounds_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_none), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -573,8 +573,8 @@ CPT(RenderState) CollisionSolid:: get_other_bounds_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index 139a39a4b1..898fbd86c6 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -120,7 +120,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); @@ -152,13 +152,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LVector3 from_direction = from_b - from_a; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or // after the end of the segment. - return NULL; + return nullptr; } // doubles, not floats, to satisfy min and max templates. @@ -176,7 +176,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } } else { // No delta, therefore no intersection. - return NULL; + return nullptr; } } @@ -231,7 +231,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -241,7 +241,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -271,7 +271,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); // Instead of transforming the box into the sphere's coordinate space, we do // it the other way around. It's easier that way. @@ -315,7 +315,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { } if (d > radius_sq) { - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -347,7 +347,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -357,12 +357,12 @@ test_intersection_from_ray(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0) { // Both intersection points are before the start of the ray. - return NULL; + return nullptr; } t1 = max(t1, 0.0); @@ -394,7 +394,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -405,13 +405,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or after // the end of the segment. - return NULL; + return nullptr; } t1 = max(t1, 0.0); @@ -443,7 +443,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_tube(const CollisionEntry &entry) const { const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), NULL); + DCAST_INTO_R(tube, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -458,13 +458,13 @@ test_intersection_from_tube(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the tube or after // the end of the tube. - return NULL; + return nullptr; } PN_stdfloat t = (t1 + t2) * (PN_stdfloat)0.5; @@ -499,7 +499,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -512,7 +512,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { local_p.calc_point(parabola->get_t1()), local_p.calc_point(parabola->get_t2()))) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionTraverser.I b/panda/src/collide/collisionTraverser.I index 4f35be0a9e..dee53e3a53 100644 --- a/panda/src/collide/collisionTraverser.I +++ b/panda/src/collide/collisionTraverser.I @@ -40,7 +40,7 @@ get_respect_prev_transform() const { */ INLINE bool CollisionTraverser:: has_recorder() const { - return _recorder != (CollisionRecorder *)NULL; + return _recorder != nullptr; } /** @@ -58,7 +58,7 @@ get_recorder() const { */ INLINE void CollisionTraverser:: clear_recorder() { - set_recorder((CollisionRecorder *)NULL); + set_recorder(nullptr); } #endif // DO_COLLISION_RECORDING diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 74973d6764..65f33cba31 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -73,7 +73,7 @@ CollisionTraverser(const string &name) : { _respect_prev_transform = respect_prev_transform; #ifdef DO_COLLISION_RECORDING - _recorder = (CollisionRecorder *)NULL; + _recorder = nullptr; #endif } @@ -100,7 +100,7 @@ void CollisionTraverser:: add_collider(const NodePath &collider, CollisionHandler *handler) { nassertv(_ordered_colliders.size() == _colliders.size()); nassertv(!collider.is_empty() && collider.node()->is_collision_node()); - nassertv(handler != (CollisionHandler *)NULL); + nassertv(handler != nullptr); Colliders::iterator ci = _colliders.find(collider); if (ci != _colliders.end()) { @@ -231,7 +231,7 @@ get_handler(const NodePath &collider) const { if (ci != _colliders.end()) { return (*ci).second; } - return NULL; + return nullptr; } /** @@ -370,20 +370,20 @@ void CollisionTraverser:: set_recorder(CollisionRecorder *recorder) { if (recorder != _recorder) { // Remove the old recorder, if any. - if (_recorder != (CollisionRecorder *)NULL) { + if (_recorder != nullptr) { nassertv(_recorder->_trav == this); - _recorder->_trav = (CollisionTraverser *)NULL; + _recorder->_trav = nullptr; } _recorder = recorder; // Tell the new recorder about his new owner. - if (_recorder != (CollisionRecorder *)NULL) { + if (_recorder != nullptr) { nassertv(_recorder->_trav != this); - if (_recorder->_trav != (CollisionTraverser *)NULL) { + if (_recorder->_trav != nullptr) { _recorder->_trav->clear_recorder(); } - nassertv(_recorder->_trav == (CollisionTraverser *)NULL); + nassertv(_recorder->_trav == nullptr); _recorder->_trav = this; } } @@ -447,7 +447,7 @@ write(ostream &out, int indent_level) const { nassertv(ci != _colliders.end()); CollisionHandler *handler = (*ci).second; - nassertv(handler != (CollisionHandler *)NULL); + nassertv(handler != nullptr); indent(out, indent_level + 2) << cnode_path; @@ -495,7 +495,7 @@ prepare_colliders_single(CollisionTraverser::LevelStatesSingle &level_states, for (i = 0; i < num_colliders; ++i) { indirect[i] = i; } - sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); + std::sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); int num_remaining_colliders = num_colliders; for (i = 0; i < num_colliders; ++i) { @@ -561,7 +561,7 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { CollisionNode *cnode; DCAST_INTO_V(cnode, node); CPT(BoundingVolume) node_bv = cnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -606,7 +606,7 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -706,7 +706,7 @@ prepare_colliders_double(CollisionTraverser::LevelStatesDouble &level_states, for (i = 0; i < num_colliders; ++i) { indirect[i] = i; } - sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); + std::sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); int num_remaining_colliders = num_colliders; for (i = 0; i < num_colliders; ++i) { @@ -772,7 +772,7 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { CollisionNode *cnode; DCAST_INTO_V(cnode, node); CPT(BoundingVolume) node_bv = cnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -817,7 +817,7 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -917,7 +917,7 @@ prepare_colliders_quad(CollisionTraverser::LevelStatesQuad &level_states, for (i = 0; i < num_colliders; ++i) { indirect[i] = i; } - sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); + std::sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); int num_remaining_colliders = num_colliders; for (i = 0; i < num_colliders; ++i) { @@ -983,7 +983,7 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { CollisionNode *cnode; DCAST_INTO_V(cnode, node); CPT(BoundingVolume) node_bv = cnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -1028,7 +1028,7 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -1110,8 +1110,8 @@ compare_collider_to_node(CollisionEntry &entry, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *into_node_gbv) { bool within_node_bounds = true; - if (from_parent_gbv != (GeometricBoundingVolume *)NULL && - into_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_parent_gbv != nullptr && + into_node_gbv != nullptr) { within_node_bounds = (into_node_gbv->contains(from_parent_gbv) != 0); _cnode_volume_pcollector.add_level(1); } @@ -1169,8 +1169,8 @@ compare_collider_to_geom_node(CollisionEntry &entry, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *into_node_gbv) { bool within_node_bounds = true; - if (from_parent_gbv != (GeometricBoundingVolume *)NULL && - into_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_parent_gbv != nullptr && + into_node_gbv != nullptr) { within_node_bounds = (into_node_gbv->contains(from_parent_gbv) != 0); _gnode_volume_pcollector.add_level(1); } @@ -1180,11 +1180,11 @@ compare_collider_to_geom_node(CollisionEntry &entry, DCAST_INTO_V(gnode, entry._into_node); int num_geoms = gnode->get_num_geoms(); for (int s = 0; s < num_geoms; ++s) { - entry._into = (CollisionSolid *)NULL; + entry._into = nullptr; const Geom *geom = DCAST(Geom, gnode->get_geom(s)); - if (geom != (Geom *)NULL) { + if (geom != nullptr) { CPT(BoundingVolume) geom_bv = geom->get_bounds(); - const GeometricBoundingVolume *geom_gbv = NULL; + const GeometricBoundingVolume *geom_gbv = nullptr; if (num_geoms > 1 && geom_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { // Only bother to test against each geom's bounding volume if we @@ -1209,8 +1209,8 @@ compare_collider_to_solid(CollisionEntry &entry, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *solid_gbv) { bool within_solid_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL && - solid_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr && + solid_gbv != nullptr) { within_solid_bounds = (solid_gbv->contains(from_node_gbv) != 0); #ifdef DO_PSTATS ((CollisionSolid *)entry.get_into())->get_volume_pcollector().add_level(1); @@ -1240,8 +1240,8 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *geom_gbv) { bool within_geom_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL && - geom_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr && + geom_gbv != nullptr) { within_geom_bounds = (geom_gbv->contains(from_node_gbv) != 0); _geom_volume_pcollector.add_level(1); } @@ -1278,7 +1278,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, // in the Geom. if (CollisionPolygon::verify_points(v[0], v[1], v[2])) { bool within_solid_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr) { PT(BoundingSphere) sphere = new BoundingSphere; sphere->around(v, v + 3); within_solid_bounds = (sphere->contains(from_node_gbv) != 0); @@ -1308,7 +1308,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, // in the Geom. if (CollisionPolygon::verify_points(v[0], v[1], v[2])) { bool within_solid_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr) { PT(BoundingSphere) sphere = new BoundingSphere; sphere->around(v, v + 3); within_solid_bounds = (sphere->contains(from_node_gbv) != 0); diff --git a/panda/src/collide/collisionTraverser.h b/panda/src/collide/collisionTraverser.h index 8aaa0fd475..5f5ebe0b13 100644 --- a/panda/src/collide/collisionTraverser.h +++ b/panda/src/collide/collisionTraverser.h @@ -111,7 +111,6 @@ private: private: PT(CollisionHandler) _default_handler; - TypeHandle _graph_type; class OrderedColliderDef { public: diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index 8e3b188aab..b84e308395 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -146,7 +146,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionTube:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); @@ -173,13 +173,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or after // the end of the segment. - return NULL; + return nullptr; } // doubles, not floats, to satisfy min and max templates. @@ -224,7 +224,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -234,7 +234,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -272,7 +272,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -282,12 +282,12 @@ test_intersection_from_ray(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0) { // Both intersection points are before the start of the ray. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -333,7 +333,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -344,13 +344,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or after // the end of the segment. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -397,7 +397,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -410,7 +410,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { local_p.calc_point(parabola->get_t1()), local_p.calc_point(parabola->get_t2()))) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionVisualizer.cxx b/panda/src/collide/collisionVisualizer.cxx index 204a39b6bd..0c7861b5eb 100644 --- a/panda/src/collide/collisionVisualizer.cxx +++ b/panda/src/collide/collisionVisualizer.cxx @@ -144,7 +144,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { const SolidInfo &solid_info = (*si).second; bool was_detected = (solid_info._detected_count > 0); PT(PandaNode) node = solid->get_viz(trav, xform_data, !was_detected); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { CullTraverserData next_data(xform_data, node); // We don't want to inherit the render state from above for these @@ -321,8 +321,8 @@ CPT(RenderState) CollisionVisualizer:: get_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (DepthOffsetAttrib::make()); } diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index a1a7264af0..99da6cf5ac 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -57,10 +57,10 @@ add_object(CullableObject *object, Thread *current_thread) { } const GeometricBoundingVolume *gbv = volume->as_geometric_bounding_volume(); - nassertv(gbv != NULL); + nassertv(gbv != nullptr); LPoint3 center = gbv->get_approx_center(); - nassertv(object->_internal_transform != (const TransformState *)NULL); + nassertv(object->_internal_transform != nullptr); center = center * object->_internal_transform->get_mat(); PN_stdfloat distance = _gsg->compute_distance_to(center); diff --git a/panda/src/cull/cullBinFixed.cxx b/panda/src/cull/cullBinFixed.cxx index 212bc4f320..e3e5637ad9 100644 --- a/panda/src/cull/cullBinFixed.cxx +++ b/panda/src/cull/cullBinFixed.cxx @@ -61,7 +61,7 @@ add_object(CullableObject *object, Thread *current_thread) { void CullBinFixed:: finish_cull(SceneSetup *, Thread *current_thread) { PStatTimer timer(_cull_this_pcollector, current_thread); - stable_sort(_objects.begin(), _objects.end()); + std::stable_sort(_objects.begin(), _objects.end()); } /** diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index 0fb05a68b5..4d297d1c94 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -57,10 +57,10 @@ add_object(CullableObject *object, Thread *current_thread) { } const GeometricBoundingVolume *gbv = volume->as_geometric_bounding_volume(); - nassertv(gbv != NULL); + nassertv(gbv != nullptr); LPoint3 center = gbv->get_approx_center(); - nassertv(object->_internal_transform != (const TransformState *)NULL); + nassertv(object->_internal_transform != nullptr); center = center * object->_internal_transform->get_mat(); PN_stdfloat distance = _gsg->compute_distance_to(center); diff --git a/panda/src/cull/cullBinStateSorted.I b/panda/src/cull/cullBinStateSorted.I index e035c433bb..1bdb99112f 100644 --- a/panda/src/cull/cullBinStateSorted.I +++ b/panda/src/cull/cullBinStateSorted.I @@ -29,8 +29,8 @@ INLINE CullBinStateSorted::ObjectData:: ObjectData(CullableObject *object) : _object(object) { - if (object->_munged_data == NULL) { - _format = NULL; + if (object->_munged_data == nullptr) { + _format = nullptr; } else { _format = object->_munged_data->get_format(); } diff --git a/panda/src/device/analogNode.I b/panda/src/device/analogNode.I index ec41944491..f02b638603 100644 --- a/panda/src/device/analogNode.I +++ b/panda/src/device/analogNode.I @@ -26,7 +26,7 @@ OutputData() { */ INLINE bool AnalogNode:: is_valid() const { - return (_analog != (ClientAnalogDevice *)NULL) && _analog->is_connected(); + return (_analog != nullptr) && _analog->is_connected(); } /** diff --git a/panda/src/device/analogNode.cxx b/panda/src/device/analogNode.cxx index d577496554..4f331c7bae 100644 --- a/panda/src/device/analogNode.cxx +++ b/panda/src/device/analogNode.cxx @@ -29,11 +29,11 @@ AnalogNode(ClientBase *client, const string &device_name) : _xy_output = define_output("xy", EventStoreVec2::get_class_type()); _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); PT(ClientDevice) device = client->get_device(ClientAnalogDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open analog device " << device_name << "\n"; return; @@ -66,7 +66,7 @@ void AnalogNode:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); - if (_analog != (ClientAnalogDevice *)NULL) { + if (_analog != nullptr) { _analog->acquire(); _analog->write_controls(out, indent_level + 2); _analog->unlock(); diff --git a/panda/src/device/buttonNode.I b/panda/src/device/buttonNode.I index 1fa5efd21b..c4ccc2c610 100644 --- a/panda/src/device/buttonNode.I +++ b/panda/src/device/buttonNode.I @@ -17,7 +17,7 @@ */ INLINE bool ButtonNode:: is_valid() const { - return (_button != (ClientButtonDevice *)NULL) && _button->is_connected(); + return (_button != nullptr) && _button->is_connected(); } /** diff --git a/panda/src/device/buttonNode.cxx b/panda/src/device/buttonNode.cxx index e3125a2db3..e2bb18eeee 100644 --- a/panda/src/device/buttonNode.cxx +++ b/panda/src/device/buttonNode.cxx @@ -29,11 +29,11 @@ ButtonNode(ClientBase *client, const string &device_name) : _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); _button_events = new ButtonEventList; - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); PT(ClientDevice) device = client->get_device(ClientButtonDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open button device " << device_name << "\n"; return; @@ -66,7 +66,7 @@ void ButtonNode:: output(ostream &out) const { DataNode::output(out); - if (_button != (ClientButtonDevice *)NULL) { + if (_button != nullptr) { out << " ("; _button->acquire(); _button->output_buttons(out); @@ -82,7 +82,7 @@ void ButtonNode:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); - if (_button != (ClientButtonDevice *)NULL) { + if (_button != nullptr) { _button->acquire(); _button->write_buttons(out, indent_level + 2); _button->unlock(); diff --git a/panda/src/device/clientBase.cxx b/panda/src/device/clientBase.cxx index 8a061ce5f5..2ad270b81b 100644 --- a/panda/src/device/clientBase.cxx +++ b/panda/src/device/clientBase.cxx @@ -27,7 +27,7 @@ ClientBase() { _cs = CS_default; #ifdef OLD_HAVE_IPC - _client_thread = (thread *)NULL; + _client_thread = nullptr; _shutdown = false; #endif } @@ -126,7 +126,7 @@ get_device(TypeHandle device_type, const string &device_name) { // We need to create a new device for this name. PT(ClientDevice) device = make_device(device_type, device_name); - if (device != (ClientDevice *)NULL) { + if (device != nullptr) { dbn.insert(DevicesByName::value_type(device_name, device)); device->_is_connected = true; } @@ -185,9 +185,9 @@ do_poll() { */ void *ClientBase:: st_callback(void *arg) { - nassertr(arg != NULL, NULL); + nassertr(arg != nullptr, nullptr); ((ClientBase *)arg)->callback(); - return NULL; + return nullptr; } /** diff --git a/panda/src/device/dialNode.I b/panda/src/device/dialNode.I index c342eba997..1f6abdbc64 100644 --- a/panda/src/device/dialNode.I +++ b/panda/src/device/dialNode.I @@ -17,7 +17,7 @@ */ INLINE bool DialNode:: is_valid() const { - return (_dial != (ClientDialDevice *)NULL) && _dial->is_connected(); + return (_dial != nullptr) && _dial->is_connected(); } /** diff --git a/panda/src/device/dialNode.cxx b/panda/src/device/dialNode.cxx index b86305ac00..86fa011908 100644 --- a/panda/src/device/dialNode.cxx +++ b/panda/src/device/dialNode.cxx @@ -25,11 +25,11 @@ DialNode:: DialNode(ClientBase *client, const string &device_name) : DataNode(device_name) { - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); PT(ClientDevice) device = client->get_device(ClientDialDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open dial device " << device_name << "\n"; return; diff --git a/panda/src/device/trackerNode.I b/panda/src/device/trackerNode.I index 75d91d1d82..99929d4af2 100644 --- a/panda/src/device/trackerNode.I +++ b/panda/src/device/trackerNode.I @@ -17,7 +17,7 @@ */ INLINE bool TrackerNode:: is_valid() const { - return (_tracker != (ClientTrackerDevice *)NULL) && _tracker->is_connected(); + return (_tracker != nullptr) && _tracker->is_connected(); } diff --git a/panda/src/device/trackerNode.cxx b/panda/src/device/trackerNode.cxx index e4c9356b13..cf4a8d0f01 100644 --- a/panda/src/device/trackerNode.cxx +++ b/panda/src/device/trackerNode.cxx @@ -28,14 +28,14 @@ TrackerNode(ClientBase *client, const string &device_name) : _transform = TransformState::make_identity(); - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); set_tracker_coordinate_system(client->get_coordinate_system()); set_graph_coordinate_system(CS_default); PT(ClientDevice) device = client->get_device(ClientTrackerDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open tracker device " << device_name << "\n"; return; @@ -63,9 +63,9 @@ TrackerNode(ClientTrackerDevice *device) : _transform = TransformState::make_identity(); - nassertv(device != (ClientTrackerDevice *)NULL); + nassertv(device != nullptr); ClientBase *client = device->get_client(); - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); set_tracker_coordinate_system(client->get_coordinate_system()); set_graph_coordinate_system(CS_default); } diff --git a/panda/src/dgraph/dataGraphTraverser.cxx b/panda/src/dgraph/dataGraphTraverser.cxx index 3b3900d8ea..d0f695bc50 100644 --- a/panda/src/dgraph/dataGraphTraverser.cxx +++ b/panda/src/dgraph/dataGraphTraverser.cxx @@ -58,7 +58,7 @@ traverse(PandaNode *node) { // We must start the traversal at the root of the graph. nassertv(data_node->get_num_parents(_current_thread) == 0); - r_transmit(data_node, (DataNodeTransmit *)NULL); + r_transmit(data_node, nullptr); } else { traverse_below(node, DataNodeTransmit()); diff --git a/panda/src/display/callbackGraphicsWindow.I b/panda/src/display/callbackGraphicsWindow.I index 1a1f104a36..3a05f82fdd 100644 --- a/panda/src/display/callbackGraphicsWindow.I +++ b/panda/src/display/callbackGraphicsWindow.I @@ -32,7 +32,7 @@ set_events_callback(CallbackObject *object) { */ INLINE void CallbackGraphicsWindow:: clear_events_callback() { - set_events_callback(NULL); + set_events_callback(nullptr); } /** @@ -66,7 +66,7 @@ set_properties_callback(CallbackObject *object) { */ INLINE void CallbackGraphicsWindow:: clear_properties_callback() { - set_properties_callback(NULL); + set_properties_callback(nullptr); } /** @@ -96,7 +96,7 @@ set_render_callback(CallbackObject *object) { */ INLINE void CallbackGraphicsWindow:: clear_render_callback() { - set_render_callback(NULL); + set_render_callback(nullptr); } /** diff --git a/panda/src/display/callbackGraphicsWindow.cxx b/panda/src/display/callbackGraphicsWindow.cxx index f9c2362ed7..7774b149c2 100644 --- a/panda/src/display/callbackGraphicsWindow.cxx +++ b/panda/src/display/callbackGraphicsWindow.cxx @@ -29,7 +29,7 @@ CallbackGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg) : - GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, NULL) + GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, nullptr) { #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); @@ -80,7 +80,7 @@ create_input_device(const string &name) { bool CallbackGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { bool result = false; - if (_render_callback != NULL) { + if (_render_callback != nullptr) { RenderCallbackData data(this, RCT_begin_frame, mode); _render_callback->do_callback(&data); result = data.get_render_flag(); @@ -105,7 +105,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { */ void CallbackGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { - if (_render_callback != NULL) { + if (_render_callback != nullptr) { // In case the callback or the application hosting the OpenGL context // wants to do more rendering, let's give it a blank slate. _gsg->set_state_and_transform(RenderState::make_empty(), _gsg->get_internal_transform()); @@ -138,7 +138,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void CallbackGraphicsWindow:: begin_flip() { - if (_render_callback != NULL) { + if (_render_callback != nullptr) { RenderCallbackData data(this, RCT_begin_flip, FM_render); _render_callback->do_callback(&data); } else { @@ -155,7 +155,7 @@ begin_flip() { */ void CallbackGraphicsWindow:: end_flip() { - if (_render_callback != NULL) { + if (_render_callback != nullptr) { RenderCallbackData data(this, RCT_end_flip, FM_render); _render_callback->do_callback(&data); } else { @@ -172,7 +172,7 @@ end_flip() { */ void CallbackGraphicsWindow:: process_events() { - if (_events_callback != NULL) { + if (_events_callback != nullptr) { EventsCallbackData data(this); _events_callback->do_callback(&data); } else { @@ -186,7 +186,7 @@ process_events() { */ void CallbackGraphicsWindow:: set_properties_now(WindowProperties &properties) { - if (_properties_callback != NULL) { + if (_properties_callback != nullptr) { PropertiesCallbackData data(this, properties); _properties_callback->do_callback(&data); } else { diff --git a/panda/src/display/displayInformation.cxx b/panda/src/display/displayInformation.cxx index d690544889..df1cec1420 100644 --- a/panda/src/display/displayInformation.cxx +++ b/panda/src/display/displayInformation.cxx @@ -64,7 +64,7 @@ output(ostream &out) const { */ DisplayInformation:: ~DisplayInformation() { - if (_display_mode_array != NULL) { + if (_display_mode_array != nullptr) { delete[] _display_mode_array; } } @@ -94,7 +94,7 @@ DisplayInformation() { window_height = 0; window_bits_per_pixel = 0; total_display_modes = 0; - display_mode_array = NULL; + display_mode_array = nullptr; video_memory = 0; texture_memory = 0; physical_memory = 0; @@ -148,8 +148,8 @@ DisplayInformation() { _num_cpu_cores = 0; _num_logical_cpus = 0; - _get_memory_information_function = 0; - _update_cpu_frequency_function = 0; + _get_memory_information_function = nullptr; + _update_cpu_frequency_function = nullptr; _os_version_major = -1; _os_version_minor = -1; diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index a1f55f5e7f..fa1c698c0a 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -306,7 +306,7 @@ set_cull_callback(CallbackObject *object) { */ INLINE void DisplayRegion:: clear_cull_callback() { - set_cull_callback(NULL); + set_cull_callback(nullptr); } /** @@ -354,7 +354,7 @@ set_draw_callback(CallbackObject *object) { */ INLINE void DisplayRegion:: clear_draw_callback() { - set_draw_callback(NULL); + set_draw_callback(nullptr); } /** @@ -581,8 +581,8 @@ INLINE DisplayRegionPipelineReader:: _object->_cycler.release_read(_cdata); #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index a84a8728e8..b1d99df839 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -56,7 +56,7 @@ DisplayRegion:: // The window pointer should already have been cleared by the time the // DisplayRegion destructs (since the GraphicsOutput class keeps a reference // count on the DisplayRegion). - nassertv(_window == (GraphicsOutput *)NULL); + nassertv(_window == nullptr); } /** @@ -107,7 +107,7 @@ set_dimensions(int i, const LVecBase4 &dimensions) { cdata->_regions[i]._dimensions = dimensions; - if (_window != (GraphicsOutput *)NULL && _window->has_size()) { + if (_window != nullptr && _window->has_size()) { do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), cdata); } } @@ -118,7 +118,7 @@ set_dimensions(int i, const LVecBase4 &dimensions) { */ GraphicsPipe *DisplayRegion:: get_pipe() const { - return (_window != (GraphicsOutput *)NULL) ? _window->get_pipe() : NULL; + return (_window != nullptr) ? _window->get_pipe() : nullptr; } /** @@ -144,7 +144,7 @@ void DisplayRegion:: set_camera(const NodePath &camera) { CDWriter cdata(_cycler, true); - Camera *camera_node = (Camera *)NULL; + Camera *camera_node = nullptr; if (!camera.is_empty()) { DCAST_INTO_V(camera_node, camera.node()); } @@ -153,12 +153,12 @@ set_camera(const NodePath &camera) { // Note that these operations on the DisplayRegion are not pipelined: they // operate across all pipeline stages. Since we have already asserted we // are running in pipeline stage 0, no problem. - if (cdata->_camera_node != (Camera *)NULL) { + if (cdata->_camera_node != nullptr) { // We need to tell the old camera we're not using him anymore. cdata->_camera_node->remove_display_region(this); } cdata->_camera_node = camera_node; - if (cdata->_camera_node != (Camera *)NULL) { + if (cdata->_camera_node != nullptr) { // Now tell the new camera we are using him. cdata->_camera_node->add_display_region(this); } @@ -307,7 +307,7 @@ set_cull_traverser(CullTraverser *trav) { */ CullTraverser *DisplayRegion:: get_cull_traverser() { - if (_trav == (CullTraverser *)NULL) { + if (_trav == nullptr) { _trav = new CullTraverser; } return _trav; @@ -356,7 +356,7 @@ output(ostream &out) const { */ Filename DisplayRegion:: make_screenshot_filename(const string &prefix) { - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *ttm = localtime(&now); int frame_count = ClockObject::get_global_clock()->get_frame_count(); @@ -456,7 +456,7 @@ bool DisplayRegion:: get_screenshot(PNMImage &image) { PT(Texture) tex = get_screenshot(); - if (tex == NULL) { + if (tex == nullptr) { return false; } @@ -476,13 +476,13 @@ get_screenshot() { Thread *current_thread = Thread::get_current_thread(); GraphicsOutput *window = get_window(); - nassertr(window != (GraphicsOutput *)NULL, NULL); + nassertr(window != nullptr, nullptr); GraphicsStateGuardian *gsg = window->get_gsg(); - nassertr(gsg != (GraphicsStateGuardian *)NULL, NULL); + nassertr(gsg != nullptr, nullptr); if (!window->begin_frame(GraphicsOutput::FM_refresh, current_thread)) { - return NULL; + return nullptr; } { @@ -496,7 +496,7 @@ get_screenshot() { RenderBuffer buffer = gsg->get_render_buffer(get_screenshot_buffer_type(), _window->get_fb_properties()); if (!gsg->framebuffer_copy_to_ram(tex, 0, -1, this, buffer)) { - return NULL; + return nullptr; } window->end_frame(GraphicsOutput::FM_refresh, current_thread); @@ -522,8 +522,8 @@ get_screenshot() { PT(PandaNode) DisplayRegion:: make_cull_result_graph() { CullResult *cull_result = get_cull_result(Thread::get_current_thread()); - if (cull_result == (CullResult *)NULL) { - return NULL; + if (cull_result == nullptr) { + return nullptr; } return cull_result->make_result_graph(); } @@ -534,7 +534,7 @@ make_cull_result_graph() { */ void DisplayRegion:: compute_pixels() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { CDWriter cdata(_cycler, false); for (size_t i = 0; i < cdata->_regions.size(); ++i) { do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), @@ -549,7 +549,7 @@ compute_pixels() { */ void DisplayRegion:: compute_pixels_all_stages() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); for (size_t i = 0; i < cdata->_regions.size(); ++i) { @@ -602,7 +602,7 @@ compute_pixels_all_stages(int x_size, int y_size) { */ bool DisplayRegion:: supports_pixel_zoom() const { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { if (_window->supports_pixel_zoom()) { return get_clear_color_active() && get_clear_depth_active(); } @@ -617,7 +617,7 @@ supports_pixel_zoom() const { */ void DisplayRegion:: win_display_regions_changed() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { _window->win_display_regions_changed(); } } @@ -640,7 +640,7 @@ do_compute_pixels(int i, int x_size, int y_size, CData *cdata) { region._pixels_i[0] = region._pixels[0]; region._pixels_i[1] = region._pixels[1]; - nassertv(_window != (GraphicsOutput *)NULL); + nassertv(_window != nullptr); if (_window->get_inverted()) { // The window is inverted; compute the DisplayRegion accordingly. region._pixels[2] = int(((1.0f - region._dimensions[3]) * y_size) + 0.5); @@ -694,7 +694,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, DisplayRegion::CData:: CData() : _lens_index(0), - _camera_node((Camera *)NULL), + _camera_node(nullptr), _active(true), _sort(0), _stereo_channel(Lens::SC_mono), @@ -745,5 +745,5 @@ make_copy() const { */ GraphicsPipe *DisplayRegionPipelineReader:: get_pipe() const { - return (_object->_window != (GraphicsOutput *)NULL) ? _object->_window->get_pipe() : NULL; + return (_object->_window != nullptr) ? _object->_window->get_pipe() : nullptr; } diff --git a/panda/src/display/displayRegionCullCallbackData.h b/panda/src/display/displayRegionCullCallbackData.h index 509f5e2e2c..bb78dbc9c9 100644 --- a/panda/src/display/displayRegionCullCallbackData.h +++ b/panda/src/display/displayRegionCullCallbackData.h @@ -24,7 +24,7 @@ class SceneSetup; * This specialization on CallbackData is passed when the callback is * initiated from the cull traversal, for a DisplayRegion. */ -class EXPCL_PANDA_PGRAPH DisplayRegionCullCallbackData : public CallbackData { +class EXPCL_PANDA_DISPLAY DisplayRegionCullCallbackData : public CallbackData { public: DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup); diff --git a/panda/src/display/displayRegionDrawCallbackData.cxx b/panda/src/display/displayRegionDrawCallbackData.cxx index e0ecfcbffb..194aa6bbef 100644 --- a/panda/src/display/displayRegionDrawCallbackData.cxx +++ b/panda/src/display/displayRegionDrawCallbackData.cxx @@ -57,7 +57,7 @@ upcall() { DisplayRegion *dr = _scene_setup->get_display_region(); GraphicsStateGuardian *gsg = dr->get_window()->get_gsg(); - if (_cull_result == NULL || _scene_setup == NULL) { + if (_cull_result == nullptr || _scene_setup == nullptr) { // Nothing to see here. } else if (dr->is_stereo()) { diff --git a/panda/src/display/displayRegionDrawCallbackData.h b/panda/src/display/displayRegionDrawCallbackData.h index 55f76baf2e..bbdfdc99b3 100644 --- a/panda/src/display/displayRegionDrawCallbackData.h +++ b/panda/src/display/displayRegionDrawCallbackData.h @@ -24,7 +24,7 @@ class SceneSetup; * This specialization on CallbackData is passed when the callback is * initiated from the draw traversal, for a DisplayRegion. */ -class EXPCL_PANDA_PGRAPH DisplayRegionDrawCallbackData : public CallbackData { +class EXPCL_PANDA_DISPLAY DisplayRegionDrawCallbackData : public CallbackData { public: DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup); diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index 6f2d3257ee..70c809c64b 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -11,21 +11,6 @@ * @date 2003-01-27 */ -/** - * - */ -INLINE FrameBufferProperties:: -FrameBufferProperties(const FrameBufferProperties ©) { - (*this) = copy; -} - -/** - * - */ -INLINE FrameBufferProperties:: -~FrameBufferProperties() { -} - /** * */ diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index ea37cc4381..81d12a98ba 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -17,28 +17,6 @@ #include "config_display.h" #include "texture.h" -/** - * - */ -FrameBufferProperties:: -FrameBufferProperties() { - clear(); -} - -/** - * - */ -void FrameBufferProperties:: -operator = (const FrameBufferProperties ©) { - _flags_specified = copy._flags_specified; - _flags = copy._flags; - _specified = copy._specified; - - for (int i = 0; i < FBP_COUNT; ++i) { - _property[i] = copy._property[i]; - } -} - /** * Returns true if this set of properties makes strictly greater or equal * demands of the framebuffer than the other set of framebuffer properties. diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h index 9ac6c015ea..67e0c50d1e 100644 --- a/panda/src/display/frameBufferProperties.h +++ b/panda/src/display/frameBufferProperties.h @@ -63,11 +63,11 @@ private: FBF_all = 0x100-1, }; - int _property[FBP_COUNT]; - int _specified; + int _property[FBP_COUNT] = {0}; + int _specified = 0; - int _flags; - int _flags_specified; + int _flags = 0; + int _flags_specified = 0; PUBLISHED: @@ -145,10 +145,8 @@ PUBLISHED: // Other. - FrameBufferProperties(); - INLINE FrameBufferProperties(const FrameBufferProperties ©); - INLINE ~FrameBufferProperties(); - void operator = (const FrameBufferProperties ©); + constexpr FrameBufferProperties() = default; + static const FrameBufferProperties &get_default(); bool operator == (const FrameBufferProperties &other) const; INLINE bool operator != (const FrameBufferProperties &other) const; diff --git a/panda/src/display/graphicsEngine.I b/panda/src/display/graphicsEngine.I index eccf5cfee4..326d073a0c 100644 --- a/panda/src/display/graphicsEngine.I +++ b/panda/src/display/graphicsEngine.I @@ -144,7 +144,7 @@ make_buffer(GraphicsStateGuardian *gsg, const string &name, WindowProperties::size(x_size, y_size), GraphicsPipe::BF_refuse_window | GraphicsPipe::BF_fb_props_optional, - gsg, NULL); + gsg, nullptr); return result; } diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index b3f931e44b..b27eaa5c39 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -147,7 +147,7 @@ GraphicsEngine(Pipeline *pipeline) : _lock("GraphicsEngine::_lock"), _loaded_textures_lock("GraphicsEngine::_loaded_textures_lock") { - if (_pipeline == (Pipeline *)NULL) { + if (_pipeline == nullptr) { _pipeline = Pipeline::get_render_pipeline(); } @@ -288,7 +288,7 @@ make_output(GraphicsPipe *pipe, if ((x_size == 0)&&(y_size == 0)) { flags |= GraphicsPipe::BF_size_track_host; } - if (host != 0) { + if (host != nullptr) { host = host->get_host(); } @@ -296,28 +296,28 @@ make_output(GraphicsPipe *pipe, // call open_windows to get both ready. If that fails, give up on using the // supplied gsg and host. - if (host == (GraphicsOutput *)NULL) { - if (gsg != (GraphicsStateGuardian*)NULL) { + if (host == nullptr) { + if (gsg != nullptr) { if ((!gsg->is_valid())||(gsg->needs_reset())) { open_windows(); } if ((!gsg->is_valid())||(gsg->needs_reset())) { - gsg = NULL; + gsg = nullptr; } } } else { - if ((host->get_gsg()==0)|| + if ((host->get_gsg()==nullptr)|| (!host->is_valid())|| (!host->get_gsg()->is_valid())|| (host->get_gsg()->needs_reset())) { open_windows(); } - if ((host->get_gsg()==0)|| + if ((host->get_gsg()==nullptr)|| (!host->is_valid())|| (!host->get_gsg()->is_valid())|| (host->get_gsg()->needs_reset())) { - host = NULL; - gsg = NULL; + host = nullptr; + gsg = nullptr; } else { gsg = host->get_gsg(); } @@ -325,21 +325,21 @@ make_output(GraphicsPipe *pipe, // Sanity check everything. - nassertr(pipe != (GraphicsPipe *)NULL, NULL); - if (gsg != (GraphicsStateGuardian *)NULL) { - nassertr(pipe == gsg->get_pipe(), NULL); - nassertr(this == gsg->get_engine(), NULL); + nassertr(pipe != nullptr, nullptr); + if (gsg != nullptr) { + nassertr(pipe == gsg->get_pipe(), nullptr); + nassertr(this == gsg->get_engine(), nullptr); } // Are we really asking for a callback window? if ((flags & GraphicsPipe::BF_require_callback_window)!=0) { PT(GraphicsStateGuardian) this_gsg = gsg; - if (this_gsg == (GraphicsStateGuardian *)NULL) { + if (this_gsg == nullptr) { // If we don't already have a GSG, we have to ask the pipe to make a new // one, unencumbered by window dressing. this_gsg = pipe->make_callback_gsg(this); } - if (this_gsg != (GraphicsStateGuardian *)NULL) { + if (this_gsg != nullptr) { CallbackGraphicsWindow *window = new CallbackGraphicsWindow(this, pipe, name, fb_prop, win_prop, flags, this_gsg); window->_sort = sort; do_add_window(window); @@ -350,13 +350,13 @@ make_output(GraphicsPipe *pipe, // Couldn't make a callback window, because the pipe wouldn't make an // unencumbered GSG. - return NULL; + return nullptr; } // Determine if a parasite buffer meets the user's specs. bool can_use_parasite = false; - if ((host != 0)&& + if ((host != nullptr)&& ((flags&GraphicsPipe::BF_require_window)==0)&& ((flags&GraphicsPipe::BF_require_callback_window)==0)&& ((flags&GraphicsPipe::BF_refuse_parasite)==0)&& @@ -406,7 +406,7 @@ make_output(GraphicsPipe *pipe, bool precertify = false; PT(GraphicsOutput) window = pipe->make_output(name, fb_prop, win_prop, flags, this, gsg, host, retry, precertify); - if (window != (GraphicsOutput *)NULL) { + if (window != nullptr) { window->_sort = sort; if (precertify && gsg != nullptr && window->get_gsg() == gsg) { do_add_window(window); @@ -445,8 +445,7 @@ make_output(GraphicsPipe *pipe, } // No good; delete the window and keep trying. - bool removed = remove_window(window); - nassertr(removed, NULL); + remove_window(window); } } @@ -464,7 +463,7 @@ make_output(GraphicsPipe *pipe, // Could not create a window to the user's specs. - return NULL; + return nullptr; } /** @@ -512,7 +511,7 @@ add_window(GraphicsOutput *window, int sort) { */ bool GraphicsEngine:: remove_window(GraphicsOutput *window) { - nassertr(window != NULL, false); + nassertr(window != nullptr, false); Thread *current_thread = Thread::get_current_thread(); // First, make sure we know what this window is. @@ -544,9 +543,9 @@ remove_window(GraphicsOutput *window) { do_remove_window(window, current_thread); GraphicsStateGuardian *gsg = window->get_gsg(); - if (gsg != (GraphicsStateGuardian *)NULL) { + if (gsg != nullptr) { PreparedGraphicsObjects *pgo = gsg->get_prepared_objects(); - if (pgo != (PreparedGraphicsObjects *)NULL) { + if (pgo != nullptr) { // Check to see if any other still-active windows share this context. bool any_common = false; { @@ -554,7 +553,7 @@ remove_window(GraphicsOutput *window) { Windows::iterator wi; for (wi = _windows.begin(); wi != _windows.end() && !any_common; ++wi) { GraphicsStateGuardian *gsg2 = (*wi)->get_gsg(); - if (gsg2 != (GraphicsStateGuardian *)NULL && + if (gsg2 != nullptr && gsg2->get_prepared_objects() == pgo) { any_common = true; } @@ -594,10 +593,10 @@ remove_all_windows() { Windows::iterator wi; for (wi = old_windows.begin(); wi != old_windows.end(); ++wi) { GraphicsOutput *win = (*wi); - nassertv(win != NULL); + nassertv(win != nullptr); do_remove_window(win, current_thread); GraphicsStateGuardian *gsg = win->get_gsg(); - if (gsg != (GraphicsStateGuardian *)NULL) { + if (gsg != nullptr) { gsg->release_all(); } } @@ -670,7 +669,7 @@ get_num_windows() const { */ GraphicsOutput *GraphicsEngine:: get_window(int n) const { - nassertr(n >= 0 && n < (int)_windows.size(), NULL); + nassertr(n >= 0 && n < (int)_windows.size(), nullptr); if (!_windows_sorted) { ((GraphicsEngine *)this)->do_resort_windows(); @@ -731,7 +730,7 @@ render_frame() { Windows::iterator wi; for (wi = _windows.begin(); wi != _windows.end(); ++wi) { GraphicsOutput *win = (*wi); - nassertv(win != NULL); + nassertv(win != nullptr); if (win->get_delete_flag()) { do_remove_window(win, current_thread); @@ -746,7 +745,7 @@ render_frame() { int num_drs = win->get_num_active_display_regions(); for (int i = 0; i < num_drs; ++i) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { NodePath camera_np = dr->get_camera(current_thread); if (!camera_np.is_empty()) { Camera *camera = DCAST(Camera, camera_np.node()); @@ -1166,7 +1165,7 @@ extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg) { */ void GraphicsEngine:: dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, GraphicsStateGuardian *gsg) { - nassertv(sattr->get_shader() != (Shader *)NULL); + nassertv(sattr->get_shader() != nullptr); nassertv(gsg != nullptr); ReMutexHolder holder(_lock); @@ -1220,7 +1219,7 @@ dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, Graph */ GraphicsEngine *GraphicsEngine:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GraphicsEngine; PandaNode::set_scene_root_func(&scene_root_func); } @@ -1261,7 +1260,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, trav->set_cull_handler(cull_handler); trav->set_scene(scene_setup, gsg, dr->get_incomplete_render()); - trav->set_view_frustum(NULL); + trav->set_view_frustum(nullptr); if (view_frustum_cull) { // If we're to be performing view-frustum culling, determine the bounding // volume associated with the current viewing frustum. @@ -1270,8 +1269,8 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, // lens. PT(BoundingVolume) bv = scene_setup->get_cull_bounds(); - if (bv != (BoundingVolume *)NULL && !bv->is_infinite() && - bv->as_geometric_bounding_volume() != NULL) { + if (bv != nullptr && !bv->is_infinite() && + bv->as_geometric_bounding_volume() != nullptr) { // Transform it into the appropriate coordinate space. PT(GeometricBoundingVolume) local_frustum; local_frustum = bv->make_copy()->as_geometric_bounding_volume(); @@ -1315,7 +1314,7 @@ is_scene_root(const PandaNode *node) { int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { NodePath camera = dr->get_camera(); if (camera.is_empty()) { continue; @@ -1391,7 +1390,7 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { cull_and_draw_together(win, dr, current_thread); } } @@ -1421,7 +1420,7 @@ void GraphicsEngine:: cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { GraphicsStateGuardian *gsg = win->get_gsg(); - nassertv(gsg != (GraphicsStateGuardian *)NULL); + nassertv(gsg != nullptr); PT(SceneSetup) scene_setup; @@ -1437,7 +1436,7 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, scene_setup = setup_scene(gsg, &dr_reader); } - if (scene_setup == (SceneSetup *)NULL) { + if (scene_setup == nullptr) { // Never mind. } else if (dr->is_stereo()) { @@ -1452,7 +1451,7 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, DrawCullHandler cull_handler(gsg); if (gsg->begin_scene()) { CallbackObject *cbobj = dr->get_cull_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { // Issue the cull callback on this DisplayRegion. DisplayRegionCullCallbackData cbdata(&cull_handler, scene_setup); cbobj->do_callback(&cbdata); @@ -1555,7 +1554,7 @@ cull_to_bins(GraphicsOutput *win, GraphicsStateGuardian *gsg, BinCullHandler cull_handler(cull_result); CallbackObject *cbobj = dr->get_cull_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { // Issue the cull callback on this DisplayRegion. DisplayRegionCullCallbackData cbdata(&cull_handler, scene_setup); cbobj->do_callback(&cbdata); @@ -1615,7 +1614,7 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; ++i) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { do_draw(win, gsg, dr, current_thread); } } @@ -1848,28 +1847,28 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { GraphicsOutput *window = dr->get_window(); // The window pointer shouldn't be NULL, since we presumably got to this // particular DisplayRegion by walking through a list on a window. - nassertr(window != (GraphicsOutput *)NULL, NULL); + nassertr(window != nullptr, nullptr); NodePath camera = dr->get_camera(); if (camera.is_empty()) { // No camera, no draw. - return NULL; + return nullptr; } Camera *camera_node; - DCAST_INTO_R(camera_node, camera.node(), NULL); + DCAST_INTO_R(camera_node, camera.node(), nullptr); if (!camera_node->is_active()) { // Camera inactive, no draw. - return NULL; + return nullptr; } camera_node->cleanup_aux_scene_data(current_thread); int lens_index = dr->get_lens_index(); Lens *lens = camera_node->get_lens(lens_index); - if (lens == (Lens *)NULL || !camera_node->get_lens_active(lens_index)) { + if (lens == nullptr || !camera_node->get_lens_active(lens_index)) { // No lens, no draw. - return NULL; + return nullptr; } NodePath scene_root = camera_node->get_scene(); @@ -1901,7 +1900,7 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { << scene_root.get_scale(NodePath()) << "); cannot render.\n"; _singular_warning_this_frame = true; } - return NULL; + return nullptr; } if (world_transform->is_invalid()) { @@ -1912,7 +1911,7 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { << camera.get_scale(NodePath()) << "); cannot render.\n"; } _singular_warning_this_frame = true; - return NULL; + return nullptr; } CPT(RenderState) initial_state = camera_node->get_initial_state(); @@ -1976,7 +1975,7 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre cbobj = dr_reader.get_draw_callback(); } - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { // Issue the draw callback on this DisplayRegion. // Set the GSG to the initial state. @@ -1993,7 +1992,7 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre return; } - if (cull_result == NULL || scene_setup == NULL) { + if (cull_result == nullptr || scene_setup == nullptr) { // Nothing to see here. } else if (dr->is_stereo()) { @@ -2049,7 +2048,7 @@ do_add_window(GraphicsOutput *window) { */ void GraphicsEngine:: do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe) { - nassertv(gsg != NULL); + nassertv(gsg != nullptr); ReMutexHolder holder(_lock); nassertv(gsg->get_pipe() == pipe && gsg->get_engine() == this); @@ -2074,7 +2073,7 @@ do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe) { */ void GraphicsEngine:: do_remove_window(GraphicsOutput *window, Thread *current_thread) { - nassertv(window != NULL); + nassertv(window != nullptr); PT(GraphicsPipe) pipe = window->get_pipe(); window->clear_pipe(); @@ -2285,8 +2284,8 @@ const RenderState *GraphicsEngine:: get_invert_polygon_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(CullFaceAttrib::make_reverse()); } @@ -2303,7 +2302,7 @@ get_invert_polygon_state() { */ GraphicsEngine::WindowRenderer *GraphicsEngine:: get_window_renderer(const string &name, int pipeline_stage) { - nassertr(_lock.debug_is_locked(), NULL); + nassertr(_lock.debug_is_locked(), nullptr); if (name.empty()) { return &_app; @@ -2362,7 +2361,7 @@ add_window(Windows &wlist, GraphicsOutput *window) { */ void GraphicsEngine::WindowRenderer:: remove_window(GraphicsOutput *window) { - nassertv(window != NULL); + nassertv(window != nullptr); LightReMutexHolder holder(_wl_lock); PT(GraphicsOutput) ptwin = window; diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index c21bec1d73..867afdfb40 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -52,7 +52,7 @@ class Texture; */ class EXPCL_PANDA_DISPLAY GraphicsEngine : public ReferenceCount { PUBLISHED: - explicit GraphicsEngine(Pipeline *pipeline = NULL); + explicit GraphicsEngine(Pipeline *pipeline = nullptr); BLOCKING ~GraphicsEngine(); void set_threading_model(const GraphicsThreadingModel &threading_model); @@ -78,8 +78,8 @@ PUBLISHED: const string &name, int sort, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, - int flags, GraphicsStateGuardian *gsg = NULL, - GraphicsOutput *host = NULL); + int flags, GraphicsStateGuardian *gsg = nullptr, + GraphicsOutput *host = nullptr); // Syntactic shorthand versions of make_output INLINE GraphicsOutput *make_buffer(GraphicsOutput *host, diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index 393dbaadb5..bc0e866f7d 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -87,7 +87,7 @@ INLINE Texture *GraphicsOutput:: get_texture(int i) const { CDReader cdata(_cycler); if ((i < 0) || (i >= ((int)cdata->_textures.size()))) { - return (Texture *)NULL; + return nullptr; } return cdata->_textures[i]._texture; } @@ -734,7 +734,7 @@ end_frame_spam(FrameMode mode) { INLINE void GraphicsOutput:: clear_cube_map_selection() { _target_tex_page = -1; - _prev_page_dr = NULL; + _prev_page_dr = nullptr; } /** diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index cb2f69ff6c..1f3141e9fc 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -101,7 +101,7 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, _is_valid = false; _flip_ready = false; _target_tex_page = -1; - _prev_page_dr = NULL; + _prev_page_dr = nullptr; _sort = 0; _child_sort = 0; _got_child_sort = false; @@ -168,7 +168,7 @@ GraphicsOutput:: nassertv(!is_valid()); // We shouldn't have a GraphicsPipe pointer anymore. - nassertv(_pipe == (GraphicsPipe *)NULL); + nassertv(_pipe == nullptr); // We don't have to destruct our child display regions explicitly, since // they are all reference-counted and will go away when their pointers do. @@ -177,11 +177,11 @@ GraphicsOutput:: for (dri = _total_display_regions.begin(); dri != _total_display_regions.end(); ++dri) { - (*dri)->_window = NULL; + (*dri)->_window = nullptr; } _total_display_regions.clear(); - _overlay_display_region = NULL; + _overlay_display_region = nullptr; } /** @@ -240,7 +240,7 @@ add_render_texture(Texture *tex, RenderTextureMode mode, LightMutexHolder holder(_lock); // Create texture if necessary. - if (tex == (Texture *)NULL) { + if (tex == nullptr) { tex = new Texture(get_name()); tex->set_wrap_u(SamplerState::WM_clamp); tex->set_wrap_v(SamplerState::WM_clamp); @@ -344,7 +344,7 @@ add_render_texture(Texture *tex, RenderTextureMode mode, } } - if (mode == RTM_bind_layered && _gsg != NULL && !_gsg->get_supports_geometry_shaders()) { + if (mode == RTM_bind_layered && _gsg != nullptr && !_gsg->get_supports_geometry_shaders()) { // Layered FBOs require a geometry shader to write to any but the first // layer. display_cat.warning() << @@ -555,8 +555,8 @@ get_delete_flag() const { void GraphicsOutput:: set_sort(int sort) { if (_sort != sort) { - if (_gsg != (GraphicsStateGuardian *)NULL && - _gsg->get_engine() != (GraphicsEngine *)NULL) { + if (_gsg != nullptr && + _gsg->get_engine() != nullptr) { _gsg->get_engine()->set_window_sort(this, sort); } } @@ -706,7 +706,7 @@ remove_all_display_regions() { if (display_region != _overlay_display_region) { // Let's aggressively clean up the display region too. display_region->cleanup(); - display_region->_window = NULL; + display_region->_window = nullptr; } } _total_display_regions.clear(); @@ -762,7 +762,7 @@ get_display_region(int n) const { if (n >= 0 && n < (int)_total_display_regions.size()) { result = _total_display_regions[n]; } else { - result = NULL; + result = nullptr; } } return result; @@ -793,7 +793,7 @@ get_active_display_region(int n) const { if (n >= 0 && n < (int)cdata->_active_display_regions.size()) { return cdata->_active_display_regions[n]; } - return NULL; + return nullptr; } /** @@ -830,7 +830,7 @@ make_texture_buffer(const string &name, int x_size, int y_size, props.set_alpha_bits(1); props.set_depth_bits(1); - if (fbp == NULL) { + if (fbp == nullptr) { fbp = &props; } @@ -838,7 +838,7 @@ make_texture_buffer(const string &name, int x_size, int y_size, if (textures_power_2 != ATS_none) { flags |= GraphicsPipe::BF_size_power_2; } - if (tex != (Texture *)NULL && + if (tex != nullptr && tex->get_texture_type() == Texture::TT_cube_map) { flags |= GraphicsPipe::BF_size_square; } @@ -849,8 +849,8 @@ make_texture_buffer(const string &name, int x_size, int y_size, *fbp, WindowProperties::size(x_size, y_size), flags, get_gsg(), get_host()); - if (buffer != (GraphicsOutput *)NULL) { - if (buffer->get_gsg() == (GraphicsStateGuardian *)NULL || + if (buffer != nullptr) { + if (buffer->get_gsg() == nullptr || buffer->get_gsg()->get_prepared_objects() != get_gsg()->get_prepared_objects()) { // If the newly-created buffer doesn't share texture objects with the // current GSG, then we will have to force the texture copy to go @@ -862,7 +862,7 @@ make_texture_buffer(const string &name, int x_size, int y_size, return buffer; } - return NULL; + return nullptr; } /** @@ -892,7 +892,7 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, // The GSG doesn't support cube mapping; too bad for you. display_cat.warning() << "Cannot make dynamic cube map; GSG does not support cube maps.\n"; - return NULL; + return nullptr; } if (max_dimension > 0) { size = min(max_dimension, size); @@ -953,7 +953,7 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, */ NodePath GraphicsOutput:: get_texture_card() { - if (_texture_card == NULL) { + if (_texture_card == nullptr) { PT(GeomVertexData) vdata = create_texture_card_vdata(get_x_size(), get_y_size()); PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); strip->set_shade_model(Geom::SM_uniform); @@ -1072,7 +1072,7 @@ reset_window(bool swapchain) { */ void GraphicsOutput:: clear_pipe() { - _pipe = (GraphicsPipe *)NULL; + _pipe = nullptr; } /** @@ -1097,7 +1097,7 @@ set_size_and_recalc(int x, int y) { (*dri)->compute_pixels_all_stages(fb_x_size, fb_y_size); } - if (_texture_card != NULL && _texture_card->get_num_geoms() > 0) { + if (_texture_card != nullptr && _texture_card->get_num_geoms() > 0) { _texture_card->modify_geom(0)->set_vertex_data(create_texture_card_vdata(x, y)); } } @@ -1118,7 +1118,7 @@ clear(Thread *current_thread) { << get_name() << " " << (void *)this << "\n"; } - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); DisplayRegionPipelineReader dr_reader(_overlay_display_region, current_thread); _gsg->prepare_display_region(&dr_reader); @@ -1182,7 +1182,7 @@ change_scenes(DisplayRegionPipelineReader *new_dr) { // In copy-to-texture mode, copy the just-rendered framebuffer to // the old texture page. - nassertv(old_page_dr != (DisplayRegion *)NULL); + nassertv(old_page_dr != nullptr); if (display_cat.is_debug()) { display_cat.debug() << "Copying texture for " << get_name() << " at scene change.\n"; @@ -1390,7 +1390,7 @@ copy_to_textures() { bool copied = false; DisplayRegion *dr = _overlay_display_region; - if (_prev_page_dr != (DisplayRegion *)NULL) { + if (_prev_page_dr != nullptr) { dr = _prev_page_dr; } @@ -1504,7 +1504,7 @@ do_remove_display_region(DisplayRegion *display_region) { // Let's aggressively clean up the display region too. CDWriter cdata(_cycler, true); display_region->cleanup(); - display_region->_window = NULL; + display_region->_window = nullptr; _total_display_regions.erase(dri); cdata->_active_display_regions_stale = true; @@ -1540,7 +1540,9 @@ do_determine_display_regions(GraphicsOutput::CData *cdata) { } } - stable_sort(cdata->_active_display_regions.begin(), cdata->_active_display_regions.end(), IndirectLess()); + std::stable_sort(cdata->_active_display_regions.begin(), + cdata->_active_display_regions.end(), + IndirectLess()); } /** diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index 93db287a74..c5ddb10ff0 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -225,11 +225,11 @@ PUBLISHED: GraphicsOutput *make_texture_buffer( const string &name, int x_size, int y_size, - Texture *tex = NULL, bool to_ram = false, FrameBufferProperties *fbp = NULL); + Texture *tex = nullptr, bool to_ram = false, FrameBufferProperties *fbp = nullptr); GraphicsOutput *make_cube_map(const string &name, int size, NodePath &camera_rig, DrawMask camera_mask = PandaNode::get_all_camera_mask(), - bool to_ram = false, FrameBufferProperties *fbp = NULL); + bool to_ram = false, FrameBufferProperties *fbp = nullptr); INLINE static Filename make_screenshot_filename( const string &prefix = "screenshot"); diff --git a/panda/src/display/graphicsPipe.cxx b/panda/src/display/graphicsPipe.cxx index ad5d1aea62..62a8ec5ad0 100644 --- a/panda/src/display/graphicsPipe.cxx +++ b/panda/src/display/graphicsPipe.cxx @@ -60,7 +60,7 @@ union cpuid_info { */ static inline uint32_t get_cpuid_max(uint32_t leaf) { #if defined(__GNUC__) && !defined(__APPLE__) - return __get_cpuid_max(leaf, 0); + return __get_cpuid_max(leaf, nullptr); #elif defined(_MSC_VER) uint32_t p[4] = {0}; __cpuid((int *)p, leaf); @@ -158,17 +158,17 @@ GraphicsPipe() : #if defined(IS_OSX) // macOS exposes a lot of useful information through sysctl. size_t len = sizeof(uint64_t); - sysctlbyname("hw.memsize", &_display_information->_physical_memory, &len, NULL, 0); + sysctlbyname("hw.memsize", &_display_information->_physical_memory, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("hw.cpufrequency", &_display_information->_cpu_frequency, &len, NULL, 0); + sysctlbyname("hw.cpufrequency", &_display_information->_cpu_frequency, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("hw.cpufrequency", &_display_information->_current_cpu_frequency, &len, NULL, 0); + sysctlbyname("hw.cpufrequency", &_display_information->_current_cpu_frequency, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("hw.cpufrequency_max", &_display_information->_maximum_cpu_frequency, &len, NULL, 0); + sysctlbyname("hw.cpufrequency_max", &_display_information->_maximum_cpu_frequency, &len, nullptr, 0); len = sizeof(int); - sysctlbyname("hw.physicalcpu", &_display_information->_num_cpu_cores, &len, NULL, 0); + sysctlbyname("hw.physicalcpu", &_display_information->_num_cpu_cores, &len, nullptr, 0); len = sizeof(int); - sysctlbyname("hw.logicalcpu", &_display_information->_num_logical_cpus, &len, NULL, 0); + sysctlbyname("hw.logicalcpu", &_display_information->_num_logical_cpus, &len, nullptr, 0); #elif defined(IS_LINUX) _display_information->_get_memory_information_function = &update_memory_info; @@ -176,9 +176,9 @@ GraphicsPipe() : #elif defined(IS_FREEBSD) size_t len = sizeof(uint64_t); - sysctlbyname("hw.physmem", &_display_information->_physical_memory, &len, NULL, 0); + sysctlbyname("hw.physmem", &_display_information->_physical_memory, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("vm.swap_total", &_display_information->_page_file_size, &len, NULL, 0); + sysctlbyname("vm.swap_total", &_display_information->_page_file_size, &len, nullptr, 0); #elif defined(_WIN32) MEMORYSTATUSEX status; @@ -228,7 +228,7 @@ GraphicsPipe::get_preferred_window_thread() const { */ PT(GraphicsStateGuardian) GraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { - return NULL; + return nullptr; } /** @@ -239,7 +239,7 @@ PT(GraphicsDevice) GraphicsPipe:: make_device(void *scrn) { display_cat.error() << "make_device() unimplemented by " << get_type() << "\n"; - return NULL; + return nullptr; } /** @@ -251,7 +251,7 @@ make_device(void *scrn) { */ void GraphicsPipe:: close_gsg(GraphicsStateGuardian *gsg) { - if (gsg != (GraphicsStateGuardian *)NULL) { + if (gsg != nullptr) { gsg->close_gsg(); } } @@ -271,7 +271,7 @@ make_output(const string &name, bool &precertify) { display_cat.error() << get_type() << " cannot create buffers or windows.\n"; - return NULL; + return nullptr; } /** diff --git a/panda/src/display/graphicsPipe.h b/panda/src/display/graphicsPipe.h index 501cc535be..032da4b1cd 100644 --- a/panda/src/display/graphicsPipe.h +++ b/panda/src/display/graphicsPipe.h @@ -110,7 +110,7 @@ public: virtual PreferredWindowThread get_preferred_window_thread() const; INLINE GraphicsDevice *get_device() const; - virtual PT(GraphicsDevice) make_device(void *scrn = NULL); + virtual PT(GraphicsDevice) make_device(void *scrn = nullptr); virtual PT(GraphicsStateGuardian) make_callback_gsg(GraphicsEngine *engine); diff --git a/panda/src/display/graphicsPipeSelection.I b/panda/src/display/graphicsPipeSelection.I index 100557bcc5..a3f68e0ec2 100644 --- a/panda/src/display/graphicsPipeSelection.I +++ b/panda/src/display/graphicsPipeSelection.I @@ -26,7 +26,7 @@ get_num_aux_modules() const { */ INLINE GraphicsPipeSelection *GraphicsPipeSelection:: get_global_ptr() { - if (_global_ptr == (GraphicsPipeSelection *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GraphicsPipeSelection; } return _global_ptr; diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index 1134cc0553..d2b145da39 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -23,7 +23,7 @@ #include -GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = NULL; +GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = nullptr; /** * @@ -171,7 +171,7 @@ make_pipe(const string &type_name, const string &module_name) { } if (type == TypeHandle::none()) { - return NULL; + return nullptr; } return make_pipe(type); @@ -193,7 +193,7 @@ make_pipe(TypeHandle type) { if (ptype._type == type) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -205,7 +205,7 @@ make_pipe(TypeHandle type) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -218,14 +218,14 @@ make_pipe(TypeHandle type) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } } // Couldn't find a matching pipe type. - return NULL; + return nullptr; } /** @@ -242,7 +242,7 @@ make_module_pipe(const string &module_name) { TypeHandle pipe_type = load_named_module(module_name); if (pipe_type == TypeHandle::none()) { - return NULL; + return nullptr; } return make_pipe(pipe_type); @@ -268,7 +268,7 @@ make_default_pipe() { if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -282,7 +282,7 @@ make_default_pipe() { if (ptype_name.find(preferred_name) != string::npos) { // Here's a substring match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -293,13 +293,13 @@ make_default_pipe() { for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { const PipeType &ptype = (*ti); PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } // Nothing. Probably the list was empty. - return NULL; + return nullptr; } /** @@ -325,7 +325,7 @@ load_aux_modules() { */ bool GraphicsPipeSelection:: add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { - nassertr(func != NULL, false); + nassertr(func != nullptr, false); if (!type.is_derived_from(GraphicsPipe::get_class_type())) { display_cat->warning() @@ -408,7 +408,7 @@ load_named_module(const string &name) { display_cat.info() << "loading display module: " << dlname.to_os_specific() << endl; void *handle = load_dso(get_plugin_path().get_value(), dlname); - if (handle == (void *)NULL) { + if (handle == nullptr) { display_cat.warning() << "Unable to load: " << load_dso_error() << endl; return TypeHandle::none(); @@ -425,7 +425,7 @@ load_named_module(const string &name) { TypeHandle pipe_type = TypeHandle::none(); - if (dso_symbol == (void *)NULL) { + if (dso_symbol == nullptr) { // Couldn't find the module function. display_cat.warning() << "Unable to find " << symbol_name << " in " << dlname.get_basename() diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 94188b85be..9f36616a95 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -767,7 +767,7 @@ get_alpha_scale_via_texture() const { INLINE bool GraphicsStateGuardian:: get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { return _alpha_scale_via_texture && - (tex_attrib == (const TextureAttrib *)NULL || + (tex_attrib == nullptr || tex_attrib->get_num_on_stages() < get_max_texture_stages()); } @@ -777,7 +777,7 @@ get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { */ INLINE TextureStage *GraphicsStateGuardian:: get_alpha_scale_texture_stage() { - if (_alpha_scale_texture_stage == (TextureStage *)NULL) { + if (_alpha_scale_texture_stage == nullptr) { _alpha_scale_texture_stage = new TextureStage("alpha-scale"); _alpha_scale_texture_stage->set_sort(1000000000); } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 5f282b82ce..d0353717c9 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -134,7 +134,7 @@ PStatCollector GraphicsStateGuardian::_draw_set_state_stencil_pcollector("Draw:S PStatCollector GraphicsStateGuardian::_draw_set_state_fog_pcollector("Draw:Set State:Fog"); PStatCollector GraphicsStateGuardian::_draw_set_state_scissor_pcollector("Draw:Set State:Scissor"); -PT(TextureStage) GraphicsStateGuardian::_alpha_scale_texture_stage = NULL; +PT(TextureStage) GraphicsStateGuardian::_alpha_scale_texture_stage = nullptr; TypeHandle GraphicsStateGuardian::_type_handle; @@ -158,17 +158,17 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, set_coordinate_system(get_default_coordinate_system()); - _data_reader = (GeomVertexDataPipelineReader *)NULL; - _current_display_region = (DisplayRegion*)NULL; + _data_reader = nullptr; + _current_display_region = nullptr; _current_stereo_channel = Lens::SC_mono; _current_tex_view_offset = 0; - _current_lens = (Lens *)NULL; + _current_lens = nullptr; _projection_mat = TransformState::make_identity(); _projection_mat_inv = TransformState::make_identity(); _needs_reset = true; _is_valid = false; - _current_properties = NULL; + _current_properties = nullptr; _closing_gsg = false; _active = true; _prepared_objects = new PreparedGraphicsObjects; @@ -317,7 +317,7 @@ GraphicsStateGuardian:: */ GraphicsEngine *GraphicsStateGuardian:: get_engine() const { - nassertr(_engine != (GraphicsEngine *)NULL, GraphicsEngine::get_global_ptr()); + nassertr(_engine != nullptr, GraphicsEngine::get_global_ptr()); return _engine; } @@ -493,7 +493,7 @@ set_flash_texture(Texture *tex) { */ void GraphicsStateGuardian:: clear_flash_texture() { - _flash_texture = NULL; + _flash_texture = nullptr; } #endif // NDEBUG @@ -518,14 +518,14 @@ bool GraphicsStateGuardian:: set_scene(SceneSetup *scene_setup) { _scene_setup = scene_setup; _current_lens = scene_setup->get_lens(); - if (_current_lens == (Lens *)NULL) { + if (_current_lens == nullptr) { return false; } set_coordinate_system(_current_lens->get_coordinate_system()); _projection_mat = calc_projection_mat(_current_lens); - if (_projection_mat == 0) { + if (_projection_mat == nullptr) { return false; } _projection_mat_inv = _projection_mat->get_inverse(); @@ -551,8 +551,8 @@ get_scene() const { * call Texture::prepare(). */ TextureContext *GraphicsStateGuardian:: -prepare_texture(Texture *) { - return (TextureContext *)NULL; +prepare_texture(Texture *, int view) { + return nullptr; } /** @@ -603,7 +603,7 @@ extract_texture_data(Texture *) { */ SamplerContext *GraphicsStateGuardian:: prepare_sampler(const SamplerState &sampler) { - return (SamplerContext *)NULL; + return nullptr; } /** @@ -622,7 +622,7 @@ release_sampler(SamplerContext *) { */ GeomContext *GraphicsStateGuardian:: prepare_geom(Geom *) { - return (GeomContext *)NULL; + return nullptr; } /** @@ -641,7 +641,7 @@ release_geom(GeomContext *) { */ ShaderContext *GraphicsStateGuardian:: prepare_shader(Shader *shader) { - return (ShaderContext *)NULL; + return nullptr; } /** @@ -656,7 +656,7 @@ release_shader(ShaderContext *sc) { */ VertexBufferContext *GraphicsStateGuardian:: prepare_vertex_buffer(GeomVertexArrayData *) { - return (VertexBufferContext *)NULL; + return nullptr; } /** @@ -672,7 +672,7 @@ release_vertex_buffer(VertexBufferContext *) { */ IndexBufferContext *GraphicsStateGuardian:: prepare_index_buffer(GeomPrimitive *) { - return (IndexBufferContext *)NULL; + return nullptr; } /** @@ -688,7 +688,7 @@ release_index_buffer(IndexBufferContext *) { */ BufferContext *GraphicsStateGuardian:: prepare_shader_buffer(ShaderBuffer *) { - return (BufferContext *)NULL; + return nullptr; } /** @@ -712,7 +712,7 @@ release_shader_buffer(BufferContext *) { */ void GraphicsStateGuardian:: begin_occlusion_query() { - nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL); + nassertv(_current_occlusion_query == nullptr); } /** @@ -723,9 +723,9 @@ begin_occlusion_query() { */ PT(OcclusionQueryContext) GraphicsStateGuardian:: end_occlusion_query() { - nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL); + nassertr(_current_occlusion_query != nullptr, nullptr); PT(OcclusionQueryContext) result = _current_occlusion_query; - _current_occlusion_query = NULL; + _current_occlusion_query = nullptr; return result; } @@ -735,7 +735,7 @@ end_occlusion_query() { */ PT(TimerQueryContext) GraphicsStateGuardian:: issue_timer_query(int pstats_index) { - return NULL; + return nullptr; } /** @@ -784,7 +784,7 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { // Nothing in the map; create a new entry. PT(GeomMunger) munger = make_geom_munger(state, current_thread); - nassertr(munger != (GeomMunger *)NULL && munger->is_registered(), munger); + nassertr(munger != nullptr && munger->is_registered(), munger); nassertr(munger->is_of_type(StateMunger::get_class_type()), munger); state->_last_mi = mungers.store(_id, munger); @@ -800,7 +800,7 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { // The default implementation returns no munger at all, but presumably, // every kind of GSG needs some special munging action, so real GSG's will // override this to return something more useful. - return NULL; + return nullptr; } /** @@ -940,7 +940,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } case Shader::SMO_texpad_x: { Texture *tex = _target_shader->get_shader_input_texture(name); - nassertr(tex != 0, &LMatrix4::zeros_mat()); + nassertr(tex != nullptr, &LMatrix4::zeros_mat()); int sx = tex->get_x_size() - tex->get_pad_x_size(); int sy = tex->get_y_size() - tex->get_pad_y_size(); int sz = tex->get_z_size() - tex->get_pad_z_size(); @@ -952,7 +952,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } case Shader::SMO_texpix_x: { Texture *tex = _target_shader->get_shader_input_texture(name); - nassertr(tex != 0, &LMatrix4::zeros_mat()); + nassertr(tex != nullptr, &LMatrix4::zeros_mat()); double px = 1.0 / tex->get_x_size(); double py = 1.0 / tex->get_y_size(); double pz = 1.0 / tex->get_z_size(); @@ -1015,7 +1015,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, const FogAttrib *target_fog = (const FogAttrib *) _target_rs->get_attrib_def(FogAttrib::get_class_slot()); Fog *fog = target_fog->get_fog(); - if (fog == (Fog*) NULL) { + if (fog == nullptr) { return &LMatrix4::ones_mat(); } PN_stdfloat start, end; @@ -1027,7 +1027,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, const FogAttrib *target_fog = (const FogAttrib *) _target_rs->get_attrib_def(FogAttrib::get_class_slot()); Fog *fog = target_fog->get_fog(); - if (fog == (Fog*) NULL) { + if (fog == nullptr) { return &LMatrix4::ones_mat(); } LVecBase4 c = fog->get_color(); @@ -1095,7 +1095,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, Spotlight *lt; DCAST_INTO_R(lt, np.node(), &LMatrix4::zeros_mat()); Lens *lens = lt->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::zeros_mat()); + nassertr(lens != nullptr, &LMatrix4::zeros_mat()); LColor const &c = lt->get_color(); LColor const &s = lt->get_specular_color(); PN_stdfloat cutoff = ccos(deg_2_rad(lens->get_hfov() * 0.5f)); @@ -1517,28 +1517,28 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) static const CPT_InternalName IN_quadraticAttenuation("quadraticAttenuation"); static const CPT_InternalName IN_shadowViewMatrix("shadowViewMatrix"); - PandaNode *node = NULL; + PandaNode *node = nullptr; if (!np.is_empty()) { node = np.node(); } if (attrib == IN_color) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); LColor c = light->get_color(); c.componentwise_mult(_light_color_scale); t.set_row(3, c); return &t; } else if (attrib == IN_ambient) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); if (node->is_ambient_light()) { LColor c = light->get_color(); c.componentwise_mult(_light_color_scale); @@ -1550,11 +1550,11 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) return &t; } else if (attrib == IN_diffuse) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); if (node->is_ambient_light()) { // Ambient light has no diffuse color. t.set_row(3, LColor(0.0f, 0.0f, 0.0f, 1.0f)); @@ -1566,11 +1566,11 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) return &t; } else if (attrib == IN_specular) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); t.set_row(3, light->get_specular_color()); return &t; @@ -1595,7 +1595,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); CPT(TransformState) transform = _scene_setup->get_cs_world_transform()->compose( @@ -1631,7 +1631,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); CPT(TransformState) transform = _scene_setup->get_cs_world_transform()->compose( @@ -1647,7 +1647,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotDirection) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { t.set_row(3, LVector3(0.0f, 0.0f, -1.0f)); return &t; } else if (node->is_ambient_light()) { @@ -1658,7 +1658,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); CPT(TransformState) transform = _scene_setup->get_cs_world_transform()->compose( @@ -1671,12 +1671,12 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotCutoff) { - if (node != (PandaNode *)NULL && + if (node != nullptr && node->is_of_type(Spotlight::get_class_type())) { LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); float cutoff = lens->get_hfov() * 0.5f; t.set_row(3, LVecBase4(cutoff)); @@ -1688,12 +1688,12 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotCosCutoff) { - if (node != (PandaNode *)NULL && + if (node != nullptr && node->is_of_type(Spotlight::get_class_type())) { LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); float cutoff = lens->get_hfov() * 0.5f; t.set_row(3, LVecBase4(ccos(deg_2_rad(cutoff)))); @@ -1705,19 +1705,19 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotExponent) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::zeros_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); t.set_row(3, LVecBase4(light->get_exponent())); return &t; } else if (attrib == IN_attenuation) { - if (node != (PandaNode *)NULL) { + if (node != nullptr) { Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); t.set_row(3, LVecBase4(light->get_attenuation(), 0)); } else { @@ -1726,31 +1726,31 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) return &t; } else if (attrib == IN_constantAttenuation) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ones_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); t.set_row(3, LVecBase4(light->get_attenuation()[0])); return &t; } else if (attrib == IN_linearAttenuation) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::zeros_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); t.set_row(3, LVecBase4(light->get_attenuation()[1])); return &t; } else if (attrib == IN_quadraticAttenuation) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::zeros_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); t.set_row(3, LVecBase4(light->get_attenuation()[2])); return &t; @@ -1761,7 +1761,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f); - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &biasmat; } @@ -1808,7 +1808,7 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, if (basename == "shadowMap") { PT(Texture) tex = get_shadow_map(np); - if (tex != (Texture *)NULL) { + if (tex != nullptr) { sampler = tex->get_default_sampler(); } return tex; @@ -1884,11 +1884,11 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, break; default: - nassertr(false, NULL); + nassertr(false, nullptr); break; } - return NULL; + return nullptr; } /** @@ -1983,7 +1983,7 @@ clear_state_and_transform() { */ void GraphicsStateGuardian:: remove_window(GraphicsOutputBase *window) { - nassertv(_engine != (GraphicsEngine *)NULL); + nassertv(_engine != nullptr); GraphicsOutput *win; DCAST_INTO_V(win, window); _engine->remove_window(win); @@ -2009,12 +2009,12 @@ prepare_lens() { */ CPT(TransformState) GraphicsStateGuardian:: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } return TransformState::make_identity(); @@ -2295,7 +2295,7 @@ CPT(RenderState) GraphicsStateGuardian:: begin_decal_base_first() { // Turn off writing the depth buffer to render the base geometry. static CPT(RenderState) decal_base_first; - if (decal_base_first == (const RenderState *)NULL) { + if (decal_base_first == nullptr) { decal_base_first = RenderState::make (DepthWriteAttrib::make(DepthWriteAttrib::M_off), RenderState::get_max_priority()); @@ -2314,7 +2314,7 @@ begin_decal_nested() { // We should keep the depth buffer off during this operation, so that decals // on decals will render properly. static CPT(RenderState) decal_nested; - if (decal_nested == (const RenderState *)NULL) { + if (decal_nested == nullptr) { decal_nested = RenderState::make (DepthWriteAttrib::make(DepthWriteAttrib::M_off), RenderState::get_max_priority()); @@ -2338,7 +2338,7 @@ begin_decal_base_second() { // buffer to render the base geometry after the second pass. Also, turn off // texturing since there's no need for it now. static CPT(RenderState) decal_base_second; - if (decal_base_second == (const RenderState *)NULL) { + if (decal_base_second == nullptr) { decal_base_second = RenderState::make (ColorWriteAttrib::make(ColorWriteAttrib::C_off), // On reflection, we need to leave texturing on so the alpha test @@ -2469,7 +2469,7 @@ draw_points(const GeomPrimitivePipelineReader *, bool) { */ void GraphicsStateGuardian:: end_draw_primitives() { - _data_reader = NULL; + _data_reader = nullptr; } /** @@ -2481,7 +2481,7 @@ reset() { _is_valid = false; _state_rs = RenderState::make_empty(); - _target_rs = NULL; + _target_rs = nullptr; _state_mask.clear(); _internal_transform = _cs_transform; _scene_null = new SceneSetup; @@ -2597,7 +2597,7 @@ do_issue_clip_plane() { const ClipPlaneAttrib *target_clip_plane = (const ClipPlaneAttrib *) _target_rs->get_attrib_def(ClipPlaneAttrib::get_class_slot()); - if (target_clip_plane != (ClipPlaneAttrib *)NULL) { + if (target_clip_plane != nullptr) { CPT(ClipPlaneAttrib) new_plane = target_clip_plane->filter_to_max(_max_clip_planes); num_on_planes = new_plane->get_num_on_planes(); @@ -3053,8 +3053,8 @@ determine_target_texture() { const TexGenAttrib *target_tex_gen = (const TexGenAttrib *) _target_rs->get_attrib_def(TexGenAttrib::get_class_slot()); - nassertv(target_texture != (TextureAttrib *)NULL && - target_tex_gen != (TexGenAttrib *)NULL); + nassertv(target_texture != nullptr && + target_tex_gen != nullptr); _target_texture = target_texture; _target_tex_gen = target_tex_gen; @@ -3182,8 +3182,8 @@ determine_light_color_scale() { */ CPT(RenderState) GraphicsStateGuardian:: get_unlit_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(LightAttrib::make_all_off()); } return state; @@ -3194,8 +3194,8 @@ get_unlit_state() { */ CPT(RenderState) GraphicsStateGuardian:: get_unclipped_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(ClipPlaneAttrib::make_all_off()); } return state; @@ -3206,8 +3206,8 @@ get_unclipped_state() { */ CPT(RenderState) GraphicsStateGuardian:: get_untextured_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(TextureAttrib::make_off()); } return state; diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index fecce7e56a..8e0e8d8489 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -290,7 +290,7 @@ PUBLISHED: MAKE_PROPERTY(scene, get_scene, set_scene); public: - virtual TextureContext *prepare_texture(Texture *tex); + virtual TextureContext *prepare_texture(Texture *tex, int view); virtual bool update_texture(TextureContext *tc, bool force); virtual void release_texture(TextureContext *tc); virtual bool extract_texture_data(Texture *tex); @@ -430,7 +430,7 @@ public: static void create_gamma_table (PN_stdfloat gamma, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table); - PT(Texture) get_shadow_map(const NodePath &light_np, GraphicsOutputBase *host=NULL); + PT(Texture) get_shadow_map(const NodePath &light_np, GraphicsOutputBase *host=nullptr); PT(Texture) get_dummy_shadow_map(Texture::TextureType texture_type) const; virtual GraphicsOutput *make_shadow_buffer(LightLensNode *light, Texture *tex, GraphicsOutput *host); diff --git a/panda/src/display/graphicsStateGuardian_ext.cxx b/panda/src/display/graphicsStateGuardian_ext.cxx index 0677741ac7..3738ef82b8 100644 --- a/panda/src/display/graphicsStateGuardian_ext.cxx +++ b/panda/src/display/graphicsStateGuardian_ext.cxx @@ -41,8 +41,8 @@ PyObject *Extension:: get_prepared_textures() const { PyObject *list = PyList_New(0); - if (list == NULL) { - return NULL; + if (list == nullptr) { + return nullptr; } _this->traverse_prepared_textures(&traverse_callback, (void *)list); diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index 88ee617f40..c3dadfa08c 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -294,7 +294,7 @@ has_keyboard(int device) const { */ ButtonMap *GraphicsWindow:: get_keyboard_map() const { - return NULL; + return nullptr; } /** @@ -432,8 +432,8 @@ get_pointer_events(int device) { PT(PointerEventList) result; { LightMutexHolder holder(_input_lock); - nassertr(device >= 0 && device < (int)_input_devices.size(), NULL); - nassertr(_input_devices[device].has_pointer_event(), NULL); + nassertr(device >= 0 && device < (int)_input_devices.size(), nullptr); + nassertr(_input_devices[device].has_pointer_event(), nullptr); result = _input_devices[device].get_pointer_events(); } return result; @@ -648,13 +648,13 @@ close_window() { << "Closing " << get_type() << "\n"; // Tell our parent window (if any) that we're no longer its child. - if (_window_handle != (WindowHandle *)NULL && - _parent_window_handle != (WindowHandle *)NULL) { + if (_window_handle != nullptr && + _parent_window_handle != nullptr) { _parent_window_handle->detach_child(_window_handle); } - _window_handle = NULL; - _parent_window_handle = NULL; + _window_handle = nullptr; + _parent_window_handle = nullptr; _is_valid = false; } diff --git a/panda/src/display/graphicsWindowInputDevice.cxx b/panda/src/display/graphicsWindowInputDevice.cxx index 89d6e9d5b4..f2af1e9df1 100644 --- a/panda/src/display/graphicsWindowInputDevice.cxx +++ b/panda/src/display/graphicsWindowInputDevice.cxx @@ -141,7 +141,7 @@ get_button_event() { bool GraphicsWindowInputDevice:: has_pointer_event() const { LightMutexHolder holder(_lock); - return (_pointer_events != 0); + return (_pointer_events != nullptr); } /** @@ -151,7 +151,7 @@ PT(PointerEventList) GraphicsWindowInputDevice:: get_pointer_events() { LightMutexHolder holder(_lock); PT(PointerEventList) result = _pointer_events; - _pointer_events = 0; + _pointer_events = nullptr; return result; } @@ -224,7 +224,7 @@ set_pointer(bool inwin, double x, double y, double time) { if (_enable_pointer_events) { int seq = _event_sequence++; - if (_pointer_events == 0) { + if (_pointer_events == nullptr) { _pointer_events = new PointerEventList(); } _pointer_events->add_event(_mouse_data._in_window, diff --git a/panda/src/display/graphicsWindow_ext.cxx b/panda/src/display/graphicsWindow_ext.cxx index 06260b4c83..ac06b3565a 100644 --- a/panda/src/display/graphicsWindow_ext.cxx +++ b/panda/src/display/graphicsWindow_ext.cxx @@ -30,7 +30,7 @@ add_python_event_handler(PyObject* handler, PyObject* name){ */ void Extension:: remove_python_event_handler(PyObject* name){ - list toRemove; + std::list toRemove; GraphicsWindow::PythonWinProcClasses::iterator iter; for (iter = _this->_python_window_proc_classes.begin(); iter != _this->_python_window_proc_classes.end(); ++iter) { PythonGraphicsWindowProc* pgwp = (PythonGraphicsWindowProc*)*iter; @@ -43,7 +43,7 @@ remove_python_event_handler(PyObject* name){ } #endif } - list::iterator iter2; + std::list::iterator iter2; for (iter2 = toRemove.begin(); iter2 != toRemove.end(); ++iter2) { PythonGraphicsWindowProc* pgwp = *iter2; _this->remove_window_proc(pgwp); diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index ace66cfdbc..c03d799f4c 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -108,7 +108,7 @@ set_size_and_recalc(int x, int y) { */ bool ParasiteBuffer:: flip_ready() const { - nassertr(_host != NULL, false); + nassertr(_host != nullptr, false); return _host->flip_ready(); } @@ -125,7 +125,7 @@ flip_ready() const { */ void ParasiteBuffer:: begin_flip() { - nassertv(_host != NULL); + nassertv(_host != nullptr); _host->begin_flip(); } @@ -140,7 +140,7 @@ begin_flip() { */ void ParasiteBuffer:: ready_flip() { - nassertv(_host != NULL); + nassertv(_host != nullptr); _host->ready_flip(); } @@ -153,7 +153,7 @@ ready_flip() { */ void ParasiteBuffer:: end_flip() { - nassertv(_host != NULL); + nassertv(_host != nullptr); _host->end_flip(); _flip_ready = false; } @@ -198,7 +198,7 @@ void ParasiteBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); _host->end_frame(FM_parasite, current_thread); diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index cdc2f0bda3..5d2a3f5102 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -125,10 +125,10 @@ munge_data_impl(const GeomVertexData *data) { } else if (hardware_animated_vertices && animation.get_animation_type() == AT_panda && - new_data->get_slider_table() == (SliderTable *)NULL) { + new_data->get_slider_table() == nullptr) { // Maybe we can animate the vertices with hardware. const TransformBlendTable *table = new_data->get_transform_blend_table(); - if (table != (TransformBlendTable *)NULL && + if (table != nullptr && table->get_num_transforms() != 0 && table->get_max_simultaneous_transforms() <= get_gsg()->get_max_vertex_transforms()) { diff --git a/panda/src/display/subprocessWindow.cxx b/panda/src/display/subprocessWindow.cxx index d001f3b1f6..261c7f161a 100644 --- a/panda/src/display/subprocessWindow.cxx +++ b/panda/src/display/subprocessWindow.cxx @@ -41,7 +41,7 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, // This will be an offscreen buffer that we use to render the actual // contents. - _buffer = NULL; + _buffer = nullptr; // Create a texture to receive the contents of the framebuffer from the // offscreen buffer. @@ -50,7 +50,7 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _fd = -1; _mmap_size = 0; _filename = string(); - _swbuffer = NULL; + _swbuffer = nullptr; _last_event_flags = 0; } @@ -59,8 +59,8 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ SubprocessWindow:: ~SubprocessWindow() { - nassertv(_buffer == NULL); - nassertv(_swbuffer == NULL); + nassertv(_buffer == nullptr); + nassertv(_swbuffer == nullptr); } /** @@ -74,7 +74,7 @@ void SubprocessWindow:: process_events() { GraphicsWindow::process_events(); - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { SubprocessWindowBuffer::Event swb_event; while (_swbuffer->get_event(swb_event)) { // Deal with this event. @@ -129,7 +129,7 @@ process_events() { */ bool SubprocessWindow:: begin_frame(FrameMode mode, Thread *current_thread) { - if (_swbuffer == NULL || _buffer == NULL) { + if (_swbuffer == nullptr || _buffer == nullptr) { return false; } @@ -164,8 +164,8 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void SubprocessWindow:: begin_flip() { - nassertv(_buffer != (GraphicsBuffer *)NULL); - if (_swbuffer == NULL) { + nassertv(_buffer != nullptr); + if (_swbuffer == nullptr) { return; } @@ -225,9 +225,9 @@ void SubprocessWindow:: set_properties_now(WindowProperties &properties) { Filename filename; WindowHandle *window_handle = properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { if (os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { NativeWindowHandle::SubprocessHandle *subprocess_handle = DCAST(NativeWindowHandle::SubprocessHandle, os_handle); filename = subprocess_handle->get_filename(); @@ -299,30 +299,30 @@ open_window() { */ void SubprocessWindow:: internal_close_window() { - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { SubprocessWindowBuffer::close_buffer (_fd, _mmap_size, _filename.to_os_specific(), _swbuffer); _fd = -1; _filename = string(); - _swbuffer = NULL; + _swbuffer = nullptr; } - if (_buffer != NULL) { + if (_buffer != nullptr) { _buffer->request_close(); _buffer->process_events(); _engine->remove_window(_buffer); - _buffer = NULL; + _buffer = nullptr; } // Tell our parent window (if any) that we're no longer its child. - if (_window_handle != (WindowHandle *)NULL && - _parent_window_handle != (WindowHandle *)NULL) { + if (_window_handle != nullptr && + _parent_window_handle != nullptr) { _parent_window_handle->detach_child(_window_handle); } - _window_handle = NULL; - _parent_window_handle = NULL; + _window_handle = nullptr; + _parent_window_handle = nullptr; _is_valid = false; } @@ -332,7 +332,7 @@ internal_close_window() { */ bool SubprocessWindow:: internal_open_window() { - nassertr(_buffer == NULL, false); + nassertr(_buffer == nullptr, false); // Create a buffer with the same properties as the window. int flags = _creation_flags; @@ -342,7 +342,7 @@ internal_open_window() { GraphicsOutput *buffer = _engine->make_output(_pipe, _name, 0, _fb_properties, win_props, flags, _gsg, _host); - if (buffer != NULL) { + if (buffer != nullptr) { _buffer = DCAST(GraphicsBuffer, buffer); // However, the buffer is not itself intended to be rendered. We only // render it indirectly, via callbacks in here. @@ -363,9 +363,9 @@ internal_open_window() { _gsg = _buffer->get_gsg(); WindowHandle *window_handle = _properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { if (os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { NativeWindowHandle::SubprocessHandle *subprocess_handle = DCAST(NativeWindowHandle::SubprocessHandle, os_handle); _filename = subprocess_handle->get_filename(); @@ -384,7 +384,7 @@ internal_open_window() { _swbuffer = SubprocessWindowBuffer::open_buffer (_fd, _mmap_size, _filename.to_os_specific()); - if (_swbuffer == NULL) { + if (_swbuffer == nullptr) { close(_fd); _fd = -1; _filename = string(); @@ -404,7 +404,7 @@ internal_open_window() { _window_handle = NativeWindowHandle::make_subprocess(_filename); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } diff --git a/panda/src/display/subprocessWindowBuffer.cxx b/panda/src/display/subprocessWindowBuffer.cxx index 36eec2def3..f2f7eea2cb 100644 --- a/panda/src/display/subprocessWindowBuffer.cxx +++ b/panda/src/display/subprocessWindowBuffer.cxx @@ -18,7 +18,6 @@ #include #include -using namespace std; const char SubprocessWindowBuffer:: _magic_number[SubprocessWindowBuffer::magic_number_length] = "pNdaSWB"; @@ -95,12 +94,12 @@ new_buffer(int &fd, size_t &mmap_size, string &filename, mmap_size = 0; fd = -1; - filename = tmpnam(NULL); + filename = tmpnam(nullptr); fd = open(filename.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); if (fd == -1) { perror(filename.c_str()); - return NULL; + return nullptr; } // Create a temporary object to determine the required size. @@ -115,14 +114,14 @@ new_buffer(int &fd, size_t &mmap_size, string &filename, write(fd, zero, zero_size); } - void *shared_mem = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, + void *shared_mem = mmap(nullptr, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (shared_mem == (void *)-1) { // Failure to map. close(fd); fd = -1; mmap_size = 0; - return NULL; + return nullptr; } // Now create the actual object in the shared-memory buffer. @@ -161,7 +160,7 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { fd = open(filename.c_str(), O_RDWR); if (fd == -1) { perror(filename.c_str()); - return NULL; + return nullptr; } // Check that the disk file is large enough. @@ -170,19 +169,19 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { cerr << filename << " not large enough.\n"; close(fd); fd = -1; - return NULL; + return nullptr; } // First, map enough memory to read the buffer object. size_t initial_size = sizeof(SubprocessWindowBuffer); - void *shared_mem = mmap(NULL, initial_size, PROT_READ, + void *shared_mem = mmap(nullptr, initial_size, PROT_READ, MAP_SHARED, fd, 0); if (shared_mem == (void *)-1) { perror("mmap"); cerr << "Couldn't map.\n"; close(fd); fd = -1; - return NULL; + return nullptr; } SubprocessWindowBuffer *temp = (SubprocessWindowBuffer *)shared_mem; @@ -191,7 +190,7 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { munmap(shared_mem, initial_size); close(fd); fd = -1; - return NULL; + return nullptr; } @@ -204,15 +203,15 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { cerr << filename << " not large enough.\n"; close(fd); fd = -1; - return NULL; + return nullptr; } - shared_mem = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, + shared_mem = mmap(nullptr, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (shared_mem == (void *)-1) { perror("mmap"); cerr << "Couldn't map 2.\n"; - return NULL; + return nullptr; } // Now that we've successfully opened and mapped the file, we can safely diff --git a/panda/src/display/subprocessWindowBuffer.h b/panda/src/display/subprocessWindowBuffer.h index 2fecbcadbc..e0d52a7f4a 100644 --- a/panda/src/display/subprocessWindowBuffer.h +++ b/panda/src/display/subprocessWindowBuffer.h @@ -17,7 +17,6 @@ #include // perror #include #include -using namespace std; /** * This is a special class that is designed to faciliate SubprocessWindow. diff --git a/panda/src/display/windowHandle.cxx b/panda/src/display/windowHandle.cxx index ecc903595f..c114da8adf 100644 --- a/panda/src/display/windowHandle.cxx +++ b/panda/src/display/windowHandle.cxx @@ -31,7 +31,7 @@ WindowHandle:: */ void WindowHandle:: send_windows_message(unsigned int msg, int wparam, int lparam) { - if (_keyboard_window != NULL) { + if (_keyboard_window != nullptr) { _keyboard_window->receive_windows_message(msg, wparam, lparam); } } @@ -42,7 +42,7 @@ send_windows_message(unsigned int msg, int wparam, int lparam) { */ size_t WindowHandle:: get_int_handle() const { - if (_os_handle != NULL) { + if (_os_handle != nullptr) { return _os_handle->get_int_handle(); } return 0; @@ -53,7 +53,7 @@ get_int_handle() const { */ void WindowHandle:: output(ostream &out) const { - if (_os_handle == NULL) { + if (_os_handle == nullptr) { out << "(null)"; } else { out << *_os_handle; @@ -75,7 +75,7 @@ attach_child(WindowHandle *child) { void WindowHandle:: detach_child(WindowHandle *child) { if (_keyboard_window == child) { - _keyboard_window = NULL; + _keyboard_window = nullptr; } } diff --git a/panda/src/display/windowProperties.I b/panda/src/display/windowProperties.I index 9179124705..f9af047b54 100644 --- a/panda/src/display/windowProperties.I +++ b/panda/src/display/windowProperties.I @@ -726,7 +726,7 @@ has_parent_window() const { INLINE void WindowProperties:: clear_parent_window() { _specified &= ~S_parent_window; - _parent_window = NULL; + _parent_window = nullptr; } diff --git a/panda/src/display/windowProperties.cxx b/panda/src/display/windowProperties.cxx index 298bed4b45..fec24e4faf 100644 --- a/panda/src/display/windowProperties.cxx +++ b/panda/src/display/windowProperties.cxx @@ -15,7 +15,7 @@ #include "config_display.h" #include "nativeWindowHandle.h" -WindowProperties *WindowProperties::_default_properties = NULL; +WindowProperties *WindowProperties::_default_properties = nullptr; /** * @@ -93,7 +93,7 @@ get_config_properties() { */ WindowProperties WindowProperties:: get_default() { - if (_default_properties != NULL) { + if (_default_properties != nullptr) { return *_default_properties; } else { return get_config_properties(); @@ -110,7 +110,7 @@ get_default() { */ void WindowProperties:: set_default(const WindowProperties &default_properties) { - if (_default_properties == NULL) { + if (_default_properties == nullptr) { _default_properties = new WindowProperties; } (*_default_properties) = default_properties; @@ -122,9 +122,9 @@ set_default(const WindowProperties &default_properties) { */ void WindowProperties:: clear_default() { - if (_default_properties != NULL) { + if (_default_properties != nullptr) { delete _default_properties; - _default_properties = NULL; + _default_properties = nullptr; } } @@ -177,7 +177,7 @@ clear() { _z_order = Z_normal; _flags = 0; _mouse_mode = M_absolute; - _parent_window = NULL; + _parent_window = nullptr; } /** @@ -197,7 +197,7 @@ clear() { void WindowProperties:: set_parent_window(size_t parent) { if (parent == 0) { - set_parent_window((WindowHandle *)NULL); + set_parent_window(nullptr); } else { PT(WindowHandle) handle = NativeWindowHandle::make_int(parent); set_parent_window(handle); @@ -312,7 +312,7 @@ output(ostream &out) const { out << get_mouse_mode() << " "; } if (has_parent_window()) { - if (get_parent_window() == NULL) { + if (get_parent_window() == nullptr) { out << "parent:none "; } else { out << "parent:" << *get_parent_window() << " "; diff --git a/panda/src/display/windowProperties.h b/panda/src/display/windowProperties.h index 16a65c0096..dd6ba5185c 100644 --- a/panda/src/display/windowProperties.h +++ b/panda/src/display/windowProperties.h @@ -166,7 +166,7 @@ PUBLISHED: MAKE_PROPERTY2(z_order, has_z_order, get_z_order, set_z_order, clear_z_order); void set_parent_window(size_t parent); - INLINE void set_parent_window(WindowHandle *parent_window = NULL); + INLINE void set_parent_window(WindowHandle *parent_window = nullptr); INLINE WindowHandle *get_parent_window() const; INLINE bool has_parent_window() const; INLINE void clear_parent_window(); diff --git a/panda/src/distort/nonlinearImager.cxx b/panda/src/distort/nonlinearImager.cxx index fb264061c3..551caac4d1 100644 --- a/panda/src/distort/nonlinearImager.cxx +++ b/panda/src/distort/nonlinearImager.cxx @@ -28,7 +28,7 @@ */ NonlinearImager:: NonlinearImager() { - _engine = (GraphicsEngine *)NULL; + _engine = nullptr; _stale = true; } @@ -40,7 +40,7 @@ NonlinearImager:: remove_all_screens(); remove_all_viewers(); - if (_recompute_task != (AsyncTask *)NULL) { + if (_recompute_task != nullptr) { AsyncTaskManager *task_mgr = AsyncTaskManager::get_global_ptr(); task_mgr->remove(_recompute_task); } @@ -82,7 +82,7 @@ add_screen(const NodePath &screen, const string &name) { new_screen._screen = screen; new_screen._screen_node = screen_node; new_screen._name = name; - new_screen._buffer = (GraphicsOutput *)NULL; + new_screen._buffer = nullptr; new_screen._tex_width = 256; new_screen._tex_height = 256; new_screen._active = true; @@ -167,7 +167,7 @@ get_screen(int index) const { */ GraphicsOutput *NonlinearImager:: get_buffer(int index) const { - nassertr(index >= 0 && index < (int)_screens.size(), (GraphicsOutput *)NULL); + nassertr(index >= 0 && index < (int)_screens.size(), nullptr); return _screens[index]._buffer; } @@ -188,9 +188,9 @@ set_texture_size(int index, int width, int height) { screen._tex_width = width; screen._tex_height = height; - if (screen._buffer != (GraphicsOutput *)NULL) { + if (screen._buffer != nullptr) { bool removed = _engine->remove_window(screen._buffer); - screen._buffer = (GraphicsOutput *)NULL; + screen._buffer = nullptr; nassertv(removed); } @@ -230,9 +230,9 @@ set_screen_active(int index, bool active) { } // Also remove its buffer. - if (screen._buffer != (GraphicsOutput *)NULL) { + if (screen._buffer != nullptr) { bool removed = _engine->remove_window(screen._buffer); - screen._buffer = (GraphicsOutput *)NULL; + screen._buffer = nullptr; nassertv(removed); } @@ -276,20 +276,20 @@ get_screen_active(int index) const { int NonlinearImager:: add_viewer(DisplayRegion *dr) { GraphicsOutput *window = dr->get_window(); - nassertr(window != (GraphicsOutput *)NULL, -1); + nassertr(window != nullptr, -1); GraphicsStateGuardian *gsg = window->get_gsg(); - nassertr(gsg != (GraphicsStateGuardian *)NULL, -1); + nassertr(gsg != nullptr, -1); GraphicsEngine *engine = gsg->get_engine(); - nassertr(engine != (GraphicsEngine *)NULL, -1); + nassertr(engine != nullptr, -1); nassertr(_viewers.empty() || (engine == _engine), -1); - if (_engine == (GraphicsEngine *)NULL) { + if (_engine == nullptr) { _engine = engine; } - if (_recompute_task == (AsyncTask *)NULL) { + if (_recompute_task == nullptr) { _recompute_task = new GenericAsyncTask("nli_recompute", recompute_callback, (void *)this); AsyncTaskManager *task_mgr = AsyncTaskManager::get_global_ptr(); @@ -310,7 +310,7 @@ add_viewer(DisplayRegion *dr) { // Get the current camera off of the DisplayRegion, if any. viewer._viewer = dr->get_camera(); if (viewer._viewer.is_empty()) { - viewer._viewer_node = (LensNode *)NULL; + viewer._viewer_node = nullptr; } else { viewer._viewer_node = DCAST(LensNode, viewer._viewer.node()); } @@ -463,7 +463,7 @@ get_num_viewers() const { */ DisplayRegion *NonlinearImager:: get_viewer(int index) const { - nassertr(index >= 0 && index < (int)_viewers.size(), (DisplayRegion *)NULL); + nassertr(index >= 0 && index < (int)_viewers.size(), nullptr); return _viewers[index]._dr; } @@ -509,8 +509,8 @@ recompute() { } } - if (viewer._viewer_node != (LensNode *)NULL && - viewer._viewer_node->get_lens() != (Lens *)NULL) { + if (viewer._viewer_node != nullptr && + viewer._viewer_node->get_lens() != nullptr) { viewer._viewer_lens_change = viewer._viewer_node->get_lens()->get_last_change(); } @@ -540,7 +540,7 @@ recompute_if_stale() { size_t vi; for (vi = 0; vi < _viewers.size(); ++vi) { Viewer &viewer = _viewers[vi]; - if (viewer._viewer_node != (LensNode *)NULL) { + if (viewer._viewer_node != nullptr) { UpdateSeq lens_change = viewer._viewer_node->get_lens()->get_last_change(); if (lens_change != viewer._viewer_lens_change) { @@ -588,16 +588,16 @@ recompute_screen(NonlinearImager::Screen &screen, size_t vi) { Viewer &viewer = _viewers[vi]; PT(PandaNode) mesh = screen._screen_node->make_flat_mesh(screen._screen, viewer._viewer); - if (mesh != (PandaNode *)NULL) { + if (mesh != nullptr) { screen._meshes[vi]._mesh = viewer._internal_scene.attach_new_node(mesh); } - if (screen._buffer == (GraphicsOutput *)NULL) { + if (screen._buffer == nullptr) { GraphicsOutput *win = viewer._dr->get_window(); GraphicsOutput *buffer = win->make_texture_buffer - (screen._name, screen._tex_width, screen._tex_height, NULL, false); + (screen._name, screen._tex_width, screen._tex_height, nullptr, false); - if (buffer != (GraphicsOutput *)NULL) { + if (buffer != nullptr) { screen._buffer = buffer; DisplayRegion *dr = buffer->make_display_region(); dr->set_camera(screen._source_camera); @@ -607,7 +607,7 @@ recompute_screen(NonlinearImager::Screen &screen, size_t vi) { } } - if (screen._buffer != (GraphicsOutput *)NULL) { + if (screen._buffer != nullptr) { screen._meshes[vi]._mesh.set_texture(screen._buffer->get_texture()); // We don't really need to set the texture on the dark room screen, since diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 1991bfc120..0ac8fd9edf 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -118,7 +118,7 @@ cull_callback(CullTraverser *, CullTraverserData &data) { */ void ProjectionScreen:: set_projector(const NodePath &projector) { - _projector_node = (LensNode *)NULL; + _projector_node = nullptr; _projector = projector; if (!projector.is_empty()) { nassertv(projector.node()->is_of_type(LensNode::get_class_type())); @@ -156,9 +156,9 @@ generate_screen(const NodePath &projector, const string &screen_name, PN_stdfloat fill_ratio) { nassertr(!projector.is_empty() && projector.node()->is_of_type(LensNode::get_class_type()), - NULL); + nullptr); LensNode *projector_node = DCAST(LensNode, projector.node()); - nassertr(projector_node->get_lens() != NULL, NULL); + nassertr(projector_node->get_lens() != nullptr, nullptr); // First, get the relative coordinate space of the projector. LMatrix4 rel_mat; @@ -204,7 +204,7 @@ generate_screen(const NodePath &projector, const string &screen_name, normal.add_data3(-normalize(norm * rel_mat)); } } - nassertr(vdata->get_num_rows() == num_verts, NULL); + nassertr(vdata->get_num_rows() == num_verts, nullptr); // Now synthesize a triangle mesh. We run triangle strips horizontally // across the grid. @@ -265,12 +265,12 @@ regenerate_screen(const NodePath &projector, const string &screen_name, */ PT(PandaNode) ProjectionScreen:: make_flat_mesh(const NodePath &this_np, const NodePath &camera) { - nassertr(!this_np.is_empty() && this_np.node() == this, NULL); + nassertr(!this_np.is_empty() && this_np.node() == this, nullptr); nassertr(!camera.is_empty() && camera.node()->is_of_type(LensNode::get_class_type()), - NULL); + nullptr); LensNode *camera_node = DCAST(LensNode, camera.node()); - nassertr(camera_node->get_lens() != (Lens *)NULL, NULL); + nassertr(camera_node->get_lens() != nullptr, nullptr); // First, ensure the UV's are up-to-date. recompute_if_stale(this_np); @@ -318,8 +318,8 @@ bool ProjectionScreen:: recompute_if_stale(const NodePath &this_np) { nassertr(!this_np.is_empty() && this_np.node() == this, false); - if (_projector_node != (LensNode *)NULL && - _projector_node->get_lens() != (Lens *)NULL) { + if (_projector_node != nullptr && + _projector_node->get_lens() != nullptr) { UpdateSeq lens_change = _projector_node->get_lens()->get_last_change(); if (_stale || lens_change != _projector_lens_change) { recompute(); @@ -346,8 +346,8 @@ recompute_if_stale(const NodePath &this_np) { */ void ProjectionScreen:: do_recompute(const NodePath &this_np) { - if (_projector_node != (LensNode *)NULL && - _projector_node->get_lens() != (Lens *)NULL) { + if (_projector_node != nullptr && + _projector_node->get_lens() != nullptr) { recompute_node(this_np, _rel_top_mat, _computed_rel_top_mat); // Make sure this flag is set to false for next time. @@ -479,7 +479,7 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { Thread *current_thread = Thread::get_current_thread(); Lens *lens = _projector_node->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); const LMatrix4 &to_uv = _invert_uvs ? lens_to_uv_inverted : lens_to_uv; @@ -620,7 +620,7 @@ make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, rel_mat, computed_rel_mat); } - if (new_child != NULL) { + if (new_child != nullptr) { // Copy all of the render state (except TransformState) to the new arc. new_child->set_state(child->get_state()); } @@ -650,7 +650,7 @@ make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, const Geom *geom = node->get_geom(i); PT(Geom) new_geom = make_mesh_geom(geom, lens_node->get_lens(), rel_mat); - if (new_geom != (Geom *)NULL) { + if (new_geom != nullptr) { new_node->add_geom(new_geom, node->get_geom_state(i)); } } diff --git a/panda/src/downloader/bioPtr.cxx b/panda/src/downloader/bioPtr.cxx index b86f37f816..8c5c76f636 100644 --- a/panda/src/downloader/bioPtr.cxx +++ b/panda/src/downloader/bioPtr.cxx @@ -36,7 +36,7 @@ static string format_error() { PVOID buffer; DWORD len; len = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, WSAGetLastError(), 0, (LPTSTR)&buffer, 0, NULL); + nullptr, WSAGetLastError(), 0, (LPTSTR)&buffer, 0, nullptr); if (len == 0) { return string("Unknown error message"); } @@ -88,17 +88,17 @@ BioPtr(const URLSpec &url) : _connecting(false) { // doesn't handle IPv6 properly. _server_name = url.get_server(); _port = url.get_port(); - _bio = NULL; + _bio = nullptr; // These hints tell getaddrinfo what kind of address to return. - struct addrinfo hints, *res = NULL; + struct addrinfo hints, *res = nullptr; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; hints.ai_family = support_ipv6 ? AF_UNSPEC : AF_INET; hints.ai_socktype = SOCK_STREAM; // Resolve the hostname or address string. - int result = getaddrinfo(_server_name.c_str(), NULL, &hints, &res); + int result = getaddrinfo(_server_name.c_str(), nullptr, &hints, &res); if (result != 0) { const char *errmsg; #ifndef _WIN32 @@ -113,14 +113,14 @@ BioPtr(const URLSpec &url) : _connecting(false) { << "Failed to resolve " << url.get_server() << ": " << errmsg << "\n"; return; } - nassertv(res != NULL && res->ai_addr != NULL); + nassertv(res != nullptr && res->ai_addr != nullptr); // Store the real resolved address. char buf[48]; buf[0] = 0; #ifdef _WIN32 DWORD bufsize = sizeof(buf); - WSAAddressToStringA(res->ai_addr, res->ai_addrlen, NULL, buf, &bufsize); + WSAAddressToStringA(res->ai_addr, res->ai_addrlen, nullptr, buf, &bufsize); #else if (res->ai_addr->sa_family == AF_INET) { inet_ntop(AF_INET, (char *)&((sockaddr_in *)res->ai_addr)->sin_addr, buf, sizeof(buf)); @@ -143,7 +143,7 @@ BioPtr(const URLSpec &url) : _connecting(false) { if (fd < 0) { downloader_cat.error() << "Failed to create socket: " << format_error() << "\n"; - _bio = NULL; + _bio = nullptr; freeaddrinfo(res); return; } @@ -170,7 +170,7 @@ BioPtr(const URLSpec &url) : _connecting(false) { */ void BioPtr:: set_nbio(bool nbio) { - if (_bio == NULL) { + if (_bio == nullptr) { return; } @@ -186,7 +186,7 @@ set_nbio(bool nbio) { */ bool BioPtr:: connect() { - if (_bio == NULL) { + if (_bio == nullptr) { return false; } @@ -226,7 +226,7 @@ connect() { */ bool BioPtr:: should_retry() const { - return (_bio != NULL) && BIO_should_retry(_bio); + return (_bio != nullptr) && BIO_should_retry(_bio); } /** @@ -234,14 +234,14 @@ should_retry() const { */ BioPtr:: ~BioPtr() { - if (_bio != (BIO *)NULL) { + if (_bio != nullptr) { if (downloader_cat.is_debug() && !_server_name.empty()) { downloader_cat.debug() << "Dropping connection to " << _server_name << " port " << _port << "\n"; } BIO_free_all(_bio); - _bio = (BIO *)NULL; + _bio = nullptr; } } diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index d0bd04e027..1598b15259 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -24,11 +24,6 @@ #undef X509_NAME #endif // WIN32_VC -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - /** * */ @@ -194,9 +189,9 @@ underflow() { << _source->get_port() << " (" << read_count << ").\n"; OpenSSLWrapper::get_global_ptr()->notify_ssl_errors(); - SSL *ssl = NULL; + SSL *ssl = nullptr; BIO_get_ssl(*_source, &ssl); - if (ssl != (SSL *)NULL) { + if (ssl != nullptr) { downloader_cat.warning() << "OpenSSL error code: " << SSL_get_error(ssl, read_count) << "\n"; @@ -276,7 +271,7 @@ write_chars(const char *start, size_t length) { fd_set wset; FD_ZERO(&wset); FD_SET(fd, &wset); - select(fd + 1, NULL, &wset, NULL, NULL); + select(fd + 1, nullptr, &wset, nullptr, nullptr); #endif // SIMPLE_THREADS } diff --git a/panda/src/downloader/bioStreamPtr.cxx b/panda/src/downloader/bioStreamPtr.cxx index 80d5e4838a..6444703b16 100644 --- a/panda/src/downloader/bioStreamPtr.cxx +++ b/panda/src/downloader/bioStreamPtr.cxx @@ -20,9 +20,9 @@ */ BioStreamPtr:: ~BioStreamPtr() { - if (_stream != (BioStream *)NULL) { + if (_stream != nullptr) { delete _stream; - _stream = (BioStream *)NULL; + _stream = nullptr; } } diff --git a/panda/src/downloader/chunkedStream.cxx b/panda/src/downloader/chunkedStream.cxx index 2b6f316c0b..279aed870d 100644 --- a/panda/src/downloader/chunkedStream.cxx +++ b/panda/src/downloader/chunkedStream.cxx @@ -21,9 +21,9 @@ */ IChunkedStream:: ~IChunkedStream() { - if (_channel != (HTTPChannel *)NULL) { + if (_channel != nullptr) { _channel->body_stream_destructs(this); - _channel = NULL; + _channel = nullptr; } } diff --git a/panda/src/downloader/chunkedStreamBuf.I b/panda/src/downloader/chunkedStreamBuf.I index b890d7349b..5942bb0f48 100644 --- a/panda/src/downloader/chunkedStreamBuf.I +++ b/panda/src/downloader/chunkedStreamBuf.I @@ -16,7 +16,7 @@ */ INLINE bool ChunkedStreamBuf:: is_closed() const { - return (_source == (BioStreamPtr *)NULL || (*_source)->is_closed()); + return (_source == nullptr || (*_source)->is_closed()); } /** diff --git a/panda/src/downloader/chunkedStreamBuf.cxx b/panda/src/downloader/chunkedStreamBuf.cxx index 9464a9c730..f6ddd39713 100644 --- a/panda/src/downloader/chunkedStreamBuf.cxx +++ b/panda/src/downloader/chunkedStreamBuf.cxx @@ -18,11 +18,6 @@ // This module is not compiled if OpenSSL is not available. #ifdef HAVE_OPENSSL -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - /** * */ @@ -71,7 +66,7 @@ open_read(BioStreamPtr *source, HTTPChannel *doc) { _read_state = ISocketStream::RS_reading; _doc = doc; - if (_doc != (HTTPChannel *)NULL) { + if (_doc != nullptr) { _read_index = doc->_read_index; _doc->_transfer_file_size = 0; _doc->_got_transfer_file_size = true; @@ -181,7 +176,7 @@ read_chars(char *start, size_t length) { return 0; } - size_t chunk_size = (size_t)strtol(line.c_str(), NULL, 16); + size_t chunk_size = (size_t)strtol(line.c_str(), nullptr, 16); if (downloader_cat.is_spam()) { downloader_cat.spam() << "Got chunk of size " << chunk_size << " bytes.\n"; @@ -190,7 +185,7 @@ read_chars(char *start, size_t length) { if (chunk_size == 0) { // Last chunk; we're done. _done = true; - if (_doc != (HTTPChannel *)NULL && _read_index == _doc->_read_index) { + if (_doc != nullptr && _read_index == _doc->_read_index) { _doc->_file_size = _doc->_transfer_file_size; _doc->_got_file_size = true; } @@ -198,7 +193,7 @@ read_chars(char *start, size_t length) { return 0; } - if (_doc != (HTTPChannel *)NULL && _read_index == _doc->_read_index) { + if (_doc != nullptr && _read_index == _doc->_read_index) { _doc->_transfer_file_size += chunk_size; } diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index da78e19fa3..b6bc542e60 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -34,9 +34,9 @@ */ Decompressor:: Decompressor() { - _source = NULL; - _decompress = NULL; - _dest = NULL; + _source = nullptr; + _decompress = nullptr; + _dest = nullptr; } /** @@ -137,7 +137,7 @@ initiate(const Filename &source_file, const Filename &dest_file) { */ int Decompressor:: run() { - if (_decompress == (istream *)NULL) { + if (_decompress == nullptr) { // Hmm, we were already done. return EU_success; } @@ -222,7 +222,7 @@ decompress(Ramfile &source_and_dest_file) { */ PN_stdfloat Decompressor:: get_progress() const { - if (_decompress == (istream *)NULL) { + if (_decompress == nullptr) { // Hmm, we were already done. return 1.0f; } @@ -240,17 +240,17 @@ get_progress() const { */ void Decompressor:: cleanup() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { delete _source; - _source = NULL; + _source = nullptr; } - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { delete _dest; - _dest = NULL; + _dest = nullptr; } - if (_decompress != (istream *)NULL) { + if (_decompress != nullptr) { delete _decompress; - _decompress = NULL; + _decompress = nullptr; } } diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index a210fba8bd..d532009e2b 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -253,7 +253,7 @@ read_db(Filename &file, bool want_server_info) { file.set_binary(); istream *read_stream = vfs->open_read_file(file, true); - if (read_stream == (istream *)NULL) { + if (read_stream == nullptr) { downloader_cat.error() << "failed to open input file: " << file << endl; diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index d387b51dd2..81568ae951 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -63,9 +63,9 @@ set_extract_dir(const Filename &extract_dir) { void Extractor:: reset() { if (_initiated) { - if (_read != (istream *)NULL) { + if (_read != nullptr) { Multifile::close_read_subfile(_read); - _read = (istream *)NULL; + _read = nullptr; } _write.close(); _initiated = false; @@ -125,7 +125,7 @@ step() { _subfile_pos = 0; _subfile_length = 0; _total_bytes_extracted = 0; - _read = (istream *)NULL; + _read = nullptr; _initiated = true; } @@ -134,7 +134,7 @@ step() { double finish = now + extractor_step_time; do { - if (_read == (istream *)NULL) { + if (_read == nullptr) { // Time to open the next subfile. if (_request_index >= (int)_requests.size()) { // All done! @@ -167,7 +167,7 @@ step() { _subfile_length = _multifile->get_subfile_length(_subfile_index); _subfile_pos = 0; _read = _multifile->open_read_subfile(_subfile_index); - if (_read == (istream *)NULL) { + if (_read == nullptr) { downloader_cat.error() << "Unable to read subfile " << _multifile->get_subfile_name(_subfile_index) << ".\n"; @@ -183,7 +183,7 @@ step() { << "Finished current subfile.\n"; } Multifile::close_read_subfile(_read); - _read = (istream *)NULL; + _read = nullptr; _write.close(); _request_index++; diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 93e04f1432..990c89d4e6 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -105,14 +105,14 @@ HTTPChannel(HTTPClient *client) : _done_state = S_new; _started_download = false; _sent_so_far = 0; - _body_stream = NULL; + _body_stream = nullptr; _owns_body_stream = false; - _sbio = NULL; + _sbio = nullptr; _cipher_list = _client->get_cipher_list(); _last_status_code = 0; _last_run_time = 0.0f; - _download_to_ramfile = NULL; - _download_to_stream = NULL; + _download_to_ramfile = nullptr; + _download_to_stream = nullptr; } /** @@ -549,7 +549,7 @@ open_read_body() { reset_body_stream(); if ((_state != S_read_header && _state != S_begin_body) || _source.is_null()) { - return NULL; + return nullptr; } string transfer_coding = downcase(get_header_value("Transfer-Encoding")); @@ -588,7 +588,7 @@ open_read_body() { */ void HTTPChannel:: close_read_body(istream *stream) const { - if (stream != (istream *)NULL) { + if (stream != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -677,7 +677,7 @@ download_to_file(const Filename &filename, bool subdocument_resumes) { */ bool HTTPChannel:: download_to_ram(Ramfile *ramfile, bool subdocument_resumes) { - nassertr(ramfile != (Ramfile *)NULL, false); + nassertr(ramfile != nullptr, false); reset_download_to(); ramfile->_pos = 0; _download_to_ramfile = ramfile; @@ -762,11 +762,11 @@ download_to_stream(ostream *strm, bool subdocument_resumes) { SocketStream *HTTPChannel:: get_connection() { if (!is_connection_ready()) { - return NULL; + return nullptr; } BioStream *stream = _source->get_stream(); - _source->set_stream(NULL); + _source->set_stream(nullptr); // We're now passing ownership of the connection to the caller. if (downloader_cat.is_debug()) { @@ -814,7 +814,7 @@ body_stream_destructs(ISocketStream *stream) { break; } } - _body_stream = NULL; + _body_stream = nullptr; _owns_body_stream = false; } } @@ -887,7 +887,7 @@ reached_done_state() { } else { // Oops, we have to download the body now. open_read_body(); - if (_body_stream == (ISocketStream *)NULL) { + if (_body_stream == nullptr) { if (downloader_cat.is_debug()) { downloader_cat.debug() << _NOTIFY_HTTP_CHANNEL_ID @@ -924,7 +924,7 @@ run_try_next_proxy() { // Now try the next proxy in sequence. _proxy = _proxies[_proxy_next_index]; - _proxy_auth = (HTTPAuthorization *)NULL; + _proxy_auth = nullptr; _proxy_next_index++; close_connection(); reconsider_proxy(); @@ -1023,7 +1023,7 @@ run_connecting_wait() { tv.tv_sec = 0; tv.tv_usec = 0; } - int errcode = select(fd + 1, NULL, &wset, NULL, &tv); + int errcode = select(fd + 1, nullptr, &wset, nullptr, &tv); if (errcode < 0) { downloader_cat.warning() << _NOTIFY_HTTP_CHANNEL_ID @@ -1138,7 +1138,7 @@ run_http_proxy_reading_header() { // 407: not authorized to proxy. Try to get the authorization. string authenticate_request = get_header_value("Proxy-Authenticate"); _proxy_auth = _client->generate_auth(_proxy, true, authenticate_request); - if (_proxy_auth != (HTTPAuthorization *)NULL) { + if (_proxy_auth != nullptr) { _proxy_realm = _proxy_auth->get_realm(); _proxy_username = _client->select_username(_proxy, true, _proxy_realm); if (!_proxy_username.empty()) { @@ -1447,9 +1447,9 @@ run_setup_ssl() { _sbio = BIO_new_ssl(_client->get_ssl_ctx(), true); BIO_push(_sbio, *_bio); - SSL *ssl = NULL; + SSL *ssl = nullptr; BIO_get_ssl(_sbio, &ssl); - nassertr(ssl != (SSL *)NULL, false); + nassertr(ssl != nullptr, false); // We only take one word at a time from the _cipher_list. If that // connection fails, then we take the next word. @@ -1511,7 +1511,7 @@ run_setup_ssl() { const char *name; int pri = 0; name = SSL_get_cipher_list(ssl, pri); - while (name != NULL) { + while (name != nullptr) { downloader_cat.spam() << _NOTIFY_HTTP_CHANNEL_ID << " " << pri + 1 << ". " << name << "\n"; @@ -1585,16 +1585,16 @@ run_ssl_handshake() { return false; } - SSL *ssl = NULL; + SSL *ssl = nullptr; BIO_get_ssl(_sbio, &ssl); - nassertr(ssl != (SSL *)NULL, false); + nassertr(ssl != nullptr, false); if (!_nonblocking) { SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); } const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl); - if (cipher == (const SSL_CIPHER *)NULL) { + if (cipher == nullptr) { downloader_cat.warning() << _NOTIFY_HTTP_CHANNEL_ID << "No current cipher on SSL connection.\n"; @@ -1609,10 +1609,10 @@ run_ssl_handshake() { // Now that we've made an SSL handshake, we can use the SSL bio to do all of // our communication henceforth. _bio->set_bio(_sbio); - _sbio = NULL; + _sbio = nullptr; X509 *cert = SSL_get_peer_certificate(ssl); - if (cert == (X509 *)NULL) { + if (cert == nullptr) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID << "No certificate was presented by server.\n"; @@ -1637,7 +1637,7 @@ run_ssl_handshake() { if (downloader_cat.is_spam()) { downloader_cat.spam() << _NOTIFY_HTTP_CHANNEL_ID - << "Received certificate from server:\n" << flush; + << "Received certificate from server:\n" << std::flush; X509_print_fp(stderr, cert); fflush(stderr); } @@ -1925,7 +1925,7 @@ run_reading_header() { string authenticate_request = get_header_value("Proxy-Authenticate"); _proxy_auth = _client->generate_auth(_proxy, true, authenticate_request); - if (_proxy_auth != (HTTPAuthorization *)NULL) { + if (_proxy_auth != nullptr) { _proxy_realm = _proxy_auth->get_realm(); _proxy_username = _client->select_username(_proxy, true, _proxy_realm); if (!_proxy_username.empty()) { @@ -1942,7 +1942,7 @@ run_reading_header() { // 401: not authorized to remote server. Try to get the authorization. string authenticate_request = get_header_value("WWW-Authenticate"); _www_auth = _client->generate_auth(_request.get_url(), false, authenticate_request); - if (_www_auth != (HTTPAuthorization *)NULL) { + if (_www_auth != nullptr) { _www_realm = _www_auth->get_realm(); _www_username = _client->select_username(_request.get_url(), false, _www_realm); if (!_www_username.empty()) { @@ -2090,7 +2090,7 @@ run_begin_body() { } else { open_read_body(); - if (_body_stream == (ISocketStream *)NULL) { + if (_body_stream == nullptr) { if (downloader_cat.is_debug()) { downloader_cat.debug() << _NOTIFY_HTTP_CHANNEL_ID @@ -2132,7 +2132,7 @@ run_reading_body() { } // Skip the body we've already started. - if (_body_stream == NULL || !_owns_body_stream) { + if (_body_stream == nullptr || !_owns_body_stream) { // Whoops, we're not in skip-body mode. Better reset. if (downloader_cat.is_debug()) { downloader_cat.debug() @@ -2144,14 +2144,14 @@ run_reading_body() { } string line; - getline(*_body_stream, line); + std::getline(*_body_stream, line); while (!_body_stream->fail() && !_body_stream->eof()) { if (downloader_cat.is_spam()) { downloader_cat.spam() << _NOTIFY_HTTP_CHANNEL_ID << "skip: " << line << "\n"; } - getline(*_body_stream, line); + std::getline(*_body_stream, line); } if (!_body_stream->is_closed()) { @@ -2232,7 +2232,7 @@ run_read_trailer() { */ bool HTTPChannel:: run_download_to_file() { - nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); + nassertr(_body_stream != nullptr && _owns_body_stream, false); bool do_throttle = _wanted_nonblocking && _download_throttle; @@ -2293,8 +2293,8 @@ run_download_to_file() { */ bool HTTPChannel:: run_download_to_ram() { - nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); - nassertr(_download_to_ramfile != (Ramfile *)NULL, false); + nassertr(_body_stream != nullptr && _owns_body_stream, false); + nassertr(_download_to_ramfile != nullptr, false); bool do_throttle = _wanted_nonblocking && _download_throttle; @@ -2343,7 +2343,7 @@ run_download_to_ram() { */ bool HTTPChannel:: run_download_to_stream() { - nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); + nassertr(_body_stream != nullptr && _owns_body_stream, false); bool do_throttle = _wanted_nonblocking && _download_throttle; @@ -2448,7 +2448,7 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, // Changing the proxy is grounds for dropping the old connection, if any. if (_proxy != new_proxy) { _proxy = new_proxy; - _proxy_auth = (HTTPAuthorization *)NULL; + _proxy_auth = nullptr; if (downloader_cat.is_debug()) { downloader_cat.debug() << _NOTIFY_HTTP_CHANNEL_ID @@ -2490,16 +2490,16 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, // underneath this. reset_to_new(); _bio = new BioPtr(_request.get_url()); - if (_bio->get_bio() != NULL) { + if (_bio->get_bio() != nullptr) { // Successfully opened the file. _source = new BioStreamPtr(new BioStream(_bio)); _status_entry._status_code = 200; _state = S_start_direct_file_read; // Get the file size. - FILE *fp = NULL; + FILE *fp = nullptr; BIO_get_fp(_bio->get_bio(), &fp); - if (fp != NULL) { + if (fp != nullptr) { if (fseek(fp, 0, SEEK_END) == 0) { _file_size = ftell(fp); _got_file_size = true; @@ -2663,7 +2663,7 @@ open_download_file() { if (_download_dest == DD_file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); _download_to_stream = vfs->open_write_file(_download_to_filename, false, !_subdocument_resumes); - if (_download_to_stream == NULL) { + if (_download_to_stream == nullptr) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID << "Could not open " << _download_to_filename << " for writing.\n"; @@ -3339,8 +3339,8 @@ validate_server_name(X509 *cert) { // According to RFC 2818, we should check the DNS name(s) in the // subjectAltName extension first, if that extension exists. STACK_OF(GENERAL_NAME) *subject_alt_names = - (STACK_OF(GENERAL_NAME) *)X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); - if (subject_alt_names != NULL) { + (STACK_OF(GENERAL_NAME) *)X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr); + if (subject_alt_names != nullptr) { int num_alts = sk_GENERAL_NAME_num(subject_alt_names); for (int i = 0; i < num_alts; ++i) { // Get the ith alt name. @@ -3348,13 +3348,13 @@ validate_server_name(X509 *cert) { sk_GENERAL_NAME_value(subject_alt_names, i); if (alt_name->type == GEN_DNS) { - char *buffer = NULL; + char *buffer = nullptr; int len = ASN1_STRING_to_UTF8((unsigned char**)&buffer, alt_name->d.ia5); if (len > 0) { cert_names.push_back(string(buffer, len)); } - if (buffer != NULL) { + if (buffer != nullptr) { OPENSSL_free(buffer); } } @@ -3365,7 +3365,7 @@ validate_server_name(X509 *cert) { // If there were no DNS names, use the common name instead. X509_NAME *xname = X509_get_subject_name(cert); - if (xname != NULL) { + if (xname != nullptr) { string common_name = get_x509_name_component(xname, NID_commonName); cert_names.push_back(common_name); } @@ -3444,7 +3444,7 @@ string HTTPChannel:: get_x509_name_component(X509_NAME *name, int nid) { ASN1_OBJECT *obj = OBJ_nid2obj(nid); - if (obj == NULL) { + if (obj == nullptr) { // Unknown nid. See opensslobjects.h. return string(); } @@ -3467,7 +3467,7 @@ void HTTPChannel:: make_header() { _proxy_auth = _client->select_auth(_proxy, true, _proxy_realm); _proxy_username = string(); - if (_proxy_auth != (HTTPAuthorization *)NULL) { + if (_proxy_auth != nullptr) { _proxy_realm = _proxy_auth->get_realm(); _proxy_username = _client->select_username(_proxy, true, _proxy_realm); } @@ -3482,7 +3482,7 @@ make_header() { _www_auth = _client->select_auth(_request.get_url(), false, _www_realm); _www_username = string(); - if (_www_auth != (HTTPAuthorization *)NULL) { + if (_www_auth != nullptr) { _www_realm = _www_auth->get_realm(); _www_username = _client->select_username(_request.get_url(), false, _www_realm); } @@ -3642,7 +3642,7 @@ void HTTPChannel:: make_proxy_request_text() { _proxy_request_text = _proxy_header; - if (_proxy_auth != (HTTPAuthorization *)NULL && !_proxy_username.empty()) { + if (_proxy_auth != nullptr && !_proxy_username.empty()) { _proxy_request_text += "Proxy-Authorization: "; _proxy_request_text += _proxy_auth->generate(HTTPEnum::M_connect, _request.get_url().get_server_and_port(), @@ -3662,14 +3662,14 @@ make_request_text() { _request_text = _header; if (_proxy_serves_document && - _proxy_auth != (HTTPAuthorization *)NULL && !_proxy_username.empty()) { + _proxy_auth != nullptr && !_proxy_username.empty()) { _request_text += "Proxy-Authorization: "; _request_text += _proxy_auth->generate(_method, _request.get_url().get_url(), _proxy_username, _body); _request_text += "\r\n"; } - if (_www_auth != (HTTPAuthorization *)NULL && !_www_username.empty()) { + if (_www_auth != nullptr && !_www_username.empty()) { string authorization = _request_text += "Authorization: "; _request_text += @@ -3767,14 +3767,14 @@ reset_download_to() { */ void HTTPChannel:: close_download_stream() { - if (_download_to_stream != NULL) { + if (_download_to_stream != nullptr) { _download_to_stream->flush(); if (_download_dest == DD_file) { VirtualFileSystem::close_write_file(_download_to_stream); } } - _download_to_ramfile = (Ramfile *)NULL; - _download_to_stream = NULL; + _download_to_ramfile = nullptr; + _download_to_stream = nullptr; } @@ -3799,12 +3799,12 @@ reset_to_new() { void HTTPChannel:: reset_body_stream() { if (_owns_body_stream) { - if (_body_stream != (ISocketStream *)NULL) { + if (_body_stream != nullptr) { close_read_body(_body_stream); - nassertv(_body_stream == (ISocketStream *)NULL && !_owns_body_stream); + nassertv(_body_stream == nullptr && !_owns_body_stream); } } else { - _body_stream = NULL; + _body_stream = nullptr; } } diff --git a/panda/src/downloader/httpClient.cxx b/panda/src/downloader/httpClient.cxx index 4770d6916d..7183b36ddf 100644 --- a/panda/src/downloader/httpClient.cxx +++ b/panda/src/downloader/httpClient.cxx @@ -216,7 +216,7 @@ HTTPClient() { _http_version = HTTPEnum::HV_11; _verify_ssl = verify_ssl ? VS_normal : VS_no_verify; - _ssl_ctx = (SSL_CTX *)NULL; + _ssl_ctx = nullptr; set_proxy_spec(http_proxy); set_direct_host_spec(http_direct_hosts); @@ -241,8 +241,8 @@ HTTPClient() { _client_certificate_passphrase = http_client_certificate_passphrase; _client_certificate_loaded = false; - _client_certificate_pub = NULL; - _client_certificate_priv = NULL; + _client_certificate_pub = nullptr; + _client_certificate_priv = nullptr; int num_server_certs = http_preapproved_server_certificate_filename.get_num_unique_values(); int si; @@ -271,7 +271,7 @@ HTTPClient() { */ HTTPClient:: HTTPClient(const HTTPClient ©) { - _ssl_ctx = (SSL_CTX *)NULL; + _ssl_ctx = nullptr; (*this) = copy; } @@ -295,12 +295,12 @@ operator = (const HTTPClient ©) { */ HTTPClient:: ~HTTPClient() { - if (_ssl_ctx != (SSL_CTX *)NULL) { + if (_ssl_ctx != nullptr) { #if OPENSSL_VERSION_NUMBER < 0x10100000 // Before we can free the context, we must remove the X509_STORE pointer // from it, so it won't be destroyed along with it (this object is shared // among all contexts). - _ssl_ctx->cert_store = NULL; + _ssl_ctx->cert_store = nullptr; #endif SSL_CTX_free(_ssl_ctx); } @@ -866,7 +866,7 @@ load_client_certificate() { ERR_clear_error(); _client_certificate_priv = - PEM_read_bio_PrivateKey(mbio, NULL, NULL, + PEM_read_bio_PrivateKey(mbio, nullptr, nullptr, (char *)_client_certificate_passphrase.c_str()); // Rewind the "file" to the beginning in order to read the public key @@ -875,7 +875,7 @@ load_client_certificate() { ERR_clear_error(); _client_certificate_pub = - PEM_read_bio_X509(mbio, NULL, NULL, NULL); + PEM_read_bio_X509(mbio, nullptr, nullptr, nullptr); BIO_free(mbio); @@ -891,18 +891,18 @@ load_client_certificate() { } if (downloader_cat.is_on(sev)) { - if (_client_certificate_priv != (EVP_PKEY *)NULL && - _client_certificate_pub != (X509 *)NULL) { + if (_client_certificate_priv != nullptr && + _client_certificate_pub != nullptr) { downloader_cat.out(sev) << "Read client certificate from " << source << "\n"; } else { - if (_client_certificate_priv == (EVP_PKEY *)NULL) { + if (_client_certificate_priv == nullptr) { downloader_cat.out(sev) << "Could not read private key from " << source << "\n"; } - if (_client_certificate_pub == (X509 *)NULL) { + if (_client_certificate_pub == nullptr) { downloader_cat.out(sev) << "Could not read public key from " << source << "\n"; } @@ -911,8 +911,8 @@ load_client_certificate() { } } - return (_client_certificate_priv != (EVP_PKEY *)NULL && - _client_certificate_pub != (X509 *)NULL); + return (_client_certificate_priv != nullptr && + _client_certificate_pub != nullptr); } /** @@ -961,10 +961,10 @@ add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem) { BIO *mbio = BIO_new_mem_buf((void *)pem.data(), pem.length()); ERR_clear_error(); - X509 *cert = PEM_read_bio_X509(mbio, NULL, NULL, NULL); + X509 *cert = PEM_read_bio_X509(mbio, nullptr, nullptr, nullptr); BIO_free(mbio); - if (cert == NULL) { + if (cert == nullptr) { downloader_cat.warning() << "Could not parse PEM data\n"; return false; @@ -1003,7 +1003,7 @@ add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem) { bool HTTPClient:: add_preapproved_server_certificate_name(const URLSpec &url, const string &name) { X509_NAME *cert_name = parse_x509_name(name); - if (cert_name == NULL) { + if (cert_name == nullptr) { downloader_cat.warning() << "Could not parse certificate name " << name << "\n"; return false; @@ -1156,7 +1156,7 @@ get_header(const URLSpec &url) { */ HTTPClient *HTTPClient:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new HTTPClient; } return _global_ptr; @@ -1168,7 +1168,7 @@ get_global_ptr() { */ SSL_CTX *HTTPClient:: get_ssl_ctx() { - if (_ssl_ctx != (SSL_CTX *)NULL) { + if (_ssl_ctx != nullptr) { return _ssl_ctx; } @@ -1190,7 +1190,7 @@ get_ssl_ctx() { X509_STORE *store = sslw->get_x509_store(); #if OPENSSL_VERSION_NUMBER >= 0x10100000 - if (store != NULL) { + if (store != nullptr) { X509_STORE_up_ref(store); } #endif @@ -1419,7 +1419,7 @@ select_auth(const URLSpec &url, bool is_proxy, const string &last_realm) { } // No matching domains. - return NULL; + return nullptr; } /** @@ -1441,14 +1441,14 @@ generate_auth(const URLSpec &url, bool is_proxy, const string &challenge) { auth = new HTTPDigestAuthorization((*si).second, url, is_proxy); } - if (auth == (HTTPAuthorization *)NULL || !auth->is_valid()) { + if (auth == nullptr || !auth->is_valid()) { si = schemes.find("basic"); if (si != schemes.end()) { auth = new HTTPBasicAuthorization((*si).second, url, is_proxy); } } - if (auth == (HTTPAuthorization *)NULL || !auth->is_valid()) { + if (auth == nullptr || !auth->is_valid()) { downloader_cat.warning() << "Don't know how to use any of the server's available authorization schemes:\n"; for (si = schemes.begin(); si != schemes.end(); ++si) { @@ -1475,14 +1475,14 @@ generate_auth(const URLSpec &url, bool is_proxy, const string &challenge) { */ void HTTPClient:: unload_client_certificate() { - if (_client_certificate_priv != (EVP_PKEY *)NULL) { + if (_client_certificate_priv != nullptr) { EVP_PKEY_free(_client_certificate_priv); - _client_certificate_priv = NULL; + _client_certificate_priv = nullptr; } - if (_client_certificate_pub != (X509 *)NULL) { + if (_client_certificate_pub != nullptr) { X509_free(_client_certificate_pub); - _client_certificate_pub = NULL; + _client_certificate_pub = nullptr; } _client_certificate_loaded = false; @@ -1494,7 +1494,7 @@ unload_client_certificate() { */ X509_NAME *HTTPClient:: parse_x509_name(const string &source) { - X509_NAME *result = NULL; + X509_NAME *result = nullptr; result = X509_NAME_new(); bool added_any = false; @@ -1526,7 +1526,7 @@ parse_x509_name(const string &source) { << "Unknown type " << type << " in X509 name: " << source << "\n"; X509_NAME_free(result); - return NULL; + return nullptr; } string value; @@ -1556,7 +1556,7 @@ parse_x509_name(const string &source) { << "Unable to add " << type << "=" << value << " in X509 name: " << source << "\n"; X509_NAME_free(result); - return NULL; + return nullptr; } added_any = true; } @@ -1567,7 +1567,7 @@ parse_x509_name(const string &source) { downloader_cat.info() << "Invalid empty X509 name: " << source << "\n"; X509_NAME_free(result); - return NULL; + return nullptr; } return result; diff --git a/panda/src/downloader/httpDate.I b/panda/src/downloader/httpDate.I index 9b5adbefe4..67aefbccb3 100644 --- a/panda/src/downloader/httpDate.I +++ b/panda/src/downloader/httpDate.I @@ -45,7 +45,7 @@ operator = (const HTTPDate ©) { */ INLINE HTTPDate HTTPDate:: now() { - return HTTPDate(time(NULL)); + return HTTPDate(time(nullptr)); } /** diff --git a/panda/src/downloader/httpDate.cxx b/panda/src/downloader/httpDate.cxx index f3d156fc6a..f8877a65c8 100644 --- a/panda/src/downloader/httpDate.cxx +++ b/panda/src/downloader/httpDate.cxx @@ -182,7 +182,7 @@ HTTPDate(const string &format) { if (t.tm_year < 100) { // Two-digit year. Assume it's in the same century, unless that // assumption puts it more than 50 years in the future. - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *tp = gmtime(&now); t.tm_year += 100 * (tp->tm_year / 100); if (t.tm_year - tp->tm_year > 50) { @@ -219,7 +219,7 @@ HTTPDate(const string &format) { if (_time != (time_t)-1) { // Unfortunately, mktime() assumes local time; convert this back to GMT. #if defined(IS_FREEBSD) - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *tp = localtime(&now); _time -= tp->tm_gmtoff; #elif defined(_WIN32) diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index e8cddbb18b..8bb2804bcf 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -86,7 +86,7 @@ HTTPDigestAuthorization(const HTTPAuthorization::Tokens &tokens, // Compute an arbitrary client nonce. ostringstream strm; - strm << time(NULL) << ":" << clock() << ":" + strm << time(nullptr) << ":" << clock() << ":" << url.get_url() << ":Panda"; _cnonce = calc_md5(strm.str()); diff --git a/panda/src/downloader/identityStream.cxx b/panda/src/downloader/identityStream.cxx index f047ac1a6e..335cb9fd23 100644 --- a/panda/src/downloader/identityStream.cxx +++ b/panda/src/downloader/identityStream.cxx @@ -22,9 +22,9 @@ */ IIdentityStream:: ~IIdentityStream() { - if (_channel != (HTTPChannel *)NULL) { + if (_channel != nullptr) { _channel->body_stream_destructs(this); - _channel = NULL; + _channel = nullptr; } } diff --git a/panda/src/downloader/identityStreamBuf.I b/panda/src/downloader/identityStreamBuf.I index 6001a14fc0..b879886dd1 100644 --- a/panda/src/downloader/identityStreamBuf.I +++ b/panda/src/downloader/identityStreamBuf.I @@ -16,7 +16,7 @@ */ INLINE bool IdentityStreamBuf:: is_closed() const { - return (_source == (BioStreamPtr *)NULL || (*_source)->is_closed()); + return (_source == nullptr || (*_source)->is_closed()); } /** diff --git a/panda/src/downloader/identityStreamBuf.cxx b/panda/src/downloader/identityStreamBuf.cxx index a11f1cfda3..4d98540423 100644 --- a/panda/src/downloader/identityStreamBuf.cxx +++ b/panda/src/downloader/identityStreamBuf.cxx @@ -17,11 +17,6 @@ #ifdef HAVE_OPENSSL #include "httpChannel.h" -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - /** * */ diff --git a/panda/src/downloader/multiplexStream.I b/panda/src/downloader/multiplexStream.I index 1da8528d0b..2a99a110d3 100644 --- a/panda/src/downloader/multiplexStream.I +++ b/panda/src/downloader/multiplexStream.I @@ -27,7 +27,7 @@ INLINE void MultiplexStream:: add_ostream(ostream *out, bool delete_later) { _msb.add_output(MultiplexStreamBuf::BT_none, MultiplexStreamBuf::OT_ostream, - out, NULL, delete_later); + out, nullptr, delete_later); } /** @@ -38,7 +38,7 @@ INLINE bool MultiplexStream:: add_stdio_file(FILE *fout, bool close_when_done) { _msb.add_output(MultiplexStreamBuf::BT_line, MultiplexStreamBuf::OT_ostream, - NULL, fout, close_when_done); + nullptr, fout, close_when_done); return true; } @@ -49,7 +49,7 @@ INLINE void MultiplexStream:: add_standard_output() { _msb.add_output(MultiplexStreamBuf::BT_none, MultiplexStreamBuf::OT_ostream, - &cout, NULL, false); + &cout, nullptr, false); } /** @@ -68,7 +68,7 @@ add_file(Filename file) { _msb.add_output(MultiplexStreamBuf::BT_line, MultiplexStreamBuf::OT_ostream, - out, NULL, true); + out, nullptr, true); return true; } diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 783558f587..3b6b0a8b10 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -24,11 +24,6 @@ // recursion. #include -#ifndef HAVE_STREAMSIZE -// Some compilers--notably SGI--don't define this for us. -typedef int streamsize; -#endif - /** * Closes or deletes the relevant pointers, if _owns_obj is true. */ @@ -37,12 +32,12 @@ close() { if (_owns_obj) { switch (_output_type) { case OT_ostream: - assert(_out != (ostream *)NULL); + assert(_out != nullptr); delete _out; break; case OT_stdio: - assert(_fout != (FILE *)NULL); + assert(_fout != nullptr); fclose(_fout); break; @@ -59,13 +54,13 @@ void MultiplexStreamBuf::Output:: write_string(const string &str) { switch (_output_type) { case OT_ostream: - assert(_out != (ostream *)NULL); + assert(_out != nullptr); _out->write(str.data(), str.length()); _out->flush(); break; case OT_stdio: - assert(_fout != (FILE *)NULL); + assert(_fout != nullptr); fwrite(str.data(), str.length(), 1, _fout); fflush(_fout); break; diff --git a/panda/src/downloader/multiplexStreamBuf.h b/panda/src/downloader/multiplexStreamBuf.h index d869124116..0e440f6ab1 100644 --- a/panda/src/downloader/multiplexStreamBuf.h +++ b/panda/src/downloader/multiplexStreamBuf.h @@ -41,8 +41,8 @@ public: }; void add_output(BufferType buffer_type, OutputType output_type, - ostream *out = (ostream *)NULL, - FILE *fout = (FILE *)NULL, + ostream *out = nullptr, + FILE *fout = nullptr, bool owns_obj = false); void flush(); diff --git a/panda/src/downloader/patcher.cxx b/panda/src/downloader/patcher.cxx index 70d0f99ef2..c0b86f2c61 100644 --- a/panda/src/downloader/patcher.cxx +++ b/panda/src/downloader/patcher.cxx @@ -44,7 +44,7 @@ init(PT(Buffer) buffer) { nassertv(!buffer.is_null()); _buffer = buffer; - _patchfile = NULL; + _patchfile = nullptr; _patchfile = new Patchfile(_buffer); } diff --git a/panda/src/downloader/socketStream.I b/panda/src/downloader/socketStream.I index 21026ebdb4..8ac4914567 100644 --- a/panda/src/downloader/socketStream.I +++ b/panda/src/downloader/socketStream.I @@ -162,7 +162,7 @@ flush() { */ INLINE ISocketStream:: ISocketStream(streambuf *buf) : istream(buf), SSReader(this) { - _channel = NULL; + _channel = nullptr; } /** diff --git a/panda/src/downloader/socketStream.cxx b/panda/src/downloader/socketStream.cxx index 4e441f8f2b..4d52a82cb5 100644 --- a/panda/src/downloader/socketStream.cxx +++ b/panda/src/downloader/socketStream.cxx @@ -248,7 +248,7 @@ send_datagram(const Datagram &dg) { ISocketStream:: ~ISocketStream() { // This should already have been cleared by the subclass destructor. - nassertv(_channel == NULL); + nassertv(_channel == nullptr); } #endif // HAVE_OPENSSL diff --git a/panda/src/downloader/stringStream_ext.cxx b/panda/src/downloader/stringStream_ext.cxx index c9d66ca0a7..631c6f4a04 100644 --- a/panda/src/downloader/stringStream_ext.cxx +++ b/panda/src/downloader/stringStream_ext.cxx @@ -51,7 +51,7 @@ void Extension:: set_data(PyObject *data) { _this->_buf.clear(); - if (data == NULL) { + if (data == nullptr) { return; } diff --git a/panda/src/downloader/virtualFileHTTP.cxx b/panda/src/downloader/virtualFileHTTP.cxx index 03bfaa1737..27f33c644a 100644 --- a/panda/src/downloader/virtualFileHTTP.cxx +++ b/panda/src/downloader/virtualFileHTTP.cxx @@ -121,7 +121,7 @@ is_regular_file() const { istream *VirtualFileHTTP:: open_read_file(bool auto_unwrap) const { if (_status_only) { - return NULL; + return nullptr; } // We pre-download the file into a StringStream, then return a buffer to @@ -130,7 +130,7 @@ open_read_file(bool auto_unwrap) const { StringStream *strstream = new StringStream; if (!fetch_file(strstream)) { delete strstream; - return NULL; + return nullptr; } return return_file(strstream, auto_unwrap); @@ -178,7 +178,7 @@ return_file(istream *buffer_stream, bool auto_unwrap) const { istream *result = buffer_stream; #ifdef HAVE_ZLIB - if (result != (istream *)NULL && do_unwrap) { + if (result != nullptr && do_unwrap) { // We have to slip in a layer to decompress the file on the fly. IDecompressStream *wrapper = new IDecompressStream(result, true); result = wrapper; diff --git a/panda/src/downloader/virtualFileMountHTTP.cxx b/panda/src/downloader/virtualFileMountHTTP.cxx index 9ad783da87..c9cc4759a0 100644 --- a/panda/src/downloader/virtualFileMountHTTP.cxx +++ b/panda/src/downloader/virtualFileMountHTTP.cxx @@ -176,7 +176,7 @@ make_virtual_file(const Filename &local_filename, */ istream *VirtualFileMountHTTP:: open_read_file(const Filename &) const { - return NULL; + return nullptr; } /** diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index 8f3df9ce14..3b58ca0d23 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -245,7 +245,7 @@ const string & get_password() { if (!got_password) { cerr << "Enter password: "; - getline(cin, password); + std::getline(std::cin, password); got_password = true; } @@ -610,7 +610,7 @@ format_timestamp(bool record_timestamp, time_t timestamp) { return " (no date) "; } - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *tm_p = localtime(×tamp); if (timestamp > now || (now - timestamp > 86400 * 365)) { @@ -635,7 +635,7 @@ list_files(const vector_string ¶ms) { // So this is the only place where we accept a .pz/.gz compressed .mf. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *istr = vfs->open_read_file(multifile_name, true); - if (istr == NULL) { + if (istr == nullptr) { cerr << "Unable to open " << multifile_name << " for reading.\n"; return false; } @@ -650,7 +650,7 @@ list_files(const vector_string ¶ms) { int i; if (verbose) { - cout << num_subfiles << " subfiles:\n" << flush; + cout << num_subfiles << " subfiles:\n" << std::flush; for (i = 0; i < num_subfiles; i++) { string subfile_name = multifile->get_subfile_name(i); if (is_named(subfile_name, params)) { diff --git a/panda/src/downloadertools/pdecrypt.cxx b/panda/src/downloadertools/pdecrypt.cxx index 73a242fda1..9ce3445bf0 100644 --- a/panda/src/downloadertools/pdecrypt.cxx +++ b/panda/src/downloadertools/pdecrypt.cxx @@ -122,7 +122,7 @@ main(int argc, char **argv) { // Prompt for password. if (!got_password) { cerr << "Enter password: "; - getline(cin, password); + std::getline(std::cin, password); got_password = true; } diff --git a/panda/src/downloadertools/pencrypt.cxx b/panda/src/downloadertools/pencrypt.cxx index 5f8774c4d9..3d61651348 100644 --- a/panda/src/downloadertools/pencrypt.cxx +++ b/panda/src/downloadertools/pencrypt.cxx @@ -181,7 +181,7 @@ main(int argc, char **argv) { // Prompt for password. if (!got_password) { cerr << "Enter password: "; - getline(cin, password); + std::getline(std::cin, password); got_password = true; } diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index 223e6478cb..596802b871 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -20,9 +20,9 @@ DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : _texture(DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_slot()))), _tex_gen(DCAST(TexGenAttrib, state->get_attrib(TexGenAttrib::get_class_slot()))) { - _filtered_texture = (TextureAttrib *)NULL; + _filtered_texture = nullptr; _reffed_filtered_texture = false; - if (_texture != (TextureAttrib *)NULL) { + if (_texture != nullptr) { _filtered_texture = _texture->filter_to_max(gsg->get_max_texture_stages()); if (_filtered_texture != _texture) { _filtered_texture->ref(); diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index e9b9ba498e..cce0f2e6f0 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -16,7 +16,7 @@ #include "geomVertexWriter.h" #include "config_dxgsg9.h" -GeomMunger *DXGeomMunger9::_deleted_chain = NULL; +GeomMunger *DXGeomMunger9::_deleted_chain = nullptr; TypeHandle DXGeomMunger9::_type_handle; /** @@ -72,7 +72,7 @@ munge_format_impl(const GeomVertexFormat *orig, const GeomVertexColumn *normal_type = orig->get_normal_column(); const GeomVertexColumn *color_type = orig->get_color_column(); - if (vertex_type != (const GeomVertexColumn *)NULL) { + if (vertex_type != nullptr) { new_array_format->add_column (InternalName::get_vertex(), 3, NT_float32, vertex_type->get_contents()); @@ -109,13 +109,13 @@ munge_format_impl(const GeomVertexFormat *orig, new_format->remove_column(InternalName::get_transform_blend()); } - if (normal_type != (const GeomVertexColumn *)NULL) { + if (normal_type != nullptr) { new_array_format->add_column (InternalName::get_normal(), 3, NT_float32, C_normal); new_format->remove_column(normal_type->get_name()); } - if (color_type != (const GeomVertexColumn *)NULL) { + if (color_type != nullptr) { new_array_format->add_column (InternalName::get_color(), 1, NT_packed_dabc, C_color); new_format->remove_column(color_type->get_name()); @@ -127,7 +127,7 @@ munge_format_impl(const GeomVertexFormat *orig, // Now set up each of the active texture coordinate stages--or at least // those for which we're not generating texture coordinates automatically. - if (_filtered_texture != (TextureAttrib *)NULL) { + if (_filtered_texture != nullptr) { int num_stages = _filtered_texture->get_num_on_ff_stages(); vector_int ff_tc_index(num_stages, 0); @@ -153,7 +153,7 @@ munge_format_impl(const GeomVertexFormat *orig, const GeomVertexColumn *texcoord_type = orig->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); } else { @@ -201,7 +201,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { const GeomVertexColumn *normal_type = orig->get_normal_column(); const GeomVertexColumn *color_type = orig->get_color_column(); - if (vertex_type != (const GeomVertexColumn *)NULL) { + if (vertex_type != nullptr) { new_array_format->add_column (InternalName::get_vertex(), 3, NT_float32, vertex_type->get_contents()); @@ -212,13 +212,13 @@ premunge_format_impl(const GeomVertexFormat *orig) { return orig; } - if (normal_type != (const GeomVertexColumn *)NULL) { + if (normal_type != nullptr) { new_array_format->add_column (InternalName::get_normal(), 3, NT_float32, C_normal); new_format->remove_column(normal_type->get_name()); } - if (color_type != (const GeomVertexColumn *)NULL) { + if (color_type != nullptr) { new_array_format->add_column (InternalName::get_color(), 1, NT_packed_dabc, C_color); new_format->remove_column(color_type->get_name()); @@ -230,7 +230,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { // Now set up each of the active texture coordinate stages--or at least // those for which we're not generating texture coordinates automatically. - if (_filtered_texture != (TextureAttrib *)NULL) { + if (_filtered_texture != nullptr) { int num_stages = _filtered_texture->get_num_on_ff_stages(); vector_int ff_tc_index(num_stages, 0); @@ -256,7 +256,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { const GeomVertexColumn *texcoord_type = orig->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); } else { diff --git a/panda/src/dxgsg9/dxGraphicsDevice9.cxx b/panda/src/dxgsg9/dxGraphicsDevice9.cxx index 6e79bb3c98..3b7f0abd82 100644 --- a/panda/src/dxgsg9/dxGraphicsDevice9.cxx +++ b/panda/src/dxgsg9/dxGraphicsDevice9.cxx @@ -23,8 +23,8 @@ DXGraphicsDevice9(wdxGraphicsPipe9 *pipe) : GraphicsDevice(pipe) { ZeroMemory(&_Scrn,sizeof(_Scrn)); - _d3d_device = NULL; - _swap_chain = NULL; + _d3d_device = nullptr; + _swap_chain = nullptr; } /** diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I index 94e50a5f7d..51846fd33c 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I @@ -121,7 +121,7 @@ get_tex_mat_sym(int stage_index) { */ INLINE unsigned char *DXGraphicsStateGuardian9:: get_safe_buffer_start() { - if (_temp_buffer == NULL) { + if (_temp_buffer == nullptr) { // Guarantee we get a buffer of size 0x10000 bytes that begins on an even // multiple of 0x10000. We do this by allocating double the required // buffer, and then pointing to the first multiple of 0x10000 within that diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 8326068dc1..389baa4dca 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -81,11 +81,11 @@ TypeHandle DXGraphicsStateGuardian9::_type_handle; D3DMATRIX DXGraphicsStateGuardian9::_d3d_ident_mat; -unsigned char *DXGraphicsStateGuardian9::_temp_buffer = NULL; -unsigned char *DXGraphicsStateGuardian9::_safe_buffer_start = NULL; +unsigned char *DXGraphicsStateGuardian9::_temp_buffer = nullptr; +unsigned char *DXGraphicsStateGuardian9::_safe_buffer_start = nullptr; #ifdef HAVE_CG -LPDIRECT3DDEVICE9 DXGraphicsStateGuardian9::_cg_device = NULL; +LPDIRECT3DDEVICE9 DXGraphicsStateGuardian9::_cg_device = nullptr; #endif #define __D3DLIGHT_RANGE_MAX ((PN_stdfloat)sqrt(FLT_MAX)) //for some reason this is missing in dx9 hdrs @@ -108,8 +108,8 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : // tells us otherwise. _is_hardware = true; - _screen = NULL; - _d3d_device = NULL; + _screen = nullptr; + _d3d_device = nullptr; _dx_is_ready = false; _vertex_blending_enabled = false; @@ -117,7 +117,7 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : _tex_stats_retrieval_impossible = false; _supports_render_texture = false; - _active_ibuffer = NULL; + _active_ibuffer = nullptr; // This is a static member, but we initialize it here in the constructor // anyway. It won't hurt if it gets repeatedly initalized. @@ -168,7 +168,7 @@ DXGraphicsStateGuardian9:: } if (IS_VALID_PTR(_d3d_device)) { - _d3d_device->SetTexture(0, NULL); // this frees reference to the old texture + _d3d_device->SetTexture(0, nullptr); // this frees reference to the old texture } free_nondx_resources(); @@ -190,7 +190,7 @@ prepare_texture(Texture *tex, int view) { if (!get_supports_compressed_texture_format(tex->get_ram_image_compression())) { dxgsg9_cat.error() << *dtc->get_texture() << " is stored in an unsupported compressed format.\n"; - return NULL; + return nullptr; } return dtc; @@ -202,7 +202,7 @@ prepare_texture(Texture *tex, int view) { */ void DXGraphicsStateGuardian9:: apply_texture(int i, TextureContext *tc, const SamplerState &sampler) { - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // The texture wasn't bound properly or something, so ensure texturing is // disabled and just return. set_texture_stage_state(i, D3DTSS_COLOROP, D3DTOP_DISABLE); @@ -387,7 +387,7 @@ extract_texture_data(Texture *tex) { int num_views = tex->get_num_views(); for (int view = 0; view < num_views; ++view) { TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc); if (!dtc->extract_texture_data(*_screen)) { @@ -409,7 +409,7 @@ prepare_shader(Shader *se) { case Shader::SL_GLSL: dxgsg9_cat.error() << "Tried to load GLSL shader, but GLSL shaders not supported by Direct3D 9.\n"; - return NULL; + return nullptr; case Shader::SL_Cg: #ifdef HAVE_CG @@ -418,21 +418,21 @@ prepare_shader(Shader *se) { } else { dxgsg9_cat.error() << "Tried to load Cg shader, but basic shaders not supported.\n"; - return NULL; + return nullptr; } #else dxgsg9_cat.error() << "Tried to load Cg shader, but Cg support not compiled in.\n"; - return NULL; + return nullptr; #endif default: dxgsg9_cat.error() << "Tried to load shader with unsupported shader language!\n"; - return NULL; + return nullptr; } - return NULL; + return nullptr; } /** @@ -476,7 +476,7 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { int attempts = 0; do { - hr = _screen->_d3d_device->CreateVertexBuffer(num_bytes, usage, dvbc->_fvf, pool, &dvbc->_vbuffer, NULL); + hr = _screen->_d3d_device->CreateVertexBuffer(num_bytes, usage, dvbc->_fvf, pool, &dvbc->_vbuffer, nullptr); attempts++; } while (check_dx_allocation(hr, num_bytes, attempts)); @@ -496,10 +496,10 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { dxgsg9_cat.error() << "CreateVertexBuffer failed" << D3DERRORSTRING(hr); - dvbc->_vbuffer = NULL; + dvbc->_vbuffer = nullptr; } - return NULL; + return nullptr; } /** @@ -524,7 +524,7 @@ apply_vertex_buffer(VertexBufferContext *vbc, if ( num_bytes != 0 ) { const unsigned char *client_pointer = reader->get_read_pointer(force); - if (client_pointer == NULL) { + if (client_pointer == nullptr) { return false; } @@ -582,7 +582,7 @@ release_vertex_buffer(VertexBufferContext *vbc) { #endif dvbc->_vbuffer->Release(); - dvbc->_vbuffer = NULL; + dvbc->_vbuffer = nullptr; delete dvbc; } @@ -607,7 +607,7 @@ setup_array_data(DXVertexBufferContext9*& dvbc, // Prepare the buffer object and bind it. VertexBufferContext* vbc = ((GeomVertexArrayData *)array_reader->get_object())->prepare_now(get_prepared_objects(), this); - nassertr(vbc != (VertexBufferContext *)NULL, false); + nassertr(vbc != nullptr, false); if (!apply_vertex_buffer(vbc, array_reader, force)) { return false; } @@ -640,11 +640,11 @@ apply_index_buffer(IndexBufferContext *ibc, const GeomPrimitivePipelineReader *reader, bool force) { DXIndexBufferContext9 *dibc = DCAST(DXIndexBufferContext9, ibc); - if (dibc->_ibuffer == NULL) { + if (dibc->_ibuffer == nullptr) { // Attempt to create a new index buffer. dibc->create_ibuffer(*_screen, reader); - if (dibc->_ibuffer != NULL) { + if (dibc->_ibuffer != nullptr) { if (!dibc->upload_data(reader, force)) { return false; } @@ -655,8 +655,8 @@ apply_index_buffer(IndexBufferContext *ibc, dibc->set_active(true); } else { - _d3d_device->SetIndices(NULL); - _active_ibuffer = NULL; + _d3d_device->SetIndices(nullptr); + _active_ibuffer = nullptr; } } else { @@ -671,7 +671,7 @@ apply_index_buffer(IndexBufferContext *ibc, } dibc->mark_loaded(reader); - _active_ibuffer = NULL; + _active_ibuffer = nullptr; } if (_active_ibuffer != dibc) { @@ -710,7 +710,7 @@ release_index_buffer(IndexBufferContext *ibc) { void DXGraphicsStateGuardian9:: begin_occlusion_query() { nassertv(_supports_occlusion_query); - nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL); + nassertv(_current_occlusion_query == nullptr); IDirect3DQuery9 *query; HRESULT hr = _d3d_device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &query); @@ -739,8 +739,8 @@ begin_occlusion_query() { */ PT(OcclusionQueryContext) DXGraphicsStateGuardian9:: end_occlusion_query() { - if (_current_occlusion_query == (OcclusionQueryContext *)NULL) { - return NULL; + if (_current_occlusion_query == nullptr) { + return nullptr; } PT(OcclusionQueryContext) result = _current_occlusion_query; @@ -752,7 +752,7 @@ end_occlusion_query() { << "ending occlusion query " << query << "\n"; } - _current_occlusion_query = NULL; + _current_occlusion_query = nullptr; query->Issue(D3DISSUE_END); return result; @@ -808,19 +808,19 @@ clear(DrawableRegion *clearable) { } if ((main_flags | aux_flags) != 0) { - HRESULT hr = _d3d_device->Clear(0, NULL, main_flags | aux_flags, color_clear_value, + HRESULT hr = _d3d_device->Clear(0, nullptr, main_flags | aux_flags, color_clear_value, depth_clear_value, stencil_clear_value); if (FAILED(hr) && main_flags == D3DCLEAR_TARGET && aux_flags != 0) { // Maybe there's a problem with the one or more of the auxiliary // buffers. - hr = _d3d_device->Clear(0, NULL, D3DCLEAR_TARGET, color_clear_value, + hr = _d3d_device->Clear(0, nullptr, D3DCLEAR_TARGET, color_clear_value, depth_clear_value, stencil_clear_value); if (!FAILED(hr)) { // Yep, it worked without them. That's a problem. Which buffer poses // the problem? if (clearable->get_clear_depth_active()) { aux_flags |= D3DCLEAR_ZBUFFER; - HRESULT hr2 = _d3d_device->Clear(0, NULL, D3DCLEAR_ZBUFFER, color_clear_value, + HRESULT hr2 = _d3d_device->Clear(0, nullptr, D3DCLEAR_ZBUFFER, color_clear_value, depth_clear_value, stencil_clear_value); if (FAILED(hr2)) { dxgsg9_cat.error() @@ -831,7 +831,7 @@ clear(DrawableRegion *clearable) { } if (clearable->get_clear_stencil_active()) { aux_flags |= D3DCLEAR_STENCIL; - HRESULT hr2 = _d3d_device->Clear(0, NULL, D3DCLEAR_STENCIL, color_clear_value, + HRESULT hr2 = _d3d_device->Clear(0, nullptr, D3DCLEAR_STENCIL, color_clear_value, stencil_clear_value, stencil_clear_value); if (FAILED(hr2)) { dxgsg9_cat.error() @@ -856,7 +856,7 @@ clear(DrawableRegion *clearable) { */ void DXGraphicsStateGuardian9:: prepare_display_region(DisplayRegionPipelineReader *dr) { - nassertv(dr != (DisplayRegionPipelineReader *)NULL); + nassertv(dr != nullptr); GraphicsStateGuardian::prepare_display_region(dr); int l, u, w, h; @@ -903,12 +903,12 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { */ CPT(TransformState) DXGraphicsStateGuardian9:: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } // DirectX also uses a Z range of 0 to 1, whereas the Panda convention is @@ -964,7 +964,7 @@ begin_frame(Thread *current_thread) { GraphicsStateGuardian::begin_frame(current_thread); - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { dxgsg9_cat.debug() << this << "::begin_frame(): no device.\n"; return false; @@ -1052,18 +1052,18 @@ end_scene() { if (_vertex_array_shader_context != 0) { _vertex_array_shader_context->disable_shader_vertex_arrays(this); - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (DXShaderContext9 *)NULL; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; } if (_texture_binding_shader_context != 0) { _texture_binding_shader_context->disable_shader_texture_bindings(this); - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (DXShaderContext9 *)NULL; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; } if (_current_shader_context != 0) { _current_shader_context->unbind(this); - _current_shader = (Shader *)NULL; - _current_shader_context = (DXShaderContext9 *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; } _dlights.clear(); @@ -1146,7 +1146,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, force)) { return false; } - nassertr(_data_reader != (GeomVertexDataPipelineReader *)NULL, false); + nassertr(_data_reader != nullptr, false); const GeomVertexFormat *format = _data_reader->get_format(); @@ -1182,7 +1182,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } const TransformTable *table = data_reader->get_transform_table(); - if (table != (TransformTable *)NULL) { + if (table != nullptr) { for (size_t i = 0; i < table->get_num_transforms(); ++i) { LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); @@ -1242,7 +1242,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Cg shader. if (_vertex_array_shader_context == 0) { disable_standard_vertex_arrays(); - if (!_current_shader_context->update_shader_vertex_arrays(NULL, this, force)) { + if (!_current_shader_context->update_shader_vertex_arrays(nullptr, this, force)) { return false; } } else { @@ -1274,7 +1274,7 @@ update_standard_vertex_arrays(bool force) { int number_of_arrays = _data_reader->get_num_arrays(); for ( int array_index = 0; array_index < number_of_arrays; ++array_index ) { const GeomVertexArrayDataHandle* array_reader = _data_reader->get_array_reader( array_index ); - if ( array_reader == NULL ) { + if ( array_reader == nullptr ) { dxgsg9_cat.error() << "Unable to get reader for array " << array_index << "\n"; return false; } @@ -1317,7 +1317,7 @@ void DXGraphicsStateGuardian9:: disable_standard_vertex_arrays() { for ( int array_index = 0; array_index < _num_bound_streams; ++array_index ) { - _d3d_device->SetStreamSource( array_index, NULL, 0, 0 ); + _d3d_device->SetStreamSource( array_index, nullptr, 0, 0 ); } _num_bound_streams = 0; } @@ -1338,7 +1338,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1351,12 +1351,12 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays. const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1375,7 +1375,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1408,7 +1408,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers, one long triangle strip. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1421,12 +1421,12 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays, one long triangle strip. const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1446,7 +1446,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays, one long triangle strip. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } draw_primitive_up(D3DPT_TRIANGLESTRIP, @@ -1475,7 +1475,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers, individual triangle strips. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1496,12 +1496,12 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, client arrays, individual triangle strips. int stride = _data_reader->get_format()->get_array(0)->get_stride(); const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1536,7 +1536,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays, individual triangle strips. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } int stride = _data_reader->get_format()->get_array(0)->get_stride(); @@ -1582,7 +1582,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1603,12 +1603,12 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, client arrays. int stride = _data_reader->get_format()->get_array(0)->get_stride(); const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1643,7 +1643,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } int stride = _data_reader->get_format()->get_array(0)->get_stride(); @@ -1679,7 +1679,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1692,12 +1692,12 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays. const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1717,7 +1717,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } draw_primitive_up(D3DPT_LINELIST, reader->get_num_primitives(), @@ -1759,7 +1759,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } draw_primitive_up(D3DPT_POINTLIST, reader->get_num_primitives(), @@ -1817,7 +1817,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, tex->set_render_to_texture(true); TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { return false; } DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc); @@ -1833,7 +1833,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, // for now. return do_framebuffer_copy_to_ram(tex, view, z, dr, rb, true); } - nassertr(dtc->get_d3d_2d_texture() != NULL, false); + nassertr(dtc->get_d3d_2d_texture() != nullptr, false); IDirect3DSurface9 *tex_level_0; hr = dtc->get_d3d_2d_texture()->GetSurfaceLevel(0, &tex_level_0); @@ -1967,7 +1967,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, set_read_buffer(rb); RECT rect; - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); int xo, yo, w, h; dr->get_region_pixels_i(xo, yo, w, h); @@ -2007,7 +2007,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, rect.bottom = yo + h; bool copy_inverted = false; - IDirect3DSurface9 *temp_surface = NULL; + IDirect3DSurface9 *temp_surface = nullptr; HRESULT hr; // Note if you try to grab the backbuffer and full-screen anti-aliasing is @@ -2015,7 +2015,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, // it's safer to get the front buffer. if (_cur_read_pixel_buffer & RenderBuffer::T_back) { DWORD render_target_index; - IDirect3DSurface9 *backbuffer = NULL; + IDirect3DSurface9 *backbuffer = nullptr; // GetRenderTarget() seems to be a little more reliable than // GetBackBuffer(). Might just be related to the swap_chain thing. @@ -2041,7 +2041,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, surface_description.Format, pool, &temp_surface, - NULL); + nullptr); if (FAILED(hr)) { dxgsg9_cat.error() << "CreateImageSurface failed in copy_pixel_buffer()" @@ -2085,7 +2085,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, // For GetFrontBuffer(), we need a temporary surface of type A8R8G8B8. // Unlike GetBackBuffer(), GetFrontBuffer() implicitly performs a copy. - hr = _d3d_device->CreateOffscreenPlainSurface(w, h, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &temp_surface, NULL); + hr = _d3d_device->CreateOffscreenPlainSurface(w, h, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &temp_surface, nullptr); if (FAILED(hr)) { dxgsg9_cat.error() << "CreateImageSurface failed in copy_pixel_buffer()" @@ -2219,9 +2219,9 @@ reset() { // TransformState::make_identity()); want gsg to pass all state settings // down so any non-matching defaults we set here get overwritten - nassertv(_screen->_d3d9 != NULL); + nassertv(_screen->_d3d9 != nullptr); - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return; } @@ -2301,10 +2301,10 @@ reset() { const char *pixel_profile_str = cgGetProfileString(pixel_profile); - if (vertex_profile_str == NULL) { + if (vertex_profile_str == nullptr) { vertex_profile_str = "(null)"; } - if (pixel_profile_str == NULL) { + if (pixel_profile_str == nullptr) { pixel_profile_str = "(null)"; } @@ -2360,7 +2360,7 @@ reset() { _supports_gamma_calibration = ((d3d_caps.Caps2 & D3DCAPS2_CANCALIBRATEGAMMA) != 0); // Test for occlusion query support - hr = _d3d_device->CreateQuery(D3DQUERYTYPE_OCCLUSION, NULL); + hr = _d3d_device->CreateQuery(D3DQUERYTYPE_OCCLUSION, nullptr); _supports_occlusion_query = !FAILED(hr); if (dxgsg9_cat.is_error()) { @@ -2669,12 +2669,12 @@ reset() { // GF2Radeon8500, no on TNT) set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD); - _current_shader = (Shader *)NULL; - _current_shader_context = (DXShaderContext9 *)NULL; - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (DXShaderContext9 *)NULL; - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (DXShaderContext9 *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; PRINT_REFCNT(dxgsg9, _d3d_device); @@ -2991,7 +2991,7 @@ do_issue_fog() { if (!target_fog->is_off()) { set_render_state(D3DRS_FOGENABLE, TRUE); Fog *fog = target_fog->get_fog(); - nassertv(fog != (Fog *)NULL); + nassertv(fog != nullptr); apply_fog(fog); } else { set_render_state(D3DRS_FOGENABLE, FALSE); @@ -3364,7 +3364,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { void DXGraphicsStateGuardian9:: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { Lens *lens = light_obj->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); // Get the light in "world coordinates" (actually, view coordinates). This // means the light in the coordinate space of the camera, converted to DX's @@ -3513,7 +3513,7 @@ do_issue_texture() { update_standard_texture_bindings(); } else { disable_standard_texture_bindings(); - _current_shader_context->update_shader_texture_bindings(NULL,this); + _current_shader_context->update_shader_texture_bindings(nullptr,this); } } else { if (_current_shader_context==0) { @@ -3537,7 +3537,7 @@ disable_standard_texture_bindings() { for (int i = 0; i < _num_active_texture_stages; i++) { HRESULT hr; - hr = _d3d_device -> SetTexture (i, NULL); + hr = _d3d_device -> SetTexture (i, nullptr); if (FAILED (hr)) { dxgsg9_cat.error() << "SetTexture (" @@ -3560,7 +3560,7 @@ update_standard_texture_bindings() { int num_stages = _target_texture->get_num_on_ff_stages(); int num_old_stages = _max_texture_stages; - if (_state_texture != (TextureAttrib *)NULL) { + if (_state_texture != nullptr) { num_old_stages = _state_texture->get_num_on_ff_stages(); } @@ -3579,7 +3579,7 @@ update_standard_texture_bindings() { int texcoord_index = _target_texture->get_ff_tc_index(si); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); const SamplerState &sampler = _target_texture->get_on_sampler(stage); // We always reissue every stage in DX, just in case the texcoord index or @@ -3754,7 +3754,7 @@ update_standard_texture_bindings() { // Disable the texture stages that are no longer used. for (si = num_stages; si < _num_active_texture_stages; si++) { set_texture_stage_state(si, D3DTSS_COLOROP, D3DTOP_DISABLE); - _d3d_device->SetTexture(si, NULL); + _d3d_device->SetTexture(si, nullptr); } // Save the count of texture stages for next time. @@ -4007,16 +4007,16 @@ free_d3d_device() { _dx_is_ready = false; - if (_d3d_device != NULL) { + if (_d3d_device != nullptr) { for(int i = 0; i < D3D_MAXTEXTURESTAGES; i++) { // d3d should release this stuff internally anyway, but whatever - _d3d_device->SetTexture(i, NULL); + _d3d_device->SetTexture(i, nullptr); } } release_all(); - if (_d3d_device != NULL) { + if (_d3d_device != nullptr) { RELEASE(_d3d_device, dxgsg9, "d3dDevice", RELEASE_DOWN_TO_ZERO); } @@ -4252,7 +4252,7 @@ report_texmgr_stats() { */ void DXGraphicsStateGuardian9:: set_context(DXScreenData *new_context) { - nassertv(new_context != NULL); + nassertv(new_context != nullptr); _screen = new_context; _d3d_device = _screen->_d3d_device; //copy this one field for speed of deref _swap_chain = _screen->_swap_chain; //copy this one field for speed of deref @@ -4266,11 +4266,11 @@ set_context(DXScreenData *new_context) { */ void DXGraphicsStateGuardian9:: set_render_target() { - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return; } - LPDIRECT3DSURFACE9 back = NULL, stencil = NULL; + LPDIRECT3DSURFACE9 back = nullptr, stencil = nullptr; UINT swap_chain; @@ -4479,7 +4479,7 @@ dx_cleanup() { // Do a safe check for releasing the D3DDEVICE. RefCount should be zero. if // we're called from exit(), _d3d_device may already have been released RELEASE(_d3d_device, dxgsg9, "d3dDevice", RELEASE_DOWN_TO_ZERO); - _screen->_d3d_device = NULL; + _screen->_d3d_device = nullptr; // Releasing pD3D is now the responsibility of the GraphicsPipe destructor } @@ -4574,7 +4574,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, get_engine()->reset_all_windows(true);// reset with new swapchains by creating if (screen) { - *screen = NULL; + *screen = nullptr; } if (presentation_params != &_screen->_presentation_params) { @@ -4589,7 +4589,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, _screen->_swap_chain->Release(); wdxdisplay9_cat.debug() << "swap chain " << _screen->_swap_chain << " is released\n"; - _screen->_swap_chain = NULL; + _screen->_swap_chain = nullptr; hr = _d3d_device->CreateAdditionalSwapChain(presentation_params, &_screen->_swap_chain); } if (SUCCEEDED(hr)) { @@ -4609,7 +4609,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, bool DXGraphicsStateGuardian9:: check_cooperative_level() { bool bDoReactivateWindow = false; - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return false; } @@ -4669,7 +4669,7 @@ check_cooperative_level() { */ void DXGraphicsStateGuardian9:: show_frame() { - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return; } @@ -4679,9 +4679,9 @@ show_frame() { DWORD flags; flags = 0; - hr = _swap_chain->Present((CONST RECT*)NULL, (CONST RECT*)NULL, (HWND)NULL, NULL, flags); + hr = _swap_chain->Present(nullptr, nullptr, (HWND)nullptr, nullptr, flags); } else { - hr = _d3d_device->Present((CONST RECT*)NULL, (CONST RECT*)NULL, (HWND)NULL, NULL); + hr = _d3d_device->Present(nullptr, nullptr, (HWND)nullptr, nullptr); } if (FAILED(hr)) { @@ -5072,7 +5072,7 @@ do_issue_stencil() { const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib(StencilAttrib::get_class_slot())); - if (stencil != (const StencilAttrib *)NULL) { + if (stencil != nullptr) { // DEBUG if (false) { dxgsg9_cat.debug() << "STENCIL STATE CHANGE\n"; @@ -5135,7 +5135,7 @@ do_issue_stencil() { } if (stencil->get_render_state(StencilAttrib::SRS_clear)) { - _d3d_device->Clear(0, NULL, D3DCLEAR_STENCIL, 0, 0.0f, stencil->get_render_state(StencilAttrib::SRS_clear_value)); + _d3d_device->Clear(0, nullptr, D3DCLEAR_STENCIL, 0, 0.0f, stencil->get_render_state(StencilAttrib::SRS_clear_value)); } } else { @@ -5291,7 +5291,7 @@ get_gamma_table(void) { get = false; if (_gamma_table_initialized == false) { - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); if (hdc) { if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { @@ -5299,7 +5299,7 @@ get_gamma_table(void) { get = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } } @@ -5312,7 +5312,7 @@ get_gamma_table(void) { bool DXGraphicsStateGuardian9:: static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); set = false; if (hdc) { @@ -5329,7 +5329,7 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { set = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } return set; @@ -5363,7 +5363,7 @@ restore_gamma() { */ void DXGraphicsStateGuardian9:: atexit_function(void) { - set_cg_device(NULL); + set_cg_device(nullptr); static_set_gamma(true, 1.0f); } diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index fa31ac12fd..5a5c3b3359 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -227,7 +227,7 @@ protected: void dx_cleanup(); HRESULT reset_d3d_device(D3DPRESENT_PARAMETERS *p_presentation_params, - DXScreenData **screen = NULL); + DXScreenData **screen = nullptr); bool check_cooperative_level(); diff --git a/panda/src/dxgsg9/dxIndexBufferContext9.cxx b/panda/src/dxgsg9/dxIndexBufferContext9.cxx index a29dff17b3..ae5db21707 100644 --- a/panda/src/dxgsg9/dxIndexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxIndexBufferContext9.cxx @@ -27,7 +27,7 @@ TypeHandle DXIndexBufferContext9::_type_handle; DXIndexBufferContext9:: DXIndexBufferContext9(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : IndexBufferContext(pgo, data), - _ibuffer(NULL), + _ibuffer(nullptr), _managed(-1) { } @@ -62,7 +62,7 @@ evict_lru() { */ void DXIndexBufferContext9:: free_ibuffer(void) { - if (_ibuffer != NULL) { + if (_ibuffer != nullptr) { if (DEBUG_INDEX_BUFFER && dxgsg9_cat.is_debug()) { dxgsg9_cat.debug() << "deleting index buffer " << _ibuffer << "\n"; @@ -74,7 +74,7 @@ free_ibuffer(void) { _ibuffer->Release(); } - _ibuffer = NULL; + _ibuffer = nullptr; } } @@ -118,7 +118,7 @@ allocate_ibuffer(DXScreenData &scrn, do { hr = scrn._d3d_device->CreateIndexBuffer - (data_size, usage, index_type, pool, &_ibuffer, NULL); + (data_size, usage, index_type, pool, &_ibuffer, nullptr); attempts++; } while (scrn._dxgsg9 -> check_dx_allocation (hr, data_size, attempts)); @@ -126,7 +126,7 @@ allocate_ibuffer(DXScreenData &scrn, if (FAILED(hr)) { dxgsg9_cat.warning() << "CreateIndexBuffer failed" << D3DERRORSTRING(hr); - _ibuffer = NULL; + _ibuffer = nullptr; } else { if (DEBUG_INDEX_BUFFER && dxgsg9_cat.is_debug()) { dxgsg9_cat.debug() @@ -162,10 +162,10 @@ upload_data(const GeomPrimitivePipelineReader *reader, bool force) { nassertr(reader->get_object() == get_data(), false); Thread *current_thread = reader->get_current_thread(); - nassertr(_ibuffer != NULL, false); + nassertr(_ibuffer != nullptr, false); const unsigned char *data_pointer = reader->get_read_pointer(force); - if (data_pointer == NULL) { + if (data_pointer == nullptr) { return false; } size_t data_size = (size_t)reader->get_data_size_bytes(); diff --git a/panda/src/dxgsg9/dxInput9.cxx b/panda/src/dxgsg9/dxInput9.cxx index 24e3ea16f3..d0556d44c7 100644 --- a/panda/src/dxgsg9/dxInput9.cxx +++ b/panda/src/dxgsg9/dxInput9.cxx @@ -32,9 +32,9 @@ BOOL CALLBACK EnumGameCtrlsCallback( const DIDEVICEINSTANCE* pdidInstance, extern BOOL CALLBACK EnumObjectsCallbackJoystick(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext); DInput9Info::DInput9Info() { - _pDInput9 = NULL; - _hDInputDLL = NULL; - _JoystickPollTimer = NULL; + _pDInput9 = nullptr; + _hDInputDLL = nullptr; + _JoystickPollTimer = nullptr; } DInput9Info::~DInput9Info() { @@ -48,7 +48,7 @@ DInput9Info::~DInput9Info() { SAFE_RELEASE(_pDInput9); if(_hDInputDLL) { FreeLibrary(_hDInputDLL); - _hDInputDLL=NULL; + _hDInputDLL=nullptr; } } @@ -70,15 +70,15 @@ bool DInput9Info::InitDirectInput() { LPDIRECTINPUT9CREATE pDInputCreate9; pDInputCreate9 = (LPDIRECTINPUT9CREATE) GetProcAddress(_hDInputDLL,DINPUTCREATE); - if(pDInputCreate9 == NULL) { + if(pDInputCreate9 == nullptr) { wdxdisplay_cat.fatal() << "GetProcAddr failed for " << DINPUTCREATE << endl; exit(1); } // Register with the DirectInput subsystem and get a pointer to a // IDirectInput interface we can use. Create a DInput object - if( FAILED( hr = (*pDInputCreate9)(GetModuleHandle(NULL), DIRECTINPUT_VERSION, - IID_IDirectInput9, (VOID**)&_pDInput9, NULL ) ) ) { + if( FAILED( hr = (*pDInputCreate9)(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, + IID_IDirectInput9, (VOID**)&_pDInput9, nullptr ) ) ) { wdxdisplay_cat.error() << DINPUTCREATE << "failed" << D3DERRORSTRING(hr); return false; } @@ -97,7 +97,7 @@ bool DInput9Info::InitDirectInput() { bool DInput9Info::CreateJoystickOrPad(HWND _window) { bool bFoundDev = false; UINT devnum=0; - char *errstr=NULL; + char *errstr=nullptr; // look through the list for the first joystick or gamepad for(;devnum<_DevInfos.size();devnum++) { @@ -116,13 +116,13 @@ bool DInput9Info::CreateJoystickOrPad(HWND _window) { LPDIRECTINPUTDEVICE9 pJoyDevice; // Obtain an interface to the enumerated joystick. - HRESULT hr = _pDInput9->CreateDevice(_DevInfos[devnum].guidInstance, &pJoyDevice, NULL ); + HRESULT hr = _pDInput9->CreateDevice(_DevInfos[devnum].guidInstance, &pJoyDevice, nullptr ); if(FAILED(hr)) { errstr="CreateDevice"; goto handle_error; } - assert(pJoyDevice!=NULL); + assert(pJoyDevice!=nullptr); _DeviceList.push_back(pJoyDevice); // Set the data format to "simple joystick" - a predefined data format A @@ -210,7 +210,7 @@ BOOL CALLBACK EnumObjectsCallbackJoystick( const DIDEVICEOBJECTINSTANCE* pdidoi, bool DInput9Info::ReadJoystick(int devnum, DIJOYSTATE2 &js) { LPDIRECTINPUTDEVICE9 pJoystick = _DeviceList[devnum]; - assert(pJoystick!=NULL); + assert(pJoystick!=nullptr); HRESULT hr; char *errstr; diff --git a/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx b/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx index 0999821080..89d584dffd 100644 --- a/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx +++ b/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx @@ -25,7 +25,7 @@ TypeHandle DXOcclusionQueryContext9::_type_handle; DXOcclusionQueryContext9:: ~DXOcclusionQueryContext9() { _query->Release(); - _query = NULL; + _query = nullptr; } /** diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index 9d151ac44a..e3992bea5d 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -35,8 +35,8 @@ TypeHandle DXShaderContext9::_type_handle; */ DXShaderContext9:: DXShaderContext9(Shader *s, GSG *gsg) : ShaderContext(s) { - _vertex_element_array = NULL; - _vertex_declaration = NULL; + _vertex_element_array = nullptr; + _vertex_declaration = nullptr; _num_bound_streams = 0; @@ -83,14 +83,14 @@ DXShaderContext9:: ~DXShaderContext9() { release_resources(); - if (_vertex_declaration != NULL) { + if (_vertex_declaration != nullptr) { _vertex_declaration->Release(); - _vertex_declaration = NULL; + _vertex_declaration = nullptr; } - if (_vertex_element_array != NULL) { + if (_vertex_element_array != nullptr) { delete _vertex_element_array; - _vertex_element_array = NULL; + _vertex_element_array = nullptr; } } @@ -200,7 +200,7 @@ issue_parameters(GSG *gsg, int altered) { if (altered & (spec._dep[0] | spec._dep[1])) { const Shader::ShaderPtrData *ptr_data = gsg->fetch_ptr_parameter(spec); - if (ptr_data == NULL) { //the input is not contained in ShaderPtrData + if (ptr_data == nullptr) { //the input is not contained in ShaderPtrData release_resources(); return; } @@ -237,7 +237,7 @@ issue_parameters(GSG *gsg, int altered) { if (altered & (spec._dep[0] | spec._dep[1])) { CGparameter p = _cg_parameter_map[spec._id._seqno]; - if (p == NULL) { + if (p == nullptr) { continue; } const LMatrix4 *val = gsg->fetch_specified_value(spec, altered); @@ -343,7 +343,7 @@ disable_shader_vertex_arrays(GSG *gsg) { LPDIRECT3DDEVICE9 device = gsg->_screen->_d3d_device; for (int array_index = 0; array_index < _num_bound_streams; ++array_index) { - device->SetStreamSource(array_index, NULL, 0, 0); + device->SetStreamSource(array_index, nullptr, 0, 0); } _num_bound_streams = 0; } @@ -377,7 +377,7 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { // Discard and recreate the VertexElementArray. This thrashes pretty // bad.... - if (_vertex_element_array != NULL) { + if (_vertex_element_array != nullptr) { delete _vertex_element_array; } _vertex_element_array = new VertexElementArray(nvarying + 2); @@ -394,14 +394,14 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { for (int array_index = 0; array_index < number_of_arrays; ++array_index) { const GeomVertexArrayDataHandle* array_reader = gsg->_data_reader->get_array_reader(array_index); - if (array_reader == NULL) { + if (array_reader == nullptr) { dxgsg9_cat.error() << "Unable to get reader for array " << array_index << "\n"; continue; } for (int var_index = 0; var_index < nvarying; ++var_index) { CGparameter p = _cg_parameter_map[_shader->_var_spec[var_index]._id._seqno]; - if (p == NULL) { + if (p == nullptr) { dxgsg9_cat.info() << "No parameter in map for parameter " << var_index << " (probably optimized away)\n"; @@ -444,7 +444,7 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { } const char *semantic = cgGetParameterSemantic(p); - if (semantic == NULL) { + if (semantic == nullptr) { dxgsg9_cat.error() << "Unable to retrieve semantic for parameter " << var_index << "\n"; continue; } @@ -564,7 +564,7 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { _num_bound_streams = number_of_arrays; - if (_vertex_element_array != NULL && + if (_vertex_element_array != nullptr && _vertex_element_array->add_end_vertex_element()) { if (dxgsg9_cat.is_debug()) { // Note that the currently generated vertex declaration works but @@ -580,9 +580,9 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { } // Discard the old VertexDeclaration. This thrashes pretty bad.... - if (_vertex_declaration != NULL) { + if (_vertex_declaration != nullptr) { _vertex_declaration->Release(); - _vertex_declaration = NULL; + _vertex_declaration = nullptr; } hr = device->CreateVertexDeclaration(_vertex_element_array->_vertex_element_array, @@ -613,14 +613,14 @@ disable_shader_texture_bindings(GSG *gsg) { if (_cg_program) { for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) { CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno]; - if (p == NULL) { + if (p == nullptr) { continue; } int texunit = cgGetParameterResourceIndex(p); HRESULT hr; - hr = gsg->_d3d_device->SetTexture(texunit, NULL); + hr = gsg->_d3d_device->SetTexture(texunit, nullptr); if (FAILED(hr)) { dxgsg9_cat.error() << "SetTexture(" << texunit << ", NULL) failed " @@ -649,7 +649,7 @@ update_shader_texture_bindings(DXShaderContext9 *prev, GSG *gsg) { for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) { Shader::ShaderTexSpec &spec = _shader->_tex_spec[i]; CGparameter p = _cg_parameter_map[spec._id._seqno]; - if (p == NULL) { + if (p == nullptr) { continue; } @@ -671,7 +671,7 @@ update_shader_texture_bindings(DXShaderContext9 *prev, GSG *gsg) { } TextureContext *tc = tex->prepare_now(view, gsg->_prepared_objects, gsg); - if (tc == (TextureContext*)NULL) { + if (tc == nullptr) { continue; } diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index c089c26e8a..12ad6dfdfe 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -40,10 +40,10 @@ DXTextureContext9(PreparedGraphicsObjects *pgo, Texture *tex, int view) : << "Creating DX texture [" << tex->get_name() << "], minfilter(" << tex->get_minfilter() << "), magfilter(" << tex->get_magfilter() << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n"; } - _d3d_texture = NULL; - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_texture = nullptr; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; _has_mipmaps = false; _is_render_target = false; _managed = -1; @@ -992,21 +992,21 @@ create_texture(DXScreenData &scrn) { case Texture::TT_2d_texture: hr = scrn._d3d_device->CreateTexture (target_width, target_height, mip_level_count, usage, - target_pixel_format, pool, &_d3d_2d_texture, NULL); + target_pixel_format, pool, &_d3d_2d_texture, nullptr); _d3d_texture = _d3d_2d_texture; break; case Texture::TT_3d_texture: hr = scrn._d3d_device->CreateVolumeTexture (target_width, target_height, target_depth, mip_level_count, usage, - target_pixel_format, pool, &_d3d_volume_texture, NULL); + target_pixel_format, pool, &_d3d_volume_texture, nullptr); _d3d_texture = _d3d_volume_texture; break; case Texture::TT_cube_map: hr = scrn._d3d_device->CreateCubeTexture (target_width, mip_level_count, usage, - target_pixel_format, pool, &_d3d_cube_texture, NULL); + target_pixel_format, pool, &_d3d_cube_texture, nullptr); _d3d_texture = _d3d_cube_texture; target_height = target_width; @@ -1050,7 +1050,7 @@ create_texture(DXScreenData &scrn) { if (tex->has_ram_image()) { BamCache *cache = BamCache::get_global_ptr(); PT(BamCacheRecord) record = cache->lookup(tex->get_fullpath(), "txo"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->set_data(tex, tex); cache->store(record); } @@ -1069,9 +1069,9 @@ create_texture(DXScreenData &scrn) { error_exit: RELEASE(_d3d_texture, dxgsg9, "texture", RELEASE_ONCE); - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; return false; } @@ -1101,7 +1101,7 @@ create_simple_texture(DXScreenData &scrn) { hr = scrn._d3d_device->CreateTexture (target_width, target_height, mip_level_count, usage, - target_pixel_format, pool, &_d3d_2d_texture, NULL); + target_pixel_format, pool, &_d3d_2d_texture, nullptr); _d3d_texture = _d3d_2d_texture; if (FAILED(hr)) { dxgsg9_cat.error() @@ -1124,7 +1124,7 @@ create_simple_texture(DXScreenData &scrn) { hr = -1; // hr = fill_d3d_texture_pixels(scrn); - IDirect3DSurface9 *surface = NULL; + IDirect3DSurface9 *surface = nullptr; _d3d_2d_texture->GetSurfaceLevel(0, &surface); RECT source_size; @@ -1135,8 +1135,8 @@ create_simple_texture(DXScreenData &scrn) { DWORD mip_filter = D3DX_FILTER_LINEAR; hr = D3DXLoadSurfaceFromMemory - (surface, (PALETTEENTRY*)NULL, (RECT*)NULL, (LPCVOID)image.p(), - target_pixel_format, target_width * 4, (PALETTEENTRY*)NULL, + (surface, nullptr, nullptr, (LPCVOID)image.p(), + target_pixel_format, target_width * 4, nullptr, &source_size, mip_filter, (D3DCOLOR)0x0); RELEASE(surface, dxgsg9, "create_simple_texture Surface", RELEASE_ONCE); @@ -1156,9 +1156,9 @@ create_simple_texture(DXScreenData &scrn) { error_exit: RELEASE(_d3d_texture, dxgsg9, "texture", RELEASE_ONCE); - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; return false; } @@ -1168,15 +1168,15 @@ create_simple_texture(DXScreenData &scrn) { void DXTextureContext9:: delete_texture() { - if (_d3d_texture == NULL) { + if (_d3d_texture == nullptr) { // don't bother printing the msg below, since we already released it. return; } RELEASE(_d3d_texture, dxgsg9, "texture", RELEASE_ONCE); - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; } /** @@ -1308,7 +1308,7 @@ extract_texture_data(DXScreenData &screen) { surface_description.Format, pool, &destination_surface, - NULL); + nullptr); if (hr == D3D_OK) { if (source_surface && destination_surface) { hr = screen._d3d_device -> GetRenderTargetData (source_surface, destination_surface); @@ -1316,7 +1316,7 @@ extract_texture_data(DXScreenData &screen) { D3DLOCKED_RECT rect; - hr = destination_surface -> LockRect (&rect, NULL, D3DLOCK_READONLY); + hr = destination_surface -> LockRect (&rect, nullptr, D3DLOCK_READONLY); if (hr == D3D_OK) { unsigned int y; @@ -1367,7 +1367,7 @@ extract_texture_data(DXScreenData &screen) { else { for (int n = 0; n < num_levels; ++n) { D3DLOCKED_RECT rect; - hr = _d3d_2d_texture->LockRect(n, &rect, NULL, D3DLOCK_READONLY); + hr = _d3d_2d_texture->LockRect(n, &rect, nullptr, D3DLOCK_READONLY); if (FAILED(hr)) { dxgsg9_cat.error() << "Texture::LockRect() failed! level = " << n << " " << D3DERRORSTRING(hr); @@ -1479,7 +1479,7 @@ d3d_surface_to_texture(RECT &source_rect, IDirect3DSurface9 *d3d_surface, return E_FAIL; } - hr = d3d_surface->LockRect(&locked_rect, (CONST RECT*)NULL, (D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE)); + hr = d3d_surface->LockRect(&locked_rect, nullptr, (D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE)); if (FAILED(hr)) { dxgsg9_cat.error() << "d3d_surface_to_texture LockRect() failed!" << D3DERRORSTRING(hr); @@ -1723,7 +1723,7 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep { // This whole function was refactored out of fill_d3d_texture_pixels to make // the code more readable and to avoid code duplication. - IDirect3DSurface9 *mip_surface = NULL; + IDirect3DSurface9 *mip_surface = nullptr; bool using_temp_buffer = false; HRESULT hr = E_FAIL; CPTA_uchar image = get_texture()->get_ram_mipmap_image(mip_level); @@ -1849,8 +1849,8 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep } else { hr = D3DXLoadSurfaceFromMemory - (mip_surface, (PALETTEENTRY*)NULL, (RECT*)NULL, (LPCVOID)pixels, - source_format, source_row_byte_length, (PALETTEENTRY*)NULL, + (mip_surface, nullptr, nullptr, (LPCVOID)pixels, + source_format, source_row_byte_length, nullptr, &source_size, mip_filter, (D3DCOLOR)0x0); if (FAILED(hr)) { dxgsg9_cat.error() @@ -1922,7 +1922,7 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { // turn off depth stencil when clearing texture if it exists depth_stencil_surface = 0; if (device -> GetDepthStencilSurface (&depth_stencil_surface) == D3D_OK) { - if (device -> SetDepthStencilSurface (NULL) == D3D_OK) { + if (device -> SetDepthStencilSurface (nullptr) == D3D_OK) { } } @@ -1935,7 +1935,7 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { scaled *= 255; color = D3DCOLOR_RGBA((int)scaled[0], (int)scaled[1], (int)scaled[2], (int)scaled[3]); flags = D3DCLEAR_TARGET; - if (device -> Clear (NULL, NULL, flags, color, 0.0f, 0) == D3D_OK) { + if (device -> Clear (0, nullptr, flags, color, 0.0f, 0) == D3D_OK) { } } @@ -2049,7 +2049,7 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { } // mip_filter_flags |= D3DX_FILTER_DITHER; - hr = D3DXFilterTexture(_d3d_texture, (PALETTEENTRY*)NULL, 0, + hr = D3DXFilterTexture(_d3d_texture, nullptr, 0, mip_filter_flags); if (FAILED(hr)) { @@ -2118,7 +2118,7 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { size_t view_size = tex->get_ram_mipmap_view_size(0); image_pixels += view_size * get_view(); - IDirect3DVolume9 *mip_level_0 = NULL; + IDirect3DVolume9 *mip_level_0 = nullptr; bool using_temp_buffer = false; BYTE *pixels = image_pixels; @@ -2212,9 +2212,9 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { GraphicsStateGuardian::_data_transferred_pcollector.add_level(source_page_byte_length * orig_depth); #endif hr = D3DXLoadVolumeFromMemory - (mip_level_0, (PALETTEENTRY*)NULL, (D3DBOX*)NULL, (LPCVOID)pixels, + (mip_level_0, nullptr, nullptr, (LPCVOID)pixels, source_format, source_row_byte_length, source_page_byte_length, - (PALETTEENTRY*)NULL, + nullptr, &source_size, level_0_filter, (D3DCOLOR)0x0); if (FAILED(hr)) { dxgsg9_cat.error() @@ -2236,7 +2236,7 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { // mip_filter_flags| = D3DX_FILTER_DITHER; - hr = D3DXFilterTexture(_d3d_texture, (PALETTEENTRY*)NULL, 0, + hr = D3DXFilterTexture(_d3d_texture, nullptr, 0, mip_filter_flags); if (FAILED(hr)) { dxgsg9_cat.error() diff --git a/panda/src/dxgsg9/dxVertexBufferContext9.cxx b/panda/src/dxgsg9/dxVertexBufferContext9.cxx index 48eb65fc6e..43ef9d51c9 100644 --- a/panda/src/dxgsg9/dxVertexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxVertexBufferContext9.cxx @@ -31,7 +31,7 @@ DXVertexBufferContext9(DXGraphicsStateGuardian9 *dxgsg, PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) : VertexBufferContext(pgo, data), - _vbuffer(NULL) + _vbuffer(nullptr) { // Now fill in the FVF code. const GeomVertexArrayFormat *array_format = data->get_array_format(); @@ -174,9 +174,9 @@ void DXVertexBufferContext9:: evict_lru() { dequeue_lru(); - if ( _vbuffer != NULL ) { + if ( _vbuffer != nullptr ) { _vbuffer->Release(); - _vbuffer = NULL; + _vbuffer = nullptr; } update_data_size_bytes(0); diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index 1566a55ba5..359b9fa2a1 100644 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -82,14 +82,14 @@ typedef DWORD DXShaderHandle; var.dwSize = sizeof(type); #define SAFE_DELSHADER(TYPE,HANDLE,PDEVICE) \ - if((HANDLE!=NULL)&&IS_VALID_PTR(PDEVICE)) { PDEVICE->Delete##TYPE##Shader(HANDLE); HANDLE=NULL; } + if((HANDLE!=nullptr)&&IS_VALID_PTR(PDEVICE)) { PDEVICE->Delete##TYPE##Shader(HANDLE); HANDLE=nullptr; } -#define SAFE_DELETE(p) { if(p) { assert(IS_VALID_PTR(p)); delete (p); (p)=NULL; } } -#define SAFE_DELETE_ARRAY(p) { if(p) { assert(IS_VALID_PTR(p)); delete [] (p); (p)=NULL; } } +#define SAFE_DELETE(p) { if(p) { assert(IS_VALID_PTR(p)); delete (p); (p)=nullptr; } } +#define SAFE_DELETE_ARRAY(p) { if(p) { assert(IS_VALID_PTR(p)); delete [] (p); (p)=nullptr; } } // for stuff outside a panda class -#define SAFE_RELEASE(p) { if(p) { assert(IS_VALID_PTR(p)); (p)->Release(); (p)=NULL; } } -#define SAFE_FREELIB(hDLL) { if(hDLL!=NULL) { FreeLibrary(hDLL);hDLL = NULL; } } +#define SAFE_RELEASE(p) { if(p) { assert(IS_VALID_PTR(p)); (p)->Release(); (p)=nullptr; } } +#define SAFE_FREELIB(hDLL) { if(hDLL!=nullptr) { FreeLibrary(hDLL);hDLL = nullptr; } } // this is bDoDownToZero argument to RELEASE() #define RELEASE_DOWN_TO_ZERO true @@ -110,7 +110,7 @@ typedef DWORD DXShaderHandle; refcnt = (OBJECT)->Release(); \ } while(refcnt>0); \ } \ - (OBJECT) = NULL; \ + (OBJECT) = nullptr; \ } else { \ MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl; \ }} @@ -129,7 +129,7 @@ typedef DWORD DXShaderHandle; refcnt = (OBJECT)->Release(); \ } while(refcnt>0); \ } \ - (OBJECT) = NULL; \ + (OBJECT) = nullptr; \ }} #define PRINT_REFCNT(MODULE,p) diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx index 3cde32fc16..9ac420db2d 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx @@ -37,10 +37,10 @@ wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe, { // initialize all class members _cube_map_index = -1; - _saved_color_buffer = NULL; - _saved_depth_buffer = NULL; - _color_backing_store = NULL; - _depth_backing_store = NULL; + _saved_color_buffer = nullptr; + _saved_depth_buffer = nullptr; + _color_backing_store = nullptr; + _depth_backing_store = nullptr; // is this correct ??? Since the pbuffer never gets flipped, we get // screenshots from the same buffer we draw into. @@ -120,7 +120,7 @@ bool wdxGraphicsBuffer9:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_dxgsg -> _d3d_device == 0) { @@ -151,7 +151,7 @@ void wdxGraphicsBuffer9:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -225,7 +225,7 @@ restore_bitplanes() { // clear all render targets, except for the main render target for (int i = 1; i _d3d_device -> SetRenderTarget (i, NULL); + hr = _dxgsg -> _d3d_device -> SetRenderTarget (i, nullptr); if (!SUCCEEDED (hr)) { dxgsg9_cat.error ( ) << "SetRenderTarget " << i << " " << D3DERRORSTRING(hr) FL; } @@ -235,8 +235,8 @@ restore_bitplanes() { if (_saved_depth_buffer) { _saved_depth_buffer->Release(); } - _saved_color_buffer = NULL; - _saved_depth_buffer = NULL; + _saved_color_buffer = nullptr; + _saved_depth_buffer = nullptr; } @@ -335,7 +335,7 @@ rebuild_bitplanes() { if ((_color_backing_store)&& ((bitplane_x != _backing_sizex)||(bitplane_y != _backing_sizey))) { _color_backing_store->Release(); - _color_backing_store = NULL; + _color_backing_store = nullptr; } if (!_color_backing_store) { hr = _dxgsg->_d3d_device->CreateRenderTarget(bitplane_x, bitplane_y, @@ -344,7 +344,7 @@ rebuild_bitplanes() { _saved_color_desc.MultiSampleQuality, FALSE, &_color_backing_store, - NULL); + nullptr); if (!SUCCEEDED(hr)) { dxgsg9_cat.error ( ) << "CreateRenderTarget " << D3DERRORSTRING(hr) FL; } @@ -354,7 +354,7 @@ rebuild_bitplanes() { // Maintain the color texture. if (_color_backing_store) { _color_backing_store->Release(); - _color_backing_store = NULL; + _color_backing_store = nullptr; } color_tex = get_texture(color_tex_index); color_tex->set_size_padded(get_x_size(), get_y_size()); @@ -409,13 +409,13 @@ rebuild_bitplanes() { if ((_depth_backing_store)&& ((bitplane_x != _backing_sizex)||(bitplane_y != _backing_sizey))) { _depth_backing_store->Release(); - _depth_backing_store = NULL; + _depth_backing_store = nullptr; } if (!_depth_backing_store) { hr = _dxgsg -> _d3d_device -> CreateDepthStencilSurface (bitplane_x, bitplane_y, _saved_depth_desc.Format, _saved_depth_desc.MultiSampleType, _saved_depth_desc.MultiSampleQuality, - false, &_depth_backing_store, NULL); + false, &_depth_backing_store, nullptr); if (!SUCCEEDED(hr)) { dxgsg9_cat.error ( ) << "CreateDepthStencilSurface " << D3DERRORSTRING(hr) FL; } @@ -426,7 +426,7 @@ rebuild_bitplanes() { // Maintain the depth texture. if (_depth_backing_store) { _depth_backing_store->Release(); - _depth_backing_store = NULL; + _depth_backing_store = nullptr; } if (_shared_depth_buffer) { @@ -704,7 +704,7 @@ process_events() { // Handle all the messages on the queue in a row. Some of these might be // for another window, but they will get dispatched appropriately. - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { process_1_event(); } } @@ -717,11 +717,11 @@ close_buffer() { if (_color_backing_store) { _color_backing_store->Release(); - _color_backing_store = NULL; + _color_backing_store = nullptr; } if (_depth_backing_store) { _depth_backing_store->Release(); - _depth_backing_store = NULL; + _depth_backing_store = nullptr; } _cube_map_index = -1; @@ -784,7 +784,7 @@ void wdxGraphicsBuffer9:: process_1_event() { MSG msg; - if (!GetMessage(&msg, NULL, 0, 0)) { + if (!GetMessage(&msg, nullptr, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index c3c0ee0099..7ff6f28e5d 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -21,7 +21,7 @@ TypeHandle wdxGraphicsPipe9::_type_handle; static bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) { *pFn = (FARPROC) GetProcAddress(hDLL, szExportedFnName); - if (*pFn == NULL) { + if (*pFn == nullptr) { wdxdisplay9_cat.error() << "GetProcAddr failed for " << szExportedFnName << ", error=" << GetLastError() < 0)|| (fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } return new wdxGraphicsWindow9(engine, this, name, fb_prop, win_prop, @@ -130,7 +130,7 @@ make_output(const string &name, ((flags&BF_require_window)!=0)|| ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -139,13 +139,13 @@ make_output(const string &name, (fb_prop.get_back_buffers() > 0)|| (fb_prop.get_accum_bits() > 0)|| (fb_prop.get_multisamples() > 0)) { - return NULL; + return nullptr; } } // Early success - if we are sure that this buffer WILL meet specs, we can // precertify it. This looks rather overly optimistic -- ie, buggy. - if ((wdxgsg != NULL) && wdxgsg->is_valid() && !wdxgsg->needs_reset() && + if ((wdxgsg != nullptr) && wdxgsg->is_valid() && !wdxgsg->needs_reset() && wdxgsg->get_supports_render_texture()) { precertify = true; } @@ -154,7 +154,7 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } /** @@ -165,7 +165,7 @@ make_output(const string &name, bool wdxGraphicsPipe9:: init() { _hDDrawDLL = LoadLibrary("ddraw.dll"); - if (_hDDrawDLL == NULL) { + if (_hDDrawDLL == nullptr) { wdxdisplay9_cat.error() << "LoadLibrary failed for ddraw.dll, error=" << GetLastError() <show_frame(); } WinGraphicsWindow::end_flip(); @@ -234,11 +234,11 @@ close_window() { << "wdxGraphicsWindow9::close_window() " << this << "\n"; } - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { _gsg.clear(); } - DXGraphicsStateGuardian9::set_cg_device(NULL); + DXGraphicsStateGuardian9::set_cg_device(nullptr); _dxgsg->release_swap_chain(&_wcontext); WinGraphicsWindow::close_window(); @@ -291,7 +291,7 @@ open_window() { // case just create an additional swapchain for this window while (true) { - if (_dxgsg->get_pipe()->get_device() == NULL || discard_device) { + if (_dxgsg->get_pipe()->get_device() == nullptr || discard_device) { wdxdisplay9_cat.debug() << "device is null or fullscreen\n"; // If device exists, free it @@ -370,7 +370,7 @@ fullscreen_restored(WindowProperties &properties) { // as soon as the window is restored, even though BeginScene() says we can. // Instead, we have to wait until TestCooperativeLevel() lets us in. We // need to set a flag so we can handle this special case in begin_frame(). - if (_dxgsg != NULL) { + if (_dxgsg != nullptr) { _awaiting_restore = true; } } @@ -384,7 +384,7 @@ handle_reshape() { GdiFlush(); WinGraphicsWindow::handle_reshape(); - if (_dxgsg != NULL && _dxgsg->_d3d_device != NULL) { + if (_dxgsg != nullptr && _dxgsg->_d3d_device != nullptr) { // create the new resized rendertargets WindowProperties props = get_properties(); int x_size = props.get_x_size(); @@ -539,7 +539,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer PRINT_REFCNT(wdxdisplay9, _d3d9); - nassertr(_d3d9 != NULL, false); + nassertr(_d3d9 != nullptr, false); nassertr(pD3DCaps->DevCaps & D3DDEVCAPS_HWRASTERIZATION, false); bool do_sync = sync_video; @@ -601,7 +601,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer while (supported_multisamples > 1){ // need to check both rendertarget and zbuffer fmts hr = _d3d9->CheckDeviceMultiSampleType(adapter, D3DDEVTYPE_HAL, display._display_mode.Format, - is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), NULL); + is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), nullptr); if (FAILED(hr)) { supported_multisamples--; continue; @@ -609,7 +609,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer if (display._presentation_params.EnableAutoDepthStencil) { hr = _d3d9->CheckDeviceMultiSampleType(adapter, D3DDEVTYPE_HAL, display._presentation_params.AutoDepthStencilFormat, - is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), NULL); + is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), nullptr); if (FAILED(hr)) { supported_multisamples--; continue; @@ -886,7 +886,7 @@ choose_device() { << " Revision: 0x" << adapter_info.Revision << dec << endl; HMONITOR _monitor = dxpipe->__d3d9->GetAdapterMonitor(i); - if (_monitor == NULL) { + if (_monitor == nullptr) { wdxdisplay9_cat.info() << "D3D9 Adapter[" << i << "]: seems to be disabled, skipping it\n"; continue; @@ -968,14 +968,14 @@ choose_device() { bool wdxGraphicsWindow9:: consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { - nassertr(dxpipe != NULL, false); + nassertr(dxpipe != nullptr, false); WindowProperties properties = get_properties(); DWORD dwRenderWidth = properties.get_x_size(); DWORD dwRenderHeight = properties.get_y_size(); HRESULT hr; LPDIRECT3D9 _d3d9 = dxpipe->__d3d9; - nassertr(_dxgsg != NULL, false); + nassertr(_dxgsg != nullptr, false); _wcontext._d3d9 = _d3d9; _wcontext._is_dx9_1 = dxpipe->__is_dx9_1; _wcontext._card_id = device_info->cardID; // could this change by end? @@ -1123,7 +1123,7 @@ bool wdxGraphicsWindow9:: reset_device_resize_window(UINT new_xsize, UINT new_ysize) { bool retval = true; - DXScreenData *screen = NULL; + DXScreenData *screen = nullptr; D3DPRESENT_PARAMETERS d3dpp; memcpy(&d3dpp, &_wcontext._presentation_params, sizeof(D3DPRESENT_PARAMETERS)); _wcontext._presentation_params.BackBufferWidth = new_xsize; @@ -1184,7 +1184,7 @@ init_resized_window() { DWORD newHeight = _wcontext._presentation_params.BackBufferHeight; nassertv((newWidth != 0) && (newHeight != 0)); - nassertv(_wcontext._window != NULL); + nassertv(_wcontext._window != nullptr); if (_wcontext._presentation_params.Windowed) { POINT ul, lr; @@ -1207,7 +1207,7 @@ init_resized_window() { } // clear window to black ASAP - nassertv(_wcontext._window != NULL); + nassertv(_wcontext._window != nullptr); ClearToBlack(_wcontext._window, get_properties()); // clear textures and VB's out of video&AGP mem, so cache is reset @@ -1229,19 +1229,19 @@ init_resized_window() { flags = D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER; clear_color = 0x00000000; - hr = _wcontext._d3d_device-> Clear (0, NULL, flags, clear_color, 0.0f, 0); + hr = _wcontext._d3d_device-> Clear (0, nullptr, flags, clear_color, 0.0f, 0); if (FAILED(hr)) { wdxdisplay9_cat.error() << "Clear failed for device" << D3DERRORSTRING(hr); } - hr = _wcontext._d3d_device-> Present (NULL, NULL, NULL, NULL); + hr = _wcontext._d3d_device-> Present (nullptr, nullptr, nullptr, nullptr); if (FAILED(hr)) { wdxdisplay9_cat.error() << "Present failed for device" << D3DERRORSTRING(hr); } - hr = _wcontext._d3d_device-> Clear (0, NULL, flags, clear_color, 0.0f, 0); + hr = _wcontext._d3d_device-> Clear (0, nullptr, flags, clear_color, 0.0f, 0); if (FAILED(hr)) { wdxdisplay9_cat.error() << "Clear failed for device" diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index 7e25a58c3a..9c9a65533b 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -59,7 +59,7 @@ read_xml_stream(istream &in) { in >> *doc; if (in.fail() && !in.eof()) { delete doc; - return NULL; + return nullptr; } return doc; @@ -103,7 +103,7 @@ print_xml_to_file(const Filename &filename, TiXmlNode *xnode) { if (fopen_s(&file, os_name.c_str(), "w") != 0) { #else FILE *file = fopen(os_name.c_str(), "w"); - if (file == NULL) { + if (file == nullptr) { #endif dxml_cat.error() << "Failed to open " << filename << " for writing\n"; } diff --git a/panda/src/dxml/tinyxml.cpp b/panda/src/dxml/tinyxml.cpp index 05c2cc2af4..be84236496 100644 --- a/panda/src/dxml/tinyxml.cpp +++ b/panda/src/dxml/tinyxml.cpp @@ -42,7 +42,7 @@ bool TiXmlBase::condenseWhiteSpace = true; FILE* TiXmlFOpen( const char* filename, const char* mode ) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - FILE* fp = 0; + FILE* fp = nullptr; /* Addition by drwr for Windows wide-character support */ //errno_t err = fopen_s( &fp, filename, mode ); @@ -65,7 +65,7 @@ FILE* TiXmlFOpen( const char* filename, const char* mode ) if ( !err && fp ) return fp; - return 0; + return nullptr; #else return fopen( filename, mode ); #endif @@ -157,19 +157,19 @@ void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() { - parent = 0; + parent = nullptr; type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; + firstChild = nullptr; + lastChild = nullptr; + prev = nullptr; + next = nullptr; } TiXmlNode::~TiXmlNode() { TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* temp = nullptr; while ( node ) { @@ -191,7 +191,7 @@ void TiXmlNode::CopyTo( TiXmlNode* target ) const void TiXmlNode::Clear() { TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* temp = nullptr; while ( node ) { @@ -200,27 +200,27 @@ void TiXmlNode::Clear() delete temp; } - firstChild = 0; - lastChild = 0; + firstChild = nullptr; + lastChild = nullptr; } TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) { - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + assert( node->parent == nullptr || node->parent == this ); + assert( node->GetDocument() == nullptr || node->GetDocument() == this->GetDocument() ); if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) { delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } node->parent = this; node->prev = lastChild; - node->next = 0; + node->next = nullptr; if ( lastChild ) lastChild->next = node; @@ -236,12 +236,12 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = addThis.Clone(); if ( !node ) - return 0; + return nullptr; return LinkEndChild( node ); } @@ -250,17 +250,17 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) { if ( !beforeThis || beforeThis->parent != this ) { - return 0; + return nullptr; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = addThis.Clone(); if ( !node ) - return 0; + return nullptr; node->parent = this; node->next = beforeThis; @@ -282,17 +282,17 @@ TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) { if ( !afterThis || afterThis->parent != this ) { - return 0; + return nullptr; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = addThis.Clone(); if ( !node ) - return 0; + return nullptr; node->parent = this; node->prev = afterThis; @@ -314,22 +314,22 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) { if ( !replaceThis ) - return 0; + return nullptr; if ( replaceThis->parent != this ) - return 0; + return nullptr; if ( withThis.ToDocument() ) { // A document can never be a child. Thanks to Noam. TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = withThis.Clone(); if ( !node ) - return 0; + return nullptr; node->next = replaceThis->next; node->prev = replaceThis->prev; @@ -384,7 +384,7 @@ const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -396,7 +396,7 @@ const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -436,7 +436,7 @@ const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -448,7 +448,7 @@ const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -478,7 +478,7 @@ const TiXmlElement* TiXmlNode::FirstChildElement() const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -493,7 +493,7 @@ const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -508,7 +508,7 @@ const TiXmlElement* TiXmlNode::NextSiblingElement() const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -523,7 +523,7 @@ const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -536,14 +536,14 @@ const TiXmlDocument* TiXmlNode::GetDocument() const if ( node->ToDocument() ) return node->ToDocument(); } - return 0; + return nullptr; } TiXmlElement::TiXmlElement (const char * _value) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { - firstChild = lastChild = 0; + firstChild = lastChild = nullptr; value = _value; } @@ -552,7 +552,7 @@ TiXmlElement::TiXmlElement (const char * _value) TiXmlElement::TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { - firstChild = lastChild = 0; + firstChild = lastChild = nullptr; value = _value; } #endif @@ -561,7 +561,7 @@ TiXmlElement::TiXmlElement( const std::string& _value ) TiXmlElement::TiXmlElement( const TiXmlElement& copy) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { - firstChild = lastChild = 0; + firstChild = lastChild = nullptr; copy.CopyTo( this ); } @@ -596,7 +596,7 @@ const char* TiXmlElement::Attribute( const char* name ) const const TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) return node->Value(); - return 0; + return nullptr; } @@ -606,7 +606,7 @@ const std::string* TiXmlElement::Attribute( const std::string& name ) const const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( attrib ) return &attrib->ValueStr(); - return 0; + return nullptr; } #endif @@ -614,7 +614,7 @@ const std::string* TiXmlElement::Attribute( const std::string& name ) const const char* TiXmlElement::Attribute( const char* name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; + const char* result = nullptr; if ( attrib ) { result = attrib->Value(); @@ -630,7 +630,7 @@ const char* TiXmlElement::Attribute( const char* name, int* i ) const const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; + const std::string* result = nullptr; if ( attrib ) { result = &attrib->ValueStr(); @@ -646,7 +646,7 @@ const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) co const char* TiXmlElement::Attribute( const char* name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; + const char* result = nullptr; if ( attrib ) { result = attrib->Value(); @@ -662,7 +662,7 @@ const char* TiXmlElement::Attribute( const char* name, double* d ) const const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; + const std::string* result = nullptr; if ( attrib ) { result = &attrib->ValueStr(); @@ -835,7 +835,7 @@ void TiXmlElement::CopyTo( TiXmlElement* target ) const // Element class: // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; + const TiXmlAttribute* attribute = nullptr; for( attribute = attributeSet.First(); attribute; attribute = attribute->Next() ) @@ -843,7 +843,7 @@ void TiXmlElement::CopyTo( TiXmlElement* target ) const target->SetAttribute( attribute->Name(), attribute->Value() ); } - TiXmlNode* node = 0; + TiXmlNode* node = nullptr; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); @@ -868,7 +868,7 @@ TiXmlNode* TiXmlElement::Clone() const { TiXmlElement* clone = new TiXmlElement( Value() ); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -884,7 +884,7 @@ const char* TiXmlElement::GetText() const return childText->Value(); } } - return 0; + return nullptr; } @@ -955,7 +955,7 @@ bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) } else { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_OPENING_FILE, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } } @@ -964,7 +964,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) { if ( !file ) { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_OPENING_FILE, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } @@ -981,7 +981,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) // Strange case, but good to handle up front. if ( length <= 0 ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } @@ -1011,7 +1011,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) if ( fread( buf, length, 1, file ) != 1 ) { delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_OPENING_FILE, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } @@ -1051,7 +1051,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) assert( q <= (buf+length) ); *q = 0; - Parse( buf, 0, encoding ); + Parse( buf, nullptr, encoding ); delete [] buf; return !Error(); @@ -1100,7 +1100,7 @@ void TiXmlDocument::CopyTo( TiXmlDocument* target ) const target->errorLocation = errorLocation; target->useMicrosoftBOM = useMicrosoftBOM; - TiXmlNode* node = 0; + TiXmlNode* node = nullptr; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); @@ -1112,7 +1112,7 @@ TiXmlNode* TiXmlDocument::Clone() const { TiXmlDocument* clone = new TiXmlDocument(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1149,7 +1149,7 @@ const TiXmlAttribute* TiXmlAttribute::Next() const // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( next->value.empty() && next->name.empty() ) - return 0; + return nullptr; return next; } @@ -1169,7 +1169,7 @@ const TiXmlAttribute* TiXmlAttribute::Previous() const // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( prev->value.empty() && prev->name.empty() ) - return 0; + return nullptr; return prev; } @@ -1298,7 +1298,7 @@ TiXmlNode* TiXmlComment::Clone() const TiXmlComment* clone = new TiXmlComment(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1341,11 +1341,11 @@ bool TiXmlText::Accept( TiXmlVisitor* visitor ) const TiXmlNode* TiXmlText::Clone() const { - TiXmlText* clone = 0; + TiXmlText* clone = nullptr; clone = new TiXmlText( "" ); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1433,7 +1433,7 @@ TiXmlNode* TiXmlDeclaration::Clone() const TiXmlDeclaration* clone = new TiXmlDeclaration(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1465,7 +1465,7 @@ TiXmlNode* TiXmlUnknown::Clone() const TiXmlUnknown* clone = new TiXmlUnknown(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1511,8 +1511,8 @@ void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) { node->prev->next = node->next; node->next->prev = node->prev; - node->next = 0; - node->prev = 0; + node->next = nullptr; + node->prev = nullptr; return; } } @@ -1528,7 +1528,7 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const if ( node->name == name ) return node; } - return 0; + return nullptr; } TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) @@ -1551,7 +1551,7 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const if ( strcmp( node->name.c_str(), name ) == 0 ) return node; } - return 0; + return nullptr; } @@ -1574,7 +1574,7 @@ std::istream& operator>> (std::istream & in, TiXmlNode & base) tag.reserve( 8 * 1000 ); base.StreamIn( &in, &tag ); - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + base.Parse( tag.c_str(), nullptr, TIXML_DEFAULT_ENCODING ); return in; } #endif @@ -1612,7 +1612,7 @@ TiXmlHandle TiXmlHandle::FirstChild() const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1624,7 +1624,7 @@ TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1636,7 +1636,7 @@ TiXmlHandle TiXmlHandle::FirstChildElement() const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1648,7 +1648,7 @@ TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1667,7 +1667,7 @@ TiXmlHandle TiXmlHandle::Child( int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1686,7 +1686,7 @@ TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1705,7 +1705,7 @@ TiXmlHandle TiXmlHandle::ChildElement( int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1724,7 +1724,7 @@ TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1747,7 +1747,7 @@ bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) { buffer += " "; - attrib->Print( 0, 0, &buffer ); + attrib->Print( nullptr, 0, &buffer ); } if ( !element.FirstChild() ) @@ -1832,7 +1832,7 @@ bool TiXmlPrinter::Visit( const TiXmlText& text ) bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) { DoIndent(); - declaration.Print( 0, 0, &buffer ); + declaration.Print( nullptr, 0, &buffer ); DoLineBreak(); return true; } diff --git a/panda/src/dxml/tinyxmlparser.cpp b/panda/src/dxml/tinyxmlparser.cpp index 666a4f757c..edf757b761 100644 --- a/panda/src/dxml/tinyxmlparser.cpp +++ b/panda/src/dxml/tinyxmlparser.cpp @@ -315,7 +315,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) { if ( !p || !*p ) { - return 0; + return nullptr; } if ( encoding == TIXML_ENCODING_UTF8 ) { @@ -432,7 +432,7 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi } return p; } - return 0; + return nullptr; } const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) @@ -451,12 +451,12 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml if ( *(p+2) == 'x' ) { // Hexadecimal. - if ( !*(p+3) ) return 0; + if ( !*(p+3) ) return nullptr; const char* q = p+3; q = strchr( q, ';' ); - if ( !q || !*q ) return 0; + if ( !q || !*q ) return nullptr; delta = q-p; --q; @@ -470,7 +470,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml else if ( *q >= 'A' && *q <= 'F' ) ucs += mult * (*q - 'A' + 10 ); else - return 0; + return nullptr; mult *= 16; --q; } @@ -478,12 +478,12 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml else { // Decimal. - if ( !*(p+2) ) return 0; + if ( !*(p+2) ) return nullptr; const char* q = p+2; q = strchr( q, ';' ); - if ( !q || !*q ) return 0; + if ( !q || !*q ) return nullptr; delta = q-p; --q; @@ -493,7 +493,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml if ( *q >= '0' && *q <= '9' ) ucs += mult * (*q - '0'); else - return 0; + return nullptr; mult *= 10; --q; } @@ -649,7 +649,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) if ( !StreamTo( in, '<', tag ) ) { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_PARSING_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -661,7 +661,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) int c = in->get(); if ( c <= 0 ) { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); break; } (*tag) += (char) c; @@ -677,9 +677,9 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) if ( node ) { node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; + bool isElement = node->ToElement() != nullptr; delete node; - node = 0; + node = nullptr; // If this is the root element, we're done. Parsing will be // done by the >> operator. @@ -690,13 +690,13 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) } else { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } } } // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); } #endif @@ -710,8 +710,8 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX // here is skipping white space. if ( !p || !*p ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } // Note that, for a document, this needs to come @@ -747,8 +747,8 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX p = SkipWhiteSpace( p, encoding ); if ( !p ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } while ( p && *p ) @@ -787,8 +787,8 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX // Was this empty? if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, encoding ); + return nullptr; } // All is well. @@ -817,19 +817,19 @@ void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* dat TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) { - TiXmlNode* returnNode = 0; + TiXmlNode* returnNode = nullptr; p = SkipWhiteSpace( p, encoding ); if( !p || !*p || *p != '<' ) { - return 0; + return nullptr; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) { - return 0; + return nullptr; } // What is this thing? @@ -911,7 +911,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c ; @@ -973,7 +973,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -1013,7 +1013,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } assert( c == '>' ); @@ -1031,7 +1031,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) return; node->StreamIn( in, tag ); delete node; - node = 0; + node = nullptr; // No return: go around from the beginning: text, closing tag, or node. } @@ -1047,8 +1047,8 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p || !*p ) { - if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding ); - return 0; + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, nullptr, nullptr, encoding ); + return nullptr; } if ( data ) @@ -1060,7 +1060,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( *p != '<' ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding ); - return 0; + return nullptr; } p = SkipWhiteSpace( p+1, encoding ); @@ -1072,7 +1072,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding ); - return 0; + return nullptr; } TIXML_STRING endTag ("SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; + return nullptr; } if ( *p == '/' ) { @@ -1096,7 +1096,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( *p != '>' ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding ); - return 0; + return nullptr; } return (p+1); } @@ -1111,7 +1111,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc // We were looking for the end tag, but found nothing. // Fix for [ 1663758 ] Failure to report error on bad XML if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); - return 0; + return nullptr; } // We should find the end tag now @@ -1128,12 +1128,12 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc return p; } if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); - return 0; + return nullptr; } else { if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); - return 0; + return nullptr; } } else @@ -1142,7 +1142,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc TiXmlAttribute* attrib = new TiXmlAttribute(); if ( !attrib ) { - return 0; + return nullptr; } attrib->SetDocument( document ); @@ -1153,7 +1153,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc { if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); delete attrib; - return 0; + return nullptr; } // Handle the strange case of double attributes: @@ -1166,7 +1166,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc { if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); delete attrib; - return 0; + return nullptr; } attributeSet.Add( attrib ); @@ -1193,7 +1193,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm if ( !textNode ) { - return 0; + return nullptr; } if ( TiXmlBase::IsWhiteSpaceCondensed() ) @@ -1231,7 +1231,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm } else { - return 0; + return nullptr; } } } @@ -1241,7 +1241,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm if ( !p ) { - if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding ); + if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, nullptr, nullptr, encoding ); } return p; } @@ -1257,7 +1257,7 @@ void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; @@ -1285,7 +1285,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p || !*p || *p != '<' ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding ); - return 0; + return nullptr; } ++p; value = ""; @@ -1298,7 +1298,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p ) { - if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding ); + if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, nullptr, nullptr, encoding ); } if ( *p == '>' ) return p+1; @@ -1315,7 +1315,7 @@ void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -1351,7 +1351,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !StringEqual( p, startTag, false, encoding ) ) { document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; + return nullptr; } p += strlen( startTag ); @@ -1390,7 +1390,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; + if ( !p || !*p ) return nullptr; if ( data ) { @@ -1403,13 +1403,13 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; + return nullptr; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p || *p != '=' ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; + return nullptr; } ++p; // skip '=' @@ -1417,7 +1417,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; + return nullptr; } const char* end; @@ -1451,7 +1451,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE // We did not have an opening quote but seem to have a // closing one. Give up and throw an error. if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; + return nullptr; } value += *p; ++p; @@ -1474,7 +1474,7 @@ void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -1513,7 +1513,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi if ( !StringEqual( p, startTag, false, encoding ) ) { document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; + return nullptr; } p += strlen( startTag ); @@ -1538,7 +1538,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi p = ReadText( p, &value, ignoreWhite, end, false, encoding ); if ( p ) return p-1; // don't truncate the '<' - return 0; + return nullptr; } } @@ -1552,7 +1552,7 @@ void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; @@ -1574,8 +1574,8 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm TiXmlDocument* document = GetDocument(); if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; + if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, nullptr, nullptr, _encoding ); + return nullptr; } if ( data ) { @@ -1622,7 +1622,7 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm ++p; } } - return 0; + return nullptr; } bool TiXmlText::Blank() const diff --git a/panda/src/egg/eggBinMaker.cxx b/panda/src/egg/eggBinMaker.cxx index 294c76de0d..9200afde6b 100644 --- a/panda/src/egg/eggBinMaker.cxx +++ b/panda/src/egg/eggBinMaker.cxx @@ -128,7 +128,7 @@ get_bin_name(int, const EggNode *) { */ PT(EggBin) EggBinMaker:: make_bin(int, const EggNode *, EggGroup *collapse_from) { - if (collapse_from == (EggGroup *)NULL) { + if (collapse_from == nullptr) { return new EggBin; } else { return new EggBin(*collapse_from); @@ -243,7 +243,7 @@ make_bins_for_group(EggGroupNode *group, const Bins &bins) { if (group->empty() && bins.size() == 1 && - group->get_parent() != NULL && + group->get_parent() != nullptr && group->is_of_type(EggGroup::get_class_type())) { const Nodes &nodes = bins.front(); nassertv(!nodes.empty()); @@ -268,7 +268,7 @@ make_bins_for_group(EggGroupNode *group, const Bins &bins) { const Nodes &nodes = (*bi); nassertv(!nodes.empty()); int bin_number = get_bin_number(nodes.front()); - PT(EggBin) bin = make_bin(bin_number, nodes.front(), NULL); + PT(EggBin) bin = make_bin(bin_number, nodes.front(), nullptr); setup_bin(bin, nodes); group->add_child(bin); diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index 65c7e338dd..b42cb080c9 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -100,7 +100,7 @@ get_shading() const { PT(EggCompositePrimitive) EggCompositePrimitive:: triangulate_in_place() { EggGroupNode *parent = get_parent(); - nassertr(parent != (EggGroupNode *)NULL, this); + nassertr(parent != nullptr, this); PT(EggCompositePrimitive) save_me = this; parent->remove_child(this); @@ -171,7 +171,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -200,7 +200,7 @@ unify_attributes(EggPrimitive::Shading shading) { vertex->clear_color(); EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -248,7 +248,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index 69eb4eb6e6..84fe2cde3c 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -70,14 +70,14 @@ read(Filename filename, string display_name) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(filename); - if (vfile == NULL) { + if (vfile == nullptr) { egg_cat.error() << "Could not find " << display_name << "\n"; return false; } set_egg_timestamp(vfile->get_timestamp()); istream *file = vfile->open_read_file(true); - if (file == (istream *)NULL) { + if (file == nullptr) { egg_cat.error() << "Unable to open " << display_name << "\n"; return false; } @@ -158,7 +158,7 @@ merge(EggData &other) { bool EggData:: load_externals(const DSearchPath &searchpath) { return - r_load_externals(searchpath, get_coordinate_system(), NULL); + r_load_externals(searchpath, get_coordinate_system(), nullptr); } /** @@ -211,7 +211,7 @@ write_egg(Filename filename) { filename.set_text(); vfs->delete_file(filename); ostream *file = vfs->open_write_file(filename, true, true); - if (file == (ostream *)NULL) { + if (file == nullptr) { egg_cat.error() << "Unable to open " << filename << " for writing.\n"; return false; } @@ -276,7 +276,7 @@ write(ostream &out, int indent_level) const { PT(EggCoordinateSystem) ecs = new EggCoordinateSystem(_coordsys); ecs->write(out, indent_level); EggGroupNode::write(out, indent_level); - out << flush; + out << std::flush; } diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index d66de55e0f..4575966733 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -686,7 +686,7 @@ set_lod(const EggSwitchCondition &lod) { */ INLINE void EggGroup:: clear_lod() { - _lod = NULL; + _lod = nullptr; } /** @@ -694,7 +694,7 @@ clear_lod() { */ INLINE bool EggGroup:: has_lod() const { - return (_lod != (EggSwitchCondition *)NULL); + return (_lod != nullptr); } /** diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index 2377006bab..b67d079cce 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -772,7 +772,7 @@ get_num_group_refs() const { */ EggGroup *EggGroup:: get_group_ref(int n) const { - nassertr(n >= 0 && n < (int)_group_refs.size(), NULL); + nassertr(n >= 0 && n < (int)_group_refs.size(), nullptr); return _group_refs[n]; } @@ -1069,7 +1069,7 @@ write_vertex_ref(ostream &out, int indent_level) const { indent(out, indent_level + 2) << " membership { " << membership << " }\n"; } - if (pool == (EggVertexPool *)NULL) { + if (pool == nullptr) { indent(out, indent_level + 2) << "// Invalid NULL vertex pool.\n"; } else { @@ -1121,7 +1121,7 @@ adjust_under() { _node_frame_inv = new MatrixFrame(mat); } else { - _node_frame_inv = NULL; + _node_frame_inv = nullptr; } _vertex_to_node = @@ -1144,8 +1144,8 @@ adjust_under() { // frame. _vertex_frame = _node_frame; _vertex_frame_inv = _node_frame_inv; - _vertex_to_node = NULL; - _node_to_vertex = NULL; + _vertex_to_node = nullptr; + _node_to_vertex = nullptr; } } diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index acf509274a..ef31289424 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -230,7 +230,7 @@ get_next_child() { if (_gnc_iterator != end()) { return *_gnc_iterator++; } - return NULL; + return nullptr; } /** @@ -241,7 +241,7 @@ EggNode *EggGroupNode:: add_child(EggNode *node) { test_ref_count_integrity(); PT(EggNode) ptnode = node; - if (node->_parent != NULL) { + if (node->_parent != nullptr) { node->_parent->remove_child(node); } prepare_add_child(node); @@ -300,7 +300,7 @@ find_child(const string &name) const { } } - return NULL; + return nullptr; } /** @@ -1177,7 +1177,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, // vertex pools we've already created already have a copy of each one of // the vertices. bool found_pool = false; - EggVertexPool *best_pool = NULL; + EggVertexPool *best_pool = nullptr; int best_new_vertices = 0; Vertices new_vertices; @@ -1198,7 +1198,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, EggVertex *vertex = (*vi); EggVertex *new_vertex = vertex_pool->find_matching_vertex(*vertex); new_vertices.push_back(new_vertex); - if (new_vertex == (EggVertex *)NULL) { + if (new_vertex == nullptr) { ++num_new_vertices; } } @@ -1212,7 +1212,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, // We would have to add some vertices to this pool, so this vertex // pool qualifies only if the number of vertices we have to add // would still keep it within our limit. - if (best_pool == (EggVertexPool *)NULL || + if (best_pool == nullptr || num_new_vertices < best_new_vertices) { // This is currently our most favorable vertex pool. best_pool = vertex_pool; @@ -1222,7 +1222,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, } if (!found_pool) { - if (best_pool == (EggVertexPool *)NULL) { + if (best_pool == nullptr) { // There was no vertex pool that qualified. We will have to create // a new vertex pool. best_pool = new EggVertexPool(""); @@ -1245,7 +1245,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, nassertv(new_vertices.size() == vertices.size()); for (vi = new_vertices.begin(); vi != new_vertices.end(); ++vi) { EggVertex *new_vertex = (*vi); - nassertv(new_vertex != (EggVertex *)NULL); + nassertv(new_vertex != nullptr); prim->add_vertex(new_vertex); } @@ -1545,7 +1545,7 @@ r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, if (ext_data.read(filename)) { // The external file was read correctly. Add its contents into the // tree at this point. - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(filename); } @@ -1577,11 +1577,11 @@ r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, */ void EggGroupNode:: prepare_add_child(EggNode *node) { - nassertv(node != (EggNode *)NULL); + nassertv(node != nullptr); test_ref_count_integrity(); node->test_ref_count_integrity(); // Make sure the node is not already a child of some other group. - nassertv(node->get_parent() == NULL); + nassertv(node->get_parent() == nullptr); nassertv(node->get_depth() == 0); node->_parent = this; @@ -1599,11 +1599,11 @@ prepare_add_child(EggNode *node) { */ void EggGroupNode:: prepare_remove_child(EggNode *node) { - nassertv(node != (EggNode *)NULL); + nassertv(node != nullptr); // Make sure the node is in fact a child of this group. nassertv(node->get_parent() == this); nassertv(node->get_depth() == get_depth() + 1); - node->_parent = NULL; + node->_parent = nullptr; node->update_under(-(get_depth() + 1)); } @@ -1867,7 +1867,7 @@ do_compute_tangent_binormal(const TBNVertexValue &value, EggVertex new_vertex(*vertex); EggVertexUV *uv_obj = new_vertex.modify_uv_obj(value._uv_name); - nassertv(uv_obj != (EggVertexUV *)NULL); + nassertv(uv_obj != nullptr); uv_obj->set_tangent(tangent); uv_obj->set_binormal(binormal); diff --git a/panda/src/egg/eggGroupNode_ext.cxx b/panda/src/egg/eggGroupNode_ext.cxx index a0ac3fcb8e..9a42bb8cad 100644 --- a/panda/src/egg/eggGroupNode_ext.cxx +++ b/panda/src/egg/eggGroupNode_ext.cxx @@ -29,8 +29,8 @@ get_children() const { // Create the Python list object. EggGroupNode::size_type len = _this->size(); PyObject *lst = PyList_New(len); - if (lst == NULL) { - return NULL; + if (lst == nullptr) { + return nullptr; } // Fill in the list. diff --git a/panda/src/egg/eggMaterialCollection.cxx b/panda/src/egg/eggMaterialCollection.cxx index b89f3a1900..3ccc9c330f 100644 --- a/panda/src/egg/eggMaterialCollection.cxx +++ b/panda/src/egg/eggMaterialCollection.cxx @@ -395,5 +395,5 @@ find_mref(const string &mref_name) const { } } - return (EggMaterial *)NULL; + return nullptr; } diff --git a/panda/src/egg/eggMesher.cxx b/panda/src/egg/eggMesher.cxx index 98e583b3e0..89261d9855 100644 --- a/panda/src/egg/eggMesher.cxx +++ b/panda/src/egg/eggMesher.cxx @@ -30,7 +30,7 @@ */ EggMesher:: EggMesher() { - _vertex_pool = NULL; + _vertex_pool = nullptr; _strip_index = 0; } @@ -70,7 +70,7 @@ mesh(EggGroupNode *group, bool flat_shaded) { if (child->is_of_type(EggPolygon::get_class_type())) { EggPolygon *poly = DCAST(EggPolygon, child); - if (_vertex_pool == (EggVertexPool *)NULL) { + if (_vertex_pool == nullptr) { _vertex_pool = poly->get_pool(); add_polygon(poly, EggMesherStrip::MO_user); @@ -93,7 +93,7 @@ mesh(EggGroupNode *group, bool flat_shaded) { Strips::iterator si; for (si = _done.begin(); si != _done.end(); ++si) { PT(EggPrimitive) egg_prim = get_prim(*si); - if (egg_prim != (EggPrimitive *)NULL) { + if (egg_prim != nullptr) { output_children->add_child(egg_prim); } } @@ -164,7 +164,7 @@ clear() { _verts.clear(); _edges.clear(); _strip_index = 0; - _vertex_pool = NULL; + _vertex_pool = nullptr; _color_sheets.clear(); } @@ -197,7 +197,7 @@ add_polygon(const EggPolygon *egg_poly, EggMesherStrip::MesherOrigin origin) { this_poly = DCAST(EggPolygon, *ci); } - if (_vertex_pool == NULL) { + if (_vertex_pool == nullptr) { _vertex_pool = this_poly->get_pool(); } else { nassertr(_vertex_pool == this_poly->get_pool(), false); @@ -557,7 +557,7 @@ build_sheets() { int num_rows_b = 0; int first_row_id_b = first_row_id; double avg_length_b; - if (edge_b != NULL) { + if (edge_b != nullptr) { (*best).measure_sheet(edge_b, true, num_prims_b, num_rows_b, first_row_id_b, 0, 0); first_row_id += num_rows_b; @@ -565,7 +565,7 @@ build_sheets() { } // Which sheet is better? - if (edge_b != NULL && avg_length_b >= avg_length_a) { + if (edge_b != nullptr && avg_length_b >= avg_length_a) { // Sheet b. That's easy. (*best).cut_sheet(first_row_id_b, true, _vertex_pool); diff --git a/panda/src/egg/eggMesherEdge.I b/panda/src/egg/eggMesherEdge.I index 9d83e936e0..abad388cc0 100644 --- a/panda/src/egg/eggMesherEdge.I +++ b/panda/src/egg/eggMesherEdge.I @@ -17,7 +17,7 @@ */ INLINE EggMesherEdge:: EggMesherEdge(int vi_a, int vi_b) : _vi_a(vi_a), _vi_b(vi_b) { - _opposite = NULL; + _opposite = nullptr; } /** diff --git a/panda/src/egg/eggMesherEdge.cxx b/panda/src/egg/eggMesherEdge.cxx index a37d6785f7..1b24891b4e 100644 --- a/panda/src/egg/eggMesherEdge.cxx +++ b/panda/src/egg/eggMesherEdge.cxx @@ -61,7 +61,7 @@ output(ostream &out) const { out << " " << (*si)->_index; } - if (_opposite!=NULL) { + if (_opposite!=nullptr) { out << " opposite " << _opposite->_strips.size() << " strips:"; diff --git a/panda/src/egg/eggMesherFanMaker.cxx b/panda/src/egg/eggMesherFanMaker.cxx index efbfad25a2..51396dd32e 100644 --- a/panda/src/egg/eggMesherFanMaker.cxx +++ b/panda/src/egg/eggMesherFanMaker.cxx @@ -24,7 +24,7 @@ EggMesherFanMaker(int vertex, EggMesherStrip *tri, EggMesher *mesher) { _vertex = vertex; const EggMesherEdge *edge = tri->find_opposite_edge(vertex); - if (edge != (const EggMesherEdge *)NULL) { + if (edge != nullptr) { _edges.push_back(edge); } _strips.push_back(tri); @@ -73,8 +73,8 @@ join(EggMesherFanMaker &other) { const EggMesherEdge *my_back = _edges.back(); const EggMesherEdge *other_front = other._edges.front(); - nassertr(my_back != (EggMesherEdge *)NULL && - other_front != (EggMesherEdge *)NULL, false); + nassertr(my_back != nullptr && + other_front != nullptr, false); int my_back_b = my_back->_vi_b; int other_front_a = other_front->_vi_a; @@ -88,8 +88,8 @@ join(EggMesherFanMaker &other) { const EggMesherEdge *my_front = _edges.front(); const EggMesherEdge *other_back = other._edges.back(); - nassertr(my_front != (EggMesherEdge *)NULL && - other_back != (EggMesherEdge *)NULL, false); + nassertr(my_front != nullptr && + other_back != nullptr, false); int my_front_a = my_front->_vi_a; int other_back_b = other_back->_vi_b; diff --git a/panda/src/egg/eggMesherStrip.cxx b/panda/src/egg/eggMesherStrip.cxx index 5059105ceb..cec01dfe36 100644 --- a/panda/src/egg/eggMesherStrip.cxx +++ b/panda/src/egg/eggMesherStrip.cxx @@ -248,15 +248,15 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, // the best. EggMesherEdge::Strips &strips = (*ei)->_strips; - EggMesherStrip *mate = NULL; + EggMesherStrip *mate = nullptr; for (si = strips.begin(); si != strips.end(); ++si) { if ((*si)->_row_id < first_row_id) { - if (mate == NULL || pick_sheet_mate(**si, *mate)) { + if (mate == nullptr || pick_sheet_mate(**si, *mate)) { mate = *si; } } } - if (mate!=NULL) { + if (mate!=nullptr) { mate->measure_sheet(*ei, secondary, num_prims, num_rows, first_row_id, this_row_id, this_row_distance + secondary); @@ -281,15 +281,15 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, // Here's the edge. Same drill as above. EggMesherEdge::Strips &strips = (*ei)->_strips; - EggMesherStrip *mate = NULL; + EggMesherStrip *mate = nullptr; for (si = strips.begin(); si != strips.end(); ++si) { if ((*si)->_row_id < first_row_id) { - if (mate == NULL || pick_sheet_mate(**si, *mate)) { + if (mate == nullptr || pick_sheet_mate(**si, *mate)) { mate = *si; } } } - if (mate != NULL) { + if (mate != nullptr) { mate->measure_sheet(*ei, false, num_prims, num_rows, first_row_id, this_row_id, this_row_distance); } @@ -428,15 +428,15 @@ find_ideal_mate(EggMesherStrip *&mate, EggMesherEdge *&common_edge, const EggVertexPool *vertex_pool) { Edges::iterator ei; - mate = NULL; - common_edge = NULL; + mate = nullptr; + common_edge = nullptr; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { EggMesherEdge::Strips &strips = (*ei)->_strips; EggMesherEdge::Strips::iterator si; for (si = strips.begin(); si != strips.end(); ++si) { if (*si != this) { - if (mate==NULL || pick_mate(**si, *mate, **ei, *common_edge, + if (mate==nullptr || pick_mate(**si, *mate, **ei, *common_edge, vertex_pool)) { mate = *si; common_edge = *ei; @@ -445,7 +445,7 @@ find_ideal_mate(EggMesherStrip *&mate, EggMesherEdge *&common_edge, } } - return (mate!=NULL); + return (mate!=nullptr); } @@ -898,7 +898,7 @@ find_opposite_edge(int vi) const { } } - return NULL; + return nullptr; } /** @@ -918,7 +918,7 @@ find_opposite_edge(const EggMesherEdge *edge) const { } } - return NULL; + return nullptr; } /** @@ -938,7 +938,7 @@ find_adjacent_edge(const EggMesherEdge *edge) const { } } - return NULL; + return nullptr; } /** diff --git a/panda/src/egg/eggMorphList.I b/panda/src/egg/eggMorphList.I index 5b665247da..deded17c7e 100644 --- a/panda/src/egg/eggMorphList.I +++ b/panda/src/egg/eggMorphList.I @@ -97,7 +97,7 @@ compare_to(const EggMorphList &other, double threshold) const { * */ template -INLINE TYPENAME EggMorphList::iterator EggMorphList:: +INLINE typename EggMorphList::iterator EggMorphList:: begin() { return _morphs.begin(); } @@ -106,7 +106,7 @@ begin() { * */ template -INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: +INLINE typename EggMorphList::const_iterator EggMorphList:: begin() const { return _morphs.begin(); } @@ -115,7 +115,7 @@ begin() const { * */ template -INLINE TYPENAME EggMorphList::iterator EggMorphList:: +INLINE typename EggMorphList::iterator EggMorphList:: end() { return _morphs.end(); } @@ -124,7 +124,7 @@ end() { * */ template -INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: +INLINE typename EggMorphList::const_iterator EggMorphList:: end() const { return _morphs.end(); } @@ -133,7 +133,7 @@ end() const { * */ template -INLINE TYPENAME EggMorphList::size_type EggMorphList:: +INLINE typename EggMorphList::size_type EggMorphList:: size() const { return _morphs.size(); } @@ -155,10 +155,10 @@ empty() const { * to *be* a set, but we cannot export STL sets from a Windows DLL. */ template -pair::iterator, bool> EggMorphList:: +pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { pair result; - TYPENAME 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/eggMorphList.h b/panda/src/egg/eggMorphList.h index c6e86388ba..581e53d9e9 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -31,9 +31,9 @@ private: typedef epvector Morphs; public: - typedef TYPENAME Morphs::iterator iterator; - typedef TYPENAME Morphs::const_iterator const_iterator; - typedef TYPENAME Morphs::size_type size_type; + typedef typename Morphs::iterator iterator; + typedef typename Morphs::const_iterator const_iterator; + typedef typename Morphs::size_type size_type; INLINE EggMorphList(); INLINE EggMorphList(const EggMorphList ©); diff --git a/panda/src/egg/eggNameUniquifier.cxx b/panda/src/egg/eggNameUniquifier.cxx index 0e50320d45..34a7123d48 100644 --- a/panda/src/egg/eggNameUniquifier.cxx +++ b/panda/src/egg/eggNameUniquifier.cxx @@ -89,7 +89,7 @@ uniquify(EggNode *node) { EggGroupNode::iterator ci; for (ci = group->begin(); ci != group->end(); ++ci) { EggNode *child = (*ci); - nassertv(child != (EggNode *)NULL); + nassertv(child != nullptr); uniquify(child); } } @@ -104,14 +104,14 @@ get_node(const string &category, const string &name) const { Categories::const_iterator ci; ci = _categories.find(category); if (ci == _categories.end()) { - return (EggNode *)NULL; + return nullptr; } const UsedNames &names = (*ci).second; UsedNames::const_iterator ni; ni = names.find(name); if (ni == names.end()) { - return (EggNode *)NULL; + return nullptr; } return (*ni).second; diff --git a/panda/src/egg/eggNameUniquifier.h b/panda/src/egg/eggNameUniquifier.h index d28457a97d..72a05698f6 100644 --- a/panda/src/egg/eggNameUniquifier.h +++ b/panda/src/egg/eggNameUniquifier.h @@ -68,7 +68,7 @@ PUBLISHED: EggNode *get_node(const string &category, const string &name) const; bool has_name(const string &category, const string &name) const; bool add_name(const string &category, const string &name, - EggNode *node = NULL); + EggNode *node = nullptr); virtual string get_category(EggNode *node)=0; virtual string filter_name(EggNode *node); diff --git a/panda/src/egg/eggNode.I b/panda/src/egg/eggNode.I index 08f2f8989b..596d61b826 100644 --- a/panda/src/egg/eggNode.I +++ b/panda/src/egg/eggNode.I @@ -16,7 +16,7 @@ */ INLINE EggNode:: EggNode(const string &name) : EggNamedObject(name) { - _parent = NULL; + _parent = nullptr; _depth = 0; _under_flags = 0; } @@ -26,7 +26,7 @@ EggNode(const string &name) : EggNamedObject(name) { */ INLINE EggNode:: EggNode(const EggNode ©) : EggNamedObject(copy) { - _parent = NULL; + _parent = nullptr; _depth = 0; _under_flags = 0; } @@ -106,7 +106,7 @@ is_local_coord() const { */ INLINE const LMatrix4d &EggNode:: get_vertex_frame() const { - if (_vertex_frame == (LMatrix4d *)NULL) { + if (_vertex_frame == nullptr) { return LMatrix4d::ident_mat(); } else { return *_vertex_frame; @@ -120,7 +120,7 @@ get_vertex_frame() const { */ INLINE const LMatrix4d &EggNode:: get_node_frame() const { - if (_node_frame == (LMatrix4d *)NULL) { + if (_node_frame == nullptr) { return LMatrix4d::ident_mat(); } else { return *_node_frame; @@ -133,7 +133,7 @@ get_node_frame() const { */ INLINE const LMatrix4d &EggNode:: get_vertex_frame_inv() const { - if (_vertex_frame_inv == (LMatrix4d *)NULL) { + if (_vertex_frame_inv == nullptr) { return LMatrix4d::ident_mat(); } else { return *_vertex_frame_inv; @@ -147,7 +147,7 @@ get_vertex_frame_inv() const { */ INLINE const LMatrix4d &EggNode:: get_node_frame_inv() const { - if (_node_frame_inv == (LMatrix4d *)NULL) { + if (_node_frame_inv == nullptr) { return LMatrix4d::ident_mat(); } else { return *_node_frame_inv; @@ -164,7 +164,7 @@ get_node_frame_inv() const { */ INLINE const LMatrix4d &EggNode:: get_vertex_to_node() const { - if (_vertex_to_node == (LMatrix4d *)NULL) { + if (_vertex_to_node == nullptr) { return LMatrix4d::ident_mat(); } else { return *_vertex_to_node; @@ -181,7 +181,7 @@ get_vertex_to_node() const { */ INLINE const LMatrix4d &EggNode:: get_node_to_vertex() const { - if (_node_to_vertex == (LMatrix4d *)NULL) { + if (_node_to_vertex == nullptr) { return LMatrix4d::ident_mat(); } else { return *_node_to_vertex; diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index 016ae01994..531f57f2c0 100644 --- a/panda/src/egg/eggNode.cxx +++ b/panda/src/egg/eggNode.cxx @@ -83,9 +83,9 @@ is_anim_matrix() const { */ EggRenderMode *EggNode:: determine_alpha_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_alpha_mode(); } @@ -98,9 +98,9 @@ determine_alpha_mode() { */ EggRenderMode *EggNode:: determine_depth_write_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_depth_write_mode(); } @@ -113,9 +113,9 @@ determine_depth_write_mode() { */ EggRenderMode *EggNode:: determine_depth_test_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_depth_test_mode(); } @@ -128,9 +128,9 @@ determine_depth_test_mode() { */ EggRenderMode *EggNode:: determine_visibility_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_visibility_mode(); } @@ -143,9 +143,9 @@ determine_visibility_mode() { */ EggRenderMode *EggNode:: determine_depth_offset() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_depth_offset(); } @@ -158,9 +158,9 @@ determine_depth_offset() { */ EggRenderMode *EggNode:: determine_draw_order() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_draw_order(); } @@ -172,9 +172,9 @@ determine_draw_order() { */ EggRenderMode *EggNode:: determine_bin() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_bin(); } @@ -189,7 +189,7 @@ determine_bin() { */ bool EggNode:: determine_indexed() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. return false; } @@ -206,7 +206,7 @@ determine_indexed() { */ bool EggNode:: determine_decal() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. return false; } @@ -252,7 +252,7 @@ parse_egg(const string &egg_syntax) { */ void EggNode:: test_under_integrity() const { - if (_parent == NULL) { + if (_parent == nullptr) { // If we have no parent, everything should be zero. nassertv(_depth == 0); nassertv(_under_flags == 0); @@ -303,15 +303,15 @@ egg_start_parse_body() { void EggNode:: update_under(int depth_offset) { int depth; - if (_parent == NULL) { + if (_parent == nullptr) { depth = 0; _under_flags = 0; - _vertex_frame = NULL; - _node_frame = NULL; - _vertex_frame_inv = NULL; - _node_frame_inv = NULL; - _vertex_to_node = NULL; - _node_to_vertex = NULL; + _vertex_frame = nullptr; + _node_frame = nullptr; + _vertex_frame_inv = nullptr; + _node_frame_inv = nullptr; + _vertex_to_node = nullptr; + _node_to_vertex = nullptr; } else { _parent->test_ref_count_integrity(); depth = _parent->_depth + 1; diff --git a/panda/src/egg/eggObject.cxx b/panda/src/egg/eggObject.cxx index b75d2ea64f..0d642ee356 100644 --- a/panda/src/egg/eggObject.cxx +++ b/panda/src/egg/eggObject.cxx @@ -96,7 +96,7 @@ get_user_data(TypeHandle type) const { if (ui != _user_data.end()) { return (*ui).second; } - return NULL; + return nullptr; } /** @@ -149,5 +149,5 @@ clear_user_data(TypeHandle type) { */ EggTransform *EggObject:: as_transform() { - return NULL; + return nullptr; } diff --git a/panda/src/egg/eggParameters.cxx b/panda/src/egg/eggParameters.cxx index 14b63ba8ea..b9fc709fcd 100644 --- a/panda/src/egg/eggParameters.cxx +++ b/panda/src/egg/eggParameters.cxx @@ -17,26 +17,3 @@ static EggParameters default_egg_parameters; EggParameters *egg_parameters = &default_egg_parameters; - - -/** - * Initializes all the parameters with default values. - */ -EggParameters:: -EggParameters() { - _pos_threshold = 0.0001; - _normal_threshold = 0.0001; - _uv_threshold = 0.0001; - _color_threshold = 1.0/256.0; - - _table_threshold = 0.0001; -} - - -/** - * - */ -EggParameters:: -EggParameters(const EggParameters &other) { - memcpy(this, &other, sizeof(EggParameters)); -} diff --git a/panda/src/egg/eggParameters.h b/panda/src/egg/eggParameters.h index 36bd1e48f6..93b1aff8b0 100644 --- a/panda/src/egg/eggParameters.h +++ b/panda/src/egg/eggParameters.h @@ -31,28 +31,27 @@ */ class EXPCL_PANDAEGG EggParameters { public: - EggParameters(); - EggParameters(const EggParameters ©); + constexpr EggParameters() = default; // The per-component difference below which two vertices are deemed to be at // the same position. - double _pos_threshold; + double _pos_threshold = 0.0001; // The per-component difference below which two vertices are deemed to have // the same normal. - double _normal_threshold; + double _normal_threshold = 0.0001; // The per-component difference below which two vertices are deemed to have // the same texture coordinates. - double _uv_threshold; + double _uv_threshold = 0.0001; // The per-component difference below which two vertices are deemed to have // the same color. - PN_stdfloat _color_threshold; + PN_stdfloat _color_threshold = 1.0/256.0; // The per-component difference below which two anim table values are deemed // to be equivalent. - double _table_threshold; + double _table_threshold = 0.0001; }; extern EXPCL_PANDAEGG EggParameters *egg_parameters; diff --git a/panda/src/egg/eggPolygon.cxx b/panda/src/egg/eggPolygon.cxx index 2d6a3378c7..cb783925e1 100644 --- a/panda/src/egg/eggPolygon.cxx +++ b/panda/src/egg/eggPolygon.cxx @@ -146,7 +146,7 @@ is_planar() const { PT(EggPolygon) EggPolygon:: triangulate_in_place(bool convex_also) { EggGroupNode *parent = get_parent(); - nassertr(parent != (EggGroupNode *)NULL, this); + nassertr(parent != nullptr, this); PT(EggPolygon) save_me = this; parent->remove_child(this); diff --git a/panda/src/egg/eggPrimitive.I b/panda/src/egg/eggPrimitive.I index 8ae8a1eecf..c90c983001 100644 --- a/panda/src/egg/eggPrimitive.I +++ b/panda/src/egg/eggPrimitive.I @@ -136,7 +136,7 @@ has_texture() const { INLINE bool EggPrimitive:: has_texture(EggTexture *texture) const { PT_EggTexture t = texture; - return (::find(_textures.begin(), _textures.end(), t) != _textures.end()); + return (std::find(_textures.begin(), _textures.end(), t) != _textures.end()); } /** @@ -148,7 +148,7 @@ has_texture(EggTexture *texture) const { */ INLINE EggTexture *EggPrimitive:: get_texture() const { - return has_texture() ? get_texture(0) : (EggTexture *)NULL; + return has_texture() ? get_texture(0) : nullptr; } /** @@ -184,7 +184,7 @@ get_num_textures() const { */ INLINE EggTexture *EggPrimitive:: get_texture(int n) const { - nassertr(n >= 0 && n < (int)_textures.size(), NULL); + nassertr(n >= 0 && n < (int)_textures.size(), nullptr); return _textures[n]; } @@ -202,7 +202,7 @@ set_material(EggMaterial *material) { */ INLINE void EggPrimitive:: clear_material() { - _material = (EggMaterial *)NULL; + _material = nullptr; } /** @@ -221,7 +221,7 @@ get_material() const { */ INLINE bool EggPrimitive:: has_material() const { - return _material != (EggMaterial *)NULL; + return _material != nullptr; } @@ -299,7 +299,7 @@ size() const { */ INLINE EggVertex *EggPrimitive:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)size(), NULL); + nassertr(index >= 0 && index < (int)size(), nullptr); return *(begin() + index); } @@ -388,7 +388,7 @@ insert_vertex(size_t index, EggVertex *vertex) { */ INLINE EggVertex *EggPrimitive:: get_vertex(size_t index) const { - nassertr(index < size(), NULL); + nassertr(index < size(), nullptr); return *(begin() + index); } @@ -398,5 +398,5 @@ get_vertex(size_t index) const { */ INLINE EggVertexPool *EggPrimitive:: get_pool() const { - return empty() ? (EggVertexPool *)NULL : _vertices.front()->get_pool(); + return empty() ? nullptr : _vertices.front()->get_pool(); } diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index e3eb0b16d7..ad0b464c30 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -37,9 +37,9 @@ determine_alpha_mode() { } EggRenderMode *result = EggNode::determine_alpha_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { EggTexture *egg_tex = get_texture(i); // We only want to consider the alpha mode on those textures that can @@ -70,9 +70,9 @@ determine_depth_write_mode() { } EggRenderMode *result = EggNode::determine_depth_write_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->get_depth_write_mode() != DWM_unspecified) { result = get_texture(i); } @@ -94,9 +94,9 @@ determine_depth_test_mode() { } EggRenderMode *result = EggNode::determine_depth_test_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->get_depth_test_mode() != DTM_unspecified) { result = get_texture(i); } @@ -118,9 +118,9 @@ determine_visibility_mode() { } EggRenderMode *result = EggNode::determine_visibility_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->get_visibility_mode() != VM_unspecified) { result = get_texture(i); } @@ -142,9 +142,9 @@ determine_depth_offset() { } EggRenderMode *result = EggNode::determine_depth_offset(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->has_depth_offset()) { result = get_texture(i); } @@ -166,9 +166,9 @@ determine_draw_order() { } EggRenderMode *result = EggNode::determine_draw_order(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->has_draw_order()) { result = get_texture(i); } @@ -190,9 +190,9 @@ determine_bin() { } EggRenderMode *result = EggNode::determine_bin(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->has_bin()) { result = get_texture(i); } @@ -374,7 +374,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -406,7 +406,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -644,7 +644,7 @@ erase(iterator first, iterator last) { EggPrimitive::iterator EggPrimitive:: find(EggVertex *vertex) { PT_EggVertex vpt = vertex; - return ::find(begin(), end(), vpt); + return std::find(begin(), end(), vpt); } @@ -670,7 +670,7 @@ add_vertex(EggVertex *vertex) { EggVertex *EggPrimitive:: remove_vertex(EggVertex *vertex) { PT_EggVertex vpt = vertex; - iterator i = ::find(begin(), end(), vpt); + iterator i = std::find(begin(), end(), vpt); if (i == end()) { return PT_EggVertex(); } else { @@ -854,7 +854,7 @@ write_body(ostream &out, int indent_level) const { EggVertexPool *pool = get_pool(); // Make sure the vertices belong to some vertex pool. - nassertv(pool != NULL); + nassertv(pool != nullptr); // Make sure the vertex pool is named. nassertv(pool->has_name()); @@ -988,7 +988,7 @@ r_apply_texmats(EggTextureCollection &textures) { EggVertex *vertex = get_vertex(i); const EggVertexUV *uv_obj = vertex->get_uv_obj(uv_name); - if (uv_obj != (EggVertexUV *)NULL) { + if (uv_obj != nullptr) { EggVertex new_vertex(*vertex); PT(EggVertexUV) new_uv_obj = new EggVertexUV(*uv_obj); LTexCoord3d uvw = uv_obj->get_uvw() * mat; diff --git a/panda/src/egg/eggTextureCollection.cxx b/panda/src/egg/eggTextureCollection.cxx index f53c9d0ddc..38ee134048 100644 --- a/panda/src/egg/eggTextureCollection.cxx +++ b/panda/src/egg/eggTextureCollection.cxx @@ -99,7 +99,7 @@ get_num_textures() const { */ EggTexture *EggTextureCollection:: get_texture(int index) const { - nassertr(index >= 0 && index < (int)_ordered_textures.size(), NULL); + nassertr(index >= 0 && index < (int)_ordered_textures.size(), nullptr); return _ordered_textures[index]; } @@ -465,7 +465,7 @@ find_tref(const string &tref_name) const { } } - return (EggTexture *)NULL; + return nullptr; } /** @@ -485,5 +485,5 @@ find_filename(const Filename &filename) const { } } - return (EggTexture *)NULL; + return nullptr; } diff --git a/panda/src/egg/eggTransform.I b/panda/src/egg/eggTransform.I index bff92d6194..e6bccb6819 100644 --- a/panda/src/egg/eggTransform.I +++ b/panda/src/egg/eggTransform.I @@ -19,10 +19,10 @@ Component(EggTransform::ComponentType type, double number) : _type(type), _number(number) { - _vec2 = (LVecBase2d *)NULL; - _vec3 = (LVecBase3d *)NULL; - _mat3 = (LMatrix3d *)NULL; - _mat4 = (LMatrix4d *)NULL; + _vec2 = nullptr; + _vec3 = nullptr; + _mat3 = nullptr; + _mat4 = nullptr; } /** @@ -33,20 +33,20 @@ Component(const EggTransform::Component ©) : _type(copy._type), _number(copy._number) { - _vec2 = (LVecBase2d *)NULL; - _vec3 = (LVecBase3d *)NULL; - _mat3 = (LMatrix3d *)NULL; - _mat4 = (LMatrix4d *)NULL; - if (copy._vec2 != (LVecBase2d *)NULL) { + _vec2 = nullptr; + _vec3 = nullptr; + _mat3 = nullptr; + _mat4 = nullptr; + if (copy._vec2 != nullptr) { _vec2 = new LVector2d(*copy._vec2); } - if (copy._vec3 != (LVecBase3d *)NULL) { + if (copy._vec3 != nullptr) { _vec3 = new LVector3d(*copy._vec3); } - if (copy._mat3 != (LMatrix3d *)NULL) { + if (copy._mat3 != nullptr) { _mat3 = new LMatrix3d(*copy._mat3); } - if (copy._mat4 != (LMatrix4d *)NULL) { + if (copy._mat4 != nullptr) { _mat4 = new LMatrix4d(*copy._mat4); } } @@ -58,32 +58,32 @@ INLINE void EggTransform::Component:: operator = (const EggTransform::Component ©) { _type = copy._type; _number = copy._number; - if (_vec2 != (LVecBase2d *)NULL) { + if (_vec2 != nullptr) { delete _vec2; - _vec2 = (LVecBase2d *)NULL; + _vec2 = nullptr; } - if (_vec3 != (LVecBase3d *)NULL) { + if (_vec3 != nullptr) { delete _vec3; - _vec3 = (LVecBase3d *)NULL; + _vec3 = nullptr; } - if (_mat3 != (LMatrix3d *)NULL) { + if (_mat3 != nullptr) { delete _mat3; - _mat3 = (LMatrix3d *)NULL; + _mat3 = nullptr; } - if (_mat4 != (LMatrix4d *)NULL) { + if (_mat4 != nullptr) { delete _mat4; - _mat4 = (LMatrix4d *)NULL; + _mat4 = nullptr; } - if (copy._vec2 != (LVecBase2d *)NULL) { + if (copy._vec2 != nullptr) { _vec2 = new LVecBase2d(*copy._vec2); } - if (copy._vec3 != (LVecBase3d *)NULL) { + if (copy._vec3 != nullptr) { _vec3 = new LVecBase3d(*copy._vec3); } - if (copy._mat3 != (LMatrix3d *)NULL) { + if (copy._mat3 != nullptr) { _mat3 = new LMatrix3d(*copy._mat3); } - if (copy._mat4 != (LMatrix4d *)NULL) { + if (copy._mat4 != nullptr) { _mat4 = new LMatrix4d(*copy._mat4); } } @@ -93,16 +93,16 @@ operator = (const EggTransform::Component ©) { */ INLINE EggTransform::Component:: ~Component() { - if (_vec2 != (LVecBase2d *)NULL) { + if (_vec2 != nullptr) { delete _vec2; } - if (_vec3 != (LVecBase3d *)NULL) { + if (_vec3 != nullptr) { delete _vec3; } - if (_mat3 != (LMatrix3d *)NULL) { + if (_mat3 != nullptr) { delete _mat3; } - if (_mat4 != (LMatrix4d *)NULL) { + if (_mat4 != nullptr) { delete _mat4; } } @@ -259,7 +259,7 @@ get_component_number(int n) const { INLINE const LVecBase2d &EggTransform:: get_component_vec2(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LVector2d::zero()); - nassertr(_components[n]._vec2 != (LVecBase2d *)NULL, LVector2d::zero()); + nassertr(_components[n]._vec2 != nullptr, LVector2d::zero()); return *_components[n]._vec2; } @@ -271,7 +271,7 @@ get_component_vec2(int n) const { INLINE const LVecBase3d &EggTransform:: get_component_vec3(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LVector3d::zero()); - nassertr(_components[n]._vec3 != (LVecBase3d *)NULL, LVector3d::zero()); + nassertr(_components[n]._vec3 != nullptr, LVector3d::zero()); return *_components[n]._vec3; } @@ -282,7 +282,7 @@ get_component_vec3(int n) const { INLINE const LMatrix3d &EggTransform:: get_component_mat3(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LMatrix3d::ident_mat()); - nassertr(_components[n]._mat3 != (LMatrix3d *)NULL, LMatrix3d::ident_mat()); + nassertr(_components[n]._mat3 != nullptr, LMatrix3d::ident_mat()); return *_components[n]._mat3; } @@ -293,7 +293,7 @@ get_component_mat3(int n) const { INLINE const LMatrix4d &EggTransform:: get_component_mat4(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LMatrix4d::ident_mat()); - nassertr(_components[n]._mat4 != (LMatrix4d *)NULL, LMatrix4d::ident_mat()); + nassertr(_components[n]._mat4 != nullptr, LMatrix4d::ident_mat()); return *_components[n]._mat4; } diff --git a/panda/src/egg/eggUtilities.I b/panda/src/egg/eggUtilities.I index 04430db8f5..4efae4df81 100644 --- a/panda/src/egg/eggUtilities.I +++ b/panda/src/egg/eggUtilities.I @@ -57,7 +57,7 @@ split_vertex(EggVertex *vert, const FunctionObject &sequence) { typedef pvector Prims; Prims prims; prims.reserve(vert->pref_size()); - copy(vert->pref_begin(), vert->pref_end(), back_inserter(prims)); + std::copy(vert->pref_begin(), vert->pref_end(), std::back_inserter(prims)); // Now walk through the list of primitives that reference this vertex. Prims::const_iterator pri; @@ -69,7 +69,7 @@ split_vertex(EggVertex *vert, const FunctionObject &sequence) { if (seq != 0) { // Here's a new sequence number! Have we already defined it? - EggVertex *new_vert = NULL; + EggVertex *new_vert = nullptr; Sequences::const_iterator si = _sequences.find(seq); diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index 7663fd4eb3..5272a9f034 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -34,7 +34,7 @@ TypeHandle EggVertex::_type_handle; */ EggVertex:: EggVertex() { - _pool = NULL; + _pool = nullptr; _forward_reference = false; _index = -1; _external_index = -1; @@ -59,7 +59,7 @@ EggVertex(const EggVertex ©) _uv_map(copy._uv_map), _aux_map(copy._aux_map) { - _pool = NULL; + _pool = nullptr; _forward_reference = false; _index = -1; test_pref_integrity(); @@ -96,7 +96,7 @@ EggVertex:: ~EggVertex() { // We should never destruct a vertex while it still thinks it belongs to a // VertexPool. If we do, we've probably lost a reference count somewhere. - nassertv(_pool == NULL); + nassertv(_pool == nullptr); // Also, a vertex shouldn't be destructed while it's being referenced by a // group or a primitive, for the same reason. @@ -244,7 +244,7 @@ get_uv_obj(const string &name) const { if (ui != _uv_map.end()) { return (*ui).second; } - return NULL; + return nullptr; } /** @@ -259,7 +259,7 @@ get_aux_obj(const string &name) const { if (xi != _aux_map.end()) { return (*xi).second; } - return NULL; + return nullptr; } /** @@ -278,7 +278,7 @@ modify_uv_obj(const string &name) { return (*ui).second; } - return NULL; + return nullptr; } /** @@ -297,7 +297,7 @@ modify_aux_obj(const string &name) { return (*xi).second; } - return NULL; + return nullptr; } /** @@ -346,12 +346,12 @@ clear_aux(const string &name) { PT(EggVertex) EggVertex:: make_average(const EggVertex *first, const EggVertex *second) { PT(EggVertexPool) pool = first->get_pool(); - nassertr(pool == second->get_pool(), NULL); + nassertr(pool == second->get_pool(), nullptr); // If both vertices are in a pool, the new vertex will be part of the pool // as well. PT(EggVertex) middle; - if (pool == NULL) { + if (pool == nullptr) { middle = new EggVertex; } else { middle = pool->make_new_vertex(); @@ -375,7 +375,7 @@ make_average(const EggVertex *first, const EggVertex *second) { const EggVertexUV *first_uv = it->second; const EggVertexUV *second_uv = second->get_uv_obj(it->first); - if (first_uv != NULL && second_uv != NULL) { + if (first_uv != nullptr && second_uv != nullptr) { middle->set_uv_obj(EggVertexUV::make_average(first_uv, second_uv)); } } @@ -386,7 +386,7 @@ make_average(const EggVertex *first, const EggVertex *second) { const EggVertexAux *first_aux = ai->second; const EggVertexAux *second_aux = second->get_aux_obj(ai->first); - if (first_aux != NULL && second_aux != NULL) { + if (first_aux != nullptr && second_aux != nullptr) { middle->set_aux_obj(EggVertexAux::make_average(first_aux, second_aux)); } } @@ -755,7 +755,7 @@ copy_grefs_from(const EggVertex &other) { for (gri = other.gref_begin(); gri != other.gref_end(); ++gri) { EggGroup *group = *gri; - nassertv(group != NULL); + nassertv(group != nullptr); group->ref_vertex(this, group->get_vertex_membership(&other)); } @@ -771,7 +771,7 @@ clear_grefs() { GroupRef::const_iterator gri; for (gri = gref_copy.begin(); gri != gref_copy.end(); ++gri) { EggGroup *group = *gri; - nassertv(group != NULL); + nassertv(group != nullptr); group->unref_vertex(this); } @@ -836,7 +836,7 @@ test_gref_integrity() const { for (gri = gref_begin(); gri != gref_end(); ++gri) { EggGroup *group = *gri; - nassertv(group != NULL); + nassertv(group != nullptr); group->test_ref_count_integrity(); double membership = group->get_vertex_membership(this); @@ -856,7 +856,7 @@ test_pref_integrity() const { for (pri = pref_begin(); pri != pref_end(); ++pri) { EggPrimitive *prim = *pri; - nassertv(prim != NULL); + nassertv(prim != nullptr); prim->test_ref_count_integrity(); EggPrimitive::iterator vi; @@ -872,7 +872,7 @@ test_pref_integrity() const { */ void EggVertex:: output(ostream &out) const { - if (get_pool() == NULL) { + if (get_pool() == nullptr) { out << "(null):" << get_index(); } else { out << get_pool()->get_name() << ":" << get_index(); diff --git a/panda/src/egg/eggVertexAux.cxx b/panda/src/egg/eggVertexAux.cxx index ec6528e380..6b12ee538b 100644 --- a/panda/src/egg/eggVertexAux.cxx +++ b/panda/src/egg/eggVertexAux.cxx @@ -62,7 +62,7 @@ EggVertexAux:: */ PT(EggVertexAux) EggVertexAux:: make_average(const EggVertexAux *first, const EggVertexAux *second) { - nassertr(first->get_name() == second->get_name(), NULL); + nassertr(first->get_name() == second->get_name(), nullptr); LVecBase4d aux = (first->_aux + second->_aux) / 2; return new EggVertexAux(first->get_name(), aux); diff --git a/panda/src/egg/eggVertexPool.I b/panda/src/egg/eggVertexPool.I index 3a13278063..8e26c30fb7 100644 --- a/panda/src/egg/eggVertexPool.I +++ b/panda/src/egg/eggVertexPool.I @@ -17,7 +17,7 @@ */ INLINE bool EggVertexPool:: has_vertex(int index) const { - return get_vertex(index) != (EggVertex *)NULL; + return get_vertex(index) != nullptr; } /** diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index f1783d8158..e3b3cad248 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -63,7 +63,7 @@ EggVertexPool:: nassertv(vertex->_pool == this); nassertv(vertex->get_index() == index); - vertex->_pool = NULL; + vertex->_pool = nullptr; vertex->_index = -1; } @@ -114,11 +114,11 @@ get_vertex(int index) const { IndexVertices::const_iterator ivi = _index_vertices.find(index); if (ivi == _index_vertices.end()) { - return NULL; + return nullptr; } else { EggVertex *vertex = (*ivi).second; if (vertex->is_forward_reference()) { - return NULL; + return nullptr; } return vertex; } @@ -133,7 +133,7 @@ get_vertex(int index) const { */ EggVertex *EggVertexPool:: get_forward_vertex(int index) { - nassertr(index >= 0, NULL); + nassertr(index >= 0, nullptr); IndexVertices::const_iterator ivi = _index_vertices.find(index); @@ -421,13 +421,13 @@ add_vertex(EggVertex *vertex, int index) { PT(EggVertex) vertex_keep = vertex; // Don't try to add a vertex while it still belongs to another pool. - nassertr(vertex->_pool == NULL, NULL); + nassertr(vertex->_pool == nullptr, nullptr); if (index == -1) { index = get_highest_index() + 1; } // Always supply an index number >= 0. - nassertr(index >= 0, NULL); + nassertr(index >= 0, nullptr); // Check for a forward reference. IndexVertices::const_iterator ivi = _index_vertices.find(index); @@ -443,7 +443,7 @@ add_vertex(EggVertex *vertex, int index) { } // Oops, you duplicated a vertex index. - nassertr(false, NULL); + nassertr(false, nullptr); } _unique_vertices.insert(vertex); @@ -495,7 +495,7 @@ find_matching_vertex(const EggVertex ©) { } // No matching vertex. - return NULL; + return nullptr; } @@ -550,7 +550,7 @@ remove_vertex(EggVertex *vertex) { _unique_vertices.erase(uvi); - vertex->_pool = NULL; + vertex->_pool = nullptr; } /** @@ -572,7 +572,7 @@ remove_unused_vertices() { if (vertex->pref_size() == 0) { // This vertex is not used. Don't add it to the new lists. vertex->clear_grefs(); - vertex->_pool = NULL; + vertex->_pool = nullptr; num_removed++; } else { @@ -598,7 +598,7 @@ remove_unused_vertices() { orig_vertex->test_pref_integrity(); nassertr(vertex->pref_size() == 0, 0); vertex->clear_grefs(); - vertex->_pool = NULL; + vertex->_pool = nullptr; num_removed++; } else { @@ -675,7 +675,7 @@ transform(const LMatrix4d &mat) { typedef pvector Verts; Verts verts; verts.reserve(size()); - copy(begin(), end(), back_inserter(verts)); + std::copy(begin(), end(), std::back_inserter(verts)); Verts::const_iterator vi; for (vi = verts.begin(); vi != verts.end(); ++vi) { @@ -742,7 +742,7 @@ sort_by_external_index() { sorted_vertices.push_back(*i); } - ::sort(sorted_vertices.begin(), sorted_vertices.end(), SortByExternalIndex()); + std::sort(sorted_vertices.begin(), sorted_vertices.end(), SortByExternalIndex()); // Now reassign the indices, and copy them into a new index map. IndexVertices new_index_vertices; diff --git a/panda/src/egg/eggVertexUV.cxx b/panda/src/egg/eggVertexUV.cxx index ded4e39dd0..4ba501d4c3 100644 --- a/panda/src/egg/eggVertexUV.cxx +++ b/panda/src/egg/eggVertexUV.cxx @@ -88,7 +88,7 @@ EggVertexUV:: */ PT(EggVertexUV) EggVertexUV:: make_average(const EggVertexUV *first, const EggVertexUV *second) { - nassertr(first->get_name() == second->get_name(), NULL); + nassertr(first->get_name() == second->get_name(), nullptr); int flags = first->_flags & second->_flags; LTexCoord3d uvw = (first->_uvw + second->_uvw) / 2; diff --git a/panda/src/egg/eggXfmSAnim.cxx b/panda/src/egg/eggXfmSAnim.cxx index 167cb531b7..c28d8c6c4e 100644 --- a/panda/src/egg/eggXfmSAnim.cxx +++ b/panda/src/egg/eggXfmSAnim.cxx @@ -73,7 +73,7 @@ optimize() { // default value. double value = sanim->get_value(0); double default_value; - if (sanim->has_name() && strchr("ijk", sanim->get_name()[0]) != NULL) { + if (sanim->has_name() && strchr("ijk", sanim->get_name()[0]) != nullptr) { default_value = 1.0; } else { default_value = 0.0; @@ -169,10 +169,10 @@ write(ostream &out, int indent_level) const { nassertv(sanim->get_name().length() == 1); char name = sanim->get_name()[0]; char *p = (char *)strchr(matrix_component_letters, name); - nassertv(p != (char *)NULL); - if (p != (char *)NULL) { + nassertv(p != nullptr); + if (p != nullptr) { int index = p - matrix_component_letters; - nassertv(tables[index] == (EggSAnimData *)NULL); + nassertv(tables[index] == nullptr); tables[index] = sanim; } } else { @@ -183,7 +183,7 @@ write(ostream &out, int indent_level) const { // Now write out the table children in our normal order. for (int i = 0; i < num_matrix_components; i++) { - if (tables[i] != (EggSAnimData *)NULL) { + if (tables[i] != nullptr) { tables[i]->write(out, indent_level + 2); } } @@ -400,7 +400,7 @@ set_value(int row, const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i++) { string name(1, matrix_component_letters[i]); EggNode *child = find_child(name); - nassertr(child != (EggNode *)NULL && + nassertr(child != nullptr && child->is_of_type(EggSAnimData::get_class_type()), false); EggSAnimData *sanim = DCAST(EggSAnimData, child); @@ -495,7 +495,7 @@ add_data(const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i++) { string name(1, matrix_component_letters[i]); EggNode *child = find_child(name); - nassertr(child != (EggNode *)NULL && + nassertr(child != nullptr && child->is_of_type(EggSAnimData::get_class_type()), false); EggSAnimData *sanim = DCAST(EggSAnimData, child); @@ -553,7 +553,7 @@ void EggXfmSAnim:: add_component_data(const string &component_name, double value) { EggNode *child = find_child(component_name); EggSAnimData *sanim; - if (child == (EggNode *)NULL) { + if (child == nullptr) { // We don't have this component yet; create it. sanim = new EggSAnimData(component_name); add_child(sanim); diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index 6f6e8bd56a..ef8160d2c2 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -1062,11 +1062,11 @@ eggyyerror(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } error_count++; } @@ -1088,11 +1088,11 @@ eggyywarning(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } warning_count++; } @@ -1215,7 +1215,7 @@ eat_c_comment() { ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" - << ends; + << std::ends; eggyywarning(errmsg); } last_c = c; diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 1ce4a0006e..468a393418 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -44,7 +44,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the egg file we're parsing. We keep it so we // can print it out for error messages. @@ -117,11 +117,11 @@ eggyyerror(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } error_count++; } @@ -143,11 +143,11 @@ eggyywarning(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } warning_count++; } @@ -162,7 +162,7 @@ eggyywarning(ostringstream &strm) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -180,7 +180,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } @@ -270,7 +270,7 @@ eat_c_comment() { ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" - << ends; + << std::ends; eggyywarning(errmsg); } last_c = c; @@ -700,7 +700,7 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) {HEX} { // A hexadecimal integer number. accept(); - eggyylval._ulong = strtoul(yytext+2, NULL, 16); + eggyylval._ulong = strtoul(yytext+2, nullptr, 16); eggyylval._string = yytext; return EGG_ULONG; } @@ -708,7 +708,7 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) {BINARY} { // A binary integer number. accept(); - eggyylval._ulong = strtoul(yytext+2, NULL, 2); + eggyylval._ulong = strtoul(yytext+2, nullptr, 2); eggyylval._string = yytext; return EGG_ULONG; } @@ -717,7 +717,7 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) // not-a-number. These sometimes show up in egg files accidentally. accept(); memset(&eggyylval._number, 0, sizeof(eggyylval._number)); - *(unsigned long *)&eggyylval._number = strtoul(yytext+3, NULL, 0); + *(unsigned long *)&eggyylval._number = strtoul(yytext+3, nullptr, 0); eggyylval._string = yytext; return EGG_NUMBER; } diff --git a/panda/src/egg/parser.cxx.prebuilt b/panda/src/egg/parser.cxx.prebuilt index 7791e8de4a..b25f0abf32 100644 --- a/panda/src/egg/parser.cxx.prebuilt +++ b/panda/src/egg/parser.cxx.prebuilt @@ -3137,14 +3137,14 @@ yyreduce: if (vertex_index < 0) { ostringstream errmsg; errmsg << "Ignoring invalid vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } else if (pool->has_vertex(vertex_index)) { ostringstream errmsg; errmsg << "Ignoring duplicate vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } @@ -4055,7 +4055,7 @@ yyreduce: if (vertex == NULL) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { group->ref_vertex(vertex, membership); @@ -4659,7 +4659,7 @@ yyreduce: if (vertex == NULL) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { prim->add_vertex(vertex); diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 02e83f18ec..8bdd6ee39d 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -903,7 +903,7 @@ vertex_pool: VERTEXPOOL required_name { string name = $2; - EggVertexPool *pool = NULL; + EggVertexPool *pool = nullptr; VertexPools::const_iterator vpi = vertex_pools.find(name); if (vpi != vertex_pools.end()) { @@ -971,14 +971,14 @@ vertex: if (vertex_index < 0) { ostringstream errmsg; errmsg << "Ignoring invalid vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } else if (pool->has_vertex(vertex_index)) { ostringstream errmsg; errmsg << "Ignoring duplicate vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } @@ -1545,7 +1545,7 @@ group_body: EggGroup *group = DCAST(EggGroup, egg_stack.back()); if (group->get_group_type() != EggGroup::GT_instance) { eggyyerror(" valid only within "); - } else if ($4 != (EggObject *)NULL) { + } else if ($4 != nullptr) { group->add_group_ref(DCAST(EggGroup, $4)); } } @@ -1785,7 +1785,7 @@ matrix4_body: group_vertex_ref: VERTEXREF '{' integer_list group_vertex_membership REF '{' vertex_pool_name '}' '}' { - if ($7 != (EggVertexPool *)NULL) { + if ($7 != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, $7); EggGroup *group = DCAST(EggGroup, egg_stack.back()); PTA_double nums = $3; @@ -1794,10 +1794,10 @@ group_vertex_ref: for (int i = 0; i < (int)nums.size(); i++) { int index = (int)nums[i]; EggVertex *vertex = pool->get_forward_vertex(index); - if (vertex == NULL) { + if (vertex == nullptr) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { group->ref_vertex(vertex, membership); @@ -2316,7 +2316,7 @@ nurbs_curve_body: primitive_tref_body: texture_name { - if ($1 != (EggTexture *)NULL) { + if ($1 != nullptr) { EggTexture *texture = DCAST(EggTexture, $1); DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); } @@ -2333,7 +2333,7 @@ primitive_tref_body: primitive_texture_body: required_name { - EggTexture *texture = NULL; + EggTexture *texture = nullptr; // Defining a texture on-the-fly. Filename filename = $1; @@ -2345,7 +2345,7 @@ primitive_texture_body: texture = new EggTexture(tref_name, filename); textures[tref_name] = texture; - if (egg_top_node != NULL) { + if (egg_top_node != nullptr) { egg_top_node->add_child(texture); } @@ -2358,7 +2358,7 @@ primitive_texture_body: } } - nassertr(texture != NULL, 0); + nassertr(texture != nullptr, 0); DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); } ; @@ -2373,7 +2373,7 @@ primitive_texture_body: primitive_material_body: material_name { - if ($1 != (EggMaterial *)NULL) { + if ($1 != nullptr) { EggMaterial *material = DCAST(EggMaterial, $1); DCAST(EggPrimitive, egg_stack.back())->set_material(material); } @@ -2466,7 +2466,7 @@ primitive_bface_body: primitive_vertex_ref: VERTEXREF '{' integer_list REF '{' vertex_pool_name '}' '}' { - if ($6 != (EggVertexPool *)NULL) { + if ($6 != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, $6); EggPrimitive *prim = DCAST(EggPrimitive, egg_stack.back()); PTA_double nums = $3; @@ -2474,10 +2474,10 @@ primitive_vertex_ref: for (int i = 0; i < (int)nums.size(); i++) { int index = (int)nums[i]; EggVertex *vertex = pool->get_forward_vertex(index); - if (vertex == NULL) { + if (vertex == nullptr) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { prim->add_vertex(vertex); diff --git a/panda/src/egg2pg/animBundleMaker.cxx b/panda/src/egg2pg/animBundleMaker.cxx index 18e7447923..b32f6d79a5 100644 --- a/panda/src/egg2pg/animBundleMaker.cxx +++ b/panda/src/egg2pg/animBundleMaker.cxx @@ -167,7 +167,7 @@ inspect_tree(EggNode *egg_node) { */ void AnimBundleMaker:: build_hierarchy(EggTable *egg_table, AnimGroup *parent) { - AnimGroup *this_node = NULL; + AnimGroup *this_node = nullptr; // First, scan the children of egg_table for anim data tables. If any of // them is named "xform", it's a special case--this one stands for the @@ -176,7 +176,7 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { EggTable::const_iterator ci; for (ci = egg_table->begin(); ci != egg_table->end(); ++ci) { if ((*ci)->get_name() == "xform") { - if (this_node == NULL) { + if (this_node == nullptr) { this_node = create_xfm_channel((*ci), egg_table->get_name(), parent); } else { egg2pg_cat.warning() @@ -187,7 +187,7 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { } // If none of them were named "xform", just create a plain old AnimGroup. - if (this_node == NULL) { + if (this_node == nullptr) { this_node = new AnimGroup(parent, egg_table->get_name()); } @@ -251,7 +251,7 @@ create_xfm_channel(EggNode *egg_node, const string &name, egg2pg_cat.warning() << "Inappropriate node named xform under node " << name << "\n"; - return NULL; + return nullptr; } diff --git a/panda/src/egg2pg/characterMaker.cxx b/panda/src/egg2pg/characterMaker.cxx index 99bbf54f47..11c3a4e9b4 100644 --- a/panda/src/egg2pg/characterMaker.cxx +++ b/panda/src/egg2pg/characterMaker.cxx @@ -48,7 +48,7 @@ CharacterMaker(EggGroup *root, EggLoader &loader, bool structured) _character_node = new Character(_egg_root->get_name()); _bundle = _character_node->get_bundle(0); - _morph_root = (PartGroup *)NULL; + _morph_root = nullptr; _skeleton_root = new PartGroup(_bundle, ""); _structured = structured; } @@ -83,7 +83,7 @@ egg_to_part(EggNode *egg_node) const { // return the root of the character. return _bundle; } - nassertr(index < (int)_parts.size(), NULL); + nassertr(index < (int)_parts.size(), nullptr); return _parts[index]; } @@ -140,7 +140,7 @@ part_to_node(PartGroup *part, const string &name) const { if (part->is_character_joint()) { CharacterJoint *joint = DCAST(CharacterJoint, part); - if (joint->_geom_node != (PandaNode *)NULL) { + if (joint->_geom_node != nullptr) { node = joint->_geom_node; } } @@ -169,7 +169,7 @@ part_to_node(PartGroup *part, const string &name) const { */ int CharacterMaker:: create_slider(const string &name) { - if (_morph_root == (PartGroup *)NULL) { + if (_morph_root == nullptr) { _morph_root = new PartGroup(_bundle, "morph"); } CharacterSlider *slider = new CharacterSlider(_morph_root, name); @@ -238,7 +238,7 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { } PT(AnimPreloadTable) anim_preload = _bundle->modify_anim_preload(); - if (anim_preload == (AnimPreloadTable *)NULL) { + if (anim_preload == nullptr) { anim_preload = new AnimPreloadTable; _bundle->set_anim_preload(anim_preload); } @@ -313,7 +313,7 @@ parent_joint_nodes(PartGroup *part) { if (part->is_character_joint()) { CharacterJoint *joint = DCAST(CharacterJoint, part); PandaNode *joint_node = joint->_geom_node; - if (joint_node != NULL) { + if (joint_node != nullptr) { _character_node->add_child(joint_node); joint->add_net_transform(joint_node); joint_node->set_transform(TransformState::make_mat(joint->_net_transform)); @@ -341,7 +341,7 @@ make_geometry(EggNode *egg_node) { EggGroupNode *bin_home = determine_bin_home(egg_bin); bool is_dynamic; - if (bin_home == (EggGroupNode *)NULL) { + if (bin_home == nullptr) { // This is a dynamic polyset that lives under the character's root // node. bin_home = _egg_root; @@ -387,7 +387,7 @@ determine_primitive_home(EggPrimitive *egg_primitive) { // We need to keep track of the one joint we've encountered so far, to see // if all the vertices are referenced by the same joint. - EggGroupNode *home = NULL; + EggGroupNode *home = nullptr; EggPrimitive::const_iterator vi; for (vi = egg_primitive->begin(); @@ -397,7 +397,7 @@ determine_primitive_home(EggPrimitive *egg_primitive) { if (vertex->gref_size() > 1) { // This vertex is referenced by multiple joints; the primitive is // dynamic. - return NULL; + return nullptr; } if (!vertex->_dxyzs.empty() || @@ -405,14 +405,14 @@ determine_primitive_home(EggPrimitive *egg_primitive) { !vertex->_drgbas.empty()) { // This vertex has some morph slider definitions; therefore, the // primitive is dynamic. - return NULL; + return nullptr; } EggVertex::const_uv_iterator uvi; for (uvi = vertex->uv_begin(); uvi != vertex->uv_end(); ++uvi) { if (!(*uvi)->_duvs.empty()) { // Ditto: the vertex has some UV morphs; therefore the primitive is // dynamic. - return NULL; + return nullptr; } } @@ -423,15 +423,15 @@ determine_primitive_home(EggPrimitive *egg_primitive) { // where it is. vertex_home = egg_primitive->get_parent(); } else { - nassertr(vertex->gref_size() == 1, NULL); + nassertr(vertex->gref_size() == 1, nullptr); // This vertex is referenced exactly once. vertex_home = *vertex->gref_begin(); } - if (home != NULL && home != vertex_home) { + if (home != nullptr && home != vertex_home) { // Oops, two vertices are referenced by different joints! The primitive // is dynamic. - return NULL; + return nullptr; } home = vertex_home; @@ -439,35 +439,35 @@ determine_primitive_home(EggPrimitive *egg_primitive) { // This shouldn't be possible, unless there are no vertices--but we check // for that before calling this function. - nassertr(home != NULL, NULL); + nassertr(home != nullptr, nullptr); // So, all the vertices are assigned to the same group. This means the // polygon belongs entirely to one joint. // If the group is not, in fact, a joint then we return the first joint // above the group. - EggGroup *egg_group = (EggGroup *)NULL; + EggGroup *egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } - while (egg_group != (EggGroup *)NULL && + while (egg_group != nullptr && egg_group->get_group_type() != EggGroup::GT_joint && egg_group->get_dart_type() == EggGroup::DT_none) { - nassertr(egg_group->get_parent() != (EggGroupNode *)NULL, NULL); + nassertr(egg_group->get_parent() != nullptr, nullptr); home = egg_group->get_parent(); - egg_group = (EggGroup *)NULL; + egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } } - if (egg_group != (EggGroup *)NULL && + if (egg_group != nullptr && egg_group->get_group_type() == EggGroup::GT_joint && !egg_group->has_dcs_type()) { // If the home is a joint without a flag--this is the normal case-- // we'll move the polygon under the character node and animate it from // there explicitly. - return NULL; + return nullptr; } // Otherwise, if the joint *does* have a flag, we'll create static @@ -494,12 +494,12 @@ determine_bin_home(EggBin *egg_bin) { if (!egg_rigid_geometry) { // If we don't have egg-rigid-geometry enabled, then all geometry is // considered dynamic. - return NULL; + return nullptr; } // We need to keep track of the one joint we've encountered so far, to see // if all the vertices are referenced by the same joint. - EggGroupNode *home = NULL; + EggGroupNode *home = nullptr; EggGroupNode::const_iterator ci; for (ci = egg_bin->begin(); ci != egg_bin->end(); ++ci) { @@ -513,7 +513,7 @@ determine_bin_home(EggBin *egg_bin) { if (vertex->gref_size() > 1) { // This vertex is referenced by multiple joints; the primitive is // dynamic. - return NULL; + return nullptr; } if (!vertex->_dxyzs.empty() || @@ -521,14 +521,14 @@ determine_bin_home(EggBin *egg_bin) { !vertex->_drgbas.empty()) { // This vertex has some morph slider definitions; therefore, the // primitive is dynamic. - return NULL; + return nullptr; } EggVertex::const_uv_iterator uvi; for (uvi = vertex->uv_begin(); uvi != vertex->uv_end(); ++uvi) { if (!(*uvi)->_duvs.empty()) { // Ditto: the vertex has some UV morphs; therefore the primitive is // dynamic. - return NULL; + return nullptr; } } @@ -539,15 +539,15 @@ determine_bin_home(EggBin *egg_bin) { // where it is. vertex_home = egg_primitive->get_parent(); } else { - nassertr(vertex->gref_size() == 1, NULL); + nassertr(vertex->gref_size() == 1, nullptr); // This vertex is referenced exactly once. vertex_home = *vertex->gref_begin(); } - if (home != NULL && home != vertex_home) { + if (home != nullptr && home != vertex_home) { // Oops, two vertices are referenced by different joints! The // primitive is dynamic. - return NULL; + return nullptr; } home = vertex_home; @@ -557,29 +557,29 @@ determine_bin_home(EggBin *egg_bin) { // This shouldn't be possible, unless there are no vertices--but we // eliminate invalid primitives before we begin, so all primitives should // have vertices, and all bins should have primitives. - nassertr(home != NULL, NULL); + nassertr(home != nullptr, nullptr); // So, all the vertices are assigned to the same group. This means all the // primitives in the bin belong entirely to one joint. // If the group is not, in fact, a joint then we return the first joint // above the group. - EggGroup *egg_group = (EggGroup *)NULL; + EggGroup *egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } - while (egg_group != (EggGroup *)NULL && + while (egg_group != nullptr && egg_group->get_group_type() != EggGroup::GT_joint && egg_group->get_dart_type() == EggGroup::DT_none) { - nassertr(egg_group->get_parent() != (EggGroupNode *)NULL, NULL); + nassertr(egg_group->get_parent() != nullptr, nullptr); home = egg_group->get_parent(); - egg_group = (EggGroup *)NULL; + egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } } - if (egg_group != (EggGroup *)NULL && + if (egg_group != nullptr && egg_group->get_group_type() == EggGroup::GT_joint && !egg_group->has_dcs_type()) { // If we have rigid geometry that is assigned to a joint without a @@ -597,7 +597,7 @@ determine_bin_home(EggBin *egg_bin) { * and this may also break up the geometry into more individual pieces, which * is the biggest limiting factor on modern PC graphics cards. */ - return NULL; + return nullptr; } CharacterJoint *joint; @@ -618,7 +618,7 @@ determine_bin_home(EggBin *egg_bin) { */ VertexTransform *CharacterMaker:: get_identity_transform() { - if (_identity_transform == (VertexTransform *)NULL) { + if (_identity_transform == nullptr) { _identity_transform = new UserVertexTransform("root"); } return _identity_transform; diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index e093990ef9..ae2c30a8c3 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -115,7 +115,7 @@ public: LODInstance:: LODInstance(EggNode *egg_node) { - nassertv(egg_node != NULL); + nassertv(egg_node != nullptr); _egg_node = egg_node; // We expect this egg node to be an EggGroup with an LOD specification. @@ -139,7 +139,7 @@ EggLoader() { _data->set_coordinate_system(egg_coordinate_system); _error = false; _dynamic_override = false; - _dynamic_override_char_maker = NULL; + _dynamic_override_char_maker = nullptr; } /** @@ -151,7 +151,7 @@ EggLoader(const EggData *data) : { _error = false; _dynamic_override = false; - _dynamic_override_char_maker = NULL; + _dynamic_override_char_maker = nullptr; } @@ -224,7 +224,7 @@ reparent_decals() { ExtraNodes::const_iterator di; for (di = _decals.begin(); di != _decals.end(); ++di) { PandaNode *node = (*di); - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); // The NodePath interface is best for this. NodePath parent(node); @@ -307,7 +307,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, EggGroupNode::const_iterator ci = egg_bin->begin(); nassertv(ci != egg_bin->end()); CPT(EggPrimitive) first_prim = DCAST(EggPrimitive, (*ci)); - nassertv(first_prim != (EggPrimitive *)NULL); + nassertv(first_prim != nullptr); const EggRenderState *render_state; DCAST_INTO_V(render_state, first_prim->get_user_data(EggRenderState::get_class_type())); @@ -390,7 +390,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, if (!primitives.empty()) { LMatrix4d mat; - if (transform != NULL) { + if (transform != nullptr) { mat = (*transform); } else { mat = egg_bin->get_vertex_to_node(); @@ -400,7 +400,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, PT(GeomVertexData) vertex_data = make_vertex_data(render_state, vertex_pool, egg_bin, mat, blend_table, is_dynamic, character_maker, has_overall_color); - nassertv(vertex_data != (GeomVertexData *)NULL); + nassertv(vertex_data != nullptr); // And create a Geom to hold the primitives. PT(Geom) geom = new Geom(vertex_data); @@ -423,7 +423,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, // render_state->_state->write(cerr, 0); // Create a new GeomNode if we haven't already. - if (geom_node == (GeomNode *)NULL) { + if (geom_node == nullptr) { // Now, is our parent node a GeomNode, or just an ordinary PandaNode? // If it's a GeomNode, we can add the new Geom directly to our parent; // otherwise, we need to create a new node. @@ -453,7 +453,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, } } - if (geom_node != (GeomNode *)NULL && egg_show_normals) { + if (geom_node != nullptr && egg_show_normals) { // Create some more geometry to visualize each normal. for (vpi = vertex_pools.begin(); vpi != vertex_pools.end(); ++vpi) { EggVertexPool *vertex_pool = (*vpi); @@ -659,11 +659,11 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, return; } - assert(parent != NULL); + assert(parent != nullptr); assert(!parent->is_geom_node()); PT(NurbsCurveEvaluator) nurbs = ::make_nurbs_curve(egg_curve, mat); - if (nurbs == (NurbsCurveEvaluator *)NULL) { + if (nurbs == nullptr) { _error = true; return; } @@ -726,14 +726,14 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, void EggLoader:: make_old_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, const LMatrix4d &mat) { - assert(parent != NULL); + assert(parent != nullptr); assert(!parent->is_geom_node()); PT(ParametricCurve) curve; curve = new NurbsCurve; NurbsCurveInterface *nurbs = curve->get_nurbs_interface(); - nassertv(nurbs != (NurbsCurveInterface *)NULL); + nassertv(nurbs != nullptr); if (egg_curve->get_order() < 1 || egg_curve->get_order() > 4) { egg2pg_cat.error() @@ -798,11 +798,11 @@ make_old_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, void EggLoader:: make_nurbs_surface(EggNurbsSurface *egg_surface, PandaNode *parent, const LMatrix4d &mat) { - assert(parent != NULL); + assert(parent != nullptr); assert(!parent->is_geom_node()); PT(NurbsSurfaceEvaluator) nurbs = ::make_nurbs_surface(egg_surface, mat); - if (nurbs == (NurbsSurfaceEvaluator *)NULL) { + if (nurbs == nullptr) { _error = true; return; } @@ -915,7 +915,7 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { // Since some properties of the textures are inferred from the texture files // themselves (if the properties are not explicitly specified in the egg // file), then we add the textures as dependents for the egg file. - if (_record != (BamCacheRecord *)NULL) { + if (_record != nullptr) { _record->add_dependent_file(egg_tex->get_fullpath()); if (egg_tex->has_alpha_filename() && wanted_alpha) { _record->add_dependent_file(egg_tex->get_alpha_fullpath()); @@ -987,7 +987,7 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { break; } - if (tex == (Texture *)NULL) { + if (tex == nullptr) { return false; } @@ -1002,7 +1002,7 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { // See if there is some egg data hanging on the texture. In particular, the // TxaFileFilter might have left that here for us. TypedReferenceCount *aux = tex->get_aux_data("egg"); - if (aux != (TypedReferenceCount *)NULL && + if (aux != nullptr && aux->is_of_type(EggTexture::get_class_type())) { EggTexture *aux_egg_tex = DCAST(EggTexture, aux); @@ -1686,7 +1686,7 @@ make_node(EggNode *egg_node, PandaNode *parent) { return make_node(DCAST(EggGroupNode, egg_node), parent); } - return (PandaNode *)NULL; + return nullptr; } /** @@ -1700,40 +1700,40 @@ make_node(EggBin *egg_bin, PandaNode *parent) { switch (egg_bin->get_bin_number()) { case EggBinner::BN_polyset: case EggBinner::BN_patches: - make_polyset(egg_bin, parent, NULL, _dynamic_override, _dynamic_override_char_maker); - return NULL; + make_polyset(egg_bin, parent, nullptr, _dynamic_override, _dynamic_override_char_maker); + return nullptr; case EggBinner::BN_lod: return make_lod(egg_bin, parent); case EggBinner::BN_nurbs_surface: { - nassertr(!egg_bin->empty(), NULL); + nassertr(!egg_bin->empty(), nullptr); EggNode *child = egg_bin->get_first_child(); EggNurbsSurface *egg_nurbs; - DCAST_INTO_R(egg_nurbs, child, NULL); + DCAST_INTO_R(egg_nurbs, child, nullptr); const LMatrix4d &mat = egg_nurbs->get_vertex_to_node(); make_nurbs_surface(egg_nurbs, parent, mat); } - return NULL; + return nullptr; case EggBinner::BN_nurbs_curve: { - nassertr(!egg_bin->empty(), NULL); + nassertr(!egg_bin->empty(), nullptr); EggNode *child = egg_bin->get_first_child(); EggNurbsCurve *egg_nurbs; - DCAST_INTO_R(egg_nurbs, child, NULL); + DCAST_INTO_R(egg_nurbs, child, nullptr); const LMatrix4d &mat = egg_nurbs->get_vertex_to_node(); make_nurbs_curve(egg_nurbs, parent, mat); } - return NULL; + return nullptr; case EggBinner::BN_none: break; } // Shouldn't get here. - return (PandaNode *)NULL; + return nullptr; } /** @@ -1769,7 +1769,7 @@ make_lod(EggBin *egg_bin, PandaNode *parent) { // All of the children should have the same center, because that's how we // binned them. nassertr(lod_node->get_center().almost_equal - (LCAST(PN_stdfloat, instance._d->_center), 0.01), NULL); + (LCAST(PN_stdfloat, instance._d->_center), 0.01), nullptr); // Tell the LOD node about this child's switching distances. lod_node->add_switch(instance._d->_switch_in, instance._d->_switch_out); @@ -1784,7 +1784,7 @@ make_lod(EggBin *egg_bin, PandaNode *parent) { */ PandaNode *EggLoader:: make_node(EggGroup *egg_group, PandaNode *parent) { - PT(PandaNode) node = NULL; + PT(PandaNode) node = nullptr; if (egg_group->get_dart_type() != EggGroup::DT_none) { // A group with the flag set means to create a character. @@ -1802,7 +1802,7 @@ make_node(EggGroup *egg_group, PandaNode *parent) { for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { make_node(*ci, node); } - _dynamic_override_char_maker = NULL; + _dynamic_override_char_maker = nullptr; _dynamic_override = false; } @@ -1956,8 +1956,8 @@ make_node(EggGroup *egg_group, PandaNode *parent) { } } - if (node == (PandaNode *)NULL) { - return NULL; + if (node == nullptr) { + return nullptr; } // Associate any instances with this node. @@ -2319,7 +2319,7 @@ make_vertex_data(const EggRenderState *render_state, vertex_data->reserve_num_rows(vertex_pool->size()); vertex_data->set_transform_blend_table(blend_table); - if (slider_table != (SliderTable *)NULL) { + if (slider_table != nullptr) { vertex_data->set_slider_table(SliderTable::register_table(slider_table)); } @@ -2477,7 +2477,7 @@ make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, // If the vertex has no explicit membership, it belongs right where it // is. PT(VertexTransform) vt = character_maker->egg_to_transform(primitive_home); - nassertr(vt != (VertexTransform *)NULL, NULL); + nassertr(vt != nullptr, nullptr); blend.add_transform(vt, 1.0f); } else { // If the vertex does have an explicit membership, ignore its parentage @@ -2492,7 +2492,7 @@ make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, } PT(VertexTransform) vt = character_maker->egg_to_transform(egg_joint); - nassertr(vt != (VertexTransform *)NULL, NULL); + nassertr(vt != nullptr, nullptr); blend.add_transform(vt, membership); } } @@ -2564,7 +2564,7 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, primitive = new GeomPatches(num_vertices, Geom::UH_static); } - if (primitive == (GeomPrimitive *)NULL) { + if (primitive == nullptr) { // Don't know how to make this kind of primitive. egg2pg_cat.warning() << "Ignoring " << egg_prim->get_type() << "\n"; @@ -2633,7 +2633,7 @@ set_portal_polygon(EggGroup *egg_group, PortalNode *pnode) { pnode->clear_vertices(); PT(EggPolygon) poly = find_first_polygon(egg_group); - if (poly != (EggPolygon *)NULL) { + if (poly != nullptr) { LMatrix4d mat = poly->get_vertex_to_node(); EggPolygon::const_iterator vi; @@ -2650,7 +2650,7 @@ set_portal_polygon(EggGroup *egg_group, PortalNode *pnode) { void EggLoader:: set_occluder_polygon(EggGroup *egg_group, OccluderNode *pnode) { PT(EggPolygon) poly = find_first_polygon(egg_group); - if (poly != (EggPolygon *)NULL) { + if (poly != nullptr) { if (poly->size() != 4) { egg2pg_cat.error() << "Invalid number of vertices for " << egg_group->get_name() << "\n"; @@ -2693,14 +2693,14 @@ find_first_polygon(EggGroup *egg_group) { if ((*ci)->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, *ci); PT(EggPolygon) found = find_first_polygon(child_group); - if (found != (EggPolygon *)NULL) { + if (found != nullptr) { return found; } } } // We got nothing. - return NULL; + return nullptr; } /** @@ -2712,7 +2712,7 @@ bool EggLoader:: make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, LPoint3 ¢er, PN_stdfloat &radius, LColor &color) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { // Collect all of the vertices. pset vertices; @@ -2772,7 +2772,7 @@ bool EggLoader:: make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, LPoint3 &min_p, LPoint3 &max_p, LColor &color) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { // Collect all of the vertices. pset vertices; @@ -2893,13 +2893,13 @@ void EggLoader:: make_collision_plane(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { EggGroup::const_iterator ci; for (ci = geom_group->begin(); ci != geom_group->end(); ++ci) { if ((*ci)->is_of_type(EggPolygon::get_class_type())) { CollisionPlane *csplane = create_collision_plane(DCAST(EggPolygon, *ci), egg_group); - if (csplane != (CollisionPlane *)NULL) { + if (csplane != nullptr) { apply_collision_flags(csplane, flags); cnode->add_solid(csplane); return; @@ -2929,7 +2929,7 @@ make_collision_floor_mesh(EggGroup *egg_group, CollisionNode *cnode, EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { create_collision_floor_mesh(cnode, geom_group,flags); } } @@ -2943,7 +2943,7 @@ make_collision_polygon(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { EggGroup::const_iterator ci; for (ci = geom_group->begin(); ci != geom_group->end(); ++ci) { if ((*ci)->is_of_type(EggPolygon::get_class_type())) { @@ -2970,7 +2970,7 @@ void EggLoader:: make_collision_polyset(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { EggGroup::const_iterator ci; for (ci = geom_group->begin(); ci != geom_group->end(); ++ci) { if ((*ci)->is_of_type(EggPolygon::get_class_type())) { @@ -3049,7 +3049,7 @@ void EggLoader:: make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { // Collect all of the vertices. pset vertices; @@ -3284,7 +3284,7 @@ find_collision_geometry(EggGroup *egg_group, EggGroup::CollideFlags flags) { } // We got nothing. - return NULL; + return nullptr; } /** @@ -3296,7 +3296,7 @@ create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { egg2pg_cat.info() << "Ignoring degenerate collision plane in " << parent_group->get_name() << "\n"; - return NULL; + return nullptr; } if (!egg_poly->is_planar()) { @@ -3328,7 +3328,7 @@ create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { } if (vertices.size() < 3) { - return NULL; + return nullptr; } LPlane plane(vertices[0], vertices[1], vertices[2]); return new CollisionPlane(plane); @@ -3792,7 +3792,7 @@ TextureStage::CombineOperand EggLoader:: get_combine_operand(const EggTexture *egg_tex, EggTexture::CombineChannel channel, int n) { switch (egg_tex->get_combine_operand(channel, n)) { - case EggTexture::CS_unspecified: + case EggTexture::CO_unspecified: if (channel == EggTexture::CC_rgb) { // The default operand for RGB is src_color, except for the third // parameter, which defaults to src_alpha. diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index cb8a9681e3..5612826ec0 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -63,50 +63,50 @@ fill_state(EggPrimitive *egg_prim) { EggRenderMode *render_mode; render_mode = egg_prim->determine_alpha_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { am = render_mode->get_alpha_mode(); } render_mode = egg_prim->determine_depth_write_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { dwm = render_mode->get_depth_write_mode(); } render_mode = egg_prim->determine_depth_test_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { dtm = render_mode->get_depth_test_mode(); } render_mode = egg_prim->determine_visibility_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { vm = render_mode->get_visibility_mode(); } render_mode = egg_prim->determine_draw_order(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { has_draw_order = true; draw_order = render_mode->get_draw_order(); } render_mode = egg_prim->determine_depth_offset(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { has_depth_offset = true; depth_offset = render_mode->get_depth_offset(); } render_mode = egg_prim->determine_bin(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { has_bin = true; bin = render_mode->get_bin(); } // add_attrib(TextureAttrib::make_off()); int num_textures = egg_prim->get_num_textures(); - CPT(RenderAttrib) texture_attrib = NULL; - CPT(RenderAttrib) tex_gen_attrib = NULL; - CPT(RenderAttrib) tex_mat_attrib = NULL; + CPT(RenderAttrib) texture_attrib = nullptr; + CPT(RenderAttrib) tex_gen_attrib = nullptr; + CPT(RenderAttrib) tex_mat_attrib = nullptr; TexMats tex_mats; for (int i = 0; i < num_textures; i++) { PT_EggTexture egg_tex = egg_prim->get_texture(i); const TextureDef &def = _loader._textures[egg_tex]; - if (def._texture != (const RenderAttrib *)NULL) { - if (texture_attrib == (RenderAttrib *)NULL) { + if (def._texture != nullptr) { + if (texture_attrib == nullptr) { texture_attrib = def._texture; } else { texture_attrib = texture_attrib->compose(def._texture); @@ -115,7 +115,7 @@ fill_state(EggPrimitive *egg_prim) { if (egg_tex->affects_polygon_alpha()) { const TextureAttrib *tex_attrib = DCAST(TextureAttrib, def._texture); Texture *tex = tex_attrib->get_texture(); - nassertv(tex != (Texture *)NULL); + nassertv(tex != nullptr); Texture::Format format = tex->get_format(); if (Texture::has_alpha(format) && !Texture::has_binary_alpha(format)) { @@ -139,7 +139,7 @@ fill_state(EggPrimitive *egg_prim) { bool has_tex_gen = false; if (egg_tex->get_tex_gen() != EggTexture::TG_unspecified) { has_tex_gen = true; - if (tex_gen_attrib == (const RenderAttrib *)NULL) { + if (tex_gen_attrib == nullptr) { tex_gen_attrib = TexGenAttrib::make(); } tex_gen_attrib = DCAST(TexGenAttrib, tex_gen_attrib)-> @@ -228,15 +228,15 @@ fill_state(EggPrimitive *egg_prim) { } } - if (texture_attrib != (RenderAttrib *)NULL) { + if (texture_attrib != nullptr) { add_attrib(texture_attrib); } - if (tex_gen_attrib != (RenderAttrib *)NULL) { + if (tex_gen_attrib != nullptr) { add_attrib(tex_gen_attrib); } - if (tex_mat_attrib != (RenderAttrib *)NULL) { + if (tex_mat_attrib != nullptr) { add_attrib(tex_mat_attrib); } @@ -580,7 +580,7 @@ apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib, if (egg_tex->has_transform()) { CPT(TransformState) transform = _loader.make_transform(egg_tex); - if (tex_mat_attrib == (const RenderAttrib *)NULL) { + if (tex_mat_attrib == nullptr) { tex_mat_attrib = TexMatrixAttrib::make(); } tex_mat_attrib = DCAST(TexMatrixAttrib, tex_mat_attrib)-> diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index 63b114ed54..b54b6df744 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -82,7 +82,7 @@ EggSaver:: EggSaver(EggData *data) : _data(data) { - if (_data == NULL) { + if (_data == nullptr) { _data = new EggData; } } @@ -97,13 +97,13 @@ add_node(PandaNode *node) { _data->add_child(_vpool); NodePath root(node); - convert_node(WorkingNodePath(root), _data, false, NULL); + convert_node(WorkingNodePath(root), _data, false, nullptr); // Remove the vertex pool if it has no vertices. if (_vpool->empty()) { _data->remove_child(_vpool); } - _vpool = NULL; + _vpool = nullptr; } /** @@ -117,13 +117,13 @@ add_subgraph(PandaNode *root) { _data->add_child(_vpool); NodePath root_path(root); - recurse_nodes(root_path, _data, false, NULL); + recurse_nodes(root_path, _data, false, nullptr); // Remove the vertex pool if it has no vertices. if (_vpool->empty()) { _data->remove_child(_vpool); } - _vpool = NULL; + _vpool = nullptr; } /** @@ -288,7 +288,7 @@ convert_switch_node(SwitchNode *node, const WorkingNodePath &node_path, EggGroupNode * EggSaver::convert_animGroup_node(AnimGroup *animGroup, double fps ) { int num_children = animGroup->get_num_children(); - EggGroupNode *eggNode = NULL; + EggGroupNode *eggNode = nullptr; if (animGroup->is_of_type(AnimBundle::get_class_type())) { EggTable *eggTable = new EggTable(animGroup->get_name()); eggTable ->set_table_type(EggTable::TT_bundle); @@ -319,8 +319,8 @@ EggGroupNode * EggSaver::convert_animGroup_node(AnimGroup *animGroup, double fps for (int i = 0; i < num_children; i++) { AnimGroup *animChild = animGroup->get_child(i); EggGroupNode *eggChildNode = convert_animGroup_node(animChild, fps); - if (eggChildNode!=NULL) { - nassertr(eggNode!=NULL, NULL); + if (eggChildNode!=nullptr) { + nassertr(eggNode!=nullptr, nullptr); eggNode->add_child(eggChildNode); } } @@ -378,7 +378,7 @@ convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, Charac joint_group = joint; egg_parent->add_child(joint_group); - if (joint_map != NULL) { + if (joint_map != nullptr) { CharacterJointMap::iterator mi = joint_map->find(character_joint); if (mi != joint_map->end()) { pvector > &joint_vertices = (*mi).second; @@ -789,11 +789,11 @@ convert_primitive(const GeomVertexData *vertex_data, } // Check for a material. - EggMaterial *egg_mat = (EggMaterial *)NULL; + EggMaterial *egg_mat = nullptr; const MaterialAttrib *ma; if (net_state->get_attrib(ma)) { egg_mat = get_egg_material(ma->get_material()); - if (egg_mat != (EggMaterial *)NULL) { + if (egg_mat != nullptr) { egg_prim->set_material(egg_mat); } } @@ -803,9 +803,9 @@ convert_primitive(const GeomVertexData *vertex_data, if (net_state->get_attrib(ta)) { EggTexture *egg_tex = get_egg_texture(ta->get_texture()); - if (egg_tex != (EggTexture *)NULL) { + if (egg_tex != nullptr) { TextureStage *tex_stage = ta->get_on_stage(0); - if (tex_stage != (TextureStage *)NULL) { + if (tex_stage != nullptr) { switch (tex_stage->get_mode()) { case TextureStage::M_modulate: if (has_color_off == true) { @@ -839,7 +839,6 @@ convert_primitive(const GeomVertexData *vertex_data, } // Check the backface flag. - bool bface = false; const CullFaceAttrib *cfa; if (net_state->get_attrib(cfa)) { if (cfa->get_effective_mode() == CullFaceAttrib::M_cull_none) { @@ -861,8 +860,6 @@ convert_primitive(const GeomVertexData *vertex_data, } } - LNormal normal; - LColor color; CPT(TransformBlendTable) transformBlendTable = vertex_data->get_transform_blend_table(); int num_primitives = primitive->get_num_primitives(); @@ -911,7 +908,7 @@ convert_primitive(const GeomVertexData *vertex_data, EggVertex *new_egg_vert = _vpool->create_unique_vertex(egg_vert); if (vertex_data->has_column(InternalName::get_transform_blend()) && - joint_map != NULL && transformBlendTable != NULL) { + joint_map != nullptr && transformBlendTable != nullptr) { reader.set_column(InternalName::get_transform_blend()); int idx = reader.get_data1i(); const TransformBlend &blend = transformBlendTable->get_blend(idx); @@ -1009,7 +1006,7 @@ apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage const RenderEffects *effects = node->get_effects(); const RenderEffect *effect = effects->get_effect(BillboardEffect::get_class_type()); - if (effect != (RenderEffect *)NULL) { + if (effect != nullptr) { const BillboardEffect *bbe = DCAST(BillboardEffect, effect); if (bbe->get_axial_rotate()) { egg_group->set_billboard_type(EggGroup::BT_axis); @@ -1201,7 +1198,7 @@ apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag) { */ EggMaterial *EggSaver:: get_egg_material(Material *mat) { - if (mat != (Material *)NULL) { + if (mat != nullptr) { EggMaterial temp(mat->get_name()); if (mat->has_base_color()) { temp.set_base(mat->get_base_color()); @@ -1242,7 +1239,7 @@ get_egg_material(Material *mat) { return _materials.create_unique_material(temp, ~EggMaterial::E_mref_name); } - return NULL; + return nullptr; } /** @@ -1250,7 +1247,7 @@ get_egg_material(Material *mat) { */ EggTexture *EggSaver:: get_egg_texture(Texture *tex) { - if (tex != (Texture *)NULL) { + if (tex != nullptr) { if (tex->has_filename()) { Filename filename = tex->get_filename(); EggTexture temp(filename.get_basename_wo_extension(), filename); @@ -1386,5 +1383,5 @@ get_egg_texture(Texture *tex) { } } - return NULL; + return nullptr; } diff --git a/panda/src/egg2pg/eggSaver.h b/panda/src/egg2pg/eggSaver.h index a361591241..bd2905398f 100644 --- a/panda/src/egg2pg/eggSaver.h +++ b/panda/src/egg2pg/eggSaver.h @@ -52,7 +52,7 @@ class EggVertex; */ class EggSaver { PUBLISHED: - EggSaver(EggData *data = NULL); + EggSaver(EggData *data = nullptr); void add_node(PandaNode *node); void add_subgraph(PandaNode *root); @@ -82,7 +82,7 @@ private: EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *joint_map); void convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, - EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=NULL); + EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=nullptr); void convert_primitive(const GeomVertexData *vertex_data, const GeomPrimitive *primitive, const RenderState *geom_state, diff --git a/panda/src/egg2pg/egg_parametrics.cxx b/panda/src/egg2pg/egg_parametrics.cxx index e57f49e297..eb2036d8a7 100644 --- a/panda/src/egg2pg/egg_parametrics.cxx +++ b/panda/src/egg2pg/egg_parametrics.cxx @@ -26,14 +26,14 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { egg2pg_cat.error() << "Invalid NURBSSurface U order for " << egg_surface->get_name() << ": " << egg_surface->get_u_order() << "\n"; - return NULL; + return nullptr; } if (egg_surface->get_v_order() < 1 || egg_surface->get_v_order() > 4) { egg2pg_cat.error() << "Invalid NURBSSurface V order for " << egg_surface->get_name() << ": " << egg_surface->get_v_order() << "\n"; - return NULL; + return nullptr; } PT(NurbsSurfaceEvaluator) nurbs = new NurbsSurfaceEvaluator; @@ -61,7 +61,7 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { << "Invalid NURBSSurface number of U knots for " << egg_surface->get_name() << ": got " << num_u_knots << " knots, expected " << nurbs->get_num_u_knots() << "\n"; - return NULL; + return nullptr; } int num_v_knots = egg_surface->get_num_v_knots(); @@ -70,7 +70,7 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { << "Invalid NURBSSurface number of U knots for " << egg_surface->get_name() << ": got " << num_v_knots << " knots, expected " << nurbs->get_num_v_knots() << "\n"; - return NULL; + return nullptr; } int i; @@ -96,7 +96,7 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat) { egg2pg_cat.error() << "Invalid NURBSCurve order for " << egg_curve->get_name() << ": " << egg_curve->get_order() << "\n"; - return NULL; + return nullptr; } PT(NurbsCurveEvaluator) nurbs = new NurbsCurveEvaluator; @@ -119,7 +119,7 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat) { << "Invalid NURBSCurve number of knots for " << egg_curve->get_name() << ": got " << num_knots << " knots, expected " << nurbs->get_num_knots() << "\n"; - return NULL; + return nullptr; } for (int i = 0; i < num_knots; i++) { diff --git a/panda/src/egg2pg/load_egg_file.cxx b/panda/src/egg2pg/load_egg_file.cxx index 36b60bb92c..bee738af4b 100644 --- a/panda/src/egg2pg/load_egg_file.cxx +++ b/panda/src/egg2pg/load_egg_file.cxx @@ -28,10 +28,10 @@ load_from_loader(EggLoader &loader) { if (loader._error && !egg_accept_errors) { egg2pg_cat.error() << "Errors in egg file.\n"; - return NULL; + return nullptr; } - if (loader._root != (PandaNode *)NULL && egg_flatten) { + if (loader._root != nullptr && egg_flatten) { SceneGraphReducer gr; int combine_siblings_bits = 0; @@ -76,7 +76,7 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, egg_filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(egg_filename); } @@ -87,18 +87,18 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, loader._record = record; PT(VirtualFile) vfile = vfs->get_file(egg_filename); - if (vfile == NULL) { - return NULL; + if (vfile == nullptr) { + return nullptr; } loader._data->set_egg_timestamp(vfile->get_timestamp()); bool okflag; istream *istr = vfile->open_read_file(true); - if (istr == (istream *)NULL) { + if (istr == nullptr) { egg2pg_cat.error() << "Couldn't read " << egg_filename << "\n"; - return NULL; + return nullptr; } egg2pg_cat.info() @@ -110,7 +110,7 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, if (!okflag) { egg2pg_cat.error() << "Error reading " << egg_filename << "\n"; - return NULL; + return nullptr; } return load_from_loader(loader); diff --git a/panda/src/egg2pg/load_egg_file.h b/panda/src/egg2pg/load_egg_file.h index 296d1aaa60..45ea636f94 100644 --- a/panda/src/egg2pg/load_egg_file.h +++ b/panda/src/egg2pg/load_egg_file.h @@ -33,7 +33,7 @@ BEGIN_PUBLISH */ EXPCL_PANDAEGG PT(PandaNode) load_egg_file(const Filename &filename, CoordinateSystem cs = CS_default, - BamCacheRecord *record = NULL); + BamCacheRecord *record = nullptr); /** * Another convenience function; works like load_egg_file() but starts from an diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index 14f6121653..07057818ab 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.cxx +++ b/panda/src/egldisplay/eglGraphicsBuffer.cxx @@ -62,7 +62,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -105,7 +105,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void eglGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -124,7 +124,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void eglGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { eglGraphicsStateGuardian *eglgsg; DCAST_INTO_V(eglgsg, _gsg); if (!eglMakeCurrent(eglgsg->_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { @@ -158,7 +158,7 @@ open_buffer() { eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, NULL); + eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, nullptr); eglgsg->choose_pixel_format(_fb_properties, egl_pipe->get_display(), egl_pipe->get_screen(), true, false); _gsg = eglgsg; } else { diff --git a/panda/src/egldisplay/eglGraphicsBuffer.h b/panda/src/egldisplay/eglGraphicsBuffer.h index 0d5d473d36..7bed62cb83 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.h +++ b/panda/src/egldisplay/eglGraphicsBuffer.h @@ -41,7 +41,6 @@ protected: virtual bool open_buffer(); private: - X11_Display *_display; EGLSurface _pbuffer; EGLDisplay _egl_display; diff --git a/panda/src/egldisplay/eglGraphicsPipe.cxx b/panda/src/egldisplay/eglGraphicsPipe.cxx index 441fc10512..93ddb7f92c 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.cxx +++ b/panda/src/egldisplay/eglGraphicsPipe.cxx @@ -27,7 +27,7 @@ TypeHandle eglGraphicsPipe::_type_handle; eglGraphicsPipe:: eglGraphicsPipe(const string &display) : x11GraphicsPipe(display) { _egl_display = eglGetDisplay((NativeDisplayType) _display); - if (!eglInitialize(_egl_display, NULL, NULL)) { + if (!eglInitialize(_egl_display, nullptr, nullptr)) { egldisplay_cat.error() << "Couldn't initialize the EGL display: " << get_egl_error_string(eglGetError()) << "\n"; @@ -88,12 +88,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } eglGraphicsStateGuardian *eglgsg = 0; if (gsg != 0) { - DCAST_INTO_R(eglgsg, gsg, NULL); + DCAST_INTO_R(eglgsg, gsg, nullptr); } bool support_rtt; @@ -117,7 +117,7 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new eglGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -129,7 +129,7 @@ make_output(const string &name, // (!gl_support_fbo)|| ((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -138,7 +138,7 @@ make_output(const string &name, (fb_prop.get_back_buffers() > 0)|| (fb_prop.get_accum_bits() > 0)|| (fb_prop.get_multisamples() > 0)) { - return NULL; + return nullptr; } } // Early success - if we are sure that this buffer WILL meet specs, we can @@ -166,7 +166,7 @@ make_output(const string &name, ((flags&BF_require_window)!=0)|| ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)) { - return NULL; + return nullptr; } if (!support_rtt) { @@ -174,7 +174,7 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { // If we require Render-to-Texture, but can't be sure we support it, // bail. - return NULL; + return nullptr; } } @@ -188,12 +188,12 @@ make_output(const string &name, ((flags&BF_require_window)!=0)|| ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)) { - return NULL; + return nullptr; } if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new eglGraphicsPixmap(engine, this, name, fb_prop, win_prop, @@ -201,5 +201,5 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } diff --git a/panda/src/egldisplay/eglGraphicsPixmap.cxx b/panda/src/egldisplay/eglGraphicsPixmap.cxx index ce0abdfdb7..ec34b460a3 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.cxx +++ b/panda/src/egldisplay/eglGraphicsPixmap.cxx @@ -67,7 +67,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -110,7 +110,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void eglGraphicsPixmap:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -129,7 +129,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void eglGraphicsPixmap:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { egldisplay_cat.error() << "Failed to call eglMakeCurrent: " << get_egl_error_string(eglGetError()) << "\n"; @@ -166,7 +166,7 @@ open_buffer() { eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, NULL); + eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, nullptr); eglgsg->choose_pixel_format(_fb_properties, _display, egl_pipe->get_screen(), false, true); _gsg = eglgsg; } else { @@ -187,7 +187,7 @@ open_buffer() { } XVisualInfo *visual_info = eglgsg->_visual; - if (visual_info == NULL) { + if (visual_info == nullptr) { // No X visual for this fbconfig; how can we create the pixmap? egldisplay_cat.error() << "No X visual: cannot create pixmap.\n"; @@ -195,7 +195,7 @@ open_buffer() { } _drawable = egl_pipe->get_root(); - if (_host != NULL) { + if (_host != nullptr) { if (_host->is_of_type(eglGraphicsWindow::get_class_type())) { eglGraphicsWindow *win = DCAST(eglGraphicsWindow, _host); _drawable = win->get_xwindow(); @@ -215,7 +215,7 @@ open_buffer() { } nassertr(eglgsg->_fbconfig, false); - _egl_surface = eglCreatePixmapSurface(_egl_display, eglgsg->_fbconfig, (NativePixmapType) _x_pixmap, NULL); + _egl_surface = eglCreatePixmapSurface(_egl_display, eglgsg->_fbconfig, (NativePixmapType) _x_pixmap, nullptr); if (_egl_surface == EGL_NO_SURFACE) { egldisplay_cat.error() diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx index 84fc303efb..0d9a70e910 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx @@ -40,7 +40,7 @@ eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _visuals=0; _fbconfig=0; - if (share_with != (eglGraphicsStateGuardian *)NULL) { + if (share_with != nullptr) { _prepared_objects = share_with->get_prepared_objects(); _share_context = share_with->_context; } @@ -51,15 +51,15 @@ eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ eglGraphicsStateGuardian:: ~eglGraphicsStateGuardian() { - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); } - if (_context != (EGLContext)NULL) { + if (_context != (EGLContext)nullptr) { if (!eglDestroyContext(_egl_display, _context)) { egldisplay_cat.error() << "Failed to destroy EGL context: " << get_egl_error_string(eglGetError()) << "\n"; } - _context = (EGLContext)NULL; + _context = (EGLContext)nullptr; } } @@ -157,7 +157,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // First get the number of matching configurations, so we know how much // memory to allocate. int num_configs = 0, returned_configs; - if (!eglChooseConfig(_egl_display, attrib_list, NULL, num_configs, &returned_configs) || returned_configs <= 0) { + if (!eglChooseConfig(_egl_display, attrib_list, nullptr, num_configs, &returned_configs) || returned_configs <= 0) { egldisplay_cat.error() << "eglChooseConfig failed: " << get_egl_error_string(eglGetError()) << "\n"; return; @@ -218,7 +218,7 @@ choose_pixel_format(const FrameBufferProperties &properties, EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; _context = eglCreateContext(_egl_display, _fbconfig, _share_context, context_attribs); #else - _context = eglCreateContext(_egl_display, _fbconfig, _share_context, NULL); + _context = eglCreateContext(_egl_display, _fbconfig, _share_context, nullptr); #endif int err = eglGetError(); if (_context && err == EGL_SUCCESS) { diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index b7e7d5dccf..094d4ae547 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -104,7 +104,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -156,7 +156,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void eglGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -180,7 +180,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void eglGraphicsWindow:: end_flip() { - if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { + if (_gsg != nullptr && _flip_ready) { // It doesn't appear to be necessary to ensure the graphics context is // current before flipping the windows, and insisting on doing so can be a @@ -199,7 +199,7 @@ end_flip() { */ void eglGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { egldisplay_cat.error() << "Failed to call eglMakeCurrent: " << get_egl_error_string(eglGetError()) << "\n"; @@ -207,9 +207,9 @@ close_window() { _gsg.clear(); } - if (_ic != (XIC)NULL) { + if (_ic != (XIC)nullptr) { XDestroyIC(_ic); - _ic = (XIC)NULL; + _ic = (XIC)nullptr; } if (_egl_surface != 0) { @@ -219,9 +219,9 @@ close_window() { } } - if (_xwindow != (X11_Window)NULL) { + if (_xwindow != (X11_Window)nullptr) { XDestroyWindow(_display, _xwindow); - _xwindow = (X11_Window)NULL; + _xwindow = (X11_Window)nullptr; // This may be necessary if we just closed the last X window in an // application, so the server hears the close request. @@ -243,7 +243,7 @@ open_window() { eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, NULL); + eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, nullptr); eglgsg->choose_pixel_format(_fb_properties, egl_pipe->get_display(), egl_pipe->get_screen(), false, false); _gsg = eglgsg; } else { @@ -258,7 +258,7 @@ open_window() { } _visual_info = eglgsg->_visual; - if (_visual_info == NULL) { + if (_visual_info == nullptr) { // No X visual for this fbconfig; how can we open the window? egldisplay_cat.error() << "No X visual: cannot open window.\n"; @@ -271,7 +271,7 @@ open_window() { return false; } - _egl_surface = eglCreateWindowSurface(_egl_display, eglgsg->_fbconfig, (NativeWindowType) _xwindow, NULL); + _egl_surface = eglCreateWindowSurface(_egl_display, eglgsg->_fbconfig, (NativeWindowType) _xwindow, nullptr); if (eglGetError() != EGL_SUCCESS) { egldisplay_cat.error() << "Failed to create window surface.\n"; diff --git a/panda/src/event/asyncFuture.I b/panda/src/event/asyncFuture.I index a11fb6b36a..960ce56b49 100644 --- a/panda/src/event/asyncFuture.I +++ b/panda/src/event/asyncFuture.I @@ -17,8 +17,8 @@ INLINE AsyncFuture:: AsyncFuture() : _manager(nullptr), - _future_state(FS_pending), - _result(nullptr) { + _result(nullptr), + _future_state(FS_pending) { } /** @@ -89,7 +89,7 @@ get_result(TypedObject *&ptr, ReferenceCount *&ref_ptr) const { * Sets this future's result. Can only be called if done() returns false. */ INLINE void AsyncFuture:: -set_result(nullptr_t) { +set_result(std::nullptr_t) { set_result(nullptr, nullptr); } diff --git a/panda/src/event/asyncFuture.h b/panda/src/event/asyncFuture.h index 18d5b773f1..5349ced637 100644 --- a/panda/src/event/asyncFuture.h +++ b/panda/src/event/asyncFuture.h @@ -83,7 +83,7 @@ PUBLISHED: BLOCKING void wait(); BLOCKING void wait(double timeout); - INLINE void set_result(nullptr_t); + INLINE void set_result(std::nullptr_t); INLINE void set_result(TypedObject *result); INLINE void set_result(TypedReferenceCount *result); INLINE void set_result(TypedWritableReferenceCount *result); diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index 95b4e5aad1..f5a796643c 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -34,8 +34,8 @@ AsyncTask(const string &name) : _sort(0), _priority(0), _state(S_inactive), - _servicing_thread(NULL), - _chain(NULL), + _servicing_thread(nullptr), + _chain(nullptr), _start_time(0.0), _start_frame(0), _dt(0.0), @@ -59,7 +59,7 @@ AsyncTask(const string &name) : */ AsyncTask:: ~AsyncTask() { - nassertv(_state == S_inactive && _manager == NULL && _chain == NULL); + nassertv(_state == S_inactive && _manager == nullptr && _chain == nullptr); } /** @@ -100,7 +100,7 @@ remove() { */ double AsyncTask:: get_wake_time() const { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_sleeping) { return _wake_time; @@ -122,7 +122,7 @@ get_wake_time() const { */ void AsyncTask:: recalc_wake_time() { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_sleeping) { double now = _manager->_clock->get_frame_time(); @@ -144,7 +144,7 @@ recalc_wake_time() { double AsyncTask:: get_elapsed_time() const { nassertr(_state != S_inactive, 0.0); - nassertr(_manager != (AsyncTaskManager *)NULL, 0.0); + nassertr(_manager != nullptr, 0.0); return _manager->_clock->get_frame_time() - _start_time; } @@ -157,7 +157,7 @@ get_elapsed_time() const { int AsyncTask:: get_elapsed_frames() const { nassertr(_state != S_inactive, 0); - nassertr(_manager != (AsyncTaskManager *)NULL, 0); + nassertr(_manager != nullptr, 0); return _manager->_clock->get_frame_count() - _start_frame; } @@ -166,7 +166,7 @@ get_elapsed_frames() const { */ void AsyncTask:: set_name(const string &name) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (Namable::get_name() != name) { // Changing an active task's name requires moving it around on its name @@ -247,7 +247,7 @@ get_name_prefix() const { void AsyncTask:: set_task_chain(const string &chain_name) { if (chain_name != _chain_name) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_active) { // Changing chains on an "active" (i.e. enqueued) task means removing @@ -256,7 +256,7 @@ set_task_chain(const string &chain_name) { PT(AsyncTaskManager) manager = _manager; AsyncTaskChain *chain_a = manager->do_find_task_chain(_chain_name); - nassertv(chain_a != (AsyncTaskChain *)NULL); + nassertv(chain_a != nullptr); chain_a->do_remove(this); _chain_name = chain_name; @@ -290,14 +290,14 @@ set_task_chain(const string &chain_name) { void AsyncTask:: set_sort(int sort) { if (sort != _sort) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_active && _sort >= _chain->_current_sort) { // Changing sort on an "active" (i.e. enqueued) task means removing // it and re-inserting it into the queue. PT(AsyncTask) hold_task = this; AsyncTaskChain *chain = _manager->do_find_task_chain(_chain_name); - nassertv(chain != (AsyncTaskChain *)NULL); + nassertv(chain != nullptr); chain->do_remove(this); _sort = sort; chain->do_add(this); @@ -335,14 +335,14 @@ set_sort(int sort) { void AsyncTask:: set_priority(int priority) { if (priority != _priority) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_active && _sort >= _chain->_current_sort) { // Changing priority on an "active" (i.e. enqueued) task means // removing it and re-inserting it into the queue. PT(AsyncTask) hold_task = this; AsyncTaskChain *chain = _manager->do_find_task_chain(_chain_name); - nassertv(chain != (AsyncTaskChain *)NULL); + nassertv(chain != nullptr); chain->do_remove(this); _priority = priority; chain->do_add(this); @@ -378,7 +378,7 @@ output(ostream &out) const { void AsyncTask:: jump_to_task_chain(AsyncTaskManager *manager) { AsyncTaskChain *chain_b = manager->do_find_task_chain(_chain_name); - if (chain_b == (AsyncTaskChain *)NULL) { + if (chain_b == nullptr) { task_cat.warning() << "Creating implicit AsyncTaskChain " << _chain_name << " for " << manager->get_type() << " " @@ -540,7 +540,7 @@ upon_death(AsyncTaskManager *manager, bool clean_exit) { //NB. done_event is now being thrown in AsyncFuture::notify_done(). // Throw a generic remove event for the manager. - if (manager != (AsyncTaskManager *)NULL) { + if (manager != nullptr) { string remove_name = manager->get_name() + "-removeTask"; PT_Event event = new Event(remove_name); event->add_parameter(EventParameter(this)); diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index 1d131d62df..eb00a5b08d 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -404,8 +404,8 @@ write(ostream &out, int indent_level) const { */ void AsyncTaskChain:: do_add(AsyncTask *task) { - nassertv(task->_chain == NULL && - task->_manager == NULL && + nassertv(task->_chain == nullptr && + task->_manager == nullptr && task->_chain_name == get_name() && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); @@ -652,7 +652,7 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { pop_heap(_active.begin(), _active.end(), AsyncTaskSortPriority()); _active.pop_back(); - if (thread != (AsyncTaskChain::AsyncTaskChainThread *)NULL) { + if (thread != nullptr) { thread->_servicing = task; } @@ -669,10 +669,10 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { AsyncTask::DoneStatus ds = task->unlock_and_do_task(); - if (thread != (AsyncTaskChain::AsyncTaskChainThread *)NULL) { - thread->_servicing = NULL; + if (thread != nullptr) { + thread->_servicing = nullptr; } - task->_servicing_thread = NULL; + task->_servicing_thread = nullptr; if (task->_chain == this) { if (task->_state == AsyncTask::S_servicing_removed) { @@ -1099,7 +1099,7 @@ do_get_active_tasks() const { Threads::const_iterator thi; for (thi = _threads.begin(); thi != _threads.end(); ++thi) { AsyncTask *task = (*thi)->_servicing; - if (task != (AsyncTask *)NULL) { + if (task != nullptr) { result.add_task(task); } } @@ -1188,7 +1188,7 @@ do_poll() { // in poll(). But it's possible, if someone calls set_num_threads() // while we're processing. _num_busy_threads++; - service_one_task(NULL); + service_one_task(nullptr); _num_busy_threads--; _cvar.notify_all(); @@ -1228,7 +1228,7 @@ cleanup_pickup_mode() { */ void AsyncTaskChain:: do_output(ostream &out) const { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { out << _manager->get_type() << " " << _manager->get_name(); } else { out << "(no manager)"; @@ -1288,7 +1288,7 @@ do_write(ostream &out, int indent_level) const { Threads::const_iterator thi; for (thi = _threads.begin(); thi != _threads.end(); ++thi) { AsyncTask *task = (*thi)->_servicing; - if (task != (AsyncTask *)NULL) { + if (task != nullptr) { tasks.push_back(task); } } @@ -1379,7 +1379,7 @@ AsyncTaskChain::AsyncTaskChainThread:: AsyncTaskChainThread(const string &name, AsyncTaskChain *chain) : Thread(name, chain->get_name()), _chain(chain), - _servicing(NULL) + _servicing(nullptr) { } diff --git a/panda/src/event/asyncTaskCollection.cxx b/panda/src/event/asyncTaskCollection.cxx index 80999362e1..af5b1bc2f5 100644 --- a/panda/src/event/asyncTaskCollection.cxx +++ b/panda/src/event/asyncTaskCollection.cxx @@ -46,7 +46,7 @@ add_task(AsyncTask *task) { // If the pointer to our internal array is shared by any other // AsyncTaskCollections, we have to copy the array now so we won't // inadvertently modify any of our brethren AsyncTaskCollection objects. - nassertv(task != (AsyncTask *)NULL); + nassertv(task != nullptr); if (_tasks.get_ref_count() > 1) { AsyncTasks old_tasks = _tasks; @@ -182,7 +182,7 @@ find_task(const string &name) const { return task; } } - return NULL; + return nullptr; } /** diff --git a/panda/src/event/asyncTaskCollection.h b/panda/src/event/asyncTaskCollection.h index 4ed6f6a59b..70918bc49f 100644 --- a/panda/src/event/asyncTaskCollection.h +++ b/panda/src/event/asyncTaskCollection.h @@ -24,7 +24,7 @@ * * TODO: None of this is thread-safe yet. */ -class EXPCL_PANDA_PGRAPH AsyncTaskCollection { +class EXPCL_PANDA_EVENT AsyncTaskCollection { PUBLISHED: AsyncTaskCollection(); AsyncTaskCollection(const AsyncTaskCollection ©); diff --git a/panda/src/event/asyncTaskManager.I b/panda/src/event/asyncTaskManager.I index c1e5775a55..8cf788dc9e 100644 --- a/panda/src/event/asyncTaskManager.I +++ b/panda/src/event/asyncTaskManager.I @@ -48,7 +48,7 @@ get_num_tasks() const { */ INLINE AsyncTaskManager *AsyncTaskManager:: get_global_ptr() { - if (_global_ptr == (AsyncTaskManager *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index c19c194e60..a9bab44898 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -22,7 +22,7 @@ #include "config_event.h" #include -AsyncTaskManager *AsyncTaskManager::_global_ptr = NULL; +AsyncTaskManager *AsyncTaskManager::_global_ptr = nullptr; TypeHandle AsyncTaskManager::_type_handle; @@ -114,7 +114,7 @@ get_num_task_chains() const { AsyncTaskChain *AsyncTaskManager:: get_task_chain(int n) const { MutexHolder holder(_lock); - nassertr(n >= 0 && n < (int)_task_chains.size(), NULL); + nassertr(n >= 0 && n < (int)_task_chains.size(), nullptr); return _task_chains[n]; } @@ -196,19 +196,19 @@ add(AsyncTask *task) { } } - nassertv(task->_manager == NULL && + nassertv(task->_manager == nullptr && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); _lock.unlock(); task->upon_birth(this); _lock.lock(); - nassertv(task->_manager == NULL && + nassertv(task->_manager == nullptr && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); AsyncTaskChain *chain = do_find_task_chain(task->_chain_name); - if (chain == (AsyncTaskChain *)NULL) { + if (chain == nullptr) { task_cat.warning() << "Creating implicit AsyncTaskChain " << task->_chain_name << " for " << get_type() << " " << get_name() << "\n"; @@ -257,7 +257,7 @@ find_task(const string &name) const { return (*tbni); } - return NULL; + return nullptr; } /** @@ -576,7 +576,7 @@ do_find_task_chain(const string &name) { return (*tci); } - return NULL; + return nullptr; } /** @@ -639,7 +639,7 @@ do_output(ostream &out) const { */ void AsyncTaskManager:: make_global_ptr() { - nassertv(_global_ptr == (AsyncTaskManager *)NULL); + nassertv(_global_ptr == nullptr); _global_ptr = new AsyncTaskManager("TaskManager"); _global_ptr->ref(); diff --git a/panda/src/event/asyncTaskSequence.cxx b/panda/src/event/asyncTaskSequence.cxx index fe306c26a3..b84a968386 100644 --- a/panda/src/event/asyncTaskSequence.cxx +++ b/panda/src/event/asyncTaskSequence.cxx @@ -32,7 +32,7 @@ AsyncTaskSequence(const string &name) : */ AsyncTaskSequence:: ~AsyncTaskSequence() { - set_current_task(NULL, true); + set_current_task(nullptr, true); } /** @@ -60,7 +60,7 @@ do_task() { if (_task_index >= get_num_tasks()) { // Ran off the end of the task list. - set_current_task(NULL, true); + set_current_task(nullptr, true); _task_index = 0; if (_task_index >= get_num_tasks()) { return DS_done; @@ -76,7 +76,7 @@ do_task() { AsyncTask *task = get_task(_task_index); set_current_task(task, true); - nassertr(_current_task != (AsyncTask *)NULL, DS_exit); + nassertr(_current_task != nullptr, DS_exit); DoneStatus result = _current_task->do_task(); switch (result) { @@ -127,7 +127,7 @@ void AsyncTaskSequence:: upon_birth(AsyncTaskManager *manager) { AsyncTask::upon_birth(manager); _task_index = 0; - set_current_task(NULL, true); + set_current_task(nullptr, true); } /** @@ -147,7 +147,7 @@ upon_birth(AsyncTaskManager *manager) { void AsyncTaskSequence:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); - set_current_task(NULL, clean_exit); + set_current_task(nullptr, clean_exit); } /** @@ -159,22 +159,22 @@ set_current_task(AsyncTask *task, bool clean_exit) { return; } - if (_current_task != (AsyncTask *)NULL) { + if (_current_task != nullptr) { nassertv(_current_task->_state == S_active_nested); - nassertv(_current_task->_manager == _manager || _manager == NULL); + nassertv(_current_task->_manager == _manager || _manager == nullptr); _current_task->_state = S_inactive; - _current_task->_manager = NULL; + _current_task->_manager = nullptr; _current_task->upon_death(_manager, clean_exit); } _current_task = task; - if (_current_task != (AsyncTask *)NULL) { + if (_current_task != nullptr) { nassertv(_current_task->_state == S_inactive); - nassertv(_current_task->_manager == NULL); + nassertv(_current_task->_manager == nullptr); _current_task->upon_birth(_manager); nassertv(_current_task->_state == S_inactive); - nassertv(_current_task->_manager == NULL); + nassertv(_current_task->_manager == nullptr); _current_task->_manager = _manager; _current_task->_state = S_active_nested; diff --git a/panda/src/event/event.cxx b/panda/src/event/event.cxx index fb510626d2..4453b890f3 100644 --- a/panda/src/event/event.cxx +++ b/panda/src/event/event.cxx @@ -86,7 +86,7 @@ get_parameter(int n) const { */ bool Event:: has_receiver() const { - return _receiver != (EventReceiver *)NULL; + return _receiver != nullptr; } /** @@ -110,7 +110,7 @@ set_receiver(EventReceiver *receiver) { */ void Event:: clear_receiver() { - _receiver = (EventReceiver *)NULL; + _receiver = nullptr; } /** diff --git a/panda/src/event/event.h b/panda/src/event/event.h index e09c4c2500..383329e233 100644 --- a/panda/src/event/event.h +++ b/panda/src/event/event.h @@ -32,7 +32,7 @@ class EventReceiver; */ class EXPCL_PANDA_EVENT Event : public TypedReferenceCount { PUBLISHED: - Event(const string &event_name, EventReceiver *receiver = NULL); + Event(const string &event_name, EventReceiver *receiver = nullptr); Event(const Event ©); void operator = (const Event ©); ~Event(); diff --git a/panda/src/event/eventHandler.cxx b/panda/src/event/eventHandler.cxx index 020ba905d5..998946e92b 100644 --- a/panda/src/event/eventHandler.cxx +++ b/panda/src/event/eventHandler.cxx @@ -17,7 +17,7 @@ TypeHandle EventHandler::_type_handle; -EventHandler *EventHandler::_global_event_handler = NULL; +EventHandler *EventHandler::_global_event_handler = nullptr; /** @@ -64,7 +64,7 @@ process_events() { */ void EventHandler:: dispatch_event(const Event *event) { - nassertv(event != (Event *)NULL); + nassertv(event != nullptr); // Is the event name defined in the hook table? It will be if anyone has // ever assigned a hook to this particular event name. diff --git a/panda/src/event/eventHandler.h b/panda/src/event/eventHandler.h index 39d84475a4..cefba2710f 100644 --- a/panda/src/event/eventHandler.h +++ b/panda/src/event/eventHandler.h @@ -52,7 +52,7 @@ PUBLISHED: void write(ostream &out) const; - INLINE static EventHandler *get_global_event_handler(EventQueue *queue = NULL); + INLINE static EventHandler *get_global_event_handler(EventQueue *queue = nullptr); public: bool add_hook(const string &event_name, EventFunction *function); diff --git a/panda/src/event/eventParameter.I b/panda/src/event/eventParameter.I index 14727106e6..1aa1888017 100644 --- a/panda/src/event/eventParameter.I +++ b/panda/src/event/eventParameter.I @@ -93,7 +93,7 @@ INLINE EventParameter:: */ INLINE bool EventParameter:: is_empty() const { - return (_ptr == (TypedWritableReferenceCount *)NULL); + return (_ptr == nullptr); } /** @@ -205,7 +205,7 @@ is_typed_ref_count() const { */ INLINE TypedReferenceCount *EventParameter:: get_typed_ref_count_value() const { - nassertr(is_typed_ref_count(), NULL); + nassertr(is_typed_ref_count(), nullptr); return ((const EventStoreTypedRefCount *)_ptr.p())->get_value(); } diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index e5e55a1bac..40122908cd 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -22,7 +22,7 @@ template class ParamValue; */ void EventParameter:: output(ostream &out) const { - if (_ptr == (TypedWritableReferenceCount *)NULL) { + if (_ptr == nullptr) { out << "(empty)"; } else if (_ptr->is_of_type(ParamValueBase::get_class_type())) { diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index 24ea3ec1e2..8519c3c4d6 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -35,7 +35,7 @@ class EXPCL_PANDA_EVENT EventParameter { PUBLISHED: INLINE EventParameter() = default; - INLINE EventParameter(nullptr_t) {}; + INLINE EventParameter(std::nullptr_t) {}; INLINE EventParameter(const TypedWritableReferenceCount *ptr); INLINE EventParameter(const TypedReferenceCount *ptr); INLINE EventParameter(int value); diff --git a/panda/src/event/eventQueue.I b/panda/src/event/eventQueue.I index 7887696222..22b97a99d7 100644 --- a/panda/src/event/eventQueue.I +++ b/panda/src/event/eventQueue.I @@ -17,7 +17,7 @@ */ INLINE EventQueue *EventQueue:: get_global_event_queue() { - if (_global_event_queue == NULL) { + if (_global_event_queue == nullptr) { make_global_event_queue(); } return _global_event_queue; diff --git a/panda/src/event/eventQueue.cxx b/panda/src/event/eventQueue.cxx index fa423b0ca9..bbd07a3725 100644 --- a/panda/src/event/eventQueue.cxx +++ b/panda/src/event/eventQueue.cxx @@ -15,7 +15,7 @@ #include "config_event.h" #include "lightMutexHolder.h" -EventQueue *EventQueue::_global_event_queue = NULL; +EventQueue *EventQueue::_global_event_queue = nullptr; /** diff --git a/panda/src/event/genericAsyncTask.cxx b/panda/src/event/genericAsyncTask.cxx index 28cbebe55f..c0d68fa3ff 100644 --- a/panda/src/event/genericAsyncTask.cxx +++ b/panda/src/event/genericAsyncTask.cxx @@ -23,10 +23,10 @@ GenericAsyncTask:: GenericAsyncTask(const string &name) : AsyncTask(name) { - _function = NULL; - _upon_birth = NULL; - _upon_death = NULL; - _user_data = NULL; + _function = nullptr; + _upon_birth = nullptr; + _upon_death = nullptr; + _user_data = nullptr; } /** @@ -38,8 +38,8 @@ GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void _function(function), _user_data(user_data) { - _upon_birth = NULL; - _upon_death = NULL; + _upon_birth = nullptr; + _upon_death = nullptr; } /** @@ -51,7 +51,7 @@ GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void */ bool GenericAsyncTask:: is_runnable() { - return _function != NULL; + return _function != nullptr; } /** @@ -61,7 +61,7 @@ is_runnable() { */ AsyncTask::DoneStatus GenericAsyncTask:: do_task() { - nassertr(_function != NULL, DS_interrupt); + nassertr(_function != nullptr, DS_interrupt); return (*_function)(this, _user_data); } @@ -75,7 +75,7 @@ void GenericAsyncTask:: upon_birth(AsyncTaskManager *manager) { AsyncTask::upon_birth(manager); - if (_upon_birth != NULL) { + if (_upon_birth != nullptr) { (*_upon_birth)(this, _user_data); } } @@ -97,7 +97,7 @@ void GenericAsyncTask:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); - if (_upon_death != NULL) { + if (_upon_death != nullptr) { (*_upon_death)(this, clean_exit, _user_data); } } diff --git a/panda/src/event/genericAsyncTask.h b/panda/src/event/genericAsyncTask.h index 9ff7ae272a..6530a8112a 100644 --- a/panda/src/event/genericAsyncTask.h +++ b/panda/src/event/genericAsyncTask.h @@ -23,7 +23,7 @@ * You can use this when you want to create an AsyncTask without having to * subclass. */ -class EXPCL_PANDA_PIPELINE GenericAsyncTask : public AsyncTask { +class EXPCL_PANDA_EVENT GenericAsyncTask : public AsyncTask { public: typedef DoneStatus TaskFunc(GenericAsyncTask *task, void *user_data); typedef void BirthFunc(GenericAsyncTask *task, void *user_data); diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 6a818ad19c..8ffa0e0793 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -134,7 +134,7 @@ set_function(PyObject *function) { void PythonTask:: set_args(PyObject *args, bool append_task) { Py_XDECREF(_args); - _args = NULL; + _args = nullptr; if (args == Py_None) { // None means no arguments; create an empty tuple. @@ -145,7 +145,7 @@ set_args(PyObject *args, bool append_task) { } } - if (_args == NULL) { + if (_args == nullptr) { nassert_raise("Invalid args passed to PythonTask"); _args = PyTuple_New(0); } @@ -213,15 +213,15 @@ set_owner(PyObject *owner) { PyObject *add = PyObject_GetAttrString(owner, "_addTask"); PyObject *clear = PyObject_GetAttrString(owner, "_clearTask"); - if (add == NULL || !PyCallable_Check(add) || - clear == NULL || !PyCallable_Check(clear)) { + if (add == nullptr || !PyCallable_Check(add) || + clear == nullptr || !PyCallable_Check(clear)) { Dtool_Raise_TypeError("owner object should have _addTask and _clearTask methods"); return; } } #endif - if (_owner != NULL && _owner != Py_None && _state != S_inactive) { + if (_owner != nullptr && _owner != Py_None && _state != S_inactive) { unregister_from_owner(); } @@ -318,7 +318,7 @@ __setattr__(PyObject *self, PyObject *attr, PyObject *v) { */ int PythonTask:: __delattr__(PyObject *self, PyObject *attr) { - if (PyObject_GenericSetAttr(self, attr, NULL) == 0) { + if (PyObject_GenericSetAttr(self, attr, nullptr) == 0) { return 0; } @@ -360,7 +360,7 @@ __getattr__(PyObject *attr) const { PyObject *item = PyDict_GetItem(__dict__, attr); - if (item == NULL) { + if (item == nullptr) { // PyDict_GetItem does not raise an exception. #if PY_MAJOR_VERSION < 3 PyErr_Format(PyExc_AttributeError, @@ -371,7 +371,7 @@ __getattr__(PyObject *attr) const { "'PythonTask' object has no attribute '%U'", attr); #endif - return NULL; + return nullptr; } // PyDict_GetItem returns a borrowed reference. @@ -683,7 +683,7 @@ do_python_task() { switch (retval) { case DS_again: Py_XDECREF(_generator); - _generator = NULL; + _generator = nullptr; // Fall through. case DS_done: @@ -727,14 +727,14 @@ do_python_task() { ostringstream strm; #if PY_MAJOR_VERSION >= 3 PyObject *str = PyObject_ASCII(result); - if (str == NULL) { + if (str == nullptr) { str = PyUnicode_FromString(""); } strm << *this << " returned " << PyUnicode_AsUTF8(str); #else PyObject *str = PyObject_Repr(result); - if (str == NULL) { + if (str == nullptr) { str = PyString_FromString(""); } strm @@ -844,7 +844,7 @@ void PythonTask:: call_owner_method(const char *method_name) { if (_owner != Py_None) { PyObject *func = PyObject_GetAttrString(_owner, (char *)method_name); - if (func == (PyObject *)NULL) { + if (func == nullptr) { task_cat.error() << "Owner object added to " << *this << " has no method " << method_name << "().\n"; diff --git a/panda/src/express/compress_string.cxx b/panda/src/express/compress_string.cxx index 8a32947490..2959d5d1a6 100644 --- a/panda/src/express/compress_string.cxx +++ b/panda/src/express/compress_string.cxx @@ -73,14 +73,14 @@ compress_file(const Filename &source, const Filename &dest, int compression_leve source_filename.set_binary(); } istream *source_stream = vfs->open_read_file(source_filename, false); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } Filename dest_filename = Filename::binary_filename(dest); ostream *dest_stream = vfs->open_write_file(dest_filename, false, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; @@ -106,7 +106,7 @@ decompress_file(const Filename &source, const Filename &dest) { Filename source_filename = Filename::binary_filename(source); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *source_stream = vfs->open_read_file(source_filename, false); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } @@ -117,7 +117,7 @@ decompress_file(const Filename &source, const Filename &dest) { dest_filename.set_binary(); } ostream *dest_stream = vfs->open_write_file(dest_filename, false, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index d86e300436..ee38f6cd69 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -150,9 +150,9 @@ init_libexpress() { bool get_use_high_res_clock() { - static ConfigVariableBool *use_high_res_clock = NULL; + static ConfigVariableBool *use_high_res_clock = nullptr; - if (use_high_res_clock == (ConfigVariableBool *)NULL) { + if (use_high_res_clock == nullptr) { use_high_res_clock = new ConfigVariableBool ("use-high-res-clock", true, PRC_DESC("Set this to false to avoid using the high-precision clock, even if " @@ -164,9 +164,9 @@ get_use_high_res_clock() { bool get_paranoid_clock() { - static ConfigVariableBool *paranoid_clock = NULL; + static ConfigVariableBool *paranoid_clock = nullptr; - if (paranoid_clock == (ConfigVariableBool *)NULL) { + if (paranoid_clock == nullptr) { paranoid_clock = new ConfigVariableBool ("paranoid-clock", false, PRC_DESC("Set this to true to double-check the results of the high-resolution " @@ -178,9 +178,9 @@ get_paranoid_clock() { bool get_verify_dcast() { - static ConfigVariableBool *verify_dcast = NULL; + static ConfigVariableBool *verify_dcast = nullptr; - if (verify_dcast == (ConfigVariableBool *)NULL) { + if (verify_dcast == nullptr) { verify_dcast = new ConfigVariableBool ("verify-dcast", true, PRC_DESC("Set this to true to verify that every attempted DCAST operation in " diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 499bfab48b..98f5fcea14 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -157,9 +157,9 @@ add_float64(PN_float64 value) { INLINE void Datagram:: add_stdfloat(PN_stdfloat value) { if (_stdfloat_double) { - add_float64(value); + add_float64((double)value); } else { - add_float32(value); + add_float32((float)value); } } @@ -378,7 +378,7 @@ get_array() const { */ INLINE PTA_uchar Datagram:: modify_array() { - if (_data == (uchar *)NULL) { + if (_data == nullptr) { // Create a new array. _data = PTA_uchar::empty_array(0); @@ -420,7 +420,7 @@ operator == (const Datagram &other) const { if (_data == other._data) { return true; } - if (_data != (uchar *)NULL && other._data != (uchar *)NULL) { + if (_data != nullptr && other._data != nullptr) { return _data.v() == other._data.v(); } return false; @@ -444,7 +444,7 @@ operator < (const Datagram &other) const { return false; } - if (_data != (uchar *)NULL && other._data != (uchar *)NULL) { + if (_data != nullptr && other._data != nullptr) { // Different pointers, neither NULL. return _data.v() < other._data.v(); } diff --git a/panda/src/express/datagram.cxx b/panda/src/express/datagram.cxx index 1121953948..826a261f93 100644 --- a/panda/src/express/datagram.cxx +++ b/panda/src/express/datagram.cxx @@ -99,7 +99,7 @@ void Datagram:: pad_bytes(size_t size) { nassertv((int)size >= 0); - if (_data == (uchar *)NULL) { + if (_data == nullptr) { // Create a new array. _data = PTA_uchar::empty_array(0); @@ -129,7 +129,7 @@ void Datagram:: append_data(const void *data, size_t size) { nassertv((int)size >= 0); - if (_data == (uchar *)NULL) { + if (_data == nullptr) { // Create a new array. _data = PTA_uchar::empty_array(0); diff --git a/panda/src/express/datagramGenerator.cxx b/panda/src/express/datagramGenerator.cxx index a5e9f52bb8..08d792bd70 100644 --- a/panda/src/express/datagramGenerator.cxx +++ b/panda/src/express/datagramGenerator.cxx @@ -44,7 +44,7 @@ save_datagram(SubfileInfo &info) { const Filename &DatagramGenerator:: get_filename() { const FileReference *file = get_file(); - if (file != (FileReference *)NULL) { + if (file != nullptr) { return file->get_filename(); } static const Filename empty_filename; @@ -66,7 +66,7 @@ get_timestamp() const { */ const FileReference *DatagramGenerator:: get_file() { - return NULL; + return nullptr; } /** @@ -75,7 +75,7 @@ get_file() { */ VirtualFile *DatagramGenerator:: get_vfile() { - return NULL; + return nullptr; } /** diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index 42c25eeed4..33af92539f 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -16,7 +16,7 @@ */ INLINE DatagramIterator:: DatagramIterator() : - _datagram((Datagram *)NULL), + _datagram(nullptr), _current_index(0) { } @@ -54,7 +54,7 @@ get_bool() { */ INLINE int8_t DatagramIterator:: get_int8() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); // Avoid reading junk data off the end of the datagram: nassertr(_current_index < _datagram->get_length(), 0); // Get the Data: @@ -70,7 +70,7 @@ get_int8() { */ INLINE uint8_t DatagramIterator:: get_uint8() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); // Avoid reading junk data off the end of the datagram: nassertr(_current_index < _datagram->get_length(), 0); // Get the Data: @@ -86,7 +86,7 @@ get_uint8() { */ INLINE int16_t DatagramIterator:: get_int16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int16_t tempvar; @@ -105,7 +105,7 @@ get_int16() { */ INLINE int32_t DatagramIterator:: get_int32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int32_t tempvar; @@ -124,7 +124,7 @@ get_int32() { */ INLINE int64_t DatagramIterator:: get_int64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int64_t tempvar; @@ -143,7 +143,7 @@ get_int64() { */ INLINE uint16_t DatagramIterator:: get_uint16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint16_t tempvar; @@ -162,7 +162,7 @@ get_uint16() { */ INLINE uint32_t DatagramIterator:: get_uint32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint32_t tempvar; @@ -181,7 +181,7 @@ get_uint32() { */ INLINE uint64_t DatagramIterator:: get_uint64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint64_t tempvar; @@ -200,7 +200,7 @@ get_uint64() { */ INLINE PN_float32 DatagramIterator:: get_float32() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float32 tempvar; @@ -219,7 +219,7 @@ get_float32() { */ INLINE PN_float64 DatagramIterator:: get_float64() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float64 tempvar; @@ -240,7 +240,7 @@ get_float64() { */ INLINE PN_stdfloat DatagramIterator:: get_stdfloat() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); if (_datagram->get_stdfloat_double()) { return (PN_stdfloat)get_float64(); } else { @@ -253,7 +253,7 @@ get_stdfloat() { */ INLINE int16_t DatagramIterator:: get_be_int16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int16_t tempvar; @@ -272,7 +272,7 @@ get_be_int16() { */ INLINE int32_t DatagramIterator:: get_be_int32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int32_t tempvar; @@ -291,7 +291,7 @@ get_be_int32() { */ INLINE int64_t DatagramIterator:: get_be_int64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int64_t tempvar; @@ -310,7 +310,7 @@ get_be_int64() { */ INLINE uint16_t DatagramIterator:: get_be_uint16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint16_t tempvar; @@ -329,7 +329,7 @@ get_be_uint16() { */ INLINE uint32_t DatagramIterator:: get_be_uint32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint32_t tempvar; @@ -348,7 +348,7 @@ get_be_uint32() { */ INLINE uint64_t DatagramIterator:: get_be_uint64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint64_t tempvar; @@ -367,7 +367,7 @@ get_be_uint64() { */ INLINE PN_float32 DatagramIterator:: get_be_float32() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float32 tempvar; @@ -386,7 +386,7 @@ get_be_float32() { */ INLINE PN_float64 DatagramIterator:: get_be_float64() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float64 tempvar; @@ -405,7 +405,7 @@ get_be_float64() { */ INLINE void DatagramIterator:: skip_bytes(size_t size) { - nassertv(_datagram != (const Datagram *)NULL); + nassertv(_datagram != nullptr); nassertv((int)size >= 0); #ifndef NDEBUG if (_current_index + size > _datagram->get_length()) { @@ -424,7 +424,7 @@ skip_bytes(size_t size) { */ INLINE vector_uchar DatagramIterator:: get_remaining_bytes() const { - nassertr(_datagram != (const Datagram *)NULL, vector_uchar()); + nassertr(_datagram != nullptr, vector_uchar()); nassertr(_current_index <= _datagram->get_length(), vector_uchar()); const unsigned char *ptr = (const unsigned char *)_datagram->get_data(); diff --git a/panda/src/express/datagramIterator.cxx b/panda/src/express/datagramIterator.cxx index 880719f32b..4006ec1eea 100644 --- a/panda/src/express/datagramIterator.cxx +++ b/panda/src/express/datagramIterator.cxx @@ -24,7 +24,7 @@ get_string() { // First, get the length of the string uint16_t s_len = get_uint16(); - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); nassertr(_current_index + s_len <= _datagram->get_length(), ""); const char *ptr = (const char *)_datagram->get_data(); @@ -43,7 +43,7 @@ get_string32() { // First, get the length of the string uint32_t s_len = get_uint32(); - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); nassertr(_current_index + s_len <= _datagram->get_length(), ""); const char *ptr = (const char *)_datagram->get_data(); @@ -59,7 +59,7 @@ get_string32() { */ string DatagramIterator:: get_z_string() { - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); // First, determine the length of the string. const char *ptr = (const char *)_datagram->get_data(); @@ -82,7 +82,7 @@ get_z_string() { */ string DatagramIterator:: get_fixed_string(size_t size) { - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); nassertr(_current_index + size <= _datagram->get_length(), ""); const char *ptr = (const char *)_datagram->get_data(); @@ -102,7 +102,7 @@ get_wstring() { // First, get the length of the string uint32_t s_len = get_uint32(); - nassertr(_datagram != (const Datagram *)NULL, wstring()); + nassertr(_datagram != nullptr, wstring()); nassertr(_current_index + s_len * 2 <= _datagram->get_length(), wstring()); wstring result; @@ -122,7 +122,7 @@ get_wstring() { vector_uchar DatagramIterator:: extract_bytes(size_t size) { nassertr((int)size >= 0, vector_uchar()); - nassertr(_datagram != (const Datagram *)NULL, vector_uchar()); + nassertr(_datagram != nullptr, vector_uchar()); nassertr(_current_index + size <= _datagram->get_length(), vector_uchar()); const unsigned char *ptr = (const unsigned char *)_datagram->get_data(); @@ -142,7 +142,7 @@ extract_bytes(size_t size) { size_t DatagramIterator:: extract_bytes(unsigned char *into, size_t size) { nassertr((int)size >= 0, 0); - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index + size <= _datagram->get_length(), 0); const char *ptr = (const char *)_datagram->get_data(); diff --git a/panda/src/express/datagramSink.cxx b/panda/src/express/datagramSink.cxx index 0941ce10fb..5b451d3bb2 100644 --- a/panda/src/express/datagramSink.cxx +++ b/panda/src/express/datagramSink.cxx @@ -56,7 +56,7 @@ copy_datagram(SubfileInfo &result, const SubfileInfo &source) { const Filename &DatagramSink:: get_filename() { const FileReference *file = get_file(); - if (file != (FileReference *)NULL) { + if (file != nullptr) { return file->get_filename(); } static const Filename empty_filename; @@ -69,7 +69,7 @@ get_filename() { */ const FileReference *DatagramSink:: get_file() { - return NULL; + return nullptr; } /** diff --git a/panda/src/express/dcast.T b/panda/src/express/dcast.T index 251f278dce..b457984ec4 100644 --- a/panda/src/express/dcast.T +++ b/panda/src/express/dcast.T @@ -1,24 +1,20 @@ -// Filename: dcast.T -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcast.T + * @author drose + * @date 2001-08-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: _dcast_get_typehandle -// Description: Returns the TypeHandle associated with the type of -// the parameter, if it can be determined. This is a -// support function for _dcast, below. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle associated with the type of the parameter, if it can + * be determined. This is a support function for _dcast, below. + */ template INLINE TypeHandle _dcast_get_typehandle(WantType *) { @@ -38,16 +34,13 @@ _dcast_get_typehandle(WantType *) { return handle; } - -//////////////////////////////////////////////////////////////////// -// Function: _dcast -// Description: The implementation of the DCAST macro, this checks -// the actual type of the pointer before performing a -// downcast operation. In NDEBUG mode, it simply -// downcasts. -// -// This flavor of _dcast works on non-const pointers. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of the DCAST macro, this checks the actual type of the + * pointer before performing a downcast operation. In NDEBUG mode, it simply + * downcasts. + * + * This flavor of _dcast works on non-const pointers. + */ template INLINE WantType * _dcast(WantType *, TypedObject *ptr) { @@ -61,15 +54,13 @@ _dcast(WantType *, TypedObject *ptr) { return (WantType *)ptr; } -//////////////////////////////////////////////////////////////////// -// Function: _dcast -// Description: The implementation of the DCAST macro, this checks -// the actual type of the pointer before performing a -// downcast operation. In NDEBUG mode, it simply -// downcasts. -// -// This flavor of _dcast works on const pointers. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of the DCAST macro, this checks the actual type of the + * pointer before performing a downcast operation. In NDEBUG mode, it simply + * downcasts. + * + * This flavor of _dcast works on const pointers. + */ template INLINE const WantType * _dcast(WantType *, const TypedObject *ptr) { @@ -83,12 +74,10 @@ _dcast(WantType *, const TypedObject *ptr) { return (const WantType *)ptr; } -//////////////////////////////////////////////////////////////////// -// Function: _dcast_ref -// Description: Similar to the above, with a pointer reference as the -// first parameter. Just for fiddly compiler reasons; -// the reference isn't used. -//////////////////////////////////////////////////////////////////// +/** + * Similar to the above, with a pointer reference as the first parameter. + * Just for fiddly compiler reasons; the reference isn't used. +*/ template INLINE WantType * _dcast_ref(WantType *&, TypedObject *ptr) { diff --git a/panda/src/express/dcast.cxx b/panda/src/express/dcast.cxx index fcb0e02baf..63265fec6f 100644 --- a/panda/src/express/dcast.cxx +++ b/panda/src/express/dcast.cxx @@ -30,7 +30,7 @@ bool _dcast_verify(TypeHandle want_handle, size_t want_size, const TypedObject *ptr) { if (get_verify_dcast()) { - if (ptr == (const TypedObject *)NULL) { + if (ptr == nullptr) { // This is allowed these days. It used to be an error, but what the // heck. return true; diff --git a/panda/src/express/dcast.h b/panda/src/express/dcast.h index 4ab30bae3d..32ea9e4238 100644 --- a/panda/src/express/dcast.h +++ b/panda/src/express/dcast.h @@ -72,13 +72,13 @@ _dcast_verify(TypeHandle want_handle, size_t want_size, #define DCAST_INTO_V(to_pointer, from_pointer) \ { \ (to_pointer) = _dcast_ref(to_pointer, from_pointer); \ - nassertv((void *)(to_pointer) != (void *)NULL); \ + nassertv((void *)(to_pointer) != nullptr); \ } #define DCAST_INTO_R(to_pointer, from_pointer, return_value) \ { \ (to_pointer) = _dcast_ref(to_pointer, from_pointer); \ - nassertr((void *)(to_pointer) != (void *)NULL, return_value); \ + nassertr((void *)(to_pointer) != nullptr, return_value); \ } #include "dcast.T" diff --git a/panda/src/express/encrypt_string.cxx b/panda/src/express/encrypt_string.cxx index 0736e30be6..db72921aa8 100644 --- a/panda/src/express/encrypt_string.cxx +++ b/panda/src/express/encrypt_string.cxx @@ -85,14 +85,14 @@ encrypt_file(const Filename &source, const Filename &dest, const string &passwor source_filename.set_binary(); } istream *source_stream = vfs->open_read_file(source_filename, true); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } Filename dest_filename = Filename::binary_filename(dest); ostream *dest_stream = vfs->open_write_file(dest_filename, true, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; @@ -120,7 +120,7 @@ decrypt_file(const Filename &source, const Filename &dest, const string &passwor Filename source_filename = Filename::binary_filename(source); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *source_stream = vfs->open_read_file(source_filename, false); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } @@ -131,7 +131,7 @@ decrypt_file(const Filename &source, const Filename &dest, const string &passwor dest_filename.set_binary(); } ostream *dest_stream = vfs->open_write_file(dest_filename, true, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; diff --git a/panda/src/express/error_utils.cxx b/panda/src/express/error_utils.cxx index bae1da4a31..8a1ec79331 100644 --- a/panda/src/express/error_utils.cxx +++ b/panda/src/express/error_utils.cxx @@ -191,7 +191,7 @@ string handle_socket_error() { return string(strerror(errno)); #else int err = WSAGetLastError(); - char *errmsg; + const char *errmsg; switch (err) { case 10022: errmsg = "An invalid argument was supplied"; diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index aa08714668..797ead2ed2 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -39,7 +39,7 @@ output_hex(ostream &out) const { */ void HashVal:: input_hex(istream &in) { - in >> ws; + in >> std::ws; char buffer[32]; size_t i = 0; int ch = in.get(); @@ -174,7 +174,7 @@ hash_file(const Filename &filename) { Filename bin_filename = Filename::binary_filename(filename); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *istr = vfs->open_read_file(bin_filename, false); - if (istr == (istream *)NULL) { + if (istr == nullptr) { (*this) = HashVal(); return false; } diff --git a/panda/src/express/make_ca_bundle.cxx b/panda/src/express/make_ca_bundle.cxx index 0794312de1..a619a0a9f1 100644 --- a/panda/src/express/make_ca_bundle.cxx +++ b/panda/src/express/make_ca_bundle.cxx @@ -21,7 +21,7 @@ static const char *target_filename = "ca_bundle_data_src.c"; int main(int argc, char *argv[]) { FILE *fin = fopen(source_filename, "r"); - if (fin == NULL) { + if (fin == nullptr) { cerr << "Couldn't open " << source_filename << " for reading.\n"; return 1; } @@ -33,7 +33,7 @@ main(int argc, char *argv[]) { // function, or it will get confused. ERR_clear_error(); STACK_OF(X509_INFO) *inf; - inf = PEM_X509_INFO_read(fin, NULL, NULL, NULL); + inf = PEM_X509_INFO_read(fin, nullptr, nullptr, nullptr); if (!inf) { // Could not scan certificates. @@ -55,7 +55,7 @@ main(int argc, char *argv[]) { if (itmp->x509) { X509 *cert = itmp->x509; - int der_len = i2d_X509(cert, NULL); + int der_len = i2d_X509(cert, nullptr); unsigned char *der_buf = new unsigned char[der_len]; unsigned char *p = der_buf; i2d_X509(cert, &p); @@ -70,7 +70,7 @@ main(int argc, char *argv[]) { // Now write the data to the .c file, in a compilable form, similar to // bin2c. - ofstream out; + std::ofstream out; Filename target = Filename::text_filename(string(target_filename)); if (!target.open_write(out)) { cerr << "Couldn't open " << target_filename << " for writing.\n"; diff --git a/panda/src/express/memoryInfo.I b/panda/src/express/memoryInfo.I index 4fb25b34ca..2e1a0ba9ac 100644 --- a/panda/src/express/memoryInfo.I +++ b/panda/src/express/memoryInfo.I @@ -16,13 +16,13 @@ * NULL. */ void *MemoryInfo::get_void_ptr() const { - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { return _void_ptr; } - if (_ref_ptr == (void *)NULL) { + if (_ref_ptr == nullptr) { return _typed_ptr; } - if (_typed_ptr == (void *)NULL) { + if (_typed_ptr == nullptr) { return _ref_ptr; } return ((void *)_ref_ptr < (void *)_typed_ptr) ? (void *)_ref_ptr : (void *)_typed_ptr; diff --git a/panda/src/express/memoryInfo.cxx b/panda/src/express/memoryInfo.cxx index d12b7313a0..b753caa043 100644 --- a/panda/src/express/memoryInfo.cxx +++ b/panda/src/express/memoryInfo.cxx @@ -23,9 +23,9 @@ */ MemoryInfo:: MemoryInfo() { - _void_ptr = (void *)NULL; - _ref_ptr = (ReferenceCount *)NULL; - _typed_ptr = (TypedObject *)NULL; + _void_ptr = nullptr; + _ref_ptr = nullptr; + _typed_ptr = nullptr; _size = 0; _static_type = TypeHandle::none(); _dynamic_type = TypeHandle::none(); @@ -79,7 +79,7 @@ determine_dynamic_type() { _static_type != TypeHandle::none()) { // See if we know enough now to infer the dynamic type from the pointer. - if (_typed_ptr == (TypedObject *)NULL) { + if (_typed_ptr == nullptr) { // If our static type is known to inherit from TypedReferenceCount, then // we can directly downcast to get the TypedObject pointer. if (_static_type.is_derived_from(TypedReferenceCount::get_class_type())) { @@ -87,7 +87,7 @@ determine_dynamic_type() { } } - if (_typed_ptr != (TypedObject *)NULL) { + if (_typed_ptr != nullptr) { // If we have a TypedObject pointer, we can determine the type. This // might still not return the exact type, particularly if we are being // called within the destructor or constructor of this object. diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index 178de476fa..d38ac0c77e 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -387,7 +387,7 @@ mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { // We're recording this pointer as now in use. ns_record_void_pointer(ptr, size); - if (ref_ptr != (ReferenceCount *)NULL) { + if (ref_ptr != nullptr) { // Make the pointer typed. This is particularly necessary in case the // ref_ptr is a different value than the base void pointer; this may be // our only opportunity to associate the two pointers. @@ -599,7 +599,7 @@ ns_record_pointer(ReferenceCount *ptr) { // We might already have a ReferenceCount pointer, thanks to a previous // call to mark_pointer(). - nassertv(info->_ref_ptr == NULL || info->_ref_ptr == ptr); + nassertv(info->_ref_ptr == nullptr || info->_ref_ptr == ptr); info->_ref_ptr = ptr; info->_static_type = ReferenceCount::get_class_type(); @@ -765,7 +765,7 @@ ns_remove_pointer(ReferenceCount *ptr) { MemoryInfo *info = (*ti).second; - if (info->_ref_ptr == NULL) { + if (info->_ref_ptr == nullptr) { express_cat.error() << "Pointer " << (void *)ptr << " deleted twice!\n"; return; @@ -777,8 +777,8 @@ ns_remove_pointer(ReferenceCount *ptr) { << "Removing ReferenceCount pointer " << (void *)ptr << "\n"; } - info->_ref_ptr = (ReferenceCount *)NULL; - info->_typed_ptr = (TypedObject *)NULL; + info->_ref_ptr = nullptr; + info->_typed_ptr = nullptr; if (info->_freeze_index == _freeze_index) { double now = TrueClock::get_global_ptr()->get_long_time(); @@ -791,7 +791,7 @@ ns_remove_pointer(ReferenceCount *ptr) { _recursion_protect = false; } - if (ptr != info->_void_ptr || info->_void_ptr == NULL) { + if (ptr != info->_void_ptr || info->_void_ptr == nullptr) { // Remove the entry from the table. // We have to protect modifications to the table from recursive calls by @@ -800,7 +800,7 @@ ns_remove_pointer(ReferenceCount *ptr) { _table.erase(ti); _recursion_protect = false; - if (info->_void_ptr == NULL) { + if (info->_void_ptr == nullptr) { // That was the last entry. Remove it altogether. _total_cpp_size -= info->_size; if (info->_freeze_index == _freeze_index) { @@ -847,7 +847,7 @@ ns_record_void_pointer(void *ptr, size_t size) { MemoryInfo *info = (*insert_result.first).second; // We shouldn't already have a void pointer. - if (info->_void_ptr != (void *)NULL) { + if (info->_void_ptr != nullptr) { express_cat.error() << "Void pointer " << (void *)ptr << " recorded twice!\n"; nassertv(false); @@ -900,14 +900,14 @@ ns_remove_void_pointer(void *ptr) { MemoryInfo *info = (*ti).second; - if (info->_void_ptr == (void *)NULL) { + if (info->_void_ptr == nullptr) { express_cat.error() << "Pointer " << (void *)ptr << " deleted twice!\n"; return; } nassertv(info->_void_ptr == ptr); - if (info->_ref_ptr != (ReferenceCount *)NULL) { + if (info->_ref_ptr != nullptr) { express_cat.error() << "Pointer " << (void *)ptr << " did not destruct before being deleted!\n"; @@ -916,7 +916,7 @@ ns_remove_void_pointer(void *ptr) { } } - info->_void_ptr = NULL; + info->_void_ptr = nullptr; // Remove it from the table. @@ -970,7 +970,7 @@ ns_get_pointers(MemoryUsagePointers &result) { for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { result.add_entry(info->_ref_ptr, info->_typed_ptr, info->get_type(), now - info->_time); } @@ -997,7 +997,7 @@ ns_get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type) { for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { TypeHandle info_type = info->get_type(); if (info_type != TypeHandle::none() && info_type.is_derived_from(type)) { @@ -1029,7 +1029,7 @@ ns_get_pointers_of_age(MemoryUsagePointers &result, for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { double age = now - info->_time; if ((age >= from && age <= to) || (age >= to && age <= from)) { @@ -1071,7 +1071,7 @@ ns_get_pointers_with_zero_count(MemoryUsagePointers &result) { for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { if (info->_ref_ptr->get_ref_count() == 0) { info->_ref_ptr->ref(); result.add_entry(info->_ref_ptr, info->_typed_ptr, info->get_type(), @@ -1185,7 +1185,7 @@ consolidate_void_ptr(MemoryInfo *info) { return; } - if (info->_typed_ptr == (TypedObject *)NULL) { + if (info->_typed_ptr == nullptr) { // We don't have a typed pointer for this thing yet. return; } @@ -1199,7 +1199,7 @@ consolidate_void_ptr(MemoryInfo *info) { return; } - nassertv(info->_void_ptr == NULL); + nassertv(info->_void_ptr == nullptr); Table::iterator ti; ti = _table.find(typed_ptr); @@ -1212,7 +1212,7 @@ consolidate_void_ptr(MemoryInfo *info) { MemoryInfo *typed_info = (*ti).second; nassertv(typed_info->_void_ptr == typed_ptr && - typed_info->_ref_ptr == NULL); + typed_info->_ref_ptr == nullptr); info->_void_ptr = typed_info->_void_ptr; if (typed_info->is_size_known()) { diff --git a/panda/src/express/memoryUsage.h b/panda/src/express/memoryUsage.h index 9742348cac..cd72581704 100644 --- a/panda/src/express/memoryUsage.h +++ b/panda/src/express/memoryUsage.h @@ -156,12 +156,12 @@ private: * one pointer or the other. We don't store an entry for an object's * TypedObject pointer. */ - typedef map Table; + typedef std::map Table; Table _table; // This table indexes the individual MemoryInfo objects, for unique // iteration. - typedef set InfoSet; + typedef std::set InfoSet; InfoSet _info_set; bool _info_set_dirty; diff --git a/panda/src/express/memoryUsagePointers_ext.cxx b/panda/src/express/memoryUsagePointers_ext.cxx index c1013027ab..27376b9cad 100644 --- a/panda/src/express/memoryUsagePointers_ext.cxx +++ b/panda/src/express/memoryUsagePointers_ext.cxx @@ -36,18 +36,18 @@ get_python_pointer(size_t n) const { ReferenceCount *ref_ptr = _this->get_pointer(n); bool memory_rules = false; - if (ref_ptr != (ReferenceCount *)NULL) { + if (ref_ptr != nullptr) { memory_rules = true; ref_ptr->ref(); } - if (typed_ptr != (TypedObject *)NULL) { + if (typed_ptr != nullptr) { return DTool_CreatePyInstanceTyped(typed_ptr, Dtool_TypedObject, memory_rules, false, typed_ptr->get_type_index()); } - if (ref_ptr == (ReferenceCount *)NULL) { + if (ref_ptr == nullptr) { return Py_BuildValue(""); } diff --git a/panda/src/express/multifile.I b/panda/src/express/multifile.I index a498534726..aa10b223f1 100644 --- a/panda/src/express/multifile.I +++ b/panda/src/express/multifile.I @@ -35,7 +35,7 @@ set_multifile_name(const Filename &multifile_name) { */ INLINE bool Multifile:: is_read_valid() const { - return (_read != (IStreamWrapper *)NULL); + return (_read != nullptr); } /** @@ -44,7 +44,7 @@ is_read_valid() const { */ INLINE bool Multifile:: is_write_valid() const { - return (_write != (ostream *)NULL && !_write->fail()); + return (_write != nullptr && !_write->fail()); } /** @@ -354,11 +354,11 @@ Subfile() { _data_start = 0; _data_length = 0; _timestamp = 0; - _source = (istream *)NULL; + _source = nullptr; _flags = 0; _compression_level = 0; #ifdef HAVE_OPENSSL - _pkey = NULL; + _pkey = nullptr; #endif } diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 0bedba8909..937bfa8435 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -102,8 +102,8 @@ Multifile() : "be loaded quickly, without paying the cost of an expensive hash on " "each subfile in order to decrypt it.")); - _read = (IStreamWrapper *)NULL; - _write = (ostream *)NULL; + _read = nullptr; + _write = nullptr; _offset = 0; _owns_stream = false; _next_index = 0; @@ -152,11 +152,11 @@ open_read(const Filename &multifile_name, const streampos &offset) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(fname); - if (vfile == NULL) { + if (vfile == nullptr) { return false; } istream *multifile_stream = vfile->open_read_file(false); - if (multifile_stream == NULL) { + if (multifile_stream == nullptr) { return false; } @@ -181,7 +181,7 @@ bool Multifile:: open_read(IStreamWrapper *multifile_stream, bool owns_pointer, const streampos &offset) { close(); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _read = multifile_stream; _owns_stream = owns_pointer; @@ -206,7 +206,7 @@ open_write(const Filename &multifile_name) { if (!fname.open_write(_write_file, true)) { return false; } - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _write = &_write_file; _multifile_name = multifile_name; @@ -224,7 +224,7 @@ open_write(const Filename &multifile_name) { bool Multifile:: open_write(ostream *multifile_stream, bool owns_pointer) { close(); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _write = multifile_stream; _owns_stream = owns_pointer; @@ -253,7 +253,7 @@ open_read_write(const Filename &multifile_name) { if (exists) { _timestamp = fname.get_timestamp(); } else { - _timestamp = time(NULL); + _timestamp = time(nullptr); } _timestamp_dirty = true; _read = &_read_write_filew; @@ -279,7 +279,7 @@ open_read_write(const Filename &multifile_name) { bool Multifile:: open_read_write(iostream *multifile_stream, bool owns_pointer) { close(); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; // We don't support locking when opening a file in read-write mode, because @@ -319,15 +319,15 @@ close() { if (_owns_stream) { // We prefer to delete the IStreamWrapper over the ostream, if possible. - if (_read != (IStreamWrapper *)NULL) { + if (_read != nullptr) { delete _read; - } else if (_write != (ostream *)NULL) { + } else if (_write != nullptr) { delete _write; } } - _read = (IStreamWrapper *)NULL; - _write = (ostream *)NULL; + _read = nullptr; + _write = nullptr; _offset = 0; _owns_stream = false; _next_index = 0; @@ -424,7 +424,7 @@ add_subfile(const string &subfile_name, const Filename &filename, add_new_subfile(subfile, compression_level); } - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; return name; @@ -509,7 +509,7 @@ update_subfile(const string &subfile_name, const Filename &filename, add_new_subfile(subfile, compression_level); } - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; return name; @@ -603,9 +603,9 @@ add_signature(const Filename &certificate, const Filename &chain, // Create an in-memory BIO to read the "file" from the buffer. BIO *certificate_mbio = BIO_new_mem_buf((void *)certificate_data.data(), certificate_data.size()); - X509 *x509 = PEM_read_bio_X509(certificate_mbio, NULL, NULL, (void *)""); + X509 *x509 = PEM_read_bio_X509(certificate_mbio, nullptr, nullptr, (void *)""); BIO_free(certificate_mbio); - if (x509 == NULL) { + if (x509 == nullptr) { express_cat.info() << "Could not read certificate in " << certificate << ".\n"; return false; @@ -625,10 +625,10 @@ add_signature(const Filename &certificate, const Filename &chain, } BIO *chain_mbio = BIO_new_mem_buf((void *)chain_data.data(), chain_data.size()); - X509 *c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); - while (c != NULL) { + X509 *c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); + while (c != nullptr) { cert_chain.push_back(c); - c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); + c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); } BIO_free(chain_mbio); @@ -649,10 +649,10 @@ add_signature(const Filename &certificate, const Filename &chain, } BIO *pkey_mbio = BIO_new_mem_buf((void *)pkey_data.data(), pkey_data.size()); - EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, NULL, NULL, + EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, nullptr, nullptr, (void *)password.c_str()); BIO_free(pkey_mbio); - if (evp_pkey == NULL) { + if (evp_pkey == nullptr) { express_cat.info() << "Could not read private key in " << pkey << ".\n"; return false; @@ -694,10 +694,10 @@ add_signature(const Filename &composite, const string &password) { // Get the private key. BIO *pkey_mbio = BIO_new_mem_buf((void *)composite_data.data(), composite_data.size()); - EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, NULL, NULL, + EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, nullptr, nullptr, (void *)password.c_str()); BIO_free(pkey_mbio); - if (evp_pkey == NULL) { + if (evp_pkey == nullptr) { express_cat.info() << "Could not read private key in " << composite << ".\n"; return false; @@ -707,10 +707,10 @@ add_signature(const Filename &composite, const string &password) { CertChain cert_chain; BIO *chain_mbio = BIO_new_mem_buf((void *)composite_data.data(), composite_data.size()); - X509 *c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); - while (c != NULL) { + X509 *c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); + while (c != nullptr) { cert_chain.push_back(c); - c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); + c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); } BIO_free(chain_mbio); @@ -791,7 +791,7 @@ add_signature(const Multifile::CertChain &cert_chain, EVP_PKEY *pkey) { return false; } - if (pkey == NULL) { + if (pkey == nullptr) { express_cat.info() << "No private key given.\n"; return false; @@ -812,7 +812,7 @@ add_signature(const Multifile::CertChain &cert_chain, EVP_PKEY *pkey) { for (ci = cert_chain.begin(); ci != cert_chain.end(); ++ci) { X509 *cert = (*ci)._cert; - int der_len = i2d_X509(cert, NULL); + int der_len = i2d_X509(cert, nullptr); unsigned char *der_buf = new unsigned char[der_len]; unsigned char *p = der_buf; i2d_X509(cert, &p); @@ -886,7 +886,7 @@ get_signature_subject_name(int n) const { nassertr(!cert_chain.empty(), string()); X509_NAME *xname = X509_get_subject_name(cert_chain[0]._cert); - if (xname != NULL) { + if (xname != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an easier // way to extract the X509_NAME text? Curse these incomplete docs. BIO *mbio = BIO_new(BIO_s_mem()); @@ -930,15 +930,15 @@ get_signature_friendly_name(int n) const { // A complex OpenSSL interface to extract out the name in utf-8. X509_NAME *xname = X509_get_subject_name(cert_chain[0]._cert); - if (xname != NULL) { + if (xname != nullptr) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { // We just get the first common name. I guess it's possible to have // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); - if (xentry != NULL) { + if (xentry != nullptr) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); - if (data != NULL) { + if (data != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an // easier way to decode the ASN1_STRING? Curse these incomplete // docs. @@ -976,8 +976,8 @@ get_signature_public_key(int n) const { nassertr(!cert_chain.empty(), string()); EVP_PKEY *pkey = X509_get_pubkey(cert_chain[0]._cert); - if (pkey != NULL) { - int key_len = i2d_PublicKey(pkey, NULL); + if (pkey != nullptr) { + int key_len = i2d_PublicKey(pkey, nullptr); unsigned char *key_buf = new unsigned char[key_len]; unsigned char *p = key_buf; i2d_PublicKey(pkey, &p); @@ -1059,9 +1059,9 @@ validate_signature_certificate(int n) const { // Copy our CertChain structure into an X509 pointer and accompanying // STACK_OF(X509) pointer. X509 *x509 = chain[0]._cert; - STACK_OF(X509) *stack = NULL; + STACK_OF(X509) *stack = nullptr; if (chain.size() > 1) { - stack = sk_X509_new(NULL); + stack = sk_X509_new(nullptr); for (size_t n = 1; n < chain.size(); ++n) { sk_X509_push(stack, chain[n]._cert); } @@ -1129,7 +1129,7 @@ flush() { } } - nassertr(_write != (ostream *)NULL, false); + nassertr(_write != nullptr, false); // First, mark out all of the removed subfiles. PendingSubfiles::iterator pi; @@ -1188,14 +1188,14 @@ flush() { for (pi = _new_subfiles.begin(); pi != _new_subfiles.end(); ++pi) { Subfile *subfile = (*pi); - if (_read != (IStreamWrapper *)NULL) { + if (_read != nullptr) { _read->acquire(); _next_index = subfile->write_data(*_write, _read->get_istream(), _next_index, this); _read->release(); } else { - _next_index = subfile->write_data(*_write, NULL, _next_index, this); + _next_index = subfile->write_data(*_write, nullptr, _next_index, this); } nassertr(_next_index == _write->tellp(), false); @@ -1296,7 +1296,7 @@ repack() { } _removed_subfiles.clear(); _new_subfiles.clear(); - copy(_subfiles.begin(), _subfiles.end(), back_inserter(_new_subfiles)); + std::copy(_subfiles.begin(), _subfiles.end(), std::back_inserter(_new_subfiles)); _next_index = 0; _last_index = 0; _last_data_byte = 0; @@ -1448,7 +1448,7 @@ remove_subfile(int index) { _removed_subfiles.push_back(subfile); _subfiles.erase(_subfiles.begin() + index); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _needs_repack = true; @@ -1585,18 +1585,18 @@ get_subfile_internal_length(int index) const { */ istream *Multifile:: open_read_subfile(int index) { - nassertr(is_read_valid(), NULL); - nassertr(index >= 0 && index < (int)_subfiles.size(), NULL); + nassertr(is_read_valid(), nullptr); + nassertr(index >= 0 && index < (int)_subfiles.size(), nullptr); Subfile *subfile = _subfiles[index]; - if (subfile->_source != (istream *)NULL || + if (subfile->_source != nullptr || !subfile->_source_filename.empty()) { // The subfile has not yet been copied into the physical Multifile. Force // a flush operation to incorporate it. flush(); // That shouldn't change the subfile index or delete the subfile pointer. - nassertr(subfile == _subfiles[index], NULL); + nassertr(subfile == _subfiles[index], nullptr); } return open_read_subfile(subfile); @@ -1610,7 +1610,7 @@ open_read_subfile(int index) { */ void Multifile:: close_read_subfile(istream *stream) { - if (stream != (istream *)NULL) { + if (stream != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -1666,7 +1666,7 @@ extract_subfile_to(int index, ostream &out) { nassertr(index >= 0 && index < (int)_subfiles.size(), false); istream *in = open_read_subfile(index); - if (in == (istream *)NULL) { + if (in == nullptr) { return false; } @@ -1741,7 +1741,7 @@ compare_subfile(int index, const Filename &filename) { } istream *in1 = open_read_subfile(index); - if (in1 == (istream *)NULL) { + if (in1 == nullptr) { return false; } @@ -1889,7 +1889,7 @@ read_subfile(int index, pvector &result) { nassertr(index >= 0 && index < (int)_subfiles.size(), false); Subfile *subfile = _subfiles[index]; - if (subfile->_source != (istream *)NULL || + if (subfile->_source != nullptr || !subfile->_source_filename.empty()) { // The subfile has not yet been copied into the physical Multifile. Force // a flush operation to incorporate it. @@ -1906,7 +1906,7 @@ read_subfile(int index, pvector &result) { // If the subfile is encrypted or compressed, we can't read it directly. // Fall back to the generic implementation. istream *in = open_read_subfile(index); - if (in == (istream *)NULL) { + if (in == nullptr) { return false; } @@ -1958,7 +1958,7 @@ read_subfile(int index, pvector &result) { */ streampos Multifile:: pad_to_streampos(streampos fpos) { - nassertr(_write != (ostream *)NULL, fpos); + nassertr(_write != nullptr, fpos); nassertr(_write->tellp() == fpos, fpos); streampos new_fpos = normalize_streampos(fpos); while (fpos < new_fpos) { @@ -2029,12 +2029,12 @@ add_new_subfile(Subfile *subfile, int compression_level) { */ istream *Multifile:: open_read_subfile(Subfile *subfile) { - nassertr(subfile->_source == (istream *)NULL && - subfile->_source_filename.empty(), NULL); + nassertr(subfile->_source == nullptr && + subfile->_source_filename.empty(), nullptr); // Return an ISubStream object that references into the open Multifile // istream. - nassertr(subfile->_data_start != (streampos)0, NULL); + nassertr(subfile->_data_start != (streampos)0, nullptr); istream *stream = new ISubStream(_read, _offset + subfile->_data_start, _offset + subfile->_data_start + (streampos)subfile->_data_length); @@ -2044,7 +2044,7 @@ open_read_subfile(Subfile *subfile) { express_cat.error() << "OpenSSL not compiled in; cannot read encrypted multifiles.\n"; delete stream; - return NULL; + return nullptr; #else // HAVE_OPENSSL // The subfile is encrypted. So actually, return an IDecryptStream that // wraps around the ISubStream. @@ -2060,7 +2060,7 @@ open_read_subfile(Subfile *subfile) { express_cat.error() << "Unable to decrypt subfile " << subfile->_name << ".\n"; delete stream; - return NULL; + return nullptr; } #endif // HAVE_OPENSSL } @@ -2070,7 +2070,7 @@ open_read_subfile(Subfile *subfile) { express_cat.error() << "zlib not compiled in; cannot read compressed multifiles.\n"; delete stream; - return NULL; + return nullptr; #else // HAVE_ZLIB // Oops, the subfile is compressed. So actually, return an // IDecompressStream that wraps around the ISubStream. @@ -2082,7 +2082,7 @@ open_read_subfile(Subfile *subfile) { if (stream->fail()) { // Hmm, some inexplicable problem. delete stream; - return NULL; + return nullptr; } return stream; @@ -2151,7 +2151,7 @@ clear_subfiles() { */ bool Multifile:: read_index() { - nassertr(_read != (IStreamWrapper *)NULL, false); + nassertr(_read != nullptr, false); // We acquire the IStreamWrapper lock for the duration of this method. _read->acquire(); @@ -2331,7 +2331,7 @@ write_header() { _file_major_ver = _current_major_ver; _file_minor_ver = _current_minor_ver; - nassertr(_write != (ostream *)NULL, false); + nassertr(_write != nullptr, false); nassertr(_write->tellp() == (streampos)0, false); _write->write(_header_prefix.data(), _header_prefix.size()); _write->write(_header, _header_size); @@ -2380,7 +2380,7 @@ check_signatures() { // Extract the signature data and certificate separately. istream *stream = open_read_subfile(subfile); - nassertv(stream != NULL); + nassertv(stream != nullptr); StreamReader reader(*stream); size_t sig_size = reader.get_uint32(); vector_uchar sig_data = reader.extract_bytes(sig_size); @@ -2396,7 +2396,7 @@ check_signatures() { // Now convert each of the certificates to an X509 object, and store it in // our CertChain. CertChain chain; - EVP_PKEY *pkey = NULL; + EVP_PKEY *pkey = nullptr; if (!buffer.empty()) { #if OPENSSL_VERSION_NUMBER >= 0x00908000L // Beginning in 0.9.8, d2i_X509() accepted a const unsigned char **. @@ -2407,13 +2407,13 @@ check_signatures() { #endif bp = (unsigned char *)&buffer[0]; bp_end = bp + buffer.size(); - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (num_certs > 0 && x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (num_certs > 0 && x509 != nullptr) { chain.push_back(CertRecord(x509)); --num_certs; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } - if (num_certs != 0 || x509 != NULL) { + if (num_certs != 0 || x509 != nullptr) { express_cat.warning() << "Extra data in signature record.\n"; } @@ -2423,11 +2423,11 @@ check_signatures() { pkey = X509_get_pubkey(chain[0]._cert); } - if (pkey != NULL) { + if (pkey != nullptr) { EVP_MD_CTX *md_ctx = EVP_MD_CTX_create(); EVP_VerifyInit(md_ctx, EVP_sha1()); - nassertv(_read != NULL); + nassertv(_read != nullptr); _read->acquire(); istream *read = _read->get_istream(); @@ -2520,7 +2520,7 @@ read_index(istream &read, streampos fpos, Multifile *multifile) { // And finally, get the rest of the name. char *name_buffer = (char *)PANDA_MALLOC_ARRAY(name_length); - nassertr(name_buffer != (char *)NULL, next_index); + nassertr(name_buffer != nullptr, next_index); for (size_t ni = 0; ni < name_length; ni++) { name_buffer[ni] = read.get() ^ 0xff; } @@ -2608,7 +2608,7 @@ write_data(ostream &write, istream *read, streampos fpos, istream *source = _source; pifstream source_file; - if (source == (istream *)NULL && !_source_filename.empty()) { + if (source == nullptr && !_source_filename.empty()) { // If we have a filename, open it up and read that. if (!_source_filename.open_read(source_file)) { // Unable to open the source file. @@ -2622,10 +2622,10 @@ write_data(ostream &write, istream *read, streampos fpos, } } - if (source == (istream *)NULL) { + if (source == nullptr) { // We don't have any source data. Perhaps we're reading from an already- // packed Subfile (e.g. during repack()). - if (read == (istream *)NULL) { + if (read == nullptr) { // No, we're just screwed. express_cat.info() << "No source for subfile " << _name << ".\n"; @@ -2698,10 +2698,10 @@ write_data(ostream &write, istream *read, streampos fpos, // In order to generate a signature, we need to have a valid read // pointer. - nassertr(read != NULL, fpos); + nassertr(read != nullptr, fpos); // And we also need to have a private key. - nassertr(_pkey != NULL, fpos); + nassertr(_pkey != nullptr, fpos); EVP_MD_CTX *md_ctx = EVP_MD_CTX_create(); EVP_SignInit(md_ctx, EVP_sha1()); @@ -2776,10 +2776,10 @@ write_data(ostream &write, istream *read, streampos fpos, _timestamp = _source_filename.get_timestamp(); } if (_timestamp == 0) { - _timestamp = time(NULL); + _timestamp = time(nullptr); } - _source = (istream *)NULL; + _source = nullptr; _source_filename = Filename(); source_file.close(); diff --git a/panda/src/express/nodePointerTo.I b/panda/src/express/nodePointerTo.I index c035cd34cf..c8020d0181 100644 --- a/panda/src/express/nodePointerTo.I +++ b/panda/src/express/nodePointerTo.I @@ -62,7 +62,7 @@ operator = (NodePointerTo &&from) noexcept { * */ template -INLINE TYPENAME NodePointerTo::To &NodePointerTo:: +INLINE typename NodePointerTo::To &NodePointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } @@ -73,7 +73,7 @@ operator *() const { * */ template -INLINE TYPENAME NodePointerTo::To *NodePointerTo:: +INLINE typename NodePointerTo::To *NodePointerTo:: operator -> () const { return (To *)(this->_void_ptr); } @@ -99,7 +99,7 @@ operator T *() const { * around compiler problems, particularly for implicit upcasts. */ template -INLINE TYPENAME NodePointerTo::To *NodePointerTo:: +INLINE typename NodePointerTo::To *NodePointerTo:: p() const { return (To *)(this->_void_ptr); } @@ -135,8 +135,8 @@ operator = (const NodePointerTo ©) { */ template INLINE NodeConstPointerTo:: -NodeConstPointerTo(const TYPENAME NodeConstPointerTo::To *ptr) : - NodePointerToBase((TYPENAME NodeConstPointerTo::To *)ptr) +NodeConstPointerTo(const typename NodeConstPointerTo::To *ptr) : + NodePointerToBase((typename NodeConstPointerTo::To *)ptr) { } #endif // CPPPARSER @@ -218,7 +218,7 @@ operator = (NodeConstPointerTo &&from) noexcept { * */ template -INLINE const TYPENAME NodeConstPointerTo::To &NodeConstPointerTo:: +INLINE const typename NodeConstPointerTo::To &NodeConstPointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } @@ -229,7 +229,7 @@ operator *() const { * */ template -INLINE const TYPENAME NodeConstPointerTo::To *NodeConstPointerTo:: +INLINE const typename NodeConstPointerTo::To *NodeConstPointerTo:: operator -> () const { return (To *)(this->_void_ptr); } @@ -256,7 +256,7 @@ operator const T * () const { * work around compiler problems, particularly for implicit upcasts. */ template -INLINE const TYPENAME NodeConstPointerTo::To *NodeConstPointerTo:: +INLINE const typename NodeConstPointerTo::To *NodeConstPointerTo:: p() const { return (To *)(this->_void_ptr); } diff --git a/panda/src/express/nodePointerTo.h b/panda/src/express/nodePointerTo.h index 169aeb71e5..7b2c189253 100644 --- a/panda/src/express/nodePointerTo.h +++ b/panda/src/express/nodePointerTo.h @@ -28,8 +28,8 @@ public: // By hiding this template from interrogate, we improve compile-time speed // and memory utilization. #ifndef CPPPARSER - typedef TYPENAME NodePointerToBase::To To; - INLINE NodePointerTo(To *ptr = (To *)NULL); + typedef typename NodePointerToBase::To To; + INLINE NodePointerTo(To *ptr = nullptr); INLINE NodePointerTo(const NodePointerTo ©); INLINE NodePointerTo(NodePointerTo &&from) noexcept; @@ -59,8 +59,8 @@ public: // By hiding this template from interrogate, we improve compile-time speed // and memory utilization. #ifndef CPPPARSER - typedef TYPENAME NodePointerToBase::To To; - INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL); + typedef typename NodePointerToBase::To To; + INLINE NodeConstPointerTo(const To *ptr = nullptr); INLINE NodeConstPointerTo(const NodePointerTo ©); INLINE NodeConstPointerTo(const NodeConstPointerTo ©); INLINE NodeConstPointerTo(NodePointerTo &&from) noexcept; diff --git a/panda/src/express/nodePointerToBase.I b/panda/src/express/nodePointerToBase.I index 1cb22132d5..40c9eb6506 100644 --- a/panda/src/express/nodePointerToBase.I +++ b/panda/src/express/nodePointerToBase.I @@ -35,7 +35,7 @@ NodePointerToBase(const NodePointerToBase ©) { template INLINE NodePointerToBase:: ~NodePointerToBase() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -45,7 +45,7 @@ template INLINE NodePointerToBase:: NodePointerToBase(NodePointerToBase &&from) noexcept { _void_ptr = from._void_ptr; - from._void_ptr = (void *)NULL; + from._void_ptr = nullptr; } /** @@ -60,10 +60,10 @@ reassign(NodePointerToBase &&from) noexcept { To *old_ptr = (To *)this->_void_ptr; this->_void_ptr = from._void_ptr; - from._void_ptr = NULL; + from._void_ptr = nullptr; // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { node_unref_delete(old_ptr); } } @@ -83,7 +83,7 @@ reassign(To *ptr) { To *old_ptr = (To *)_void_ptr; _void_ptr = (void *)ptr; - if (ptr != (To *)NULL) { + if (ptr != nullptr) { ptr->node_ref(); #ifdef DO_MEMORY_USAGE if (MemoryUsage::get_track_memory_usage()) { @@ -102,7 +102,7 @@ reassign(To *ptr) { } // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { node_unref_delete(old_ptr); } } @@ -125,7 +125,7 @@ reassign(const NodePointerToBase ©) { template INLINE void NodePointerToBase:: clear() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -136,7 +136,7 @@ template INLINE void NodePointerToBase:: output(ostream &out) const { out << _void_ptr; - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_node_ref_count() << "/" << ((To *)_void_ptr)->get_ref_count(); } diff --git a/panda/src/express/nodeReferenceCount.I b/panda/src/express/nodeReferenceCount.I index 4273f0b78c..4f963476f7 100644 --- a/panda/src/express/nodeReferenceCount.I +++ b/panda/src/express/nodeReferenceCount.I @@ -52,8 +52,6 @@ NodeReferenceCount(const NodeReferenceCount ©) : ReferenceCount(copy) { */ INLINE void NodeReferenceCount:: operator = (const NodeReferenceCount ©) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -74,8 +72,6 @@ operator = (const NodeReferenceCount ©) { */ INLINE NodeReferenceCount:: ~NodeReferenceCount() { - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/express/nodeReferenceCount.cxx b/panda/src/express/nodeReferenceCount.cxx index 05c9b6d63f..f965f240a4 100644 --- a/panda/src/express/nodeReferenceCount.cxx +++ b/panda/src/express/nodeReferenceCount.cxx @@ -21,8 +21,6 @@ TypeHandle NodeReferenceCount::_type_handle; */ bool NodeReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/express/openSSLWrapper.cxx b/panda/src/express/openSSLWrapper.cxx index 6492bb1596..97fe936d21 100644 --- a/panda/src/express/openSSLWrapper.cxx +++ b/panda/src/express/openSSLWrapper.cxx @@ -18,7 +18,7 @@ #include "virtualFileSystem.h" #include "ca_bundle_data_src.c" -OpenSSLWrapper *OpenSSLWrapper::_global_ptr = NULL; +OpenSSLWrapper *OpenSSLWrapper::_global_ptr = nullptr; /** * @@ -154,7 +154,7 @@ load_certificates_from_pem_ram(const char *data, size_t data_size) { // We have to be sure and clear the OpenSSL error state before we call this // function, or it will get confused. ERR_clear_error(); - inf = PEM_X509_INFO_read_bio(mbio, NULL, NULL, NULL); + inf = PEM_X509_INFO_read_bio(mbio, nullptr, nullptr, nullptr); BIO_free(mbio); if (!inf) { @@ -257,8 +257,8 @@ load_certificates_from_der_ram(const char *data, size_t data_size) { bp = (unsigned char *)data; bp_end = bp + data_size; while (bp < bp_end) { - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - if (x509 == NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + if (x509 == nullptr) { notify_ssl_errors(); break; } @@ -350,7 +350,7 @@ notify_debug_ssl_errors() { */ OpenSSLWrapper *OpenSSLWrapper:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new OpenSSLWrapper; } return _global_ptr; diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index 287998b85c..aedee72232 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -37,7 +37,7 @@ ordered_vector(const Compare &compare, TypeHandle type_handle) : * Returns the iterator that marks the first element in the ordered vector. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +INLINE typename ordered_vector::ITERATOR ordered_vector:: begin() { return _vector.begin(); } @@ -46,7 +46,7 @@ begin() { * Returns the iterator that marks the end of the ordered vector. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +INLINE typename ordered_vector::ITERATOR ordered_vector:: end() { return _vector.end(); } @@ -56,7 +56,7 @@ end() { * when viewed in reverse order. */ template -INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::REVERSE_ITERATOR ordered_vector:: rbegin() { return _vector.rbegin(); } @@ -66,7 +66,7 @@ rbegin() { * in reverse order. */ template -INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::REVERSE_ITERATOR ordered_vector:: rend() { return _vector.rend(); } @@ -75,7 +75,7 @@ rend() { * Returns the iterator that marks the first element in the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: begin() const { return _vector.begin(); } @@ -84,7 +84,7 @@ begin() const { * Returns the iterator that marks the end of the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: end() const { return _vector.end(); } @@ -94,7 +94,7 @@ end() const { * when viewed in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rbegin() const { return _vector.rbegin(); } @@ -104,7 +104,7 @@ rbegin() const { * in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rend() const { return _vector.rend(); } @@ -113,7 +113,7 @@ rend() const { * Returns the iterator that marks the first element in the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: cbegin() const { return _vector.begin(); } @@ -122,7 +122,7 @@ cbegin() const { * Returns the iterator that marks the end of the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: cend() const { return _vector.end(); } @@ -132,7 +132,7 @@ cend() const { * when viewed in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: crbegin() const { return _vector.rbegin(); } @@ -142,7 +142,7 @@ crbegin() const { * in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: crend() const { return _vector.rend(); } @@ -151,8 +151,8 @@ crend() const { * Returns the nth element. */ template -INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: -operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { +INLINE typename ordered_vector::REFERENCE ordered_vector:: +operator [] (typename ordered_vector::SIZE_TYPE n) { return _vector[n]; } @@ -160,8 +160,8 @@ operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { * Returns the nth element. */ template -INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: -operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { +INLINE typename ordered_vector::CONST_REFERENCE ordered_vector:: +operator [] (typename ordered_vector::SIZE_TYPE n) const { return _vector[n]; } @@ -169,7 +169,7 @@ operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { * Returns a reference to the first element. */ template -INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: +INLINE typename ordered_vector::REFERENCE ordered_vector:: front() { #ifdef _DEBUG assert(!_vector.empty()); @@ -181,7 +181,7 @@ front() { * Returns a const reference to the first element. */ template -INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: +INLINE typename ordered_vector::CONST_REFERENCE ordered_vector:: front() const { #ifdef _DEBUG assert(!_vector.empty()); @@ -193,7 +193,7 @@ front() const { * Returns a reference to the first element. */ template -INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: +INLINE typename ordered_vector::REFERENCE ordered_vector:: back() { #ifdef _DEBUG assert(!_vector.empty()); @@ -205,7 +205,7 @@ back() { * Returns a const reference to the last element. */ template -INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: +INLINE typename ordered_vector::CONST_REFERENCE ordered_vector:: back() const { #ifdef _DEBUG assert(!_vector.empty()); @@ -217,7 +217,7 @@ back() const { * Returns the number of elements in the ordered vector. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: size() const { return _vector.size(); } @@ -227,7 +227,7 @@ size() const { * ordered vector. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: max_size() const { return _vector.max_size(); } @@ -312,8 +312,8 @@ operator >= (const ordered_vector &other) const { * componet is true if the insert operation has taken place. */ template -INLINE pair::ITERATOR, bool> ordered_vector:: -insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { +INLINE pair::ITERATOR, bool> ordered_vector:: +insert_unique(const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); #ifdef NDEBUG @@ -341,8 +341,8 @@ insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &k * The return value is the iterator referencing the new element. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +insert_nonunique(const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_nonunique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); nassertr(position >= begin() && position <= end(), end()); @@ -358,9 +358,9 @@ insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE * sorting position; no checks are made. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_unverified(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +insert_unverified(typename ordered_vector::ITERATOR position, + const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unverified(iterator, const value_type &)", " ", TAU_USER); ITERATOR result = _vector.insert(position, key); return result; @@ -371,8 +371,8 @@ insert_unverified(TYPENAME ordered_vector::ITERATOR positi * sequential iterator. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -erase(TYPENAME ordered_vector::ITERATOR position) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +erase(typename ordered_vector::ITERATOR position) { TAU_PROFILE("ordered_vector::erase(iterator)", " ", TAU_USER); SIZE_TYPE count = position - begin(); _vector.erase(position); @@ -384,8 +384,8 @@ erase(TYPENAME ordered_vector::ITERATOR position) { * elements removed. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: -erase(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: +erase(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::erase(const key_type &)", " ", TAU_USER); pair result = equal_range(key); SIZE_TYPE count = result.second - result.first; @@ -398,8 +398,8 @@ erase(const TYPENAME ordered_vector::KEY_TYPE &key) { */ template INLINE void ordered_vector:: -erase(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last) { +erase(typename ordered_vector::ITERATOR first, + typename ordered_vector::ITERATOR last) { TAU_PROFILE("ordered_vector::erase(iterator, iterator)", " ", TAU_USER); _vector.erase(first, last); } @@ -420,8 +420,8 @@ clear() { * matching the key, the particular iterator returned is not defined. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +find(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return nci(r_find(begin(), end(), end(), key)); } @@ -432,8 +432,8 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) { * matching the key, the particular iterator returned is not defined. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -find(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +find(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return r_find(begin(), end(), end(), key); } @@ -452,8 +452,8 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) const { * not necessarily the converse. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +find_particular(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return nci(r_find_particular(begin(), end(), end(), key)); } @@ -469,8 +469,8 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &k * is not defined. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +find_particular(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return r_find_particular(begin(), end(), end(), key); } @@ -480,7 +480,7 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &k * the vector. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: count(const key_type &key) const { TAU_PROFILE("ordered_vector::count(const key_type &)", " ", TAU_USER); return r_count(begin(), end(), key); @@ -491,8 +491,8 @@ count(const key_type &key) const { * all elements are less than key. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +lower_bound(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return nci(r_lower_bound(begin(), end(), key)); } @@ -502,8 +502,8 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * all elements are less than key. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +lower_bound(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return r_lower_bound(begin(), end(), key); } @@ -513,8 +513,8 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * element is greater than key. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +upper_bound(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return nci(r_upper_bound(begin(), end(), key)); } @@ -524,8 +524,8 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * element is greater than key. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +upper_bound(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return r_upper_bound(begin(), end(), key); } @@ -534,20 +534,20 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * Returns the pair (lower_bound(key), upper_bound(key)). */ template -INLINE pair::ITERATOR, TYPENAME ordered_vector::ITERATOR> ordered_vector:: -equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE pair::ITERATOR, typename ordered_vector::ITERATOR> ordered_vector:: +equal_range(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); - pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> result; + pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> result; result = r_equal_range(begin(), end(), key); - return pair::ITERATOR, TYPENAME ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); + return pair::ITERATOR, typename ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); } /** * Returns the pair (lower_bound(key), upper_bound(key)). */ template -INLINE pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: -equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: +equal_range(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); return r_equal_range(begin(), end(), key); } @@ -569,7 +569,7 @@ swap(ordered_vector ©) { */ template INLINE void ordered_vector:: -reserve(TYPENAME ordered_vector::SIZE_TYPE n) { +reserve(typename ordered_vector::SIZE_TYPE n) { TAU_PROFILE("ordered_vector::reserve(size_type)", " ", TAU_USER); _vector.reserve(n); } @@ -601,7 +601,7 @@ template INLINE void ordered_vector:: sort_nonunique() { TAU_PROFILE("ordered_vector::sort_nonunique()", " ", TAU_USER); - stable_sort(begin(), end(), _compare); + std::stable_sort(begin(), end(), _compare); } /** @@ -666,8 +666,8 @@ resize(SIZE_TYPE n, const VALUE_TYPE &value) { * const flavors of some of these methods. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -nci(TYPENAME ordered_vector::CONST_ITERATOR i) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +nci(typename ordered_vector::CONST_ITERATOR i) { return begin() + (i - begin()); } @@ -676,10 +676,10 @@ nci(TYPENAME ordered_vector::CONST_ITERATOR i) { * indicated key, and returns the corresponding iterator. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find_insert_position(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +find_insert_position(typename ordered_vector::ITERATOR first, + typename ordered_vector::ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) { ITERATOR result = r_find_insert_position(first, last, key); return result; } @@ -708,9 +708,9 @@ ov_set(const Compare &compare, TypeHandle type_handle) : * Maps to insert_unique(). */ template -TYPENAME ov_set::ITERATOR ov_set:: -insert(TYPENAME ov_set::ITERATOR position, - const TYPENAME ov_set::VALUE_TYPE &key) { +typename ov_set::ITERATOR ov_set:: +insert(typename ov_set::ITERATOR position, + const typename ov_set::VALUE_TYPE &key) { return ordered_vector::insert_unique(position, key); } @@ -718,8 +718,8 @@ insert(TYPENAME ov_set::ITERATOR position, * Maps to insert_unique(). */ template -INLINE pair::ITERATOR, bool> ov_set:: -insert(const TYPENAME ov_set::VALUE_TYPE &key) { +INLINE pair::ITERATOR, bool> ov_set:: +insert(const typename ov_set::VALUE_TYPE &key) { return ordered_vector::insert_unique(key); } @@ -765,9 +765,9 @@ ov_multiset(const Compare &compare, TypeHandle type_handle) : * Maps to insert_nonunique(). */ template -TYPENAME ov_multiset::ITERATOR ov_multiset:: -insert(TYPENAME ov_multiset::ITERATOR position, - const TYPENAME ov_multiset::VALUE_TYPE &key) { +typename ov_multiset::ITERATOR ov_multiset:: +insert(typename ov_multiset::ITERATOR position, + const typename ov_multiset::VALUE_TYPE &key) { return ordered_vector::insert_nonunique(position, key); } @@ -775,8 +775,8 @@ insert(TYPENAME ov_multiset::ITERATOR position, * Maps to insert_nonunique(). */ template -INLINE TYPENAME ov_multiset::ITERATOR ov_multiset:: -insert(const TYPENAME ov_multiset::VALUE_TYPE &key) { +INLINE typename ov_multiset::ITERATOR ov_multiset:: +insert(const typename ov_multiset::VALUE_TYPE &key) { return ordered_vector::insert_nonunique(key); } diff --git a/panda/src/express/ordered_vector.T b/panda/src/express/ordered_vector.T index 7ea866e52f..2d57d0a1d3 100644 --- a/panda/src/express/ordered_vector.T +++ b/panda/src/express/ordered_vector.T @@ -1,36 +1,30 @@ -// Filename: ordered_vector.T -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ordered_vector.T + * @author drose + * @date 2002-02-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::insert_unique -// Access: Public -// Description: Inserts the indicated key into the ordered vector. -// The iterator is a hint to the expected position; if -// this is correct, the insert operation is likely to be -// faster. The return value is the iterator referencing -// the new element. -// -// This flavor of insert does not allow multiple copies -// of the same key to be inserted. If the key is -// already present, it is not inserted, and the iterator -// referencing the original value is returned. -//////////////////////////////////////////////////////////////////// +/** + * Inserts the indicated key into the ordered vector. The iterator is a hint + * to the expected position; if this is correct, the insert operation is + * likely to be faster. The return value is the iterator referencing the new + * element. + * + * This flavor of insert does not allow multiple copies of the same key to be + * inserted. If the key is already present, it is not inserted, and the + * iterator referencing the original value is returned. + */ template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_unique(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +typename ordered_vector::ITERATOR ordered_vector:: +insert_unique(typename ordered_vector::ITERATOR position, + const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're @@ -62,22 +56,20 @@ insert_unique(TYPENAME ordered_vector::ITERATOR position, return result; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::insert_nonunique -// Access: Public -// Description: Inserts the indicated key into the ordered vector. -// The iterator is a hint to the expected position; if -// this is correct, the insert operation is likely to be -// faster. The return value is the iterator referencing -// the new element. -// -// This flavor of insert allows multiple copies of the -// same key to be inserted. -//////////////////////////////////////////////////////////////////// + +/** + * Inserts the indicated key into the ordered vector. The iterator is a hint + * to the expected position; if this is correct, the insert operation is + * likely to be faster. The return value is the iterator referencing the new + * element. + * + * This flavor of insert allows multiple copies of the + * same key to be inserted. + */ template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_nonunique(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +typename ordered_vector::ITERATOR ordered_vector:: +insert_nonunique(typename ordered_vector::ITERATOR position, + const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_nonunique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're @@ -100,13 +92,10 @@ insert_nonunique(TYPENAME ordered_vector::ITERATOR positio return result; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::verify_list_unique -// Access: Public -// Description: Ensures that the indicated range of elements is -// sorted correctly. Returns true if this is the case; -// otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the indicated range of elements is sorted correctly. Returns + * true if this is the case; otherwise, returns false. + */ template bool ordered_vector:: verify_list_unique() const { @@ -127,13 +116,10 @@ verify_list_unique() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::verify_list_nonunique -// Access: Public -// Description: Ensures that the indicated range of elements is -// sorted correctly. Returns true if this is the case; -// otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the indicated range of elements is sorted correctly. Returns + * true if this is the case; otherwise, returns false. + */ template bool ordered_vector:: verify_list_nonunique() const { @@ -155,17 +141,14 @@ verify_list_nonunique() const { } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_find_insert_position -// Access: Private -// Description: The recursive implementation of -// find_insert_position(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find_insert_position(). + */ template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -r_find_insert_position(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) { +typename ordered_vector::ITERATOR ordered_vector:: +r_find_insert_position(typename ordered_vector::ITERATOR first, + typename ordered_vector::ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) { if (first == last) { // The list is empty; the insert position is the last of the list. return last; @@ -184,17 +167,15 @@ r_find_insert_position(TYPENAME ordered_vector::ITERATOR f } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_find -// Access: Private -// Description: The recursive implementation of find(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find(). + */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_find(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - TYPENAME ordered_vector::CONST_ITERATOR not_found, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_find(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + typename ordered_vector::CONST_ITERATOR not_found, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return not_found; @@ -217,17 +198,15 @@ r_find(TYPENAME ordered_vector::CONST_ITERATOR first, } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_find_particular -// Access: Private -// Description: The recursive implementation of find_particular(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find_particular(). + */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - TYPENAME ordered_vector::CONST_ITERATOR not_found, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_find_particular(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + typename ordered_vector::CONST_ITERATOR not_found, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return not_found; @@ -270,16 +249,14 @@ r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_count -// Access: Private -// Description: The recursive implementation of count(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of count(). + */ template -TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: -r_count(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::SIZE_TYPE ordered_vector:: +r_count(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. @@ -305,16 +282,14 @@ r_count(TYPENAME ordered_vector::CONST_ITERATOR first, } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_lower_bound -// Access: Private -// Description: The recursive implementation of lower_bound(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of lower_bound(). + */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_lower_bound(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return last; @@ -338,16 +313,14 @@ r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR firs } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_upper_bound -// Access: Private -// Description: The recursive implementation of upper_bound(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of upper_bound(). + */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_upper_bound(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return last; @@ -371,17 +344,15 @@ r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR firs } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_equal_range -// Access: Private -// Description: The recursive implementation of equal_range(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of equal_range(). + */ template -pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: -r_equal_range(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { - typedef pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> pair_type; +pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: +r_equal_range(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { + typedef pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> pair_type; if (first == last) { // The list is empty; the key is not on the list. diff --git a/panda/src/express/ordered_vector.h b/panda/src/express/ordered_vector.h index e9e3a03693..651a0c27fb 100644 --- a/panda/src/express/ordered_vector.h +++ b/panda/src/express/ordered_vector.h @@ -105,13 +105,13 @@ public: // Be careful when using the non-const iterators that you do not disturb the // sorted order of the vector, or that if you do, you call sort() when you // are done. - typedef TYPENAME Vector::iterator ITERATOR; - typedef TYPENAME Vector::const_iterator CONST_ITERATOR; - typedef TYPENAME Vector::reverse_iterator REVERSE_ITERATOR; - typedef TYPENAME Vector::const_reverse_iterator CONST_REVERSE_ITERATOR; + typedef typename Vector::iterator ITERATOR; + typedef typename Vector::const_iterator CONST_ITERATOR; + typedef typename Vector::reverse_iterator REVERSE_ITERATOR; + typedef typename Vector::const_reverse_iterator CONST_REVERSE_ITERATOR; - typedef TYPENAME Vector::difference_type DIFFERENCE_TYPE; - typedef TYPENAME Vector::size_type SIZE_TYPE; + typedef typename Vector::difference_type DIFFERENCE_TYPE; + typedef typename Vector::size_type SIZE_TYPE; // Since the #define symbols do not actually expand to the correct names, we // have to re-typedef them so callers can reference them by their correct, @@ -268,8 +268,8 @@ private: template, class Vector = pvector > class ov_set : public ordered_vector { public: - typedef TYPENAME ordered_vector::ITERATOR ITERATOR; - typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; + typedef typename ordered_vector::ITERATOR ITERATOR; + typedef typename ordered_vector::VALUE_TYPE VALUE_TYPE; INLINE ov_set(TypeHandle type_handle = ov_set_type_handle); INLINE ov_set(const Compare &compare, @@ -289,8 +289,8 @@ public: template, class Vector = pvector > class ov_multiset : public ordered_vector { public: - typedef TYPENAME ordered_vector::ITERATOR ITERATOR; - typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; + typedef typename ordered_vector::ITERATOR ITERATOR; + typedef typename ordered_vector::VALUE_TYPE VALUE_TYPE; INLINE ov_multiset(TypeHandle type_handle = ov_set_type_handle); INLINE ov_multiset(const Compare &compare, diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 73b04139a0..9c0ebc9481 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -32,7 +32,7 @@ #endif // HAVE_TAR #ifdef HAVE_TAR -istream *Patchfile::_tar_istream = NULL; +istream *Patchfile::_tar_istream = nullptr; #endif // HAVE_TAR // this actually slows things down... #define @@ -99,7 +99,7 @@ void Patchfile:: init(PT(Buffer) buffer) { _rename_output_to_orig = false; _delete_patchfile = false; - _hash_table = NULL; + _hash_table = nullptr; _initiated = false; nassertv(!buffer.is_null()); _buffer = buffer; @@ -107,8 +107,8 @@ init(PT(Buffer) buffer) { _version_number = 0; _allow_multifile = true; - _patch_stream = NULL; - _origfile_stream = NULL; + _patch_stream = nullptr; + _origfile_stream = nullptr; reset_footprint_length(); } @@ -118,7 +118,7 @@ init(PT(Buffer) buffer) { */ Patchfile:: ~Patchfile() { - if (_hash_table != (uint32_t *)NULL) { + if (_hash_table != nullptr) { PANDA_FREE_ARRAY(_hash_table); } @@ -126,8 +126,8 @@ Patchfile:: cleanup(); } - nassertv(_patch_stream == NULL); - nassertv(_origfile_stream == NULL); + nassertv(_patch_stream == nullptr); + nassertv(_origfile_stream == nullptr); } /** @@ -144,13 +144,13 @@ cleanup() { // close files VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - if (_origfile_stream != NULL) { + if (_origfile_stream != nullptr) { vfs->close_read_file(_origfile_stream); - _origfile_stream = NULL; + _origfile_stream = nullptr; } - if (_patch_stream != NULL) { + if (_patch_stream != nullptr) { vfs->close_read_file(_patch_stream); - _patch_stream = NULL; + _patch_stream = nullptr; } _write_stream.close(); @@ -195,11 +195,11 @@ initiate(const Filename &patch_file, const Filename &orig_file, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); // Open the original file for read - nassertr(_origfile_stream == NULL, EU_error_abort); + nassertr(_origfile_stream == nullptr, EU_error_abort); _orig_file = orig_file; _orig_file.set_binary(); _origfile_stream = vfs->open_read_file(_orig_file, false); - if (_origfile_stream == NULL) { + if (_origfile_stream == nullptr) { express_cat.error() << "Patchfile::initiate() - Failed to open file: " << _orig_file << endl; return get_write_error(); @@ -241,10 +241,10 @@ read_header(const Filename &patch_file) { } int result = internal_read_header(patch_file); - if (_patch_stream != NULL) { + if (_patch_stream != nullptr) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_patch_stream); - _patch_stream = NULL; + _patch_stream = nullptr; } return result; } @@ -272,8 +272,8 @@ run() { return EU_error_abort; } - nassertr(_patch_stream != NULL, EU_error_abort); - nassertr(_origfile_stream != NULL, EU_error_abort); + nassertr(_patch_stream != nullptr, EU_error_abort); + nassertr(_origfile_stream != nullptr, EU_error_abort); StreamReader patch_reader(*_patch_stream); buflen = _buffer->get_length(); @@ -399,10 +399,10 @@ run() { MD5_actual.hash_file(_output_file); if (_MD5_ofResult != MD5_actual) { // Whoops, patching screwed up somehow. - if (_origfile_stream != NULL) { + if (_origfile_stream != nullptr) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_origfile_stream); - _origfile_stream = NULL; + _origfile_stream = nullptr; } _write_stream.close(); @@ -520,11 +520,11 @@ int Patchfile:: internal_read_header(const Filename &patch_file) { // Open the patch file for read VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - nassertr(_patch_stream == NULL, EU_error_abort); + nassertr(_patch_stream == nullptr, EU_error_abort); _patch_file = patch_file; _patch_file.set_binary(); _patch_stream = vfs->open_read_file(_patch_file, true); - if (_patch_stream == NULL) { + if (_patch_stream == nullptr) { express_cat.error() << "Patchfile::initiate() - Failed to open file: " << _patch_file << endl; return get_write_error(); @@ -840,7 +840,7 @@ emit_add_and_copy(ostream &write_stream, emit_COPY(write_stream, max_write, copy_pos); copy_pos += max_write; copy_length -= max_write; - emit_ADD(write_stream, 0, NULL); + emit_ADD(write_stream, 0, nullptr); } emit_COPY(write_stream, copy_length, copy_pos); @@ -946,7 +946,7 @@ void Patchfile:: write_terminator(ostream &write_stream) { cache_flush(write_stream); // write terminator (null ADD, null COPY) - emit_ADD(write_stream, 0, NULL); + emit_ADD(write_stream, 0, nullptr); emit_COPY(write_stream, 0, 0); } @@ -987,7 +987,7 @@ compute_file_patches(ostream &write_stream, stream_new.read(buffer_new, result_file_length); // allocate hashlink tables - if (_hash_table == (uint32_t *)NULL) { + if (_hash_table == nullptr) { if (express_cat.is_debug()) { express_cat.debug() << "Allocating hashtable of size " << _HASHTABLESIZE << " * 4\n"; @@ -1166,10 +1166,10 @@ read_tar(TarDef &tar, istream &stream) { tt.writefunc = tar_writefunc; stream.seekg(0, ios::beg); - nassertr(_tar_istream == NULL, false); + nassertr(_tar_istream == nullptr, false); _tar_istream = &stream; if (tar_open(&tfile, (char *)"dummy", &tt, O_RDONLY, 0, 0) != 0) { - _tar_istream = NULL; + _tar_istream = nullptr; return false; } @@ -1205,7 +1205,7 @@ read_tar(TarDef &tar, istream &stream) { tar.push_back(subfile); tar_close(tfile); - _tar_istream = NULL; + _tar_istream = nullptr; return (flag == 1); } #endif // HAVE_TAR @@ -1326,7 +1326,7 @@ tar_closefunc(int) { */ ssize_t Patchfile:: tar_readfunc(int, void *buffer, size_t nbytes) { - nassertr(_tar_istream != NULL, 0); + nassertr(_tar_istream != nullptr, 0); _tar_istream->read((char *)buffer, nbytes); return (ssize_t)_tar_istream->gcount(); } @@ -1436,8 +1436,8 @@ do_compute_patches(const Filename &file_orig, const Filename &file_new, #endif // HAVE_TAR if (_allow_multifile) { - if (strstr(file_orig.get_basename().c_str(), ".mf") != NULL || - strstr(file_new.get_basename().c_str(), ".mf") != NULL) { + if (strstr(file_orig.get_basename().c_str(), ".mf") != nullptr || + strstr(file_new.get_basename().c_str(), ".mf") != nullptr) { // Read the first n bytes of both files for the Multifile magic number. string magic_number = Multifile::get_magic_number(); char *buffer = (char *)PANDA_MALLOC_ARRAY(magic_number.size()); @@ -1456,8 +1456,8 @@ do_compute_patches(const Filename &file_orig, const Filename &file_new, PANDA_FREE_ARRAY(buffer); } #ifdef HAVE_TAR - if (strstr(file_orig.get_basename().c_str(), ".tar") != NULL || - strstr(file_new.get_basename().c_str(), ".tar") != NULL) { + if (strstr(file_orig.get_basename().c_str(), ".tar") != nullptr || + strstr(file_new.get_basename().c_str(), ".tar") != nullptr) { if (read_tar(tar_orig, stream_orig) && read_tar(tar_new, stream_new)) { is_tarfile = true; @@ -1534,7 +1534,7 @@ patch_subfile(ostream &write_stream, express_cat.debug() << "Keeping subfile " << filename << "\n"; } - cache_add_and_copy(write_stream, 0, NULL, + cache_add_and_copy(write_stream, 0, nullptr, orig_size, offset_orig + orig_start); } else { diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index bc71cfbfd9..20e667fa11 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -53,7 +53,7 @@ operator = (PointerTo &&from) noexcept { * */ template -constexpr TYPENAME PointerTo::To &PointerTo:: +constexpr typename PointerTo::To &PointerTo:: operator *() const noexcept { return *((To *)(this->_void_ptr)); } @@ -62,7 +62,7 @@ operator *() const noexcept { * */ template -constexpr TYPENAME PointerTo::To *PointerTo:: +constexpr typename PointerTo::To *PointerTo:: operator -> () const noexcept { return (To *)(this->_void_ptr); } @@ -97,7 +97,7 @@ cheat() { * compiler problems, particularly for implicit upcasts. */ template -constexpr TYPENAME PointerTo::To *PointerTo:: +constexpr typename PointerTo::To *PointerTo:: p() const noexcept { return (To *)(this->_void_ptr); } @@ -127,8 +127,8 @@ operator = (const PointerTo ©) { */ template ALWAYS_INLINE ConstPointerTo:: -ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) noexcept : - PointerToBase((TYPENAME ConstPointerTo::To *)ptr) +ConstPointerTo(const typename ConstPointerTo::To *ptr) noexcept : + PointerToBase((typename ConstPointerTo::To *)ptr) { } @@ -196,7 +196,7 @@ operator = (ConstPointerTo &&from) noexcept { * */ template -constexpr const TYPENAME ConstPointerTo::To &ConstPointerTo:: +constexpr const typename ConstPointerTo::To &ConstPointerTo:: operator *() const noexcept { return *((To *)(this->_void_ptr)); } @@ -205,7 +205,7 @@ operator *() const noexcept { * */ template -constexpr const TYPENAME ConstPointerTo::To *ConstPointerTo:: +constexpr const typename ConstPointerTo::To *ConstPointerTo:: operator -> () const noexcept { return (To *)(this->_void_ptr); } @@ -240,7 +240,7 @@ cheat() { * around compiler problems, particularly for implicit upcasts. */ template -constexpr const TYPENAME ConstPointerTo::To *ConstPointerTo:: +constexpr const typename ConstPointerTo::To *ConstPointerTo:: p() const noexcept { return (To *)(this->_void_ptr); } diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index 313ad41a55..1f9704c3f3 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -68,9 +68,10 @@ template class PointerTo : public PointerToBase { public: - typedef TYPENAME PointerToBase::To To; + typedef typename PointerToBase::To To; PUBLISHED: ALWAYS_INLINE constexpr PointerTo() noexcept = default; + ALWAYS_INLINE explicit constexpr PointerTo(std::nullptr_t) noexcept {} ALWAYS_INLINE PointerTo(To *ptr) noexcept; INLINE PointerTo(const PointerTo ©); @@ -129,9 +130,10 @@ PUBLISHED: template class ConstPointerTo : public PointerToBase { public: - typedef TYPENAME PointerToBase::To To; + typedef typename PointerToBase::To To; PUBLISHED: ALWAYS_INLINE constexpr ConstPointerTo() noexcept = default; + ALWAYS_INLINE explicit constexpr ConstPointerTo(std::nullptr_t) noexcept {} ALWAYS_INLINE ConstPointerTo(const To *ptr) noexcept; INLINE ConstPointerTo(const PointerTo ©); INLINE ConstPointerTo(const ConstPointerTo ©); diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index f665e38415..04e943c5fc 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -25,7 +25,7 @@ pvector ConstPointerToArray::_empty_array; template INLINE PointerToArray:: PointerToArray(TypeHandle type_handle) : - PointerToArrayBase((ReferenceCountedVector *)NULL), + PointerToArrayBase(nullptr), _type_handle(type_handle) { } @@ -105,9 +105,9 @@ PointerToArray(pvector &&from, TypeHandle type_handle) : * */ template -INLINE TYPENAME PointerToArray::iterator PointerToArray:: +INLINE typename PointerToArray::iterator PointerToArray:: begin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->begin(); @@ -117,9 +117,9 @@ begin() const { * */ template -INLINE TYPENAME PointerToArray::iterator PointerToArray:: +INLINE typename PointerToArray::iterator PointerToArray:: end() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->end(); @@ -129,9 +129,9 @@ end() const { * */ template -INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: +INLINE typename PointerToArray::reverse_iterator PointerToArray:: rbegin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rbegin(); @@ -141,9 +141,9 @@ rbegin() const { * */ template -INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: +INLINE typename PointerToArray::reverse_iterator PointerToArray:: rend() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rend(); @@ -153,18 +153,18 @@ rend() const { * */ template -INLINE TYPENAME PointerToArray::size_type PointerToArray:: +INLINE typename PointerToArray::size_type PointerToArray:: size() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->size(); } /** * */ template -INLINE TYPENAME PointerToArray::size_type PointerToArray:: +INLINE typename PointerToArray::size_type PointerToArray:: max_size() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return ((To *)(this->_void_ptr))->max_size(); @@ -176,7 +176,7 @@ max_size() const { template INLINE bool PointerToArray:: empty() const { - return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty(); + return ((this->_void_ptr) == nullptr) ? true : ((To *)(this->_void_ptr))->empty(); } /** @@ -184,8 +184,8 @@ empty() const { */ template INLINE void PointerToArray:: -reserve(TYPENAME PointerToArray::size_type n) { - if ((this->_void_ptr) == NULL) { +reserve(typename PointerToArray::size_type n) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->reserve(n); @@ -196,8 +196,8 @@ reserve(TYPENAME PointerToArray::size_type n) { */ template INLINE void PointerToArray:: -resize(TYPENAME PointerToArray::size_type n) { - if ((this->_void_ptr) == NULL) { +resize(typename PointerToArray::size_type n) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->resize(n); @@ -207,9 +207,9 @@ resize(TYPENAME PointerToArray::size_type n) { * */ template -INLINE TYPENAME PointerToArray::size_type PointerToArray:: +INLINE typename PointerToArray::size_type PointerToArray:: capacity() const { - nassertr((this->_void_ptr) != NULL, 0); + nassertr((this->_void_ptr) != nullptr, 0); return ((To *)(this->_void_ptr))->capacity(); } @@ -217,9 +217,9 @@ capacity() const { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: front() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -232,9 +232,9 @@ front() const { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: back() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -247,9 +247,9 @@ back() const { * */ template -INLINE TYPENAME PointerToArray::iterator PointerToArray:: +INLINE typename PointerToArray::iterator PointerToArray:: insert(iterator position, const Element &x) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); position = end(); } @@ -264,7 +264,7 @@ insert(iterator position, const Element &x) { template INLINE void PointerToArray:: insert(iterator position, size_type n, const Element &x) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); position = end(); } @@ -279,7 +279,7 @@ insert(iterator position, size_type n, const Element &x) { template INLINE void PointerToArray:: erase(iterator position) { - nassertv((this->_void_ptr) != NULL); + nassertv((this->_void_ptr) != nullptr); nassertv(position >= ((To *)(this->_void_ptr))->begin() && position <= ((To *)(this->_void_ptr))->end()); ((To *)(this->_void_ptr))->erase(position); @@ -291,7 +291,7 @@ erase(iterator position) { template INLINE void PointerToArray:: erase(iterator first, iterator last) { - nassertv((this->_void_ptr) != NULL); + nassertv((this->_void_ptr) != nullptr); nassertv(first >= ((To *)(this->_void_ptr))->begin() && first <= ((To *)(this->_void_ptr))->end()); nassertv(last >= ((To *)(this->_void_ptr))->begin() && last <= ((To *)(this->_void_ptr))->end()); ((To *)(this->_void_ptr))->erase(first, last); @@ -302,9 +302,9 @@ erase(iterator first, iterator last) { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: operator [](size_type n) const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -318,7 +318,7 @@ operator [](size_type n) const { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: operator [](int n) const { return operator[]((size_type)n); } @@ -330,7 +330,7 @@ operator [](int n) const { template INLINE void PointerToArray:: push_back(const Element &x) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->push_back(x); @@ -342,7 +342,7 @@ push_back(const Element &x) { template INLINE void PointerToArray:: pop_back() { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertv(!((To *)(this->_void_ptr))->empty()); @@ -356,7 +356,7 @@ pop_back() { template INLINE void PointerToArray:: make_empty() { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertv(!((To *)(this->_void_ptr))->empty()); @@ -373,7 +373,7 @@ template INLINE PointerToArray:: operator Element *() const { To *vec = (To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -384,7 +384,7 @@ template INLINE Element *PointerToArray:: p() const { To *vec = (To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -394,7 +394,7 @@ p() const { template INLINE pvector &PointerToArray:: v() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return *((To *)(this->_void_ptr)); @@ -492,7 +492,7 @@ INLINE void PointerToArray:: set_subdata(size_type n, size_type count, const string &data) { nassertv((data.length() % sizeof(Element)) == 0); nassertv(n <= size() && n + count <= size()); - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } size_type ncount = data.length() / sizeof(Element); @@ -534,7 +534,7 @@ set_void_ptr(void *p) { template INLINE int PointerToArray:: get_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); } /** @@ -543,7 +543,7 @@ get_ref_count() const { template INLINE void PointerToArray:: ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->ref(); @@ -555,7 +555,7 @@ ref() const { template INLINE bool PointerToArray:: unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->unref(); } @@ -565,7 +565,7 @@ unref() const { template INLINE int PointerToArray:: get_node_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); } /** @@ -574,7 +574,7 @@ get_node_ref_count() const { template INLINE void PointerToArray:: node_ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->node_ref(); @@ -586,7 +586,7 @@ node_ref() const { template INLINE bool PointerToArray:: node_unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->node_unref(); } @@ -642,7 +642,7 @@ operator = (PointerToArray &&from) noexcept { template INLINE void PointerToArray:: clear() { - ((PointerToArray *)this)->reassign((ReferenceCountedVector *)NULL); + ((PointerToArray *)this)->reassign(nullptr); } @@ -653,7 +653,7 @@ clear() { template INLINE ConstPointerToArray:: ConstPointerToArray(TypeHandle type_handle) : - PointerToArrayBase((ReferenceCountedVector *)NULL), + PointerToArrayBase(nullptr), _type_handle(type_handle) { } @@ -728,9 +728,9 @@ ConstPointerToArray(pvector &&from, TypeHandle type_handle) : * */ template -INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::iterator ConstPointerToArray:: begin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->begin(); @@ -740,9 +740,9 @@ begin() const { * */ template -INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::iterator ConstPointerToArray:: end() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->end(); @@ -752,9 +752,9 @@ end() const { * */ template -INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::reverse_iterator ConstPointerToArray:: rbegin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rbegin(); @@ -764,9 +764,9 @@ rbegin() const { * */ template -INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::reverse_iterator ConstPointerToArray:: rend() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rend(); @@ -776,18 +776,18 @@ rend() const { * */ template -INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: +INLINE typename ConstPointerToArray::size_type ConstPointerToArray:: size() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->size(); } /** * */ template -INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: +INLINE typename ConstPointerToArray::size_type ConstPointerToArray:: max_size() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return ((To *)(this->_void_ptr))->max_size(); @@ -799,16 +799,16 @@ max_size() const { template INLINE bool ConstPointerToArray:: empty() const { - return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty(); + return ((this->_void_ptr) == nullptr) ? true : ((To *)(this->_void_ptr))->empty(); } /** * */ template -INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: +INLINE typename ConstPointerToArray::size_type ConstPointerToArray:: capacity() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return ((To *)(this->_void_ptr))->capacity(); @@ -818,9 +818,9 @@ capacity() const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: front() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -833,9 +833,9 @@ front() const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: back() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -849,9 +849,9 @@ back() const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: operator [](size_type n) const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -865,7 +865,7 @@ operator [](size_type n) const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: operator [](int n) const { return operator[]((size_type)n); } @@ -881,7 +881,7 @@ template INLINE ConstPointerToArray:: operator const Element *() const { const To *vec = (const To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -892,7 +892,7 @@ template INLINE const Element *ConstPointerToArray:: p() const { const To *vec = (const To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -902,7 +902,7 @@ p() const { template INLINE const pvector &ConstPointerToArray:: v() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return *(const To *)(this->_void_ptr); @@ -977,7 +977,7 @@ get_subdata(size_type n, size_type count) const { template INLINE int ConstPointerToArray:: get_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); } /** @@ -986,7 +986,7 @@ get_ref_count() const { template INLINE void ConstPointerToArray:: ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->ref(); @@ -998,7 +998,7 @@ ref() const { template INLINE bool ConstPointerToArray:: unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->unref(); } @@ -1008,7 +1008,7 @@ unref() const { template INLINE int ConstPointerToArray:: get_node_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); } /** @@ -1017,7 +1017,7 @@ get_node_ref_count() const { template INLINE void ConstPointerToArray:: node_ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->node_ref(); @@ -1029,7 +1029,7 @@ node_ref() const { template INLINE bool ConstPointerToArray:: node_unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->node_unref(); } @@ -1107,7 +1107,7 @@ operator = (ConstPointerToArray &&from) noexcept { template INLINE void ConstPointerToArray:: clear() { - ((ConstPointerToArray *)this)->reassign((ReferenceCountedVector *)NULL); + ((ConstPointerToArray *)this)->reassign(nullptr); } #endif // CPPPARSER diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 1df1193b3c..57c8be2f92 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -91,7 +91,7 @@ public: // subset of this class. So we define just the exportable interface here. #ifdef CPPPARSER PUBLISHED: - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::size_type size_type; INLINE PointerToArray(TypeHandle type_handle = get_type_handle(Element)); INLINE static PointerToArray empty_array(size_type n, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(const PointerToArray ©); @@ -123,16 +123,16 @@ PUBLISHED: #else // CPPPARSER // This is the actual, complete interface. - typedef TYPENAME PointerToArrayBase::To To; - typedef TYPENAME pvector::value_type value_type; - typedef TYPENAME pvector::reference reference; - typedef TYPENAME pvector::const_reference const_reference; - typedef TYPENAME pvector::iterator iterator; - typedef TYPENAME pvector::const_iterator const_iterator; - typedef TYPENAME pvector::reverse_iterator reverse_iterator; - typedef TYPENAME pvector::const_reverse_iterator const_reverse_iterator; - typedef TYPENAME pvector::difference_type difference_type; - typedef TYPENAME pvector::size_type size_type; + typedef typename PointerToArrayBase::To To; + typedef typename pvector::value_type value_type; + typedef typename pvector::reference reference; + typedef typename pvector::const_reference const_reference; + typedef typename pvector::iterator iterator; + typedef typename pvector::const_iterator const_iterator; + typedef typename pvector::reverse_iterator reverse_iterator; + typedef typename pvector::const_reverse_iterator const_reverse_iterator; + typedef typename pvector::difference_type difference_type; + typedef typename pvector::size_type size_type; public: INLINE PointerToArray(TypeHandle type_handle = get_type_handle(Element)); @@ -150,8 +150,8 @@ public: INLINE iterator begin() const; INLINE iterator end() const; - INLINE TYPENAME PointerToArray::reverse_iterator rbegin() const; - INLINE TYPENAME PointerToArray::reverse_iterator rend() const; + INLINE typename PointerToArray::reverse_iterator rbegin() const; + INLINE typename PointerToArray::reverse_iterator rend() const; // Equality and comparison operators are pointerwise for PointerToArrays, // not elementwise as in vector. @@ -261,7 +261,7 @@ PUBLISHED: INLINE void clear(); - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::size_type size_type; INLINE size_type size() const; INLINE const Element &get_element(size_type n) const; EXTENSION(const Element &__getitem__(size_type n) const); @@ -279,21 +279,21 @@ PUBLISHED: #else // CPPPARSER // This is the actual, complete interface. - typedef TYPENAME PointerToArrayBase::To To; - typedef TYPENAME pvector::value_type value_type; - typedef TYPENAME pvector::const_reference reference; - typedef TYPENAME pvector::const_reference const_reference; - typedef TYPENAME pvector::const_iterator iterator; - typedef TYPENAME pvector::const_iterator const_iterator; + typedef typename PointerToArrayBase::To To; + typedef typename pvector::value_type value_type; + typedef typename pvector::const_reference reference; + typedef typename pvector::const_reference const_reference; + typedef typename pvector::const_iterator iterator; + typedef typename pvector::const_iterator const_iterator; #if defined(WIN32_VC) || defined(WIN64_VC) // VC++ seems to break the const_reverse_iterator definition somehow. - typedef TYPENAME pvector::reverse_iterator reverse_iterator; + typedef typename pvector::reverse_iterator reverse_iterator; #else - typedef TYPENAME pvector::const_reverse_iterator reverse_iterator; + typedef typename pvector::const_reverse_iterator reverse_iterator; #endif - typedef TYPENAME pvector::const_reverse_iterator const_reverse_iterator; - typedef TYPENAME pvector::difference_type difference_type; - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::const_reverse_iterator const_reverse_iterator; + typedef typename pvector::difference_type difference_type; + typedef typename pvector::size_type size_type; INLINE ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element)); INLINE ConstPointerToArray(const PointerToArray ©); @@ -306,8 +306,8 @@ PUBLISHED: INLINE iterator begin() const; INLINE iterator end() const; - INLINE TYPENAME ConstPointerToArray::reverse_iterator rbegin() const; - INLINE TYPENAME ConstPointerToArray::reverse_iterator rend() const; + INLINE typename ConstPointerToArray::reverse_iterator rbegin() const; + INLINE typename ConstPointerToArray::reverse_iterator rend() const; // Equality and comparison operators are pointerwise for PointerToArrays, // not elementwise as in vector. diff --git a/panda/src/express/pointerToArrayBase.I b/panda/src/express/pointerToArrayBase.I index 2b60162abc..a5188040fb 100644 --- a/panda/src/express/pointerToArrayBase.I +++ b/panda/src/express/pointerToArrayBase.I @@ -24,7 +24,7 @@ ReferenceCountedVector(TypeHandle type_handle) : pvector(type_handle) { */ template INLINE ReferenceCountedVector:: -ReferenceCountedVector(TYPENAME ReferenceCountedVector::size_type initial_size, TypeHandle type_handle) : +ReferenceCountedVector(typename ReferenceCountedVector::size_type initial_size, TypeHandle type_handle) : pvector(initial_size, type_handle) { } @@ -53,7 +53,7 @@ ReferenceCountedVector(pvector &&from) : * */ template -INLINE TYPENAME ReferenceCountedVector::size_type ReferenceCountedVector:: +INLINE typename ReferenceCountedVector::size_type ReferenceCountedVector:: size() const { return pvector::size(); } @@ -62,7 +62,7 @@ size() const { * */ template -INLINE TYPENAME ReferenceCountedVector::iterator ReferenceCountedVector:: +INLINE typename ReferenceCountedVector::iterator ReferenceCountedVector:: insert(iterator position, const Element &x) { return pvector::insert(position, x); } diff --git a/panda/src/express/pointerToArrayBase.cxx b/panda/src/express/pointerToArrayBase.cxx index 86366ae892..0be7bbc08a 100644 --- a/panda/src/express/pointerToArrayBase.cxx +++ b/panda/src/express/pointerToArrayBase.cxx @@ -13,4 +13,4 @@ #include "pointerToArrayBase.h" -EXPCL_PANDAEXPRESS PTASetLevelFunc *pta_set_level = NULL; +EXPCL_PANDAEXPRESS PTASetLevelFunc *pta_set_level = nullptr; diff --git a/panda/src/express/pointerToArrayBase.h b/panda/src/express/pointerToArrayBase.h index 6f6128e26b..3c985ff379 100644 --- a/panda/src/express/pointerToArrayBase.h +++ b/panda/src/express/pointerToArrayBase.h @@ -37,8 +37,8 @@ template class ReferenceCountedVector : public NodeReferenceCount, public pvector { public: - typedef TYPENAME pvector::iterator iterator; - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::iterator iterator; + typedef typename pvector::size_type size_type; INLINE ReferenceCountedVector(TypeHandle type_handle); INLINE ReferenceCountedVector(size_type initial_size, TypeHandle type_handle); @@ -68,7 +68,7 @@ public: template class PointerToArrayBase : public PointerToBase > { public: - typedef TYPENAME PointerToBase >::To To; + typedef typename PointerToBase >::To To; protected: INLINE PointerToArrayBase(ReferenceCountedVector *ptr); diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I index 644b5f0645..eedb92d3f4 100644 --- a/panda/src/express/pointerToArray_ext.I +++ b/panda/src/express/pointerToArray_ext.I @@ -37,17 +37,19 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo mat_size = sizeof(UnalignedLMatrix4f); } else if (size == 4 && double_prec) { mat_size = sizeof(UnalignedLMatrix4d); + } else { + assert(false); } view.len = length * mat_size; view.readonly = (read_only ? 1 : 0); view.itemsize = item_size; - view.format = NULL; + view.format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view.format = (char*) format; } view.ndim = 3; - view.shape = NULL; + view.shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // This leaks, which sucks, but __releasebuffer__ doesn't give us the same // pointer, so we would need to store it elsewhere if we wanted to delete @@ -58,7 +60,7 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo shape[2] = size; view.shape = shape; } - view.strides = NULL; + view.strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { Py_ssize_t* strides = new Py_ssize_t[3]; strides[0] = mat_size; @@ -66,7 +68,7 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo strides[2] = item_size; view.strides = strides; } - view.suboffsets = NULL; + view.suboffsets = nullptr; } /** @@ -99,7 +101,7 @@ __init__(PyObject *self, PyObject *source) { // from Python. PyObject *dict = DtoolInstance_TYPE(self)->_PyType.tp_dict; PyObject *push_back = PyDict_GetItemString(dict, "push_back"); - if (push_back == NULL) { + if (push_back == nullptr) { PyErr_BadArgument(); return; } @@ -111,12 +113,12 @@ __init__(PyObject *self, PyObject *source) { this->_this->reserve(size); for (Py_ssize_t i = 0; i < size; ++i) { PyObject *item = PySequence_GetItem(source, i); - if (item == NULL) { + if (item == nullptr) { return; } - PyObject *result = PyObject_CallFunctionObjArgs(push_back, self, item, NULL); + PyObject *result = PyObject_CallFunctionObjArgs(push_back, self, item, nullptr); Py_DECREF(item); - if (result == NULL) { + if (result == nullptr) { // Unable to add item--probably it wasn't of the appropriate type. PyErr_Print(); PyErr_Format(PyExc_TypeError, @@ -310,12 +312,12 @@ INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 const char *format = get_format_code(Element); - if (format == NULL) { + if (format == nullptr) { // Not supported. return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -323,23 +325,23 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { view->len = this->_this->size() * sizeof(Element); view->readonly = 0; view->itemsize = sizeof(Element); - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) format; } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // This leaks, which sucks, but __releasebuffer__ doesn't give us the same // pointer, so we would need to store it elsewhere if we wanted to delete // it there. Eh, it's just an int, who cares. view->shape = new Py_ssize_t(this->_this->size()); } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &(view->itemsize); } - view->suboffsets = NULL; + view->suboffsets = nullptr; // Store a reference to ourselves on the Py_buffer object as a reminder that // we have increased our refcount. @@ -360,7 +362,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -386,7 +388,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -412,7 +414,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -438,7 +440,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -464,10 +466,10 @@ INLINE void Extension >:: __releasebuffer__(PyObject *self, Py_buffer *view) const { #if PY_VERSION_HEX >= 0x02060000 // Note: PyBuffer_Release automatically decrements view->obj. - if (view->internal != NULL) { + if (view->internal != nullptr) { // Oh, right, let's not forget to unref this. unref_delete((const PointerToArray *)view->internal); - view->internal = NULL; + view->internal = nullptr; } #endif } @@ -487,12 +489,12 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { } const char *format = get_format_code(Element); - if (format == NULL) { + if (format == nullptr) { // Not supported. return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -500,23 +502,23 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->len = this->_this->size() * sizeof(Element); view->readonly = 1; view->itemsize = sizeof(Element); - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) format; } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // This leaks, which sucks, but __releasebuffer__ doesn't give us the same // pointer, so we would need to store it elsewhere if we wanted to delete // it there. Eh, it's just an int, who cares. view->shape = new Py_ssize_t(this->_this->size()); } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &(view->itemsize); } - view->suboffsets = NULL; + view->suboffsets = nullptr; // Store a reference to ourselves on the Py_buffer object as a reminder that // we have increased our refcount. @@ -541,7 +543,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -571,7 +573,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -601,7 +603,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -631,7 +633,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -657,10 +659,10 @@ INLINE void Extension >:: __releasebuffer__(PyObject *self, Py_buffer *view) const { #if PY_VERSION_HEX >= 0x02060000 // Note: PyBuffer_Release automatically decrements obj->view. - if (view->internal != NULL) { + if (view->internal != nullptr) { // Oh, right, let's not forget to unref this. unref_delete((const PointerToArray *)view->internal); - view->internal = NULL; + view->internal = nullptr; } #endif } diff --git a/panda/src/express/pointerToArray_ext.h b/panda/src/express/pointerToArray_ext.h index 469b449fed..2daf885943 100644 --- a/panda/src/express/pointerToArray_ext.h +++ b/panda/src/express/pointerToArray_ext.h @@ -125,7 +125,7 @@ template class EXPORT_THIS Extension; template INLINE const char *_get_format_code(const T *) { - return NULL; + return nullptr; } define_format_code("c", char); diff --git a/panda/src/express/pointerToBase.I b/panda/src/express/pointerToBase.I index 27a02daa46..acd3123394 100644 --- a/panda/src/express/pointerToBase.I +++ b/panda/src/express/pointerToBase.I @@ -18,7 +18,7 @@ template INLINE PointerToBase:: PointerToBase(To *ptr) { _void_ptr = (void *)ptr; - if (ptr != (To *)NULL) { + if (ptr != nullptr) { ptr->ref(); #ifdef DO_MEMORY_USAGE update_type(ptr); @@ -33,7 +33,7 @@ template INLINE PointerToBase:: PointerToBase(const PointerToBase ©) { _void_ptr = copy._void_ptr; - if (_void_ptr != NULL) { + if (_void_ptr != nullptr) { To *ptr = (To *)_void_ptr; ptr->ref(); } @@ -45,9 +45,9 @@ PointerToBase(const PointerToBase ©) { template INLINE PointerToBase:: ~PointerToBase() { - if (_void_ptr != NULL) { + if (_void_ptr != nullptr) { unref_delete((To *)_void_ptr); - _void_ptr = NULL; + _void_ptr = nullptr; } } @@ -58,7 +58,7 @@ template INLINE PointerToBase:: PointerToBase(PointerToBase &&from) noexcept { _void_ptr = from._void_ptr; - from._void_ptr = (void *)NULL; + from._void_ptr = nullptr; } /** @@ -75,10 +75,10 @@ reassign(PointerToBase &&from) noexcept { To *old_ptr = (To *)this->_void_ptr; this->_void_ptr = from._void_ptr; - from._void_ptr = NULL; + from._void_ptr = nullptr; // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { unref_delete(old_ptr); } } @@ -167,7 +167,7 @@ update_type(To *ptr) { template ALWAYS_INLINE void PointerToBase:: clear() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -178,7 +178,7 @@ template INLINE void PointerToBase:: output(ostream &out) const { out << _void_ptr; - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); } } diff --git a/panda/src/express/profileTimer.cxx b/panda/src/express/profileTimer.cxx index 41d1ac8f89..e21b41da59 100644 --- a/panda/src/express/profileTimer.cxx +++ b/panda/src/express/profileTimer.cxx @@ -13,8 +13,6 @@ #include "pmap.h" -using namespace std; - // See ProfileTimer.h for documentation. @@ -24,7 +22,7 @@ ProfileTimer* ProfileTimer::_head; ProfileTimer:: ProfileTimer(const char* name, int maxEntries) : - _entries(0), + _entries(nullptr), _autoTimerCount(0) { // Keep a list of the ProfileTimers, so we can print them: _next=_head; @@ -120,13 +118,13 @@ consolidateTo(ostream &out) const { { pmap::const_iterator i=entries.begin(); for (;i!=entries.end(); ++i) { - out << " " << setw(50) << i->first << ": " - << setiosflags(ios::fixed) << setprecision(6) << setw(10) << i->second << "\n"; + out << " " << std::setw(50) << i->first << ": " + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << i->second << "\n"; total+=i->second; } } out << "\n [Total Time: " - << setiosflags(ios::fixed) << setprecision(6) << total + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; out << endl; @@ -150,12 +148,12 @@ printTo(ostream &out) const { int i; for (i=0; i<_entryCount; ++i) { TimerEntry& te=_entries[i]; - out << " " << setw(50) << te._tag << ": " - << setiosflags(ios::fixed) << setprecision(6) << setw(10) << te._time << "\n"; + out << " " << std::setw(50) << te._tag << ": " + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << te._time << "\n"; total+=te._time; } out << "\n [Total Time: " - << setiosflags(ios::fixed) << setprecision(6) << total + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; out << endl; diff --git a/panda/src/express/ramfile_ext.cxx b/panda/src/express/ramfile_ext.cxx index 6de3e62bfd..c52641abca 100644 --- a/panda/src/express/ramfile_ext.cxx +++ b/panda/src/express/ramfile_ext.cxx @@ -58,8 +58,8 @@ readline() { PyObject *Extension:: readlines() { PyObject *lst = PyList_New(0); - if (lst == NULL) { - return NULL; + if (lst == nullptr) { + return nullptr; } string line = _this->readline(); diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index f18c60a02c..da0ede4a73 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -28,7 +28,7 @@ TypeHandle RefCountObj::_type_handle; */ INLINE ReferenceCount:: ReferenceCount() { - _weak_list = (WeakReferenceList *)NULL; + _weak_list = nullptr; _ref_count = 0; #ifdef DO_MEMORY_USAGE MemoryUsage::record_pointer(this); @@ -45,7 +45,7 @@ ReferenceCount() { */ INLINE ReferenceCount:: ReferenceCount(const ReferenceCount &) { - _weak_list = (WeakReferenceList *)NULL; + _weak_list = nullptr; _ref_count = 0; #ifdef DO_MEMORY_USAGE MemoryUsage::record_pointer(this); @@ -63,8 +63,6 @@ ReferenceCount(const ReferenceCount &) { */ INLINE void ReferenceCount:: operator = (const ReferenceCount &) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -80,8 +78,6 @@ operator = (const ReferenceCount &) { ReferenceCount:: ~ReferenceCount() { TAU_PROFILE("ReferenceCount::~ReferenceCount()", " ", TAU_USER); - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. @@ -246,7 +242,7 @@ local_object() { */ INLINE bool ReferenceCount:: has_weak_list() const { - return _weak_list != (WeakReferenceList *)NULL; + return _weak_list != nullptr; } /** @@ -259,7 +255,7 @@ has_weak_list() const { */ INLINE WeakReferenceList *ReferenceCount:: get_weak_list() const { - if (AtomicAdjust::get_ptr(_weak_list) == (WeakReferenceList *)NULL) { + if (AtomicAdjust::get_ptr(_weak_list) == nullptr) { ((ReferenceCount *)this)->create_weak_list(); } return (WeakReferenceList *)AtomicAdjust::get_ptr(_weak_list); diff --git a/panda/src/express/referenceCount.cxx b/panda/src/express/referenceCount.cxx index f5d988cf8e..f446b3be46 100644 --- a/panda/src/express/referenceCount.cxx +++ b/panda/src/express/referenceCount.cxx @@ -23,8 +23,6 @@ TypeHandle ReferenceCount::_type_handle; */ bool ReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. @@ -58,8 +56,8 @@ void ReferenceCount:: create_weak_list() { WeakReferenceList *weak_list = new WeakReferenceList; void *orig = - AtomicAdjust::compare_and_exchange_ptr(_weak_list, NULL, weak_list); - if (orig != (void *)NULL) { + AtomicAdjust::compare_and_exchange_ptr(_weak_list, nullptr, weak_list); + if (orig != nullptr) { // Someone else created it first. delete weak_list; } diff --git a/panda/src/express/subStream.I b/panda/src/express/subStream.I index 346b66d46a..0749a4012a 100644 --- a/panda/src/express/subStream.I +++ b/panda/src/express/subStream.I @@ -38,7 +38,7 @@ ISubStream(IStreamWrapper *source, streampos start, streampos end) : istream(&_b INLINE ISubStream &ISubStream:: open(IStreamWrapper *source, streampos start, streampos end) { clear((ios_iostate)0); - _buf.open(source, NULL, start, end, false); + _buf.open(source, nullptr, start, end, false); return *this; } @@ -79,7 +79,7 @@ OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append) : INLINE OSubStream &OSubStream:: open(OStreamWrapper *dest, streampos start, streampos end, bool append) { clear((ios_iostate)0); - _buf.open(NULL, dest, start, end, append); + _buf.open(nullptr, dest, start, end, append); return *this; } diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 61a349b215..0a3f44da9e 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -15,11 +15,6 @@ #include "pnotify.h" #include "memoryHook.h" -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - static const size_t substream_buffer_size = 4096; /** @@ -27,8 +22,8 @@ static const size_t substream_buffer_size = 4096; */ SubStreamBuf:: SubStreamBuf() { - _source = (IStreamWrapper *)NULL; - _dest = (OStreamWrapper *)NULL; + _source = nullptr; + _dest = nullptr; // _start is the streampos of the first byte of the SubStream within its // parent stream. @@ -98,8 +93,8 @@ close() { // Make sure the write buffer is flushed. sync(); - _source = (IStreamWrapper *)NULL; - _dest = (OStreamWrapper *)NULL; + _source = nullptr; + _dest = nullptr; _start = 0; _end = 0; @@ -251,7 +246,7 @@ overflow(int ch) { } } - nassertr(_dest != NULL, EOF); + nassertr(_dest != nullptr, EOF); bool fail = false; if (_append) { _dest->seek_eof_write(pbase(), n, fail); @@ -291,7 +286,7 @@ sync() { size_t n = pptr() - pbase(); if (n != 0) { - nassertr(_dest != NULL, EOF); + nassertr(_dest != nullptr, EOF); bool fail = false; if (_append) { _dest->seek_eof_write(pbase(), n, fail); @@ -340,7 +335,7 @@ underflow() { nassertr(egptr() - gptr() == num_bytes, EOF); } - nassertr(_source != NULL, EOF); + nassertr(_source != nullptr, EOF); streamsize read_count; bool eof; _source->seek_read(_gpos, gptr(), num_bytes, read_count, eof); diff --git a/panda/src/express/subfileInfo.I b/panda/src/express/subfileInfo.I index d34fe7af97..d488537b60 100644 --- a/panda/src/express/subfileInfo.I +++ b/panda/src/express/subfileInfo.I @@ -70,7 +70,7 @@ operator = (const SubfileInfo ©) { */ INLINE bool SubfileInfo:: is_empty() const { - return _file == (FileReference *)NULL; + return _file == nullptr; } /** @@ -86,7 +86,7 @@ get_file() const { */ INLINE const Filename &SubfileInfo:: get_filename() const { - if (_file != (FileReference *)NULL) { + if (_file != nullptr) { return _file->get_filename(); } static const Filename empty_filename; diff --git a/panda/src/express/threadSafePointerTo.I b/panda/src/express/threadSafePointerTo.I index 7525fd4e4c..ef2b8db410 100644 --- a/panda/src/express/threadSafePointerTo.I +++ b/panda/src/express/threadSafePointerTo.I @@ -41,7 +41,7 @@ INLINE ThreadSafePointerTo:: * */ template -INLINE TYPENAME ThreadSafePointerTo::To &ThreadSafePointerTo:: +INLINE typename ThreadSafePointerTo::To &ThreadSafePointerTo:: operator *() const { return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); } @@ -50,7 +50,7 @@ operator *() const { * */ template -INLINE TYPENAME ThreadSafePointerTo::To *ThreadSafePointerTo:: +INLINE typename ThreadSafePointerTo::To *ThreadSafePointerTo:: operator -> () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } @@ -72,7 +72,7 @@ operator T * () const { * work around compiler problems, particularly for implicit upcasts. */ template -INLINE TYPENAME ThreadSafePointerTo::To *ThreadSafePointerTo:: +INLINE typename ThreadSafePointerTo::To *ThreadSafePointerTo:: p() const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } @@ -102,8 +102,8 @@ operator = (const ThreadSafePointerTo ©) { */ template INLINE ThreadSafeConstPointerTo:: -ThreadSafeConstPointerTo(const TYPENAME ThreadSafeConstPointerTo::To *ptr) : - ThreadSafePointerToBase((TYPENAME ThreadSafeConstPointerTo::To *)ptr) +ThreadSafeConstPointerTo(const typename ThreadSafeConstPointerTo::To *ptr) : + ThreadSafePointerToBase((typename ThreadSafeConstPointerTo::To *)ptr) { } @@ -139,7 +139,7 @@ ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©) : * */ template -INLINE const TYPENAME ThreadSafeConstPointerTo::To &ThreadSafeConstPointerTo:: +INLINE const typename ThreadSafeConstPointerTo::To &ThreadSafeConstPointerTo:: operator *() const { return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); } @@ -148,7 +148,7 @@ operator *() const { * */ template -INLINE const TYPENAME ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: +INLINE const typename ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: operator -> () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } @@ -171,7 +171,7 @@ operator const T * () const { * to work around compiler problems, particularly for implicit upcasts. */ template -INLINE const TYPENAME ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: +INLINE const typename ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: p() const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } diff --git a/panda/src/express/threadSafePointerTo.h b/panda/src/express/threadSafePointerTo.h index 56eeed1651..88699fa23a 100644 --- a/panda/src/express/threadSafePointerTo.h +++ b/panda/src/express/threadSafePointerTo.h @@ -26,9 +26,9 @@ template class ThreadSafePointerTo : public ThreadSafePointerToBase { public: - typedef TYPENAME ThreadSafePointerToBase::To To; + typedef typename ThreadSafePointerToBase::To To; PUBLISHED: - INLINE ThreadSafePointerTo(To *ptr = (To *)NULL); + INLINE ThreadSafePointerTo(To *ptr = nullptr); INLINE ThreadSafePointerTo(const ThreadSafePointerTo ©); INLINE ~ThreadSafePointerTo(); @@ -71,9 +71,9 @@ PUBLISHED: template class ThreadSafeConstPointerTo : public ThreadSafePointerToBase { public: - typedef TYPENAME ThreadSafePointerToBase::To To; + typedef typename ThreadSafePointerToBase::To To; PUBLISHED: - INLINE ThreadSafeConstPointerTo(const To *ptr = (const To *)NULL); + INLINE ThreadSafeConstPointerTo(const To *ptr = nullptr); INLINE ThreadSafeConstPointerTo(const ThreadSafePointerTo ©); INLINE ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©); INLINE ~ThreadSafeConstPointerTo(); diff --git a/panda/src/express/threadSafePointerToBase.I b/panda/src/express/threadSafePointerToBase.I index 4d200a483a..d00bcf1dbc 100644 --- a/panda/src/express/threadSafePointerToBase.I +++ b/panda/src/express/threadSafePointerToBase.I @@ -35,7 +35,7 @@ ThreadSafePointerToBase(const ThreadSafePointerToBase ©) { template INLINE ThreadSafePointerToBase:: ~ThreadSafePointerToBase() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -65,7 +65,7 @@ reassign(To *ptr) { _void_ptr = ptr; #endif // HAVE_THREADS - if (ptr != (To *)NULL) { + if (ptr != nullptr) { ptr->ref(); #ifdef DO_MEMORY_USAGE if (MemoryUsage::get_track_memory_usage()) { @@ -75,7 +75,7 @@ reassign(To *ptr) { } // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { unref_delete(old_ptr); } } @@ -115,7 +115,7 @@ update_type(To *ptr) { template INLINE void ThreadSafePointerToBase:: clear() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -126,7 +126,7 @@ template INLINE void ThreadSafePointerToBase:: output(ostream &out) const { out << _void_ptr; - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); } } diff --git a/panda/src/express/trueClock.I b/panda/src/express/trueClock.I index e9bc56aed4..3b7a80f66d 100644 --- a/panda/src/express/trueClock.I +++ b/panda/src/express/trueClock.I @@ -66,7 +66,7 @@ get_error_count() const { */ INLINE TrueClock *TrueClock:: get_global_ptr() { - if (_global_ptr == (TrueClock *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TrueClock; } return _global_ptr; diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index d2104f0ae0..ea60c5bb1e 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -17,7 +17,7 @@ #include // for fabs() -TrueClock *TrueClock::_global_ptr = NULL; +TrueClock *TrueClock::_global_ptr = nullptr; #if defined(WIN32_VC) || defined(WIN64_VC) @@ -501,7 +501,7 @@ get_long_time() { #ifdef GETTIMEOFDAY_ONE_PARAM result = gettimeofday(&tv); #else - result = gettimeofday(&tv, (struct timezone *)NULL); + result = gettimeofday(&tv, nullptr); #endif if (result < 0) { @@ -527,7 +527,7 @@ get_short_raw_time() { #ifdef GETTIMEOFDAY_ONE_PARAM result = gettimeofday(&tv); #else - result = gettimeofday(&tv, (struct timezone *)NULL); + result = gettimeofday(&tv, nullptr); #endif if (result < 0) { @@ -561,7 +561,7 @@ TrueClock() { #ifdef GETTIMEOFDAY_ONE_PARAM result = gettimeofday(&tv); #else - result = gettimeofday(&tv, (struct timezone *)NULL); + result = gettimeofday(&tv, nullptr); #endif if (result < 0) { diff --git a/panda/src/express/virtualFile.cxx b/panda/src/express/virtualFile.cxx index 1d12b7f250..67595b586b 100644 --- a/panda/src/express/virtualFile.cxx +++ b/panda/src/express/virtualFile.cxx @@ -108,8 +108,8 @@ scan_directory() const { // Copy the set of nested mount points to a sorted list so we can search it // quickly. ov_set mount_points; - copy(mount_points_flat.begin(), mount_points_flat.end(), - back_inserter(mount_points)); + std::copy(mount_points_flat.begin(), mount_points_flat.end(), + std::back_inserter(mount_points)); mount_points.sort(); @@ -130,7 +130,7 @@ scan_directory() const { if (!scan_local_directory(file_list, mount_points)) { // Not a directory, or unable to read directory. if (file_list->get_num_files() == 0) { - return NULL; + return nullptr; } // We couldn't read the physical directory, but we do have some mounted @@ -155,7 +155,7 @@ output(ostream &out) const { void VirtualFile:: ls(ostream &out) const { CPT(VirtualFileList) contents = scan_directory(); - if (contents == (VirtualFileList *)NULL) { + if (contents == nullptr) { if (!is_directory()) { out << get_filename() << "\n"; } else { @@ -191,7 +191,7 @@ ls_all(ostream &out) const { */ istream *VirtualFile:: open_read_file(bool auto_unwrap) const { - return NULL; + return nullptr; } /** @@ -224,7 +224,7 @@ was_read_successful() const { */ ostream *VirtualFile:: open_write_file(bool auto_wrap, bool truncate) { - return NULL; + return nullptr; } /** @@ -234,7 +234,7 @@ open_write_file(bool auto_wrap, bool truncate) { */ ostream *VirtualFile:: open_append_file() { - return NULL; + return nullptr; } /** @@ -255,7 +255,7 @@ close_write_file(ostream *stream) { */ iostream *VirtualFile:: open_read_write_file(bool truncate) { - return NULL; + return nullptr; } /** @@ -265,7 +265,7 @@ open_read_write_file(bool truncate) { */ iostream *VirtualFile:: open_read_append_file() { - return NULL; + return nullptr; } /** @@ -443,7 +443,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 == (VirtualFileList *)NULL) { + if (contents == nullptr) { return; } diff --git a/panda/src/express/virtualFileList.I b/panda/src/express/virtualFileList.I index efd87c2711..14b29361b3 100644 --- a/panda/src/express/virtualFileList.I +++ b/panda/src/express/virtualFileList.I @@ -46,7 +46,7 @@ get_num_files() const { */ INLINE VirtualFile *VirtualFileList:: get_file(size_t n) const { - nassertr(n < _files.size(), NULL); + nassertr(n < _files.size(), nullptr); return _files[n]; } @@ -55,7 +55,7 @@ get_file(size_t n) const { */ INLINE VirtualFile *VirtualFileList:: operator [](size_t n) const { - nassertr(n < _files.size(), NULL); + nassertr(n < _files.size(), nullptr); return _files[n]; } diff --git a/panda/src/express/virtualFileMount.I b/panda/src/express/virtualFileMount.I index 81e22016bf..f1195a49ef 100644 --- a/panda/src/express/virtualFileMount.I +++ b/panda/src/express/virtualFileMount.I @@ -16,7 +16,7 @@ */ INLINE VirtualFileMount:: VirtualFileMount() : - _file_system(NULL), + _file_system(nullptr), _mount_flags(0) { } diff --git a/panda/src/express/virtualFileMount.cxx b/panda/src/express/virtualFileMount.cxx index 89e8ddfc24..0c60f96f7f 100644 --- a/panda/src/express/virtualFileMount.cxx +++ b/panda/src/express/virtualFileMount.cxx @@ -24,7 +24,7 @@ TypeHandle VirtualFileMount::_type_handle; */ VirtualFileMount:: ~VirtualFileMount() { - nassertv(_file_system == NULL); + nassertv(_file_system == nullptr); } /** @@ -128,7 +128,7 @@ read_file(const Filename &file, bool do_uncompress, result.clear(); istream *in = open_read_file(file, do_uncompress); - if (in == (istream *)NULL) { + if (in == nullptr) { express_cat.info() << "Unable to read " << file << "\n"; return false; @@ -158,7 +158,7 @@ bool VirtualFileMount:: write_file(const Filename &file, bool do_compress, const unsigned char *data, size_t data_size) { ostream *out = open_write_file(file, do_compress, true); - if (out == (ostream *)NULL) { + if (out == nullptr) { express_cat.info() << "Unable to write " << file << "\n"; return false; @@ -188,7 +188,7 @@ open_read_file(const Filename &file, bool do_uncompress) const { istream *result = open_read_file(file); #ifdef HAVE_ZLIB - if (result != (istream *)NULL && do_uncompress) { + if (result != nullptr && do_uncompress) { // We have to slip in a layer to decompress the file on the fly. IDecompressStream *wrapper = new IDecompressStream(result, true); result = wrapper; @@ -216,7 +216,7 @@ close_read_file(istream *stream) const { */ ostream *VirtualFileMount:: open_write_file(const Filename &file, bool truncate) { - return NULL; + return nullptr; } /** @@ -231,7 +231,7 @@ open_write_file(const Filename &file, bool do_compress, bool truncate) { ostream *result = open_write_file(file, truncate); #ifdef HAVE_ZLIB - if (result != (ostream *)NULL && do_compress) { + if (result != nullptr && do_compress) { // We have to slip in a layer to compress the file on the fly. OCompressStream *wrapper = new OCompressStream(result, true); result = wrapper; @@ -248,7 +248,7 @@ open_write_file(const Filename &file, bool do_compress, bool truncate) { */ ostream *VirtualFileMount:: open_append_file(const Filename &file) { - return NULL; + return nullptr; } /** @@ -269,7 +269,7 @@ close_write_file(ostream *stream) { */ iostream *VirtualFileMount:: open_read_write_file(const Filename &file, bool truncate) { - return NULL; + return nullptr; } /** @@ -279,7 +279,7 @@ open_read_write_file(const Filename &file, bool truncate) { */ iostream *VirtualFileMount:: open_read_append_file(const Filename &file) { - return NULL; + return nullptr; } /** diff --git a/panda/src/express/virtualFileMountAndroidAsset.cxx b/panda/src/express/virtualFileMountAndroidAsset.cxx index d7ffb6254a..8f8494b58a 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.cxx +++ b/panda/src/express/virtualFileMountAndroidAsset.cxx @@ -80,7 +80,7 @@ is_regular_file(const Filename &file) const { //express_cat.error() << "is_regular_file " << file << " - " << asset << "\n"; - if (asset == NULL) { + if (asset == nullptr) { return false; } AAsset_close(asset); @@ -107,7 +107,7 @@ read_file(const Filename &file, bool do_uncompress, AAsset* asset; asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_STREAMING); - if (asset == (AAsset *)NULL) { + if (asset == nullptr) { express_cat.info() << "Unable to read " << file << "\n"; return false; @@ -144,8 +144,8 @@ istream *VirtualFileMountAndroidAsset:: open_read_file(const Filename &file) const { AAsset* asset; asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_UNKNOWN); - if (asset == (AAsset *)NULL) { - return NULL; + if (asset == nullptr) { + return nullptr; } AssetStream *stream = new AssetStream(asset); @@ -229,14 +229,14 @@ get_system_info(const Filename &file, SubfileInfo &info) { bool VirtualFileMountAndroidAsset:: scan_directory(vector_string &contents, const Filename &dir) const { AAssetDir *asset_dir = AAssetManager_openDir(_asset_mgr, dir.c_str()); - if (asset_dir == NULL) { + if (asset_dir == nullptr) { return false; } // Note: this returns the full path. const char *fullpath = AAssetDir_getNextFileName(asset_dir); - while (fullpath != NULL) { + while (fullpath != nullptr) { express_cat.error() << fullpath << "\n"; // DEBUG // Determine the basename and add it to the vector. Filename fname (fullpath); diff --git a/panda/src/express/virtualFileMountMultifile.cxx b/panda/src/express/virtualFileMountMultifile.cxx index c871ea39a1..da449c7bc9 100644 --- a/panda/src/express/virtualFileMountMultifile.cxx +++ b/panda/src/express/virtualFileMountMultifile.cxx @@ -89,7 +89,7 @@ istream *VirtualFileMountMultifile:: open_read_file(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { - return NULL; + return nullptr; } // The caller will eventually pass this pointer to diff --git a/panda/src/express/virtualFileMountRamdisk.I b/panda/src/express/virtualFileMountRamdisk.I index 37d89f9ce3..b943f8bb51 100644 --- a/panda/src/express/virtualFileMountRamdisk.I +++ b/panda/src/express/virtualFileMountRamdisk.I @@ -15,7 +15,7 @@ * */ INLINE VirtualFileMountRamdisk::FileBase:: -FileBase(const string &basename) : _basename(basename), _timestamp(time(NULL)) { +FileBase(const string &basename) : _basename(basename), _timestamp(time(nullptr)) { } /** diff --git a/panda/src/express/virtualFileMountRamdisk.cxx b/panda/src/express/virtualFileMountRamdisk.cxx index 78652e9cc3..2f1f481b3d 100644 --- a/panda/src/express/virtualFileMountRamdisk.cxx +++ b/panda/src/express/virtualFileMountRamdisk.cxx @@ -35,7 +35,7 @@ has_file(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -48,7 +48,7 @@ create_file(const Filename &file) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -61,7 +61,7 @@ delete_file(const Filename &file) { _lock.lock(); PT(FileBase) f = _root.do_delete_file(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -74,7 +74,7 @@ bool VirtualFileMountRamdisk:: rename_file(const Filename &orig_filename, const Filename &new_filename) { _lock.lock(); PT(FileBase) orig_fb = _root.do_find_file(orig_filename); - if (orig_fb == NULL) { + if (orig_fb == nullptr) { _lock.unlock(); return false; } @@ -83,7 +83,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { // Rename the directory. Directory *orig_d = DCAST(Directory, orig_fb); PT(Directory) new_d = _root.do_make_directory(new_filename); - if (new_d == NULL || !new_d->_files.empty()) { + if (new_d == nullptr || !new_d->_files.empty()) { _lock.unlock(); return false; } @@ -102,7 +102,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { // Rename the file. File *orig_f = DCAST(File, orig_fb); PT(File) new_f = _root.do_create_file(new_filename); - if (new_f == NULL) { + if (new_f == nullptr) { _lock.unlock(); return false; } @@ -129,7 +129,7 @@ bool VirtualFileMountRamdisk:: copy_file(const Filename &orig_filename, const Filename &new_filename) { _lock.lock(); PT(FileBase) orig_fb = _root.do_find_file(orig_filename); - if (orig_fb == NULL || orig_fb->is_directory()) { + if (orig_fb == nullptr || orig_fb->is_directory()) { _lock.unlock(); return false; } @@ -137,7 +137,7 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { // Copy the file. File *orig_f = DCAST(File, orig_fb); PT(File) new_f = _root.do_create_file(new_filename); - if (new_f == NULL) { + if (new_f == nullptr) { _lock.unlock(); return false; } @@ -164,7 +164,7 @@ make_directory(const Filename &file) { _lock.lock(); PT(Directory) f = _root.do_make_directory(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -176,7 +176,7 @@ is_directory(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - return (f != NULL && f->is_directory()); + return (f != nullptr && f->is_directory()); } /** @@ -188,7 +188,7 @@ is_regular_file(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - return (f != NULL && !f->is_directory()); + return (f != nullptr && !f->is_directory()); } /** @@ -210,8 +210,8 @@ open_read_file(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { - return NULL; + if (f == nullptr || f->is_directory()) { + return nullptr; } File *f2 = DCAST(File, f); @@ -228,8 +228,8 @@ open_write_file(const Filename &file, bool truncate) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - if (f == (File *)NULL) { - return NULL; + if (f == nullptr) { + return nullptr; } if (truncate) { @@ -241,7 +241,7 @@ open_write_file(const Filename &file, bool truncate) { // second, since the timer only has a one second precision. The proper // solution to fix this would be to switch to a higher precision // timer everywhere. - f->_timestamp = max(f->_timestamp + 1, time(NULL)); + f->_timestamp = max(f->_timestamp + 1, time(nullptr)); } return new OSubStream(&f->_wrapper, 0, 0); @@ -257,8 +257,8 @@ open_append_file(const Filename &file) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - if (f == (File *)NULL) { - return NULL; + if (f == nullptr) { + return nullptr; } return new OSubStream(&f->_wrapper, 0, 0, true); @@ -274,8 +274,8 @@ open_read_write_file(const Filename &file, bool truncate) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - if (f == (File *)NULL) { - return NULL; + if (f == nullptr) { + return nullptr; } if (truncate) { @@ -283,7 +283,7 @@ open_read_write_file(const Filename &file, bool truncate) { f->_data.str(string()); // See open_write_file - f->_timestamp = max(f->_timestamp + 1, time(NULL)); + f->_timestamp = max(f->_timestamp + 1, time(nullptr)); } return new SubStream(&f->_wrapper, 0, 0); @@ -299,8 +299,8 @@ open_read_append_file(const Filename &file) { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { - return NULL; + if (f == nullptr || f->is_directory()) { + return nullptr; } File *f2 = DCAST(File, f); @@ -317,7 +317,7 @@ get_file_size(const Filename &file, istream *stream) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { return 0; } @@ -334,7 +334,7 @@ get_file_size(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { return 0; } @@ -374,7 +374,7 @@ bool VirtualFileMountRamdisk:: scan_directory(vector_string &contents, const Filename &dir) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(dir); - if (f == (FileBase *)NULL || !f->is_directory()) { + if (f == nullptr || !f->is_directory()) { _lock.unlock(); return false; } @@ -395,7 +395,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents const string &new_contents) { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { _lock.unlock(); return false; } @@ -405,7 +405,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents orig_contents = f2->_data.str(); if (orig_contents == old_contents) { f2->_data.str(new_contents); - f2->_timestamp = time(NULL); + f2->_timestamp = time(nullptr); retval = true; } @@ -420,7 +420,7 @@ bool VirtualFileMountRamdisk:: atomic_read_contents(const Filename &file, string &contents) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { _lock.unlock(); return false; } @@ -479,7 +479,7 @@ do_find_file(const string &filename) const { if (fi != _files.end()) { return (*fi); } - return NULL; + return nullptr; } // A nested directory. Search for the directory name, then recurse. @@ -495,7 +495,7 @@ do_find_file(const string &filename) const { } } - return NULL; + return nullptr; } /** @@ -516,7 +516,7 @@ do_create_file(const string &filename) { return DCAST(File, file.p()); } // Cannot create: a directory by the same name already exists. - return NULL; + return nullptr; } // Create a new file. @@ -526,7 +526,7 @@ do_create_file(const string &filename) { } PT(File) file = new File(filename); _files.insert(file.p()); - _timestamp = time(NULL); + _timestamp = time(nullptr); return file; } @@ -543,7 +543,7 @@ do_create_file(const string &filename) { } } - return NULL; + return nullptr; } /** @@ -564,7 +564,7 @@ do_make_directory(const string &filename) { return DCAST(Directory, file.p()); } // Cannot create: a file by the same name already exists. - return NULL; + return nullptr; } // Create a new directory. @@ -574,7 +574,7 @@ do_make_directory(const string &filename) { } PT(Directory) file = new Directory(filename); _files.insert(file.p()); - _timestamp = time(NULL); + _timestamp = time(nullptr); return file; } @@ -591,7 +591,7 @@ do_make_directory(const string &filename) { } } - return NULL; + return nullptr; } /** @@ -612,14 +612,14 @@ do_delete_file(const string &filename) { Directory *dir = DCAST(Directory, file.p()); if (!dir->_files.empty()) { // Can't delete a nonempty directory. - return NULL; + return nullptr; } } _files.erase(fi); - _timestamp = time(NULL); + _timestamp = time(nullptr); return file; } - return NULL; + return nullptr; } // A nested directory. Search for the directory name, then recurse. @@ -635,7 +635,7 @@ do_delete_file(const string &filename) { } } - return NULL; + return nullptr; } /** diff --git a/panda/src/express/virtualFileMountSystem.cxx b/panda/src/express/virtualFileMountSystem.cxx index ce201712b2..4ef0d32ab1 100644 --- a/panda/src/express/virtualFileMountSystem.cxx +++ b/panda/src/express/virtualFileMountSystem.cxx @@ -49,7 +49,7 @@ bool VirtualFileMountSystem:: create_file(const Filename &file) { Filename pathname(_physical_filename, file); pathname.set_binary(); - ofstream stream; + std::ofstream stream; return pathname.open_write(stream, false); } @@ -167,7 +167,7 @@ open_read_file(const Filename &file) const { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -176,7 +176,7 @@ open_read_file(const Filename &file) const { if (!pathname.open_read(*stream)) { // Couldn't open the file for some reason. close_read_file(stream); - return NULL; + return nullptr; } return stream; @@ -193,7 +193,7 @@ open_write_file(const Filename &file, bool truncate) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -202,7 +202,7 @@ open_write_file(const Filename &file, bool truncate) { if (!pathname.open_write(*stream, truncate)) { // Couldn't open the file for some reason. close_write_file(stream); - return NULL; + return nullptr; } return stream; @@ -219,7 +219,7 @@ open_append_file(const Filename &file) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -228,7 +228,7 @@ open_append_file(const Filename &file) { if (!pathname.open_append(*stream)) { // Couldn't open the file for some reason. close_write_file(stream); - return NULL; + return nullptr; } return stream; @@ -245,7 +245,7 @@ open_read_write_file(const Filename &file, bool truncate) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -254,7 +254,7 @@ open_read_write_file(const Filename &file, bool truncate) { if (!pathname.open_read_write(*stream, truncate)) { // Couldn't open the file for some reason. close_read_write_file(stream); - return NULL; + return nullptr; } return stream; @@ -271,7 +271,7 @@ open_read_append_file(const Filename &file) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -280,7 +280,7 @@ open_read_append_file(const Filename &file) { if (!pathname.open_read_append(*stream)) { // Couldn't open the file for some reason. close_read_write_file(stream); - return NULL; + return nullptr; } return stream; @@ -385,7 +385,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return false; } } #endif // WIN32 @@ -402,7 +402,7 @@ atomic_read_contents(const Filename &file, string &contents) const { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return false; } } #endif // WIN32 diff --git a/panda/src/express/virtualFileSimple.I b/panda/src/express/virtualFileSimple.I index dcdd7cec90..1d30ef08e5 100644 --- a/panda/src/express/virtualFileSimple.I +++ b/panda/src/express/virtualFileSimple.I @@ -19,8 +19,7 @@ VirtualFileSimple(VirtualFileMount *mount, const Filename &local_filename, bool implicit_pz_file, int open_flags) : _mount(mount), _local_filename(local_filename), - _implicit_pz_file(implicit_pz_file), - _open_flags(open_flags) + _implicit_pz_file(implicit_pz_file) { } diff --git a/panda/src/express/virtualFileSimple.h b/panda/src/express/virtualFileSimple.h index 917898791e..c0f1da1fc7 100644 --- a/panda/src/express/virtualFileSimple.h +++ b/panda/src/express/virtualFileSimple.h @@ -74,7 +74,6 @@ private: VirtualFileMount *_mount; Filename _local_filename; bool _implicit_pz_file; - int _open_flags; public: virtual TypeHandle get_type() const { diff --git a/panda/src/express/virtualFileSystem.I b/panda/src/express/virtualFileSystem.I index 3a33e3df9c..b2f86e17bb 100644 --- a/panda/src/express/virtualFileSystem.I +++ b/panda/src/express/virtualFileSystem.I @@ -16,7 +16,7 @@ */ INLINE bool VirtualFileSystem:: exists(const Filename &filename) const { - return get_file(filename, true) != (VirtualFile *)NULL; + return get_file(filename, true) != nullptr; } /** @@ -26,7 +26,7 @@ exists(const Filename &filename) const { INLINE bool VirtualFileSystem:: is_directory(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - return (file != (VirtualFile *)NULL && file->is_directory()); + return (file != nullptr && file->is_directory()); } /** @@ -36,7 +36,7 @@ is_directory(const Filename &filename) const { INLINE bool VirtualFileSystem:: is_regular_file(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - return (file != (VirtualFile *)NULL && file->is_regular_file()); + return (file != nullptr && file->is_regular_file()); } /** @@ -48,8 +48,8 @@ is_regular_file(const Filename &filename) const { INLINE PT(VirtualFileList) VirtualFileSystem:: scan_directory(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } return file->scan_directory(); @@ -61,7 +61,7 @@ scan_directory(const Filename &filename) const { INLINE void VirtualFileSystem:: ls(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { express_cat.info() << "Not found: " << filename << "\n"; } else { @@ -76,7 +76,7 @@ ls(const Filename &filename) const { INLINE void VirtualFileSystem:: ls_all(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { express_cat.info() << "Not found: " << filename << "\n"; } else { @@ -126,7 +126,7 @@ write_file(const Filename &filename, const string &data, bool auto_wrap) { INLINE bool VirtualFileSystem:: read_file(const Filename &filename, string &result, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); - return (file != (VirtualFile *)NULL && file->read_file(result, auto_unwrap)); + return (file != nullptr && file->read_file(result, auto_unwrap)); } /** @@ -142,7 +142,7 @@ read_file(const Filename &filename, string &result, bool auto_unwrap) const { INLINE bool VirtualFileSystem:: read_file(const Filename &filename, pvector &result, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); - return (file != (VirtualFile *)NULL && file->read_file(result, auto_unwrap)); + return (file != nullptr && file->read_file(result, auto_unwrap)); } /** @@ -155,5 +155,5 @@ read_file(const Filename &filename, pvector &result, bool auto_un INLINE bool VirtualFileSystem:: write_file(const Filename &filename, const unsigned char *data, size_t data_size, bool auto_wrap) { PT(VirtualFile) file = create_file(filename); - return (file != (VirtualFile *)NULL && file->write_file(data, data_size, auto_wrap)); + return (file != nullptr && file->write_file(data, data_size, auto_wrap)); } diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index d69f518bc1..0262392216 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -25,7 +25,7 @@ #include "executionEnvironment.h" #include "pset.h" -VirtualFileSystem *VirtualFileSystem::_global_ptr = NULL; +VirtualFileSystem *VirtualFileSystem::_global_ptr = nullptr; /** @@ -151,7 +151,7 @@ bool VirtualFileSystem:: mount_loop(const Filename &virtual_filename, const Filename &mount_point, int flags, const string &password) { PT(VirtualFile) file = get_file(virtual_filename, false); - if (file == NULL) { + if (file == nullptr) { express_cat->warning() << "Attempt to mount " << virtual_filename << ", not found.\n"; return false; @@ -218,7 +218,7 @@ unmount(Multifile *multifile) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -260,7 +260,7 @@ unmount(const Filename &physical_filename) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -276,7 +276,7 @@ unmount(const Filename &physical_filename) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -314,7 +314,7 @@ unmount(VirtualFileMount *mount) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - (*ri)->_file_system = NULL; + (*ri)->_file_system = nullptr; } else { // Don't remove this one. @@ -350,7 +350,7 @@ unmount_point(const Filename &mount_point) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -380,7 +380,7 @@ unmount_all() { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } int num_removed = _mounts.size(); @@ -409,7 +409,7 @@ get_mount(int n) const { _lock.lock(); nassertd(n >= 0 && n < (int)_mounts.size()) { _lock.unlock(); - return NULL; + return nullptr; } PT(VirtualFileMount) result = _mounts[n]; _lock.unlock(); @@ -432,7 +432,7 @@ chdir(const Filename &new_directory) { } PT(VirtualFile) file = do_get_file(new_directory, OF_status_only); - if (file != (VirtualFile *)NULL && file->is_directory()) { + if (file != nullptr && file->is_directory()) { _cwd = file->get_filename(); _lock.unlock(); return true; @@ -463,7 +463,7 @@ make_directory(const Filename &filename) { _lock.lock(); PT(VirtualFile) result = do_get_file(filename, OF_make_directory); _lock.unlock(); - nassertr_always(result != NULL, false); + nassertr_always(result != nullptr, false); return result->is_directory(); } @@ -490,7 +490,7 @@ make_directory_full(const Filename &filename) { // Now make the last one, and check the return value. PT(VirtualFile) result = do_get_file(filename, OF_make_directory); _lock.unlock(); - nassertr_always(result != NULL, false); + nassertr_always(result != nullptr, false); return result->is_directory(); } @@ -552,12 +552,12 @@ find_file(const Filename &filename, const DSearchPath &searchpath, match = filename; } PT(VirtualFile) found_file = get_file(match, status_only); - if (found_file != (VirtualFile *)NULL) { + if (found_file != nullptr) { return found_file; } } - return NULL; + return nullptr; } /** @@ -568,7 +568,7 @@ find_file(const Filename &filename, const DSearchPath &searchpath, bool VirtualFileSystem:: delete_file(const Filename &filename) { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { return false; } @@ -590,13 +590,13 @@ bool VirtualFileSystem:: rename_file(const Filename &orig_filename, const Filename &new_filename) { _lock.lock(); PT(VirtualFile) orig_file = do_get_file(orig_filename, OF_status_only); - if (orig_file == (VirtualFile *)NULL) { + if (orig_file == nullptr) { _lock.unlock(); return false; } PT(VirtualFile) new_file = do_get_file(new_filename, OF_status_only | OF_allow_nonexist); - if (new_file == (VirtualFile *)NULL) { + if (new_file == nullptr) { _lock.unlock(); return false; } @@ -613,12 +613,12 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { bool VirtualFileSystem:: copy_file(const Filename &orig_filename, const Filename &new_filename) { PT(VirtualFile) orig_file = get_file(orig_filename, true); - if (orig_file == (VirtualFile *)NULL) { + if (orig_file == nullptr) { return false; } PT(VirtualFile) new_file = create_file(new_filename); - if (new_file == (VirtualFile *)NULL) { + if (new_file == nullptr) { return false; } @@ -733,7 +733,7 @@ write(ostream &out) const { */ VirtualFileSystem *VirtualFileSystem:: get_global_ptr() { - if (_global_ptr == (VirtualFileSystem *)NULL) { + if (_global_ptr == nullptr) { // Make sure this is initialized. init_libexpress(); @@ -839,13 +839,13 @@ get_global_ptr() { istream *VirtualFileSystem:: open_read_file(const Filename &filename, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } istream *str = file->open_read_file(auto_unwrap); - if (str != (istream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_read_file(str); - str = (istream *)NULL; + str = nullptr; } return str; } @@ -858,7 +858,7 @@ open_read_file(const Filename &filename, bool auto_unwrap) const { */ void VirtualFileSystem:: close_read_file(istream *stream) { - if (stream != (istream *)NULL) { + if (stream != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -883,13 +883,13 @@ close_read_file(istream *stream) { ostream *VirtualFileSystem:: open_write_file(const Filename &filename, bool auto_wrap, bool truncate) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } ostream *str = file->open_write_file(auto_wrap, truncate); - if (str != (ostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_write_file(str); - str = (ostream *)NULL; + str = nullptr; } return str; } @@ -902,13 +902,13 @@ open_write_file(const Filename &filename, bool auto_wrap, bool truncate) { ostream *VirtualFileSystem:: open_append_file(const Filename &filename) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } ostream *str = file->open_append_file(); - if (str != (ostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_write_file(str); - str = (ostream *)NULL; + str = nullptr; } return str; } @@ -921,7 +921,7 @@ open_append_file(const Filename &filename) { */ void VirtualFileSystem:: close_write_file(ostream *stream) { - if (stream != (ostream *)NULL) { + if (stream != nullptr) { #if (!defined(WIN32_VC) && !defined(WIN64_VC)) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~ostream(); (*global_operator_delete)(stream); @@ -939,13 +939,13 @@ close_write_file(ostream *stream) { iostream *VirtualFileSystem:: open_read_write_file(const Filename &filename, bool truncate) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } iostream *str = file->open_read_write_file(truncate); - if (str != (iostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_read_write_file(str); - str = (iostream *)NULL; + str = nullptr; } return str; } @@ -958,13 +958,13 @@ open_read_write_file(const Filename &filename, bool truncate) { iostream *VirtualFileSystem:: open_read_append_file(const Filename &filename) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } iostream *str = file->open_read_append_file(); - if (str != (iostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_read_write_file(str); - str = (iostream *)NULL; + str = nullptr; } return str; } @@ -977,7 +977,7 @@ open_read_append_file(const Filename &filename) { */ void VirtualFileSystem:: close_read_write_file(iostream *stream) { - if (stream != (iostream *)NULL) { + if (stream != nullptr) { #if (!defined(WIN32_VC) && !defined(WIN64_VC)) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~iostream(); (*global_operator_delete)(stream); @@ -995,7 +995,7 @@ atomic_compare_and_exchange_contents(const Filename &filename, string &orig_cont const string &old_contents, const string &new_contents) { PT(VirtualFile) file = create_file(filename); - if (file == NULL) { + if (file == nullptr) { return false; } @@ -1008,7 +1008,7 @@ atomic_compare_and_exchange_contents(const Filename &filename, string &orig_cont bool VirtualFileSystem:: atomic_read_contents(const Filename &filename, string &contents) const { PT(VirtualFile) file = get_file(filename, false); - if (file == NULL) { + if (file == nullptr) { return false; } @@ -1118,7 +1118,7 @@ normalize_mount_point(const Filename &mount_point) const { */ bool VirtualFileSystem:: do_mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { - nassertr(mount->_file_system == NULL, false); + nassertr(mount->_file_system == nullptr, false); mount->_file_system = this; mount->_mount_point = normalize_mount_point(mount_point); mount->_mount_flags = flags; @@ -1134,7 +1134,7 @@ do_mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { PT(VirtualFile) VirtualFileSystem:: do_get_file(const Filename &filename, int open_flags) const { if (filename.empty()) { - return NULL; + return nullptr; } Filename pathname(filename); if (pathname.is_local()) { @@ -1151,8 +1151,8 @@ do_get_file(const Filename &filename, int open_flags) const { // Now scan all the mount points, from the back (since later mounts override // more recent ones), until a match is found. - PT(VirtualFile) found_file = NULL; - VirtualFileComposite *composite_file = NULL; + PT(VirtualFile) found_file = nullptr; + VirtualFileComposite *composite_file = nullptr; // We use an index instead of an iterator, since the vector might change if // implicit mounts are added during this loop. @@ -1214,7 +1214,7 @@ do_get_file(const Filename &filename, int open_flags) const { } } - if (found_file == (VirtualFile *)NULL && vfs_implicit_mf) { + if (found_file == nullptr && vfs_implicit_mf) { // The file wasn't found, as-is. Does it appear to be an implicit .mf // file reference? ((VirtualFileSystem *)this)->consider_mount_mf(filename); @@ -1268,7 +1268,7 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil return false; } - if (found_file == (VirtualFile *)NULL) { + if (found_file == nullptr) { // This was our first match. Save it. found_file = vfile; if (!found_file->is_directory() || ((open_flags & OF_make_directory) != 0)) { @@ -1279,7 +1279,7 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil // It is a directory, so save it for later. if (implicit_pz_file) { // Don't look for directories named file.pz. - found_file = NULL; + found_file = nullptr; } } else { @@ -1293,7 +1293,7 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil if (!implicit_pz_file) { // At least two directories matched to the same path. We need a // composite directory. - if (composite_file == (VirtualFileComposite *)NULL) { + if (composite_file == nullptr) { composite_file = new VirtualFileComposite((VirtualFileSystem *)this, found_file->get_original_filename()); composite_file->set_original_filename(original_filename); @@ -1333,7 +1333,7 @@ consider_mount_mf(const Filename &filename) { // Hey, here's a multifile reference! dirname.set_binary(); PT(VirtualFile) file = do_get_file(dirname, false); - if (file == (VirtualFile *)NULL || !file->is_regular_file()) { + if (file == nullptr || !file->is_regular_file()) { // Oh, never mind. Not a real file. return false; } @@ -1341,7 +1341,7 @@ consider_mount_mf(const Filename &filename) { PT(Multifile) multifile = new Multifile; istream *stream = file->open_read_file(false); - if (stream == (istream *)NULL) { + if (stream == nullptr) { // Couldn't read file. return false; } diff --git a/panda/src/express/virtualFileSystem_ext.cxx b/panda/src/express/virtualFileSystem_ext.cxx index 6bc375c0d9..6018378f90 100644 --- a/panda/src/express/virtualFileSystem_ext.cxx +++ b/panda/src/express/virtualFileSystem_ext.cxx @@ -73,11 +73,11 @@ write_file(const Filename &filename, PyObject *data, bool auto_wrap) { #if PY_MAJOR_VERSION >= 3 if (PyBytes_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #else if (PyString_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #endif diff --git a/panda/src/express/virtualFile_ext.cxx b/panda/src/express/virtualFile_ext.cxx index db1a9a62ab..afe7473bbd 100644 --- a/panda/src/express/virtualFile_ext.cxx +++ b/panda/src/express/virtualFile_ext.cxx @@ -74,11 +74,11 @@ write_file(PyObject *data, bool auto_wrap) { #if PY_MAJOR_VERSION >= 3 if (PyBytes_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #else if (PyString_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #endif diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index 60ac8a1917..c6e570979f 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -43,9 +43,9 @@ WeakPointerTo(const WeakPointerTo ©) : * */ template -INLINE TYPENAME WeakPointerTo::To &WeakPointerTo:: +INLINE typename WeakPointerTo::To &WeakPointerTo:: operator *() const { - nassertr(!this->was_deleted(), *((To *)NULL)); + assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); } @@ -53,9 +53,9 @@ operator *() const { * */ template -INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: +INLINE typename WeakPointerTo::To *WeakPointerTo:: operator -> () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -68,7 +68,7 @@ operator -> () const { template INLINE WeakPointerTo:: operator T * () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -106,9 +106,9 @@ lock() const { * around compiler problems, particularly for implicit upcasts. */ template -INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: +INLINE typename WeakPointerTo::To *WeakPointerTo:: p() const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -117,7 +117,7 @@ p() const { * deleted. */ template -INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: +INLINE typename WeakPointerTo::To *WeakPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } @@ -158,7 +158,7 @@ operator = (const WeakPointerTo ©) { template INLINE WeakConstPointerTo:: WeakConstPointerTo(const To *ptr) : - WeakPointerToBase((TYPENAME WeakConstPointerTo::To *)ptr) + WeakPointerToBase((typename WeakConstPointerTo::To *)ptr) { } @@ -206,9 +206,9 @@ WeakConstPointerTo(const WeakConstPointerTo ©) : * */ template -INLINE const TYPENAME WeakConstPointerTo::To &WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To &WeakConstPointerTo:: operator *() const { - nassertr(!this->was_deleted(), *((To *)NULL)); + assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); } @@ -216,9 +216,9 @@ operator *() const { * */ template -INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To *WeakConstPointerTo:: operator -> () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -232,7 +232,7 @@ operator -> () const { template INLINE WeakConstPointerTo:: operator const T * () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -267,9 +267,9 @@ lock() const { * work around compiler problems, particularly for implicit upcasts. */ template -INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To *WeakConstPointerTo:: p() const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -278,7 +278,7 @@ p() const { * deleted. */ template -INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To *WeakConstPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 897c46a210..5834113b7a 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -28,9 +28,9 @@ template class WeakPointerTo : public WeakPointerToBase { public: - typedef TYPENAME WeakPointerToBase::To To; + typedef typename WeakPointerToBase::To To; PUBLISHED: - INLINE WeakPointerTo(To *ptr = (To *)NULL); + INLINE WeakPointerTo(To *ptr = nullptr); INLINE WeakPointerTo(const PointerTo ©); INLINE WeakPointerTo(const WeakPointerTo ©); @@ -64,9 +64,9 @@ PUBLISHED: template class WeakConstPointerTo : public WeakPointerToBase { public: - typedef TYPENAME WeakPointerToBase::To To; + typedef typename WeakPointerToBase::To To; PUBLISHED: - INLINE WeakConstPointerTo(const To *ptr = (const To *)NULL); + INLINE WeakConstPointerTo(const To *ptr = nullptr); INLINE WeakConstPointerTo(const PointerTo ©); INLINE WeakConstPointerTo(const ConstPointerTo ©); INLINE WeakConstPointerTo(const WeakPointerTo ©); diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 1c831529a1..4b610e34fd 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -292,6 +292,51 @@ operator >= (To *other) const { return (To *)_void_ptr >= other; } +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator == (std::nullptr_t) const { + return _void_ptr == nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator != (std::nullptr_t) const { + return _void_ptr != nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator > (std::nullptr_t) const { + return _void_ptr != nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator <= (std::nullptr_t) const { + return _void_ptr == nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator >= (std::nullptr_t) const { + return true; +} + /** * */ @@ -392,6 +437,15 @@ operator < (const To *other) const { return (To *)_void_ptr < other; } +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator < (std::nullptr_t) const { + return false; +} + /** * */ @@ -455,7 +509,7 @@ output(ostream &out) const { out << _void_ptr; if (was_deleted()) { out << ":deleted"; - } else if (_void_ptr != (void *)NULL) { + } else if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); } } diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 4870ef21d8..34960920ab 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -60,6 +60,12 @@ public: INLINE bool operator <= (To *other) const; INLINE bool operator >= (To *other) const; + INLINE bool operator == (std::nullptr_t) const; + INLINE bool operator != (std::nullptr_t) const; + INLINE bool operator > (std::nullptr_t) const; + INLINE bool operator <= (std::nullptr_t) const; + INLINE bool operator >= (std::nullptr_t) const; + INLINE bool operator == (const WeakPointerToBase &other) const; INLINE bool operator != (const WeakPointerToBase &other) const; INLINE bool operator > (const WeakPointerToBase &other) const; @@ -73,6 +79,7 @@ public: INLINE bool operator >= (const PointerToBase &other) const; #endif // WIN32_VC INLINE bool operator < (const To *other) const; + INLINE bool operator < (std::nullptr_t) const; INLINE bool operator < (const WeakPointerToBase &other) const; INLINE bool operator < (const PointerToBase &other) const; #endif // CPPPARSER diff --git a/panda/src/express/weakReferenceList.cxx b/panda/src/express/weakReferenceList.cxx index f9e92d6009..0534556d7a 100644 --- a/panda/src/express/weakReferenceList.cxx +++ b/panda/src/express/weakReferenceList.cxx @@ -47,7 +47,7 @@ add_callback(WeakPointerCallback *callback, void *data) { // have been deleted in the meantime. bool deleted = was_deleted(); if (!deleted) { - _callbacks.insert(make_pair(callback, data)); + _callbacks.insert(std::make_pair(callback, data)); } _lock.unlock(); diff --git a/panda/src/express/windowsRegistry.cxx b/panda/src/express/windowsRegistry.cxx index 183a3a9c0d..29255a5e74 100644 --- a/panda/src/express/windowsRegistry.cxx +++ b/panda/src/express/windowsRegistry.cxx @@ -34,8 +34,6 @@ set_string_value(const string &key, const string &name, const string &value, TextEncoder encoder; wstring wvalue = encoder.decode_text(value); - bool okflag = true; - // Now convert the string to Windows' idea of the correct wide-char // encoding, so we can store it in the registry. This might well be the // same string we just decoded from, but it might not. @@ -46,8 +44,8 @@ set_string_value(const string &key, const string &name, const string &value, int mb_result_len = WideCharToMultiByte(CP_ACP, 0, wvalue.data(), wvalue.length(), - NULL, 0, - NULL, NULL); + nullptr, 0, + nullptr, nullptr); if (mb_result_len == 0) { express_cat.error() << "Unable to convert '" << value @@ -59,7 +57,7 @@ set_string_value(const string &key, const string &name, const string &value, WideCharToMultiByte(CP_ACP, 0, wvalue.data(), wvalue.length(), mb_result, mb_result_len, - NULL, NULL); + nullptr, nullptr); if (express_cat.is_debug()) { express_cat.debug() @@ -141,7 +139,7 @@ get_string_value(const string &key, const string &name, int wide_result_len = MultiByteToWideChar(CP_ACP, 0, data.data(), data.length(), - NULL, 0); + nullptr, 0); if (wide_result_len == 0) { express_cat.error() << "Unable to convert '" << data @@ -347,7 +345,7 @@ format_message(int error_code) { PVOID buffer; DWORD length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error_code, 0, (LPTSTR)&buffer, 0, NULL); + nullptr, error_code, 0, (LPTSTR)&buffer, 0, nullptr); if (length == 0) { return "Unknown error message"; } diff --git a/panda/src/express/zStreamBuf.cxx b/panda/src/express/zStreamBuf.cxx index c6af03499b..c037252895 100644 --- a/panda/src/express/zStreamBuf.cxx +++ b/panda/src/express/zStreamBuf.cxx @@ -35,9 +35,9 @@ do_zlib_free(voidpf opaque, voidpf address) { */ ZStreamBuf:: ZStreamBuf() { - _source = (istream *)NULL; + _source = nullptr; _owns_source = false; - _dest = (ostream *)NULL; + _dest = nullptr; _owns_dest = false; #ifdef PHAVE_IOSTREAM @@ -100,7 +100,7 @@ open_read(istream *source, bool owns_source) { */ void ZStreamBuf:: close_read() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { int result = inflateEnd(&_z_source); if (result < 0) { @@ -112,7 +112,7 @@ close_read() { delete _source; _owns_source = false; } - _source = (istream *)NULL; + _source = nullptr; } } @@ -151,7 +151,7 @@ open_write(ostream *dest, bool owns_dest, int compression_level) { */ void ZStreamBuf:: close_write() { - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n, Z_FINISH); pbump(-(int)n); @@ -166,7 +166,7 @@ close_write() { delete _dest; _owns_dest = false; } - _dest = (ostream *)NULL; + _dest = nullptr; } } @@ -250,12 +250,12 @@ overflow(int ch) { */ int ZStreamBuf:: sync() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { size_t n = egptr() - gptr(); gbump(n); } - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n, Z_SYNC_FLUSH); pbump(-(int)n); @@ -427,7 +427,7 @@ show_zlib_error(const char *function, int error_code, z_stream &z) { default: error_line << error_code; } - if (z.msg != (char *)NULL) { + if (z.msg != nullptr) { error_line << " = " << z.msg; } diff --git a/panda/src/ffmpeg/ffmpegAudio.cxx b/panda/src/ffmpeg/ffmpegAudio.cxx index ee7fee8669..6fd9a01c9e 100644 --- a/panda/src/ffmpeg/ffmpegAudio.cxx +++ b/panda/src/ffmpeg/ffmpegAudio.cxx @@ -41,9 +41,9 @@ FfmpegAudio:: PT(MovieAudioCursor) FfmpegAudio:: open() { PT(FfmpegAudioCursor) result = new FfmpegAudioCursor(this); - if (result->_format_ctx == 0) { + if (result->_format_ctx == nullptr) { ffmpeg_cat.error() << "Could not open " << _filename << "\n"; - return NULL; + return nullptr; } else { return (MovieAudioCursor*)(FfmpegAudioCursor*)result; } diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index ef6cd14d92..dd5d49cc59 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -46,14 +46,14 @@ FfmpegAudioCursor:: FfmpegAudioCursor(FfmpegAudio *src) : MovieAudioCursor(src), _filename(src->_filename), - _packet(0), - _packet_data(0), - _format_ctx(0), - _audio_ctx(0), - _resample_ctx(0), - _buffer(0), - _buffer_alloc(0), - _frame(0) + _packet(nullptr), + _packet_data(nullptr), + _format_ctx(nullptr), + _audio_ctx(nullptr), + _resample_ctx(nullptr), + _buffer(nullptr), + _buffer_alloc(nullptr), + _frame(nullptr) { if (!_ffvfile.open_vfs(_filename)) { cleanup(); @@ -61,9 +61,9 @@ FfmpegAudioCursor(FfmpegAudio *src) : } _format_ctx = _ffvfile.get_format_context(); - nassertv(_format_ctx != NULL); + nassertv(_format_ctx != nullptr); - if (avformat_find_stream_info(_format_ctx, NULL) < 0) { + if (avformat_find_stream_info(_format_ctx, nullptr) < 0) { cleanup(); return; } @@ -102,7 +102,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : _audio_channels = codecpar->channels; AVCodec *pAudioCodec = avcodec_find_decoder(codecpar->codec_id); - if (pAudioCodec == 0) { + if (pAudioCodec == nullptr) { cleanup(); return; } @@ -120,9 +120,9 @@ FfmpegAudioCursor(FfmpegAudio *src) : avcodec_copy_context(_audio_ctx, codecpar); #endif - AVDictionary *opts = NULL; + AVDictionary *opts = nullptr; av_dict_set(&opts, "request_sample_fmt", "s16", 0); - if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) { + if (avcodec_open2(_audio_ctx, pAudioCodec, nullptr) < 0) { cleanup(); return; } @@ -148,7 +148,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : if (swr_init(_resample_ctx) != 0) { ffmpeg_cat.error() << "Failed to set up resample context.\n"; - _resample_ctx = NULL; + _resample_ctx = nullptr; } #else ffmpeg_cat.error() @@ -176,7 +176,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : _buffer_alloc = new int16_t[_buffer_size + 64]; // Allocate enough space for 1024 samples per channel. - if ((_packet == 0)||(_buffer_alloc == 0)) { + if ((_packet == nullptr)||(_buffer_alloc == nullptr)) { cleanup(); return; } @@ -216,7 +216,7 @@ cleanup() { #else avcodec_free_frame(&_frame); #endif - _frame = NULL; + _frame = nullptr; } if (_packet) { @@ -227,14 +227,14 @@ cleanup() { av_free_packet(_packet); } delete _packet; - _packet = NULL; + _packet = nullptr; #endif } if (_buffer_alloc) { delete[] _buffer_alloc; - _buffer_alloc = 0; - _buffer = NULL; + _buffer_alloc = nullptr; + _buffer = nullptr; } if ((_audio_ctx)&&(_audio_ctx->codec)) { @@ -245,17 +245,17 @@ cleanup() { delete _audio_ctx; #endif } - _audio_ctx = NULL; + _audio_ctx = nullptr; if (_format_ctx) { _ffvfile.close(); - _format_ctx = NULL; + _format_ctx = nullptr; } #ifdef HAVE_SWRESAMPLE if (_resample_ctx) { swr_free(&_resample_ctx); - _resample_ctx = NULL; + _resample_ctx = nullptr; } #endif @@ -287,9 +287,9 @@ fetch_packet() { av_free_packet(_packet); #endif } - _packet->data = 0; + _packet->data = nullptr; _packet_size = 0; - _packet_data = 0; + _packet_data = nullptr; } /** @@ -320,7 +320,7 @@ reload_buffer() { fetch_packet(); if (_packet->data == nullptr) { // fetch_packet() says we're out of packets. Let the codec know. - ret = avcodec_send_packet(_audio_ctx, NULL); + ret = avcodec_send_packet(_audio_ctx, nullptr); } } @@ -444,7 +444,7 @@ seek(double t) { double ts = _packet->dts * _audio_timebase; if (t > ts) { int skip = (int)((t-ts) * _audio_rate); - read_samples(skip, 0); + read_samples(skip, nullptr); } _last_seek = t; _samples_read = 0; @@ -469,7 +469,7 @@ read_samples(int n, int16_t *data) { int available = _buffer_tail - _buffer_head; int ncopy = (desired > available) ? available : desired; if (ncopy) { - if (data != 0) { + if (data != nullptr) { memcpy(data, _buffer + _buffer_head, ncopy * 2); data += ncopy; } diff --git a/panda/src/ffmpeg/ffmpegVideo.cxx b/panda/src/ffmpeg/ffmpegVideo.cxx index a16336260e..c12892fe47 100644 --- a/panda/src/ffmpeg/ffmpegVideo.cxx +++ b/panda/src/ffmpeg/ffmpegVideo.cxx @@ -56,9 +56,9 @@ FfmpegVideo:: PT(MovieVideoCursor) FfmpegVideo:: open() { PT(FfmpegVideoCursor) result = new FfmpegVideoCursor(this); - if (result->_format_ctx == 0) { + if (result->_format_ctx == nullptr) { ffmpeg_cat.error() << "Could not open " << _filename << "\n"; - return NULL; + return nullptr; } else { return result.p(); } diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 21137b30e8..b7b67a8ecf 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -51,14 +51,14 @@ FfmpegVideoCursor() : _action_cvar(_lock), _thread_status(TS_stopped), _seek_frame(0), - _packet(NULL), - _format_ctx(NULL), - _video_ctx(NULL), - _convert_ctx(NULL), + _packet(nullptr), + _format_ctx(nullptr), + _video_ctx(nullptr), + _convert_ctx(nullptr), _pixel_format((int)AV_PIX_FMT_NONE), _video_index(-1), - _frame(NULL), - _frame_out(NULL), + _frame(nullptr), + _frame_out(nullptr), _eof_known(false) { } @@ -69,8 +69,8 @@ FfmpegVideoCursor() : */ void FfmpegVideoCursor:: init_from(FfmpegVideo *source) { - nassertv(_thread == NULL && _thread_status == TS_stopped); - nassertv(source != NULL); + nassertv(_thread == nullptr && _thread_status == TS_stopped); + nassertv(source != nullptr); _source = source; _filename = _source->get_filename(); @@ -89,7 +89,7 @@ init_from(FfmpegVideo *source) { _frame_out = avcodec_alloc_frame(); #endif - if ((_frame == 0)||(_frame_out == 0)) { + if ((_frame == nullptr)||(_frame_out == nullptr)) { cleanup(); return; } @@ -122,10 +122,10 @@ init_from(FfmpegVideo *source) { } #ifdef HAVE_SWSCALE - nassertv(_convert_ctx == NULL); + nassertv(_convert_ctx == nullptr); _convert_ctx = sws_getContext(_size_x, _size_y, _video_ctx->pix_fmt, _size_x, _size_y, (AVPixelFormat)_pixel_format, - SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); + SWS_BILINEAR | SWS_PRINT_INFO, nullptr, nullptr, nullptr); #endif // HAVE_SWSCALE #ifdef HAVE_THREADS @@ -144,13 +144,13 @@ FfmpegVideoCursor(FfmpegVideo *src) : _action_cvar(_lock), _thread_status(TS_stopped), _seek_frame(0), - _packet(NULL), - _format_ctx(NULL), - _video_ctx(NULL), - _convert_ctx(NULL), + _packet(nullptr), + _format_ctx(nullptr), + _video_ctx(nullptr), + _convert_ctx(nullptr), _video_index(-1), - _frame(NULL), - _frame_out(NULL), + _frame(nullptr), + _frame_out(nullptr), _eof_known(false) { init_from(src); @@ -256,7 +256,7 @@ start_thread() { _thread = new GenericThread(_filename.get_basename(), _sync_name, st_thread_main, this); if (!_thread->start(_thread_priority, true)) { // Couldn't start the thread. - _thread = NULL; + _thread = nullptr; _thread_status = TS_stopped; } } @@ -279,7 +279,7 @@ stop_thread() { _thread_status = TS_shutdown; } _action_cvar.notify(); - _thread = NULL; + _thread = nullptr; } // Now that we've released the lock, we can join the thread. @@ -334,7 +334,7 @@ set_time(double timestamp, int loop_count) { } _current_frame = frame; - if (_current_frame_buffer != NULL) { + if (_current_frame_buffer != nullptr) { // If we've previously returned a frame, don't bother asking for a next // one if that frame is still valid. return (_current_frame >= _current_frame_buffer->_end_frame || @@ -353,8 +353,8 @@ fetch_buffer() { MutexHolder holder(_lock); // If there was an error at any point, just return NULL. - if (_format_ctx == (AVFormatContext *)NULL) { - return NULL; + if (_format_ctx == nullptr) { + return nullptr; } PT(FfmpegBuffer) frame; @@ -400,7 +400,7 @@ fetch_buffer() { } } } - if (frame == NULL || frame->_end_frame < _current_frame) { + if (frame == nullptr || frame->_end_frame < _current_frame) { // No frame available, or the frame is too old. Seek. if (_thread_status == TS_wait || _thread_status == TS_seek || _thread_status == TS_readahead) { _thread_status = TS_seek; @@ -410,16 +410,16 @@ fetch_buffer() { } } - if (frame != NULL) { + if (frame != nullptr) { bool too_old = (frame->_end_frame < _current_frame && !ffmpeg_show_seek_frames); bool too_new = frame->_begin_frame > _current_frame; if (too_old || too_new) { // The frame is too old or too new. Just recycle it. - frame = NULL; + frame = nullptr; } } - if (frame != NULL) { + if (frame != nullptr) { _current_frame_buffer = frame; if (ffmpeg_cat.is_debug()) { ffmpeg_cat.debug() @@ -475,18 +475,18 @@ open_stream() { } } - nassertr(_format_ctx == NULL, false); + nassertr(_format_ctx == nullptr, false); _format_ctx = _ffvfile.get_format_context(); - nassertr(_format_ctx != NULL, false); + nassertr(_format_ctx != nullptr, false); - if (avformat_find_stream_info(_format_ctx, NULL) < 0) { + if (avformat_find_stream_info(_format_ctx, nullptr) < 0) { ffmpeg_cat.info() << "Couldn't find stream info\n"; close_stream(); return false; } - nassertr(_video_ctx == NULL, false); + nassertr(_video_ctx == nullptr, false); // As of libavformat version 57.41.100, AVStream.codec is deprecated in favor // of AVStream.codecpar. Fortunately, the two structures have @@ -522,7 +522,7 @@ open_stream() { _video_timebase = av_q2d(stream->time_base); _min_fseek = (int)(3.0 / _video_timebase); - AVCodec *pVideoCodec = NULL; + AVCodec *pVideoCodec = nullptr; if (ffmpeg_prefer_libvpx) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 0, 0) if (codecpar->codec_id == AV_CODEC_ID_VP9) { @@ -533,10 +533,10 @@ open_stream() { pVideoCodec = avcodec_find_decoder_by_name("libvpx"); } } - if (pVideoCodec == NULL) { + if (pVideoCodec == nullptr) { pVideoCodec = avcodec_find_decoder(codecpar->codec_id); } - if (pVideoCodec == NULL) { + if (pVideoCodec == nullptr) { ffmpeg_cat.info() << "Couldn't find codec\n"; close_stream(); @@ -558,7 +558,7 @@ open_stream() { avcodec_copy_context(_video_ctx, codecpar); #endif - if (avcodec_open2(_video_ctx, pVideoCodec, NULL) < 0) { + if (avcodec_open2(_video_ctx, pVideoCodec, nullptr) < 0) { ffmpeg_cat.info() << "Couldn't open codec\n"; close_stream(); @@ -591,10 +591,10 @@ close_stream() { delete _video_ctx; #endif } - _video_ctx = NULL; + _video_ctx = nullptr; _ffvfile.close(); - _format_ctx = NULL; + _format_ctx = nullptr; _video_index = -1; } @@ -610,21 +610,21 @@ cleanup() { ReMutexHolder av_holder(_av_lock); #ifdef HAVE_SWSCALE - if (_convert_ctx != NULL) { + if (_convert_ctx != nullptr) { sws_freeContext(_convert_ctx); } - _convert_ctx = NULL; + _convert_ctx = nullptr; #endif // HAVE_SWSCALE if (_frame) { av_free(_frame); - _frame = NULL; + _frame = nullptr; } if (_frame_out) { - _frame_out->data[0] = 0; + _frame_out->data[0] = nullptr; av_free(_frame_out); - _frame_out = NULL; + _frame_out = nullptr; } if (_packet) { @@ -635,7 +635,7 @@ cleanup() { av_free_packet(_packet); } delete _packet; - _packet = NULL; + _packet = nullptr; #endif } } @@ -711,7 +711,7 @@ do_poll() { if ((int)_readahead_frames.size() < _max_readahead_frames) { // Time to read the next frame. PT(FfmpegBuffer) frame = do_alloc_frame(); - nassertr(frame != NULL, false); + nassertr(frame != nullptr, false); _lock.release(); fetch_frame(-1); if (_frame_ready) { @@ -734,7 +734,7 @@ do_poll() { int seek_frame = _seek_frame; _thread_status = TS_seeking; PT(FfmpegBuffer) frame = do_alloc_frame(); - nassertr(frame != NULL, false); + nassertr(frame != nullptr, false); _lock.release(); advance_to_frame(seek_frame); if (_frame_ready) { @@ -819,7 +819,7 @@ do_fetch_packet(int default_frame) { av_free_packet(_packet); #endif } - _packet->data = 0; + _packet->data = nullptr; if (!_eof_known && default_frame != 0) { _eof_frame = _packet_frame; @@ -1146,7 +1146,7 @@ export_frame(FfmpegBuffer *buffer) { if (ffmpeg_global_lock) { ReMutexHolder av_holder(_av_lock); #ifdef HAVE_SWSCALE - nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); + nassertv(_convert_ctx != nullptr && _frame != nullptr && _frame_out != nullptr); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else img_convert((AVPicture *)_frame_out, (AVPixelFormat)_pixel_format, @@ -1154,7 +1154,7 @@ export_frame(FfmpegBuffer *buffer) { #endif } else { #ifdef HAVE_SWSCALE - nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); + nassertv(_convert_ctx != nullptr && _frame != nullptr && _frame_out != nullptr); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else img_convert((AVPicture *)_frame_out, (AVPixelFormat)_pixel_format, @@ -1190,7 +1190,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { */ void FfmpegVideoCursor:: finalize(BamReader *) { - if (_source != (MovieVideo *)NULL) { + if (_source != nullptr) { FfmpegVideo *video; DCAST_INTO_V(video, _source); init_from(video); diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.I b/panda/src/ffmpeg/ffmpegVirtualFile.I index c7a65bef36..c7e8e5d6c2 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.I +++ b/panda/src/ffmpeg/ffmpegVirtualFile.I @@ -16,7 +16,7 @@ */ INLINE bool FfmpegVirtualFile:: is_open() const { - return (_format_context != NULL); + return (_format_context != nullptr); } /** diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index b671ce0ba6..6acf6debcd 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -31,9 +31,9 @@ extern "C" { */ FfmpegVirtualFile:: FfmpegVirtualFile() : - _io_context(NULL), - _format_context(NULL), - _in(NULL), + _io_context(nullptr), + _format_context(nullptr), + _in(nullptr), _owns_in(false), _buffer_size(ffmpeg_read_buffer_size) { @@ -65,12 +65,12 @@ open_vfs(const Filename &filename) { Filename fname = filename; fname.set_binary(); PT(VirtualFile) vfile = vfs->get_file(fname); - if (vfile == NULL) { + if (vfile == nullptr) { return false; } _in = vfile->open_read_file(true); - if (_in == NULL) { + if (_in == nullptr) { return false; } @@ -84,14 +84,14 @@ open_vfs(const Filename &filename) { // pointer. unsigned char *buffer = (unsigned char*) av_malloc(_buffer_size); _io_context = avio_alloc_context(buffer, _buffer_size, 0, (void*) this, - &read_packet, 0, &seek); + &read_packet, nullptr, &seek); _format_context = avformat_alloc_context(); _format_context->pb = _io_context; // Now we can open the stream. int result = - avformat_open_input(&_format_context, "", NULL, NULL); + avformat_open_input(&_format_context, "", nullptr, nullptr); if (result < 0) { close(); return false; @@ -132,14 +132,14 @@ open_subfile(const SubfileInfo &info) { // pointer. unsigned char *buffer = (unsigned char*) av_malloc(_buffer_size); _io_context = avio_alloc_context(buffer, _buffer_size, 0, (void*) this, - &read_packet, 0, &seek); + &read_packet, nullptr, &seek); _format_context = avformat_alloc_context(); _format_context->pb = _io_context; // Now we can open the stream. int result = - avformat_open_input(&_format_context, fname.c_str(), NULL, NULL); + avformat_open_input(&_format_context, fname.c_str(), nullptr, nullptr); if (result < 0) { close(); return false; @@ -154,24 +154,24 @@ open_subfile(const SubfileInfo &info) { */ void FfmpegVirtualFile:: close() { - if (_format_context != NULL) { + if (_format_context != nullptr) { avformat_close_input(&_format_context); } - if (_io_context != NULL) { - if (_io_context->buffer != NULL) { + if (_io_context != nullptr) { + if (_io_context->buffer != nullptr) { av_free(_io_context->buffer); } av_free(_io_context); - _io_context = NULL; + _io_context = nullptr; } if (_owns_in) { - nassertv(_in != NULL); + nassertv(_in != nullptr); VirtualFileSystem::close_read_file(_in); _owns_in = false; } - _in = NULL; + _in = nullptr; } /** diff --git a/panda/src/framework/pandaFramework.I b/panda/src/framework/pandaFramework.I index 552d5bc2f2..d17bc8dad7 100644 --- a/panda/src/framework/pandaFramework.I +++ b/panda/src/framework/pandaFramework.I @@ -17,7 +17,7 @@ */ INLINE GraphicsEngine *PandaFramework:: get_graphics_engine() { - if (_engine == (GraphicsEngine *)NULL) { + if (_engine == nullptr) { _engine = GraphicsEngine::get_global_ptr(); PT(GenericAsyncTask) task = new GenericAsyncTask("igloop", task_igloop, this); task->set_sort(50); @@ -74,7 +74,7 @@ get_num_windows() const { */ INLINE WindowFramework *PandaFramework:: get_window(int n) const { - nassertr(n >= 0 && n < (int)_windows.size(), NULL); + nassertr(n >= 0 && n < (int)_windows.size(), nullptr); return _windows[n]; } diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 30968e70b3..26f5f2d3ce 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -50,7 +50,7 @@ PandaFramework() : _is_open = false; _made_default_pipe = false; _window_title = string(); - _engine = (GraphicsEngine *)NULL; + _engine = nullptr; _start_time = 0.0; _frame_count = 0; _wireframe_enabled = false; @@ -172,9 +172,9 @@ close_framework() { close_all_windows(); // Also close down any other windows that might have been opened. - if (_engine != (GraphicsEngine *)NULL) { + if (_engine != nullptr) { _engine->remove_all_windows(); - _engine = NULL; + _engine = nullptr; } _event_handler.remove_all_hooks(); @@ -191,7 +191,7 @@ close_framework() { _default_keys_enabled = false; _exit_flag = false; - _recorder = NULL; + _recorder = nullptr; Thread::prepare_for_exit(); } @@ -208,7 +208,7 @@ close_framework() { */ GraphicsPipe *PandaFramework:: get_default_pipe() { - nassertr(_is_open, NULL); + nassertr(_is_open, nullptr); if (!_made_default_pipe) { make_default_pipe(); _made_default_pipe = true; @@ -240,7 +240,7 @@ get_mouse(GraphicsOutput *window) { mouse = data_root.attach_new_node(mouse_node); RecorderController *recorder = get_recorder(); - if (recorder != (RecorderController *)NULL) { + if (recorder != nullptr) { // If we're in recording or playback mode, associate a recorder. MouseRecorder *mouse_recorder = new MouseRecorder("mouse"); mouse = mouse.attach_new_node(mouse_recorder); @@ -324,13 +324,13 @@ get_default_window_props(WindowProperties &props) { WindowFramework *PandaFramework:: open_window() { GraphicsPipe *pipe = get_default_pipe(); - if (pipe == (GraphicsPipe *)NULL) { + if (pipe == nullptr) { // Can't get a pipe. - return NULL; + return nullptr; } - WindowFramework *wf = open_window(pipe, NULL); - if (wf == (WindowFramework *)NULL) { + WindowFramework *wf = open_window(pipe, nullptr); + if (wf == nullptr) { // Ok, the default graphics pipe failed; try a little harder. GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); selection->load_aux_modules(); @@ -340,9 +340,9 @@ open_window() { TypeHandle pipe_type = selection->get_pipe_type(i); if (pipe_type != _default_pipe->get_type()) { PT(GraphicsPipe) new_pipe = selection->make_pipe(pipe_type); - if (new_pipe != (GraphicsPipe *)NULL) { - wf = open_window(new_pipe, NULL); - if (wf != (WindowFramework *)NULL) { + if (new_pipe != nullptr) { + wf = open_window(new_pipe, nullptr); + if (wf != nullptr) { // Here's the winner! _default_pipe = new_pipe; return wf; @@ -364,7 +364,7 @@ open_window() { */ WindowFramework *PandaFramework:: open_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { - nassertr(_is_open, NULL); + nassertr(_is_open, nullptr); WindowProperties props; get_default_window_props(props); @@ -387,15 +387,15 @@ open_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { WindowFramework *PandaFramework:: open_window(const WindowProperties &props, int flags, GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { - if (pipe == (GraphicsPipe *)NULL) { + if (pipe == nullptr) { pipe = get_default_pipe(); - if (pipe == (GraphicsPipe *)NULL) { + if (pipe == nullptr) { // Can't get a pipe. - return NULL; + return nullptr; } } - nassertr(_is_open, NULL); + nassertr(_is_open, nullptr); PT(WindowFramework) wf = make_window_framework(); wf->set_wireframe(get_wireframe()); wf->set_texture(get_texture()); @@ -407,18 +407,18 @@ open_window(const WindowProperties &props, int flags, GraphicsOutput *win = wf->open_window(props, flags, get_graphics_engine(), pipe, gsg); _engine->open_windows(); - if (win != (GraphicsOutput *)NULL && !win->is_valid()) { + if (win != nullptr && !win->is_valid()) { // The window won't open. _engine->remove_window(win); wf->close_window(); - win = NULL; + win = nullptr; } - if (win == (GraphicsOutput *)NULL) { + if (win == nullptr) { // Oops, couldn't make a window or buffer. framework_cat.error() << "Unable to create window.\n"; - return NULL; + return nullptr; } _windows.push_back(wf); @@ -467,7 +467,7 @@ close_window(int n) { WindowFramework *wf = _windows[n]; GraphicsOutput *win = wf->get_graphics_output(); - if (win != (GraphicsOutput *)NULL) { + if (win != nullptr) { _engine->remove_window(win); } @@ -485,7 +485,7 @@ close_all_windows() { WindowFramework *wf = (*wi); GraphicsOutput *win = wf->get_graphics_output(); - if (win != (GraphicsOutput *)NULL) { + if (win != nullptr) { _engine->remove_window(win); } @@ -780,7 +780,7 @@ make_default_pipe() { _default_pipe = selection->make_default_pipe(); - if (_default_pipe == (GraphicsPipe*)NULL) { + if (_default_pipe == nullptr) { nout << "No graphics pipe is available!\n" << "Your Config.prc file must name at least one valid panda display\n" << "library via load-display or aux-display.\n"; @@ -1412,7 +1412,7 @@ AsyncTask::DoneStatus PandaFramework:: task_record_frame(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; - if (self->_recorder != (RecorderController *)NULL) { + if (self->_recorder != nullptr) { self->_recorder->record_frame(); } @@ -1427,7 +1427,7 @@ AsyncTask::DoneStatus PandaFramework:: task_play_frame(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; - if (self->_recorder != (RecorderController *)NULL) { + if (self->_recorder != nullptr) { self->_recorder->play_frame(); } diff --git a/panda/src/framework/pandaFramework.h b/panda/src/framework/pandaFramework.h index 46df0f3bdd..01c50ae8d0 100644 --- a/panda/src/framework/pandaFramework.h +++ b/panda/src/framework/pandaFramework.h @@ -61,10 +61,10 @@ public: WindowFramework *open_window(); WindowFramework *open_window(GraphicsPipe *pipe, - GraphicsStateGuardian *gsg = NULL); + GraphicsStateGuardian *gsg = nullptr); WindowFramework *open_window(const WindowProperties &props, int flags, - GraphicsPipe *pipe = NULL, - GraphicsStateGuardian *gsg = NULL); + GraphicsPipe *pipe = nullptr, + GraphicsStateGuardian *gsg = nullptr); INLINE int get_num_windows() const; INLINE WindowFramework *get_window(int n) const; diff --git a/panda/src/framework/windowFramework.I b/panda/src/framework/windowFramework.I index 6cd1da7d64..5fa4caafe8 100644 --- a/panda/src/framework/windowFramework.I +++ b/panda/src/framework/windowFramework.I @@ -25,11 +25,11 @@ get_panda_framework() const { */ INLINE GraphicsWindow *WindowFramework:: get_graphics_window() const { - if (_window != (GraphicsOutput *)NULL && + if (_window != nullptr && _window->is_of_type(GraphicsWindow::get_class_type())) { return DCAST(GraphicsWindow, _window); } - return NULL; + return nullptr; } /** @@ -55,7 +55,7 @@ get_num_cameras() const { */ INLINE Camera *WindowFramework:: get_camera(int n) const { - nassertr(n >= 0 && n < (int)_cameras.size(), NULL); + nassertr(n >= 0 && n < (int)_cameras.size(), nullptr); return _cameras[n]; } diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 756a1b61f1..3b1cb1807c 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -65,7 +65,7 @@ // This number is chosen arbitrarily to override any settings in model files. static const int override_priority = 100; -PT(TextFont) WindowFramework::_shuttle_controls_font = NULL; +PT(TextFont) WindowFramework::_shuttle_controls_font = nullptr; TypeHandle WindowFramework::_type_handle; /** @@ -134,7 +134,7 @@ GraphicsOutput *WindowFramework:: open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsStateGuardian *gsg, const FrameBufferProperties &fbprops) { - nassertr(_window == (GraphicsOutput *)NULL, _window); + nassertr(_window == nullptr, _window); static int next_window_index = 1; ostringstream stream; @@ -142,11 +142,11 @@ open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, next_window_index++; string name = stream.str(); - _window = 0; + _window = nullptr; GraphicsOutput *winout = engine->make_output(pipe, name, 0, fbprops, - props, flags, gsg, NULL); - if (winout != (GraphicsOutput *)NULL) { + props, flags, gsg, nullptr); + if (winout != nullptr) { _window = winout; // _window->request_properties(props); @@ -203,13 +203,13 @@ close_window() { _lighting_enabled = false; _perpixel_enabled = false; - if (_frame_rate_meter != (FrameRateMeter *)NULL) { + if (_frame_rate_meter != nullptr) { _frame_rate_meter->clear_window(); - _frame_rate_meter = (FrameRateMeter *)NULL; + _frame_rate_meter = nullptr; } - if (_scene_graph_analyzer_meter != (SceneGraphAnalyzerMeter *)NULL) { + if (_scene_graph_analyzer_meter != nullptr) { _scene_graph_analyzer_meter->clear_window(); - _scene_graph_analyzer_meter = (SceneGraphAnalyzerMeter *)NULL; + _scene_graph_analyzer_meter = nullptr; } } @@ -455,13 +455,13 @@ setup_trackball() { */ void WindowFramework:: center_trackball(const NodePath &object) { - if (_trackball == (Trackball *)NULL) { + if (_trackball == nullptr) { return; } PT(BoundingVolume) volume = object.get_bounds(); // We expect at least a geometric bounding volume around the world. - nassertv(volume != (BoundingVolume *)NULL); + nassertv(volume != nullptr); nassertv(volume->is_of_type(GeometricBoundingVolume::get_class_type())); CPT(GeometricBoundingVolume) gbv = DCAST(GeometricBoundingVolume, volume); @@ -502,17 +502,17 @@ center_trackball(const NodePath &object) { // Choose a suitable distance to view the whole volume in our frame. This // is based on the camera lens in use. Determine the lens based on the // first camera; this will be the default camera. - Lens *lens = (Lens *)NULL; + Lens *lens = nullptr; if (!_cameras.empty()) { Cameras::const_iterator ci; for (ci = _cameras.begin(); - ci != _cameras.end() && lens == (Lens *)NULL; + ci != _cameras.end() && lens == nullptr; ++ci) { lens = (*ci)->get_lens(); } } - if (lens != (Lens *)NULL) { + if (lens != nullptr) { LVecBase2 fov = lens->get_fov(); distance = radius / ctan(deg_2_rad(min(fov[0], fov[1]) / 2.0f)); @@ -544,7 +544,7 @@ bool WindowFramework:: load_models(const NodePath &parent, int argc, char *argv[], int first_arg) { pvector files; - for (int i = first_arg; i < argc && argv[i] != (char *)NULL; i++) { + for (int i = first_arg; i < argc && argv[i] != nullptr; i++) { files.push_back(Filename::from_os_specific(argv[i])); } @@ -596,17 +596,17 @@ load_model(const NodePath &parent, Filename filename) { } #endif // HAVE_ZLIB TexturePool *texture_pool = TexturePool::get_global_ptr(); - LoaderFileType *model_type = NULL; + LoaderFileType *model_type = nullptr; if (!extension.empty()) { LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); model_type = reg->get_type_from_extension(extension); - if (model_type == (LoaderFileType *)NULL) { + if (model_type == nullptr) { // The extension isn't a known model file type; is it a known image file // extension? TexturePool *texture_pool = TexturePool::get_global_ptr(); - if (texture_pool->get_texture_type(extension) != NULL) { + if (texture_pool->get_texture_type(extension) != nullptr) { // It is a known image file extension. is_image = true; } @@ -630,12 +630,12 @@ load_model(const NodePath &parent, Filename filename) { // It failed to load. Is it because the extension isn't recognised? If // so, then we just got done printing out the known scene types, and we // should also print out the supported texture types. - if (node == (PandaNode *)NULL && !is_image && model_type == NULL) { + if (node == nullptr && !is_image && model_type == nullptr) { texture_pool->write_texture_types(nout, 2); } } - if (node == (PandaNode *)NULL) { + if (node == nullptr) { nout << "Unable to load " << filename << "\n"; return NodePath::not_found(); } @@ -822,7 +822,7 @@ adjust_dimensions() { Cameras::iterator ci; for (ci = _cameras.begin(); ci != _cameras.end(); ++ci) { Lens *lens = (*ci)->get_lens(); - if (lens != (Lens *)NULL) { + if (lens != nullptr) { if (y_size != 0) { lens->set_film_size(x_size, y_size); } else { @@ -840,7 +840,7 @@ adjust_dimensions() { */ WindowFramework *WindowFramework:: split_window(SplitType split_type) { - DisplayRegion *new_region = NULL; + DisplayRegion *new_region = nullptr; if (split_type == ST_default) { // Choose either horizontal or vertical according to the largest @@ -860,7 +860,7 @@ split_window(SplitType split_type) { if (split_type == ST_vertical) { _display_region_3d->set_dimensions(left, right, bottom, (top + bottom) / 2.0f); - if (_display_region_2d != (DisplayRegion *)NULL) { + if (_display_region_2d != nullptr) { _display_region_2d->set_dimensions(left, right, bottom, (top + bottom) / 2.0f); } @@ -868,7 +868,7 @@ split_window(SplitType split_type) { } else { _display_region_3d->set_dimensions(left, (left + right) / 2.0f, bottom, top); - if (_display_region_2d != (DisplayRegion *)NULL) { + if (_display_region_2d != nullptr) { _display_region_2d->set_dimensions(left, (left + right) / 2.0f, bottom, top); } @@ -1044,7 +1044,7 @@ void WindowFramework:: set_background_type(WindowFramework::BackgroundType type) { _background_type = type; - if (_display_region_3d == (DisplayRegion *)NULL) { + if (_display_region_3d == nullptr) { return; } @@ -1101,7 +1101,7 @@ set_background_type(WindowFramework::BackgroundType type) { */ TextFont *WindowFramework:: get_shuttle_controls_font() { - if (_shuttle_controls_font == (TextFont *)NULL) { + if (_shuttle_controls_font == nullptr) { PT(TextFont) font; string shuttle_controls_string((const char *)shuttle_controls, shuttle_controls_len); @@ -1109,7 +1109,7 @@ get_shuttle_controls_font() { BamFile bam_file; if (bam_file.open_read(in, "shuttle_controls font stream")) { PT(PandaNode) node = bam_file.read_node(); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { _shuttle_controls_font = new StaticTextFont(node); } } @@ -1182,8 +1182,8 @@ setup_lights() { PT(PandaNode) WindowFramework:: load_image_as_model(const Filename &filename) { PT(Texture) tex = TexturePool::load_texture(filename); - if (tex == NULL) { - return NULL; + if (tex == nullptr) { + return nullptr; } // Yes, it is an image file; make a texture out of it. @@ -1365,7 +1365,7 @@ create_anim_controls() { } AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); if (control->get_num_frames() <= 1) { // Don't show the controls when the animation has only 0 or 1 frames. @@ -1438,7 +1438,7 @@ destroy_anim_controls() { _anim_controls_group.remove_node(); _panda_framework->get_event_handler().remove_hooks_with((void *)this); - if (_update_anim_controls_task != NULL) { + if (_update_anim_controls_task != nullptr) { _panda_framework->get_task_mgr().remove(_update_anim_controls_task); _update_anim_controls_task.clear(); } @@ -1451,9 +1451,9 @@ destroy_anim_controls() { void WindowFramework:: update_anim_controls() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); - if (_anim_slider != NULL) { + if (_anim_slider != nullptr) { if (_anim_slider->is_button_down()) { control->pose((int)(_anim_slider->get_value() + 0.5)); } else { @@ -1461,7 +1461,7 @@ update_anim_controls() { } } - if (_frame_number != NULL) { + if (_frame_number != nullptr) { _frame_number->set_text(format_string(control->get_frame())); } @@ -1494,7 +1494,7 @@ setup_shuttle_button(const string &label, int index, style.set_type(PGFrameStyle::T_bevel_out); button->set_frame_style(PGButton::S_rollover, style); - if (get_shuttle_controls_font() != (TextFont *)NULL) { + if (get_shuttle_controls_font() != nullptr) { PT(TextNode) tn = new TextNode("label"); tn->set_align(TextNode::A_center); tn->set_font(get_shuttle_controls_font()); @@ -1521,7 +1521,7 @@ setup_shuttle_button(const string &label, int index, void WindowFramework:: back_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->pose(control->get_frame() - 1); } @@ -1531,7 +1531,7 @@ back_button() { void WindowFramework:: pause_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->stop(); } @@ -1541,7 +1541,7 @@ pause_button() { void WindowFramework:: play_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->loop(false); } @@ -1551,7 +1551,7 @@ play_button() { void WindowFramework:: forward_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->pose(control->get_frame() + 1); } diff --git a/panda/src/framework/windowFramework.h b/panda/src/framework/windowFramework.h index c74310e197..c7745b0fea 100644 --- a/panda/src/framework/windowFramework.h +++ b/panda/src/framework/windowFramework.h @@ -59,7 +59,7 @@ public: protected: GraphicsOutput *open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, GraphicsPipe *pipe, - GraphicsStateGuardian *gsg = NULL, + GraphicsStateGuardian *gsg = nullptr, const FrameBufferProperties &fbprops = FrameBufferProperties::get_default()); void close_window(); diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 23efd27d9a..d70b2a4a1a 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -195,7 +195,7 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte // used, but it instead uses specially named variables. A bit of // guesswork is involved here; Cg seems to mostly use the semantics as // attribute names in GLSL, with a few exceptions. - const char *attribname = NULL; + const char *attribname = nullptr; switch (res) { case CG_POSITION0: attribname = "cg_Vertex"; @@ -519,7 +519,7 @@ issue_parameters(int altered) { Shader::ShaderPtrSpec &spec = _shader->_ptr_spec[i]; const Shader::ShaderPtrData *ptr_data =_glgsg->fetch_ptr_parameter(spec); - if (ptr_data == NULL){ //the input is not contained in ShaderPtrData + if (ptr_data == nullptr){ //the input is not contained in ShaderPtrData release_resources(); return; } @@ -736,7 +736,7 @@ update_transform_table(const TransformTable *table) { LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); int i = 0; - if (table != NULL) { + if (table != nullptr) { int num_transforms = min(_transform_table_size, (long)table->get_num_transforms()); for (; i < num_transforms; ++i) { #ifdef STDFLOAT_DOUBLE @@ -764,7 +764,7 @@ update_slider_table(const SliderTable *table) { float *sliders = (float *)alloca(_slider_table_size * 4); memset(sliders, 0, _slider_table_size * 4); - if (table != NULL) { + if (table != nullptr) { int num_sliders = min(_slider_table_size, (long)table->get_num_sliders()); for (int i = 0; i < num_sliders; ++i) { sliders[i] = table->get_slider(i)->get_slider(); @@ -1079,7 +1079,6 @@ update_shader_texture_bindings(ShaderContext *prev) { for (int i = 0; i < (int)_shader->_tex_spec.size(); ++i) { Shader::ShaderTexSpec &spec = _shader->_tex_spec[i]; - const InternalName *id = spec._name; CGparameter p = _cg_parameter_map[spec._id._seqno]; if (p == 0) { @@ -1111,7 +1110,7 @@ update_shader_texture_bindings(ShaderContext *prev) { _glgsg->set_active_texture_stage(texunit); TextureContext *tc = tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg); - if (tc == (TextureContext*)NULL) { + if (tc == nullptr) { continue; } diff --git a/panda/src/glstuff/glGeomContext_src.cxx b/panda/src/glstuff/glGeomContext_src.cxx index 11a9cf3f23..2640c1d855 100644 --- a/panda/src/glstuff/glGeomContext_src.cxx +++ b/panda/src/glstuff/glGeomContext_src.cxx @@ -41,7 +41,7 @@ get_display_list(GLuint &index, const CLP(GeomMunger) *munger, if (dl._index == 0) { dl._index = glGenLists(1); list_current = false; - if (munger != (CLP(GeomMunger) *)NULL) { + if (munger != (CLP(GeomMunger) *)nullptr) { ((CLP(GeomMunger) *)munger)->_geom_contexts.insert(this); } } @@ -70,7 +70,7 @@ release_display_lists() { ++dli) { CLP(GeomMunger) *munger = (*dli).first; const DisplayList &dl = (*dli).second; - if (munger != (CLP(GeomMunger) *)NULL) { + if (munger != (CLP(GeomMunger) *)nullptr) { munger->_geom_contexts.erase(this); } diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index eea42762ce..fae758f2c8 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -84,13 +84,13 @@ munge_format_impl(const GeomVertexFormat *orig, new_format->set_animation(animation); CLP(GraphicsStateGuardian) *glgsg; - DCAST_INTO_R(glgsg, get_gsg(), NULL); + DCAST_INTO_R(glgsg, get_gsg(), nullptr); #ifndef OPENGLES // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices and // texture coordinates. const GeomVertexColumn *vertex_type = orig->get_vertex_column(); - if (vertex_type != (GeomVertexColumn *)NULL && + if (vertex_type != nullptr && (vertex_type->get_numeric_type() == NT_int8 || vertex_type->get_numeric_type() == NT_uint8)) { int vertex_array = orig->get_array_with(InternalName::get_vertex()); @@ -127,7 +127,7 @@ munge_format_impl(const GeomVertexFormat *orig, #endif // !OPENGLES const GeomVertexColumn *color_type = orig->get_color_column(); - if (color_type != (GeomVertexColumn *)NULL && + if (color_type != nullptr && color_type->get_numeric_type() == NT_packed_dabc && !glgsg->_supports_packed_dabc) { // We need to convert the color format; OpenGL doesn't support the byte @@ -198,7 +198,7 @@ munge_format_impl(const GeomVertexFormat *orig, PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; const GeomVertexColumn *column = format->get_vertex_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -207,7 +207,7 @@ munge_format_impl(const GeomVertexFormat *orig, } column = format->get_normal_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -216,7 +216,7 @@ munge_format_impl(const GeomVertexFormat *orig, } column = format->get_color_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -239,7 +239,7 @@ munge_format_impl(const GeomVertexFormat *orig, // This is the first time we've encountered this texcoord name. const GeomVertexColumn *texcoord_type = format->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord, -1, texcoord_type->get_column_alignment()); @@ -270,13 +270,13 @@ premunge_format_impl(const GeomVertexFormat *orig) { PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig); CLP(GraphicsStateGuardian) *glgsg; - DCAST_INTO_R(glgsg, get_gsg(), NULL); + DCAST_INTO_R(glgsg, get_gsg(), nullptr); #ifndef OPENGLES // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices and // texture coordinates. const GeomVertexColumn *vertex_type = orig->get_vertex_column(); - if (vertex_type != (GeomVertexColumn *)NULL && + if (vertex_type != nullptr && (vertex_type->get_numeric_type() == NT_int8 || vertex_type->get_numeric_type() == NT_uint8)) { int vertex_array = orig->get_array_with(InternalName::get_vertex()); @@ -337,7 +337,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; const GeomVertexColumn *column = format->get_vertex_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -346,7 +346,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { } column = format->get_normal_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -355,7 +355,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { } column = format->get_color_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -379,7 +379,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { // This is the first time we've encountered this texcoord name. const GeomVertexColumn *texcoord_type = format->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord, -1, texcoord_type->get_column_alignment()); diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 35daa0b225..8d77e56086 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -32,7 +32,7 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, _resolve_multisample_pcollector(_draw_window_pcollector, "Resolve multisamples"), _requested_multisamples(0), _requested_coverage_samples(0), - _rb_context(NULL) + _rb_context(nullptr) { // A FBO doesn't have a back buffer. _draw_buffer_type = RenderBuffer::T_front; @@ -97,7 +97,7 @@ clear(Thread *current_thread) { CLP(GraphicsStateGuardian) *glgsg = (CLP(GraphicsStateGuardian) *)_gsg.p(); - if (glgsg->_glClearBufferfv == NULL) { + if (glgsg->_glClearBufferfv == nullptr) { // We can't efficiently clear the buffer. Fall back to the inefficient // default implementation for now. GraphicsOutput::clear(current_thread); @@ -267,7 +267,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { for (it = _texture_contexts.begin(); it != _texture_contexts.end(); ++it) { CLP(TextureContext) *gtc = *it; - if (gtc != NULL && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { + if (gtc != nullptr && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { glgsg->issue_memory_barrier(GL_FRAMEBUFFER_BARRIER_BIT); // If we've done it for one, we've done it for all. break; @@ -492,7 +492,7 @@ rebuild_bitplanes() { // requested. _use_depth_stencil = true; } - } else if (attach[RTP_depth_stencil] != NULL && attach[RTP_depth] == NULL) { + } else if (attach[RTP_depth_stencil] != nullptr && attach[RTP_depth] == nullptr) { // The depth stencil slot was assigned a texture, but we don't support it. // Downgrade to a regular depth texture. swap(attach[RTP_depth], attach[RTP_depth_stencil]); @@ -510,7 +510,7 @@ rebuild_bitplanes() { // depth_stencil implies depth, and we can't bind them both. Detect that // case, normalize it, and complain. if (_use_depth_stencil && attach[RTP_depth] && attach[RTP_depth_stencil]) { - attach[RTP_depth] = NULL; + attach[RTP_depth] = nullptr; GLCAT.warning() << "Attempt to bind both RTP_depth and RTP_depth_stencil bitplanes.\n"; } @@ -562,7 +562,7 @@ rebuild_bitplanes() { if (_fb_properties.is_stereo()) { // The second tex view has already been initialized, so bind it // straight away. - if (attach[RTP_color] != NULL) { + if (attach[RTP_color] != nullptr) { attach_tex(layer, 1, attach[RTP_color], next++); } else { // XXX hack: I needed a slot to use, and we don't currently use @@ -696,7 +696,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, if (tex && layer >= tex->get_z_size()) { // If the requested layer index exceeds the number of layers in the // texture, we will not bind this layer. - tex = NULL; + tex = nullptr; } if (!tex && _rb_size_z > 1) { @@ -1154,7 +1154,7 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { // Create the OpenGL texture object. TextureContext *tc = attach->prepare_now(view, glgsg->get_prepared_objects(), glgsg); - nassertv(tc != (TextureContext *)NULL); + nassertv(tc != nullptr); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); glgsg->update_texture(gtc, true); @@ -1175,7 +1175,7 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { #ifndef OPENGLES if (_rb_size_z != 1) { // Bind all of the layers of the texture. - nassertv(glgsg->_glFramebufferTexture != NULL); + nassertv(glgsg->_glFramebufferTexture != nullptr); glgsg->_glFramebufferTexture(GL_FRAMEBUFFER_EXT, attachpoint, gtc->_index, 0); return; @@ -1240,7 +1240,7 @@ generate_mipmaps() { void CLP(GraphicsBuffer):: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); // Resolve Multisample rendering if using it. if (_requested_multisamples && _fbo_multisample) { @@ -1347,7 +1347,7 @@ open_buffer() { return false; } - if (_rb_context == NULL) { + if (_rb_context == nullptr) { _rb_context = new BufferContext(&(glgsg->_renderbuffer_residency)); } @@ -1534,10 +1534,10 @@ get_host() { void CLP(GraphicsBuffer):: close_buffer() { _rb_data_size_bytes = 0; - if (_rb_context != NULL) { + if (_rb_context != nullptr) { _rb_context->update_data_size_bytes(0); delete _rb_context; - _rb_context = NULL; + _rb_context = nullptr; } check_host_valid(); @@ -1718,12 +1718,12 @@ void CLP(GraphicsBuffer):: check_host_valid() { if (_host != nullptr && !_host->is_valid()) { _rb_data_size_bytes = 0; - if (_rb_context != NULL) { + if (_rb_context != nullptr) { // We must delete this object first, because when the GSG destructs, so // will the tracker that this context is attached to. _rb_context->update_data_size_bytes(0); delete _rb_context; - _rb_context = NULL; + _rb_context = nullptr; } _is_valid = false; _gsg.clear(); @@ -1751,7 +1751,7 @@ resolve_multisamples() { for (it = _texture_contexts.begin(); it != _texture_contexts.end(); ++it) { CLP(TextureContext) *gtc = *it; - if (gtc != NULL && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { + if (gtc != nullptr && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { glgsg->issue_memory_barrier(GL_FRAMEBUFFER_BARRIER_BIT); // If we've done it for one, we've done it for all. break; @@ -1773,7 +1773,7 @@ resolve_multisamples() { bool do_depth_blit = false; if (_rbm[RTP_depth_stencil] != 0 || _rbm[RTP_depth] != 0) { if (_shared_depth_buffer) { - CLP(GraphicsBuffer) *graphics_buffer = NULL; + CLP(GraphicsBuffer) *graphics_buffer = nullptr; //CLP(GraphicsBuffer) *highest_sort_graphics_buffer = NULL; list ::iterator graphics_buffer_iterator; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index c4dd42ceb3..6c06ae0b6b 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -86,7 +86,7 @@ PStatCollector CLP(GraphicsStateGuardian)::_fbo_bind_pcollector("Draw:Bind FBO") PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check errors"); #ifndef OPENGLES_1 -PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = NULL; +PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = nullptr; #endif // The following noop functions are assigned to the corresponding glext @@ -528,7 +528,7 @@ reset() { PFNGLGETSTRINGIPROC _glGetStringi = (PFNGLGETSTRINGIPROC)get_extension_func("glGetStringi"); - if (_glGetStringi != NULL) { + if (_glGetStringi != nullptr) { GLint n = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &n); for (GLint i = 0; i < n; ++i) { @@ -611,13 +611,13 @@ reset() { if (_supports_debug) { // Set the categories we want to listen to. _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, - 0, NULL, GLCAT.is_error()); + 0, nullptr, GLCAT.is_error()); _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, - 0, NULL, GLCAT.is_warning()); + 0, nullptr, GLCAT.is_warning()); _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, - 0, NULL, GLCAT.is_info()); + 0, nullptr, GLCAT.is_info()); _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, - 0, NULL, GLCAT.is_debug()); + 0, nullptr, GLCAT.is_debug()); // Enable the callback. _glDebugMessageCallback((GLDEBUGPROC_P) &debug_callback, (void*)this); @@ -677,7 +677,7 @@ reset() { get_extension_func("glPointParameterfvARB"); } if (_supports_point_parameters) { - if (_glPointParameterfv == NULL) { + if (_glPointParameterfv == nullptr) { GLCAT.warning() << "glPointParameterfv advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_point_parameters = false; @@ -718,7 +718,7 @@ reset() { #else _explicit_primitive_restart = false; - _glPrimitiveRestartIndex = NULL; + _glPrimitiveRestartIndex = nullptr; if (gl_support_primitive_restart_index) { if ((is_at_least_gl_version(4, 3) || has_extension("GL_ARB_ES3_compatibility")) && @@ -772,7 +772,7 @@ reset() { get_extension_func("glDrawRangeElementsEXT"); } #endif - if (_glDrawRangeElements == NULL) { + if (_glDrawRangeElements == nullptr) { GLCAT.warning() << "glDrawRangeElements advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _glDrawRangeElements = null_glDrawRangeElements; @@ -801,7 +801,7 @@ reset() { _glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) get_extension_func("glTexSubImage3DEXT"); - _glCopyTexSubImage3D = NULL; + _glCopyTexSubImage3D = nullptr; if (has_extension("GL_EXT_copy_texture")) { _glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) get_extension_func("glCopyTexSubImage3DEXT"); @@ -822,7 +822,7 @@ reset() { } if (_supports_3d_texture) { - if (_glTexImage3D == NULL || _glTexSubImage3D == NULL) { + if (_glTexImage3D == nullptr || _glTexSubImage3D == nullptr) { GLCAT.warning() << "3-D textures advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_3d_texture = false; @@ -860,7 +860,7 @@ reset() { #endif if (_supports_tex_storage) { - if (_glTexStorage1D == NULL || _glTexStorage2D == NULL || _glTexStorage3D == NULL) { + if (_glTexStorage1D == nullptr || _glTexStorage2D == nullptr || _glTexStorage3D == nullptr) { GLCAT.warning() << "Immutable texture storage advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_tex_storage = false; @@ -873,7 +873,7 @@ reset() { _glClearTexImage = (PFNGLCLEARTEXIMAGEPROC) get_extension_func("glClearTexImage"); - if (_glClearTexImage == NULL) { + if (_glClearTexImage == nullptr) { GLCAT.warning() << "GL_ARB_clear_texture advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -888,7 +888,7 @@ reset() { _glClearBufferData = (PFNGLCLEARBUFFERDATAPROC) get_extension_func("glClearBufferData"); - if (_glClearBufferData == NULL) { + if (_glClearBufferData == nullptr) { GLCAT.warning() << "GL_ARB_clear_buffer_object advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -914,7 +914,7 @@ reset() { #endif } - if (_supports_2d_texture_array && _glFramebufferTextureLayer == NULL) { + if (_supports_2d_texture_array && _glFramebufferTextureLayer == nullptr) { GLCAT.warning() << "Texture arrays advertised as supported by OpenGL runtime, but could not get pointer to glFramebufferTextureLayer function.\n"; } @@ -965,14 +965,14 @@ reset() { _supports_compressed_texture = true; // Supported in the core. 1D textures are not supported by OpenGL ES. - _glCompressedTexImage1D = NULL; + _glCompressedTexImage1D = nullptr; _glCompressedTexImage2D = glCompressedTexImage2D; - _glCompressedTexSubImage1D = NULL; + _glCompressedTexSubImage1D = nullptr; _glCompressedTexSubImage2D = glCompressedTexSubImage2D; - _glGetCompressedTexImage = NULL; + _glGetCompressedTexImage = nullptr; - _glCompressedTexImage3D = NULL; - _glCompressedTexSubImage3D = NULL; + _glCompressedTexImage3D = nullptr; + _glCompressedTexSubImage3D = nullptr; #ifdef OPENGLES_2 if (_supports_3d_texture) { _glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) @@ -1024,13 +1024,13 @@ reset() { } if (_supports_compressed_texture) { - if (_glCompressedTexImage1D == NULL || - _glCompressedTexImage2D == NULL || - _glCompressedTexImage3D == NULL || - _glCompressedTexSubImage1D == NULL || - _glCompressedTexSubImage2D == NULL || - _glCompressedTexSubImage3D == NULL || - _glGetCompressedTexImage == NULL) { + if (_glCompressedTexImage1D == nullptr || + _glCompressedTexImage2D == nullptr || + _glCompressedTexImage3D == nullptr || + _glCompressedTexSubImage1D == nullptr || + _glCompressedTexSubImage2D == nullptr || + _glCompressedTexSubImage3D == nullptr || + _glGetCompressedTexImage == nullptr) { GLCAT.warning() << "Compressed textures advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_compressed_texture = false; @@ -1245,13 +1245,13 @@ reset() { } if (supports_multitexture) { - if (_glActiveTexture == NULL + if (_glActiveTexture == nullptr #ifdef SUPPORT_FIXED_FUNCTION - || (has_fixed_function_pipeline() && _glClientActiveTexture == NULL) + || (has_fixed_function_pipeline() && _glClientActiveTexture == nullptr) #endif #ifdef SUPPORT_IMMEDIATE_MODE - || GLf(_glMultiTexCoord1) == NULL || GLf(_glMultiTexCoord2) == NULL - || GLf(_glMultiTexCoord3) == NULL || GLf(_glMultiTexCoord4) == NULL + || GLf(_glMultiTexCoord1) == nullptr || GLf(_glMultiTexCoord2) == nullptr + || GLf(_glMultiTexCoord3) == nullptr || GLf(_glMultiTexCoord4) == nullptr #endif ) { GLCAT.warning() @@ -1414,9 +1414,9 @@ reset() { #endif // OPENGLES_1 if (_supports_buffers) { - if (_glGenBuffers == NULL || _glBindBuffer == NULL || - _glBufferData == NULL || _glBufferSubData == NULL || - _glDeleteBuffers == NULL) { + if (_glGenBuffers == nullptr || _glBindBuffer == nullptr || + _glBufferData == nullptr || _glBufferSubData == nullptr || + _glDeleteBuffers == nullptr) { GLCAT.warning() << "Buffers advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_buffers = false; @@ -1434,7 +1434,7 @@ reset() { get_extension_func("glMapBufferRangeEXT"); } else { - _glMapBufferRange = NULL; + _glMapBufferRange = nullptr; } #else // Check for various advanced buffer management features. @@ -1442,14 +1442,14 @@ reset() { _glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) get_extension_func("glMapBufferRange"); } else { - _glMapBufferRange = NULL; + _glMapBufferRange = nullptr; } if (is_at_least_gl_version(4, 4) || has_extension("GL_ARB_buffer_storage")) { _glBufferStorage = (PFNGLBUFFERSTORAGEPROC) get_extension_func("glBufferStorage"); - if (_glBufferStorage != NULL) { + if (_glBufferStorage != nullptr) { _supports_buffer_storage = true; } else { GLCAT.warning() @@ -1491,8 +1491,8 @@ reset() { } if (_supports_vao) { - if (_glBindVertexArray == NULL || _glDeleteVertexArrays == NULL || - _glGenVertexArrays == NULL) { + if (_glBindVertexArray == nullptr || _glDeleteVertexArrays == nullptr || + _glGenVertexArrays == nullptr) { GLCAT.warning() << "Vertex array objects advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_vao = false; @@ -1526,13 +1526,13 @@ reset() { } else if (has_extension("GL_EXT_geometry_shader4")) { _supports_geometry_shaders = true; - _glFramebufferTexture = NULL; + _glFramebufferTexture = nullptr; _glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) get_extension_func("glProgramParameteriEXT"); } else { _supports_geometry_shaders = false; - _glFramebufferTexture = NULL; + _glFramebufferTexture = nullptr; } #endif _shader_caps._supports_glsl = _supports_glsl; @@ -1620,7 +1620,7 @@ reset() { _glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC) get_extension_func("glDispatchCompute"); - if (_glDispatchCompute != NULL) { + if (_glDispatchCompute != nullptr) { _supports_compute_shaders = true; } } @@ -1707,14 +1707,14 @@ reset() { _glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) get_extension_func("glVertexAttribIPointer"); } else { - _glVertexAttribIPointer = NULL; + _glVertexAttribIPointer = nullptr; } if (is_at_least_gl_version(4, 1) || has_extension("GL_ARB_vertex_attrib_64bit")) { _glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC) get_extension_func("glVertexAttribLPointer"); } else { - _glVertexAttribLPointer = NULL; + _glVertexAttribLPointer = nullptr; } if (_supports_tessellation_shaders) { @@ -1735,8 +1735,8 @@ reset() { _glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) get_extension_func("glVertexAttribPointerARB"); - _glVertexAttribIPointer = NULL; - _glVertexAttribLPointer = NULL; + _glVertexAttribIPointer = nullptr; + _glVertexAttribLPointer = nullptr; } #endif @@ -1774,13 +1774,13 @@ reset() { _glVertexAttrib4fv = glVertexAttrib4fv; _glVertexAttrib4dv = null_glVertexAttrib4dv; _glVertexAttribPointer = glVertexAttribPointer; - _glVertexAttribLPointer = NULL; + _glVertexAttribLPointer = nullptr; if (is_at_least_gles_version(3, 0)) { _glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) get_extension_func("glVertexAttribIPointer"); } else { - _glVertexAttribIPointer = NULL; + _glVertexAttribIPointer = nullptr; } #endif @@ -1817,7 +1817,7 @@ reset() { // to have a shader applied, or if it failed to compile. This default // shader just outputs a red color, indicating that something went wrong. #ifndef OPENGLES_1 - if (_default_shader == NULL && !has_fixed_function_pipeline()) { + if (_default_shader == nullptr && !has_fixed_function_pipeline()) { _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); } #endif @@ -1985,7 +1985,7 @@ reset() { #ifndef OPENGLES_1 if (_supports_geometry_instancing) { - if (_glDrawArraysInstanced == NULL || _glDrawElementsInstanced == NULL) { + if (_glDrawArraysInstanced == nullptr || _glDrawElementsInstanced == nullptr) { GLCAT.warning() << "Geometry instancing advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_geometry_instancing = false; @@ -1993,7 +1993,7 @@ reset() { } if (_supports_vertex_attrib_divisor) { - if (_glVertexAttribDivisor == NULL) { + if (_glVertexAttribDivisor == nullptr) { GLCAT.warning() << "Instanced vertex arrays advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_vertex_attrib_divisor = false; @@ -2014,7 +2014,7 @@ reset() { _glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC) get_extension_func("glDrawElementsIndirect"); - if (_glDrawArraysIndirect == NULL || _glDrawElementsIndirect == NULL) { + if (_glDrawArraysIndirect == nullptr || _glDrawElementsIndirect == nullptr) { GLCAT.warning() << "Indirect draw advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; } else { @@ -2051,7 +2051,7 @@ reset() { get_extension_func("glGenFramebuffersOES"); _glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) get_extension_func("glCheckFramebufferStatusOES"); - _glFramebufferTexture1D = NULL; + _glFramebufferTexture1D = nullptr; _glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC) get_extension_func("glFramebufferTexture2DOES"); _glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) @@ -2062,7 +2062,7 @@ reset() { get_extension_func("glGenerateMipmapOES"); } else { _supports_framebuffer_object = false; - _glGenerateMipmap = NULL; + _glGenerateMipmap = nullptr; } #elif defined(OPENGLES) // In OpenGL ES 2.x, FBO's are supported in the core. @@ -2078,7 +2078,7 @@ reset() { _glDeleteFramebuffers = glDeleteFramebuffers; _glGenFramebuffers = glGenFramebuffers; _glCheckFramebufferStatus = glCheckFramebufferStatus; - _glFramebufferTexture1D = NULL; + _glFramebufferTexture1D = nullptr; _glFramebufferTexture2D = glFramebufferTexture2D; _glFramebufferRenderbuffer = glFramebufferRenderbuffer; _glGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv; @@ -2209,7 +2209,7 @@ reset() { _supports_framebuffer_object = false; _supports_framebuffer_multisample = false; _supports_framebuffer_blit = false; - _glGenerateMipmap = NULL; + _glGenerateMipmap = nullptr; } #endif @@ -2218,7 +2218,7 @@ reset() { _glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) get_extension_func("glGenerateTextureMipmap"); } else { - _glGenerateTextureMipmap = NULL; + _glGenerateTextureMipmap = nullptr; } #endif @@ -2248,7 +2248,7 @@ reset() { #endif #if defined(OPENGLES_1) - _glDrawBuffers = NULL; + _glDrawBuffers = nullptr; _max_color_targets = 1; #elif defined(OPENGLES_2) @@ -2265,7 +2265,7 @@ reset() { get_extension_func("glDrawBuffersNV"); } else { - _glDrawBuffers = NULL; + _glDrawBuffers = nullptr; } #else @@ -2278,13 +2278,13 @@ reset() { get_extension_func("glDrawBuffersARB"); } else { - _glDrawBuffers = NULL; + _glDrawBuffers = nullptr; } #endif #ifndef OPENGLES_1 _max_color_targets = 1; - if (_glDrawBuffers != NULL) { + if (_glDrawBuffers != nullptr) { GLint max_draw_buffers = 0; glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers); _max_color_targets = max_draw_buffers; @@ -2301,9 +2301,9 @@ reset() { get_extension_func("glClearBufferfi"); } else { - _glClearBufferfv = NULL; - _glClearBufferiv = NULL; - _glClearBufferfi = NULL; + _glClearBufferfv = nullptr; + _glClearBufferiv = nullptr; + _glClearBufferfi = nullptr; } #endif // !OPENGLES @@ -2318,7 +2318,7 @@ reset() { _glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC) get_extension_func("glDepthRangeArrayv"); - if (_glViewportArrayv == NULL || _glScissorArrayv == NULL || _glDepthRangeArrayv == NULL) { + if (_glViewportArrayv == nullptr || _glScissorArrayv == nullptr || _glDepthRangeArrayv == nullptr) { GLCAT.warning() << "Viewport arrays advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; } else { @@ -2371,9 +2371,9 @@ reset() { } if (_supports_occlusion_query) { - if (_glGenQueries == NULL || _glBeginQuery == NULL || - _glEndQuery == NULL || _glDeleteQueries == NULL || - _glGetQueryiv == NULL || _glGetQueryObjectuiv == NULL) { + if (_glGenQueries == nullptr || _glBeginQuery == nullptr || + _glEndQuery == nullptr || _glDeleteQueries == nullptr || + _glGetQueryiv == nullptr || _glGetQueryObjectuiv == nullptr) { GLCAT.warning() << "Occlusion queries advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_occlusion_query = false; @@ -2414,7 +2414,7 @@ reset() { _glBlendEquation = (PFNGLBLENDEQUATIONPROC) get_extension_func("glBlendEquationOES"); - if (_glBlendEquation == NULL) { + if (_glBlendEquation == nullptr) { _glBlendEquation = null_glBlendEquation; GLCAT.warning() << "BlendEquationOES advertised as supported by OpenGL ES runtime, but " @@ -2428,7 +2428,7 @@ reset() { _glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEOESPROC) get_extension_func("glBlendEquationSeparateOES"); - if (_glBlendEquation == NULL) { + if (_glBlendEquation == nullptr) { _supports_blend_equation_separate = false; GLCAT.warning() << "BlendEquationSeparateOES advertised as supported by OpenGL ES " @@ -2438,14 +2438,14 @@ reset() { } } else { _supports_blend_equation_separate = false; - _glBlendEquationSeparate = NULL; + _glBlendEquationSeparate = nullptr; } if (has_extension("GL_OES_blend_func_separate")) { _glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEOESPROC) get_extension_func("glBlendFuncSeparateOES"); - if (_glBlendFuncSeparate == NULL) { + if (_glBlendFuncSeparate == nullptr) { _glBlendFuncSeparate = null_glBlendFuncSeparate; GLCAT.warning() << "BlendFuncSeparateOES advertised as supported by OpenGL ES runtime, but " @@ -2472,7 +2472,7 @@ reset() { _glBlendEquation = null_glBlendEquation; } - if (_glBlendEquation == NULL) { + if (_glBlendEquation == nullptr) { _glBlendEquation = null_glBlendEquation; GLCAT.warning() << "BlendEquation advertised as supported by OpenGL runtime, but could " @@ -2491,10 +2491,10 @@ reset() { } else { _supports_blend_equation_separate = false; - _glBlendEquationSeparate = NULL; + _glBlendEquationSeparate = nullptr; } - if (_supports_blend_equation_separate && _glBlendEquationSeparate == NULL) { + if (_supports_blend_equation_separate && _glBlendEquationSeparate == nullptr) { _supports_blend_equation_separate = false; GLCAT.warning() << "BlendEquationSeparate advertised as supported by OpenGL runtime, " @@ -2513,7 +2513,7 @@ reset() { _glBlendFuncSeparate = null_glBlendFuncSeparate; } - if (_glBlendFuncSeparate == NULL) { + if (_glBlendFuncSeparate == nullptr) { _glBlendFuncSeparate = null_glBlendFuncSeparate; GLCAT.warning() << "BlendFuncSeparate advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; @@ -2522,7 +2522,7 @@ reset() { // In OpenGL ES 2.x, this is supported in the core. In 1.x, not at all. #ifndef OPENGLES - _glBlendColor = NULL; + _glBlendColor = nullptr; bool supports_blend_color = false; if (is_at_least_gl_version(1, 2)) { supports_blend_color = true; @@ -2533,11 +2533,11 @@ reset() { _glBlendColor = (PFNGLBLENDCOLORPROC) get_extension_func("glBlendColorEXT"); } - if (supports_blend_color && _glBlendColor == NULL) { + if (supports_blend_color && _glBlendColor == nullptr) { GLCAT.warning() << "BlendColor advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } - if (_glBlendColor == NULL) { + if (_glBlendColor == nullptr) { _glBlendColor = null_glBlendColor; } #endif @@ -2643,7 +2643,6 @@ reset() { GLint max_3d_texture_size = 0; GLint max_2d_texture_array_layers = 0; GLint max_cube_map_size = 0; - GLint max_buffer_texture_size = 0; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); _max_texture_dimension = max_texture_size; @@ -2671,6 +2670,7 @@ reset() { #ifndef OPENGLES if (_supports_buffer_texture) { + GLint max_buffer_texture_size = 0; glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max_buffer_texture_size); _max_buffer_texture_size = max_buffer_texture_size; } else { @@ -2678,8 +2678,8 @@ reset() { } #endif // !OPENGLES - GLint max_elements_vertices = 0, max_elements_indices = 0; #ifndef OPENGLES + GLint max_elements_vertices = 0, max_elements_indices = 0; if (is_at_least_gl_version(1, 2) || has_extension("GL_EXT_draw_range_elements")) { glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &max_elements_vertices); glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &max_elements_indices); @@ -2742,7 +2742,7 @@ reset() { glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats); for (int i = 0; i < num_compressed_formats; ++i) { const char *format_str = get_compressed_format_string(formats[i]); - if (format_str != NULL) { + if (format_str != nullptr) { GLCAT.debug(false) << " " << format_str << '\n'; } else { GLCAT.debug(false) @@ -2794,8 +2794,8 @@ reset() { #endif } else { - _glBindImageTexture = NULL; - _glMemoryBarrier = NULL; + _glBindImageTexture = nullptr; + _glMemoryBarrier = nullptr; } #endif // !OPENGLES_1 @@ -2816,10 +2816,10 @@ reset() { _glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) get_extension_func("glSamplerParameterf"); _glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) get_extension_func("glSamplerParameterfv"); - if (_glGenSamplers == NULL || _glDeleteSamplers == NULL || - _glBindSampler == NULL || _glSamplerParameteri == NULL || - _glSamplerParameteriv == NULL || _glSamplerParameterf == NULL || - _glSamplerParameterfv == NULL) { + if (_glGenSamplers == nullptr || _glDeleteSamplers == nullptr || + _glBindSampler == nullptr || _glSamplerParameteri == nullptr || + _glSamplerParameteriv == nullptr || _glSamplerParameterf == nullptr || + _glSamplerParameterfv == nullptr) { GLCAT.warning() << "GL_ARB_sampler_objects advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -2847,7 +2847,7 @@ reset() { get_extension_func("glBindVertexBuffers"); } - if (_glBindTextures != NULL && _glBindImageTextures != NULL) { + if (_glBindTextures != nullptr && _glBindImageTextures != nullptr) { _supports_multi_bind = true; } else { GLCAT.warning() @@ -2865,7 +2865,7 @@ reset() { _glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC) get_extension_func("glGetInternalformativ"); - if (_glGetInternalformativ == NULL) { + if (_glGetInternalformativ == nullptr) { GLCAT.warning() << "ARB_internalformat_query2 advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } @@ -2884,8 +2884,8 @@ reset() { _glUniformHandleui64 = (PFNGLUNIFORMHANDLEUI64PROC) get_extension_func("glUniformHandleui64ARB"); - if (_glGetTextureHandle == NULL || _glMakeTextureHandleResident == NULL || - _glUniformHandleui64 == NULL) { + if (_glGetTextureHandle == nullptr || _glMakeTextureHandleResident == nullptr || + _glUniformHandleui64 == nullptr) { GLCAT.warning() << "GL_ARB_bindless_texture advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -2911,9 +2911,9 @@ reset() { get_extension_func("glProgramParameteri"); GLint num_binary_formats = 0; - if (_glGetProgramBinary != NULL && - _glProgramBinary != NULL && - _glProgramParameteri != NULL) { + if (_glGetProgramBinary != nullptr && + _glProgramBinary != nullptr && + _glProgramParameteri != nullptr) { glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num_binary_formats); } @@ -3015,12 +3015,12 @@ reset() { _dithering_enabled = false; #ifndef OPENGLES_1 - _current_shader = (Shader *)NULL; - _current_shader_context = (ShaderContext *)NULL; - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (ShaderContext *)NULL; - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (ShaderContext *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; #endif // Count the max number of lights @@ -3302,7 +3302,7 @@ clear(DrawableRegion *clearable) { int mask = 0; #ifndef OPENGLES_1 - if (_current_fbo != 0 && _glClearBufferfv != NULL) { + if (_current_fbo != 0 && _glClearBufferfv != nullptr) { // We can use glClearBuffer to clear all the color attachments, which // protects us from the overhead of having to call set_draw_buffer for // every single attachment. @@ -3457,7 +3457,7 @@ clear(DrawableRegion *clearable) { */ void CLP(GraphicsStateGuardian):: prepare_display_region(DisplayRegionPipelineReader *dr) { - nassertv(dr != (DisplayRegionPipelineReader *)NULL); + nassertv(dr != nullptr); GraphicsStateGuardian::prepare_display_region(dr); int l, b, w, h; @@ -3580,8 +3580,8 @@ clear_before_callback() { #ifndef OPENGLES_1 if (_vertex_array_shader_context != 0) { _vertex_array_shader_context->disable_shader_vertex_arrays(); - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (ShaderContext *)NULL; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; } #endif unbind_buffers(); @@ -3617,12 +3617,12 @@ clear_before_callback() { */ CPT(TransformState) CLP(GraphicsStateGuardian):: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } // The projection matrix must always be right-handed Y-up, even if our @@ -3815,18 +3815,18 @@ end_frame(Thread *current_thread) { // This breaks shaders across multiple regions. if (_vertex_array_shader_context != 0) { _vertex_array_shader_context->disable_shader_vertex_arrays(); - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (ShaderContext *)NULL; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; } if (_texture_binding_shader_context != 0) { _texture_binding_shader_context->disable_shader_texture_bindings(); - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (ShaderContext *)NULL; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; } if (_current_shader_context != 0) { _current_shader_context->unbind(); - _current_shader = (Shader *)NULL; - _current_shader_context = (ShaderContext *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; } #endif @@ -3964,7 +3964,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!has_fixed_function_pipeline()) { // We can't draw without a shader bound in OpenGL ES 2. This shouldn't // happen anyway unless the default shader failed to compile somehow. - if (_current_shader_context == NULL) { + if (_current_shader_context == nullptr) { return false; } } @@ -3973,7 +3973,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, force)) { return false; } - nassertr(_data_reader != (GeomVertexDataPipelineReader *)NULL, false); + nassertr(_data_reader != nullptr, false); _geom_display_list = 0; @@ -4033,7 +4033,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, unbind_buffers(); GeomContext *gc = geom_reader->prepare_now(get_prepared_objects(), this); - nassertr(gc != (GeomContext *)NULL, false); + nassertr(gc != nullptr, false); CLP(GeomContext) *ggc = DCAST(CLP(GeomContext), gc); //const CLP(GeomMunger) *gmunger = DCAST(CLP(GeomMunger), _munger); @@ -4176,7 +4176,7 @@ update_standard_vertex_arrays(bool force) { _sender.clear(); _sender.add_column(_data_reader, InternalName::get_normal(), - NULL, NULL, GLPf(Normal3), NULL); + nullptr, nullptr, GLPf(Normal3), nullptr); #ifndef NDEBUG if (_show_texture_usage) { // In show_texture_usage mode, all colors are white, so as not to @@ -4185,7 +4185,7 @@ update_standard_vertex_arrays(bool force) { } else #endif // NDEBUG if (!_sender.add_column(_data_reader, InternalName::get_color(), - NULL, NULL, GLPf(Color3), GLPf(Color4))) { + nullptr, nullptr, GLPf(Color3), GLPf(Color4))) { // If we didn't have a color column, the item color is white. GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } @@ -4229,7 +4229,7 @@ update_standard_vertex_arrays(bool force) { // We must add vertex last, because glVertex3f() is the key function call // that actually issues the vertex. _sender.add_column(_data_reader, InternalName::get_vertex(), - NULL, GLPf(Vertex2), GLPf(Vertex3), GLPf(Vertex4)); + nullptr, GLPf(Vertex2), GLPf(Vertex3), GLPf(Vertex4)); } else #endif // SUPPORT_IMMEDIATE_MODE @@ -4365,7 +4365,7 @@ unbind_buffers() { #ifndef OPENGLES if (_current_vertex_buffers.size() > 1 && _supports_multi_bind) { - _glBindVertexBuffers(0, _current_vertex_buffers.size(), NULL, NULL, NULL); + _glBindVertexBuffers(0, _current_vertex_buffers.size(), nullptr, nullptr, nullptr); } else { for (int i = 0; i < _current_vertex_buffers.size(); ++i) { if (_current_vertex_buffers[i] != 0) { @@ -4443,7 +4443,7 @@ update_shader_vertex_format(const GeomVertexFormat *format) { continue; } - if (_vertex_attrib_columns[loc] != NULL && + if (_vertex_attrib_columns[loc] != nullptr && _vertex_attrib_columns[loc]->compare_to(*column) == 0) { continue; } @@ -5480,7 +5480,7 @@ end_draw_primitives() { */ void CLP(GraphicsStateGuardian):: issue_memory_barrier(GLbitfield barriers) { - if (!gl_enable_memory_barriers || _glMemoryBarrier == NULL) { + if (!gl_enable_memory_barriers || _glMemoryBarrier == nullptr) { return; } @@ -5542,7 +5542,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_3d_texture) { GLCAT.warning() << "3-D textures are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5550,7 +5550,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_2d_texture_array) { GLCAT.warning() << "2-D texture arrays are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5558,7 +5558,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_cube_map) { GLCAT.warning() << "Cube map textures are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5566,7 +5566,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_buffer_texture) { GLCAT.warning() << "Buffer textures are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5574,7 +5574,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_cube_map_array) { GLCAT.warning() << "Cube map arrays are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5693,7 +5693,7 @@ extract_texture_data(Texture *tex) { int num_views = tex->get_num_views(); for (int view = 0; view < num_views; ++view) { TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); if (!do_extract_texture_data(gtc)) { @@ -5717,7 +5717,7 @@ extract_texture_data(Texture *tex) { */ SamplerContext *CLP(GraphicsStateGuardian):: prepare_sampler(const SamplerState &sampler) { - nassertr(_supports_sampler_objects, NULL); + nassertr(_supports_sampler_objects, nullptr); PStatGPUTimer timer(this, _prepare_sampler_pcollector); CLP(SamplerContext) *gsc = new CLP(SamplerContext)(this, sampler); @@ -5852,7 +5852,7 @@ prepare_shader(Shader *se) { PStatGPUTimer timer(this, _prepare_shader_pcollector); #ifndef OPENGLES_1 - ShaderContext *result = NULL; + ShaderContext *result = nullptr; switch (se->get_language()) { case Shader::SL_GLSL: @@ -5862,7 +5862,7 @@ prepare_shader(Shader *se) { } else { GLCAT.error() << "Tried to load GLSL shader, but GLSL shaders not supported.\n"; - return NULL; + return nullptr; } case Shader::SL_Cg: @@ -5873,22 +5873,22 @@ prepare_shader(Shader *se) { } else { GLCAT.error() << "Tried to load Cg shader, but basic shaders not supported.\n"; - return NULL; + return nullptr; } #elif defined(OPENGLES) GLCAT.error() << "Tried to load Cg shader, but Cg support is not available for OpenGL ES.\n"; - return NULL; + return nullptr; #else GLCAT.error() << "Tried to load Cg shader, but Cg support not compiled in.\n"; - return NULL; + return nullptr; #endif default: GLCAT.error() << "Tried to load shader with unsupported shader language!\n"; - return NULL; + return nullptr; } if (result->valid()) { @@ -5898,7 +5898,7 @@ prepare_shader(Shader *se) { delete result; #endif // OPENGLES_1 - return NULL; + return nullptr; } /** @@ -5961,7 +5961,7 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { return gvbc; } - return NULL; + return nullptr; } /** @@ -5988,7 +5988,7 @@ update_vertex_buffer(CLP(VertexBufferContext) *gvbc, } if (num_bytes != 0) { const unsigned char *client_pointer = reader->get_read_pointer(force); - if (client_pointer == NULL) { + if (client_pointer == nullptr) { return false; } @@ -6077,7 +6077,7 @@ setup_array_data(const unsigned char *&client_pointer, if (!_supports_buffers) { // No support for buffer objects; always render from client. client_pointer = array_reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } if (!vertex_buffers || _geom_display_list != 0 || array_reader->get_usage_hint() < gl_min_buffer_usage_hint) { @@ -6092,14 +6092,14 @@ setup_array_data(const unsigned char *&client_pointer, _current_vbuffer_index = 0; } client_pointer = array_reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } // Prepare the buffer object and bind it. CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), array_reader->prepare_now(get_prepared_objects(), this)); - nassertr(gvbc != (CLP(VertexBufferContext) *)NULL, false); + nassertr(gvbc != (CLP(VertexBufferContext) *)nullptr, false); if (!update_vertex_buffer(gvbc, array_reader, force)) { return false; } @@ -6114,7 +6114,7 @@ setup_array_data(const unsigned char *&client_pointer, } // NULL is the OpenGL convention for the first byte of the buffer object. - client_pointer = NULL; + client_pointer = nullptr; return true; } @@ -6149,7 +6149,7 @@ prepare_index_buffer(GeomPrimitive *data) { return gibc; } - return NULL; + return nullptr; } /** @@ -6186,7 +6186,7 @@ apply_index_buffer(IndexBufferContext *ibc, } if (num_bytes != 0) { const unsigned char *client_pointer = reader->get_read_pointer(force); - if (client_pointer == NULL) { + if (client_pointer == nullptr) { return false; } @@ -6266,7 +6266,7 @@ setup_primitive(const unsigned char *&client_pointer, if (!_supports_buffers) { // No support for buffer objects; always render from client. client_pointer = reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } if (!vertex_buffers || _geom_display_list != 0 || reader->get_usage_hint() == Geom::UH_client) { @@ -6281,18 +6281,18 @@ setup_primitive(const unsigned char *&client_pointer, _current_ibuffer_index = 0; } client_pointer = reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } // Prepare the buffer object and bind it. IndexBufferContext *ibc = reader->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } // NULL is the OpenGL convention for the first byte of the buffer object. - client_pointer = NULL; + client_pointer = nullptr; return true; } @@ -6339,7 +6339,7 @@ prepare_shader_buffer(ShaderBuffer *data) { return gbc; } - return NULL; + return nullptr; } /** @@ -6348,9 +6348,9 @@ prepare_shader_buffer(ShaderBuffer *data) { void CLP(GraphicsStateGuardian):: apply_shader_buffer(GLuint base, ShaderBuffer *buffer) { GLuint index = 0; - if (buffer != NULL) { + if (buffer != nullptr) { BufferContext *bc = buffer->prepare_now(get_prepared_objects(), this); - if (bc != NULL) { + if (bc != nullptr) { CLP(BufferContext) *gbc = DCAST(CLP(BufferContext), bc); index = gbc->_index; gbc->set_active(true); @@ -6427,7 +6427,7 @@ release_shader_buffer(BufferContext *bc) { void CLP(GraphicsStateGuardian):: begin_occlusion_query() { nassertv(_supports_occlusion_query); - nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL); + nassertv(_current_occlusion_query == nullptr); PT(CLP(OcclusionQueryContext)) query = new CLP(OcclusionQueryContext)(this); _glGenQueries(1, &query->_index); @@ -6453,7 +6453,7 @@ begin_occlusion_query() { */ PT(OcclusionQueryContext) CLP(GraphicsStateGuardian):: end_occlusion_query() { - nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL); + nassertr(_current_occlusion_query != nullptr, nullptr); PT(OcclusionQueryContext) result = _current_occlusion_query; GLuint index = DCAST(CLP(OcclusionQueryContext), result)->_index; @@ -6463,7 +6463,7 @@ end_occlusion_query() { << "ending occlusion query index " << (int)index << "\n"; } - _current_occlusion_query = NULL; + _current_occlusion_query = nullptr; _glEndQuery(GL_SAMPLES_PASSED); // Temporary hack to try working around an apparent driver bug on iMacs. @@ -6493,7 +6493,7 @@ end_occlusion_query() { PT(TimerQueryContext) CLP(GraphicsStateGuardian):: issue_timer_query(int pstats_index) { #if defined(DO_PSTATS) && !defined(OPENGLES) - nassertr(_supports_timer_query, NULL); + nassertr(_supports_timer_query, nullptr); PT(CLP(TimerQueryContext)) query; @@ -6531,7 +6531,7 @@ issue_timer_query(int pstats_index) { return (TimerQueryContext *)query; #else - return NULL; + return nullptr; #endif } @@ -6546,7 +6546,7 @@ dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { PStatGPUTimer timer(this, _compute_dispatch_pcollector); nassertv(_supports_compute_shaders); - nassertv(_current_shader_context != NULL); + nassertv(_current_shader_context != nullptr); _glDispatchCompute(num_groups_x, num_groups_y, num_groups_z); maybe_gl_finish(); @@ -6572,7 +6572,7 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { bool CLP(GraphicsStateGuardian):: framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); set_read_buffer(rb._buffer_type); clear_color_write_mask(); @@ -6659,7 +6659,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); apply_texture(gtc); @@ -6675,7 +6675,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, if (uses_mipmaps) { if (_supports_generate_mipmap) { #ifndef OPENGLES_2 - if (_glGenerateMipmap == NULL) { + if (_glGenerateMipmap == nullptr) { glTexParameteri(target, GL_GENERATE_MIPMAP, true); } #endif @@ -6735,7 +6735,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, // to specify them. Might as well use the actual values. GLint external_format = get_external_image_format(tex); GLint component_type = get_component_type(tex->get_component_type()); - _glTexImage3D(target, 0, internal_format, width, height, depth, 0, external_format, component_type, NULL); + _glTexImage3D(target, 0, internal_format, width, height, depth, 0, external_format, component_type, nullptr); } _glCopyTexSubImage3D(target, 0, 0, 0, z, xo, yo, w, h); @@ -6752,7 +6752,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } } - if (uses_mipmaps && _glGenerateMipmap != NULL) { + if (uses_mipmaps && _glGenerateMipmap != nullptr) { glEnable(target); _glGenerateMipmap(target); glDisable(target); @@ -6787,7 +6787,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, bool CLP(GraphicsStateGuardian):: framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); set_read_buffer(rb._buffer_type); glPixelStorei(GL_PACK_ALIGNMENT, 1); clear_color_write_mask(); @@ -7059,7 +7059,7 @@ do_issue_shader() { // If we don't have a shader, apply the default shader. if (!has_fixed_function_pipeline() && !shader) { shader = _default_shader; - nassertv(shader != NULL); + nassertv(shader != nullptr); } if (shader) { @@ -7074,7 +7074,7 @@ do_issue_shader() { if (_default_shader != nullptr && shader != _default_shader && (context == 0 || !context->valid())) { shader = _default_shader; - nassertv(shader != NULL); + nassertv(shader != nullptr); if (_current_shader != shader) { context = shader->prepare_now(get_prepared_objects(), this); } else { @@ -7092,7 +7092,7 @@ do_issue_shader() { if (context != _current_shader_context) { // Use a completely different shader than before. Unbind old shader, // bind the new one. - if (_current_shader_context != NULL && + if (_current_shader_context != nullptr && _current_shader->get_language() != shader->get_language()) { // If it's a different type of shader, make sure to unbind the old. _current_shader_context->unbind(); @@ -7403,7 +7403,7 @@ do_issue_fog() { if (!target_fog->is_off()) { enable_fog(true); Fog *fog = target_fog->get_fog(); - nassertv(fog != (Fog *)NULL); + nassertv(fog != nullptr); apply_fog(fog); } else { enable_fog(false); @@ -7461,7 +7461,7 @@ do_issue_material() { const MaterialAttrib *target_material; _target_rs->get_attrib_def(target_material); - if (target_material == (MaterialAttrib *)NULL || + if (target_material == nullptr || target_material->is_off()) { material = ∅ } else { @@ -7604,7 +7604,6 @@ do_issue_blending() { #endif if (color_channels == ColorWriteAttrib::C_off) { - int color_write_slot = ColorWriteAttrib::get_class_slot(); enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); if (gl_color_mask) { @@ -7891,7 +7890,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { // _draw_set_state_light_bind_spotlight_pcollector); Lens *lens = light_obj->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); GLenum id = get_light_id(light_id); static const LColor black(0.0f, 0.0f, 0.0f, 1.0f); @@ -8117,7 +8116,7 @@ show_gl_string(const string &name, GLenum id) { const GLubyte *text = glGetString(id); - if (text == (const GLubyte *)NULL) { + if (text == nullptr) { GLCAT.warning() << "Unable to query " << name << "\n"; @@ -8282,7 +8281,7 @@ query_glsl_version() { */ void CLP(GraphicsStateGuardian):: save_extensions(const char *extensions) { - if (extensions != (const char *)NULL) { + if (extensions != nullptr) { vector_string tokens; extract_words(extensions, tokens); @@ -8311,7 +8310,6 @@ report_extensions() const { ostream &out = GLCAT.debug(); out << "GL Extensions:\n"; - size_t maxlen = 0; pset::const_iterator ei; for (ei = _extensions.begin(); ei != _extensions.end(); ++ei) { size_t len = (*ei).size(); @@ -8399,11 +8397,11 @@ get_extension_func(const char *name) { { "glDeleteBuffers", (void *)&glDeleteBuffers }, { "glGenBuffers", (void *)&glGenBuffers }, #endif - { NULL, NULL } + { nullptr, nullptr } }; int i = 0; - while (compiled_function_table[i].name != NULL) { + while (compiled_function_table[i].name != nullptr) { if (strcmp(compiled_function_table[i].name, name) == 0) { return compiled_function_table[i].fptr; } @@ -8423,7 +8421,7 @@ get_extension_func(const char *name) { */ void *CLP(GraphicsStateGuardian):: do_get_extension_func(const char *) { - return NULL; + return nullptr; } /** @@ -10448,7 +10446,7 @@ get_compressed_format_string(GLenum format) { case 0x93F0: return "GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG"; case 0x93F1: return "GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG"; default: - return NULL; + return nullptr; } } #endif @@ -10762,13 +10760,13 @@ set_state_and_transform(const RenderState *target, _state_shader = _target_shader; _state_mask.clear_bit(TextureAttrib::get_class_slot()); } - else if (!has_fixed_function_pipeline() && _current_shader == NULL) { // In the case of OpenGL ES 2.x, we need to glUseShader before we draw anything. + else if (!has_fixed_function_pipeline() && _current_shader == nullptr) { // In the case of OpenGL ES 2.x, we need to glUseShader before we draw anything. do_issue_shader(); _state_mask.clear_bit(TextureAttrib::get_class_slot()); } // Update all of the state that is bound to the shader program. - if (_current_shader_context != NULL) { + if (_current_shader_context != nullptr) { _current_shader_context->set_state_and_transform(target, transform, _scene_setup->get_camera_transform(), _projection_mat); } #endif @@ -10915,7 +10913,6 @@ set_state_and_transform(const RenderState *target, !_state_mask.get_bit(texture_slot)) { // PStatGPUTimer timer(this, _draw_set_state_texture_pcollector); determine_target_texture(); - int prev_active = _num_active_texture_stages; do_issue_texture(); // Since the TexGen and TexMatrix states depend partly on the particular @@ -11058,7 +11055,7 @@ do_issue_texture() { disable_standard_texture_bindings(); } #endif - _current_shader_context->update_shader_texture_bindings(NULL); + _current_shader_context->update_shader_texture_bindings(nullptr); } else { _current_shader_context-> update_shader_texture_bindings(_texture_binding_shader_context); @@ -11091,7 +11088,7 @@ update_standard_texture_bindings() { // see if our flash_texture is in the texture stack here. If so, then we // need to call the special show_texture method instead of the normal // texture stack. - if (_flash_texture != (Texture *)NULL) { + if (_flash_texture != nullptr) { double now = ClockObject::get_global_clock()->get_frame_time(); int this_second = (int)floor(now); if (this_second & 1) { @@ -11123,7 +11120,7 @@ update_standard_texture_bindings() { for (i = 0; i < num_stages; i++) { TextureStage *stage = _target_texture->get_on_ff_stage(i); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); // Issue the texture on stage i. set_active_texture_stage(i); @@ -11143,7 +11140,7 @@ update_standard_texture_bindings() { int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // Something wrong with this texture; skip it. continue; } @@ -11378,11 +11375,11 @@ update_show_usage_texture_bindings(int show_stage_index) { for (i = 0; i < num_stages; i++) { TextureStage *stage = _target_texture->get_on_ff_stage(i); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // Something wrong with this texture; skip it. break; } @@ -11423,7 +11420,7 @@ update_show_usage_texture_bindings(int show_stage_index) { TextureStage *stage = _target_texture->get_on_ff_stage(i); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); // Choose the corresponding usage texture and apply it. set_active_texture_stage(i); @@ -12043,7 +12040,7 @@ apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc // We support sampler objects. Prepare the sampler object and bind it to // the indicated texture unit. SamplerContext *sc = sampler.prepare_now(get_prepared_objects(), this); - nassertr(sc != (SamplerContext *)NULL, false); + nassertr(sc != nullptr, false); CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc); gsc->enqueue_lru(&_prepared_objects->_sampler_object_lru); @@ -12264,10 +12261,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } if (image_compression != Texture::CM_off) { - Texture::QualityLevel quality_level = tex->get_effective_quality_level(); - #ifndef OPENGLES - switch (quality_level) { + switch (tex->get_effective_quality_level()) { case Texture::QL_fastest: glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); break; @@ -12402,7 +12397,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } #ifndef OPENGLES_2 - if (gtc->_generate_mipmaps && _glGenerateMipmap == NULL) { + if (gtc->_generate_mipmaps && _glGenerateMipmap == nullptr) { // The old, deprecated way to generate mipmaps. glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE); } @@ -12552,7 +12547,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { component_type, false, 0, image_compression); } - if (gtc->_generate_mipmaps && _glGenerateMipmap != NULL && + if (gtc->_generate_mipmaps && _glGenerateMipmap != nullptr && !image.is_null()) { // We uploaded an image; we may need to generate mipmaps. if (GLCAT.is_debug()) { @@ -12587,7 +12582,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { if (tex->has_ram_image()) { BamCache *cache = BamCache::get_global_ptr(); PT(BamCacheRecord) record = cache->lookup(tex->get_fullpath(), "txo"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->set_data(tex, tex); cache->store(record); } @@ -12596,7 +12591,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } GraphicsEngine *engine = get_engine(); - nassertr(engine != (GraphicsEngine *)NULL, false); + nassertr(engine != nullptr, false); engine->texture_uploaded(tex); gtc->mark_loaded(); @@ -12639,7 +12634,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } Texture *tex = gtc->get_texture(); - nassertr(tex != (Texture *)NULL, false); + nassertr(tex != nullptr, false); CPTA_uchar image = tex->get_ram_mipmap_image(mipmap_bias); int width = tex->get_expected_mipmap_x_size(mipmap_bias); @@ -12702,7 +12697,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, // mipmap image pointer which is a PTA_uchar const unsigned char *image_ptr = (unsigned char*)tex->get_ram_mipmap_pointer(n); CPTA_uchar ptimage; - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { ptimage = tex->get_ram_mipmap_image(n); if (ptimage.is_null()) { if (n < num_ram_mipmap_levels) { @@ -12755,7 +12750,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, PTA_uchar bgr_image; size_t view_size = tex->get_ram_mipmap_view_size(n); - if (image_ptr != (const unsigned char *)NULL) { + if (image_ptr != nullptr) { const unsigned char *orig_image_ptr = image_ptr; image_ptr += view_size * gtc->get_view(); if (one_page_only) { @@ -12899,7 +12894,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, for (int n = mipmap_bias; n < num_levels; ++n) { const unsigned char *image_ptr = (unsigned char*)tex->get_ram_mipmap_pointer(n); CPTA_uchar ptimage; - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { ptimage = tex->get_ram_mipmap_image(n); if (ptimage.is_null()) { if (n < num_ram_mipmap_levels) { @@ -12935,7 +12930,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, PTA_uchar bgr_image; size_t view_size = tex->get_ram_mipmap_view_size(n); - if (image_ptr != (const unsigned char *)NULL) { + if (image_ptr != nullptr) { const unsigned char *orig_image_ptr = image_ptr; image_ptr += view_size * gtc->get_view(); if (one_page_only) { @@ -13059,14 +13054,14 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, void CLP(GraphicsStateGuardian):: generate_mipmaps(CLP(TextureContext) *gtc) { #ifndef OPENGLES - if (_glGenerateTextureMipmap != NULL) { + if (_glGenerateTextureMipmap != nullptr) { // OpenGL 4.5 offers an easy way to do this without binding. _glGenerateTextureMipmap(gtc->_index); return; } #endif - if (_glGenerateMipmap != NULL) { + if (_glGenerateMipmap != nullptr) { _state_texture = 0; update_texture(gtc, true); apply_texture(gtc); @@ -13087,13 +13082,13 @@ upload_simple_texture(CLP(TextureContext) *gtc) { PStatGPUTimer timer(this, _load_texture_pcollector); Texture *tex = gtc->get_texture(); - nassertr(tex != (Texture *)NULL, false); + nassertr(tex != nullptr, false); GLenum internal_format = GL_RGBA; GLenum external_format = GL_BGRA; const unsigned char *image_ptr = tex->get_simple_ram_image(); - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { return false; } @@ -13150,7 +13145,6 @@ get_texture_memory_size(CLP(TextureContext) *gtc) { int height = tex->get_y_size(); int depth = 1; int scale = 1; - bool has_mipmaps = tex->uses_mipmaps(); size_t num_bytes = 2; // Temporary assumption? @@ -13254,7 +13248,7 @@ check_nonresident_texture(BufferContextChain &chain) { GLuint *texture_list = (GLuint *)alloca(num_textures * sizeof(GLuint)); size_t ti = 0; BufferContext *node = chain.get_first(); - while (node != (BufferContext *)NULL) { + while (node != nullptr) { CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), node); gtc_list[ti] = gtc; texture_list[ti] = gtc->_index; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index ab1d27a2a4..15ecebe439 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -269,7 +269,7 @@ public: virtual int get_driver_shader_version_major(); virtual int get_driver_shader_version_minor(); - static void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); + static void APIENTRY debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); virtual void reset(); diff --git a/panda/src/glstuff/glImmediateModeSender_src.cxx b/panda/src/glstuff/glImmediateModeSender_src.cxx index b832132a33..f7fba14cc3 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.cxx +++ b/panda/src/glstuff/glImmediateModeSender_src.cxx @@ -74,35 +74,35 @@ add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName * Func1f *func1f, Func2f *func2, Func3f *func3, Func4f *func4) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: - if (func1f != (Func1f *)NULL) { + if (func1f != nullptr) { sender = new ComponentSender1f(reader, func1f); } break; case 2: - if (func2 != (Func2f *)NULL) { + if (func2 != nullptr) { sender = new ComponentSender2f(reader, func2); } break; case 3: - if (func3 != (Func3f *)NULL) { + if (func3 != nullptr) { sender = new ComponentSender3f(reader, func3); } break; case 4: - if (func4 != (Func4f *)NULL) { + if (func4 != nullptr) { sender = new ComponentSender4f(reader, func4); } break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; @@ -135,7 +135,7 @@ add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, TexcoordFunc3f *func3, TexcoordFunc4f *func4) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: @@ -155,7 +155,7 @@ add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; @@ -186,7 +186,7 @@ add_vector_column(const GeomVertexDataPipelineReader *data_reader, const Interna VectorFunc *func) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: @@ -206,7 +206,7 @@ add_vector_column(const GeomVertexDataPipelineReader *data_reader, const Interna break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; @@ -236,7 +236,7 @@ add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, VectorUintFunc *func) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: @@ -256,7 +256,7 @@ add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index b5fd39350d..203cccb727 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -318,7 +318,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext for (int i = 0; i < block_count; ++i) { block_name_cstr[0] = 0; - _glgsg->_glGetActiveUniformBlockName(_glsl_program, i, block_maxlength, NULL, block_name_cstr); + _glgsg->_glGetActiveUniformBlockName(_glsl_program, i, block_maxlength, nullptr, block_name_cstr); reflect_uniform_block(i, block_name_cstr, name_buffer, name_buflen); } @@ -337,11 +337,11 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext for (int i = 0; i < block_count; ++i) { block_name_cstr[0] = 0; - _glgsg->_glGetProgramResourceName(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, block_maxlength, NULL, block_name_cstr); + _glgsg->_glGetProgramResourceName(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, block_maxlength, nullptr, block_name_cstr); const GLenum props[] = {GL_BUFFER_BINDING, GL_BUFFER_DATA_SIZE}; GLint values[2]; - _glgsg->_glGetProgramResourceiv(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, 2, props, 2, NULL, values); + _glgsg->_glGetProgramResourceiv(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, 2, props, 2, nullptr, values); StorageBlock block; block._name = InternalName::make(block_name_cstr); @@ -369,7 +369,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext _glgsg->report_my_gl_errors(); // Restore the active shader. - if (_glgsg->_current_shader_context == NULL) { + if (_glgsg->_current_shader_context == nullptr) { _glgsg->_glUseProgram(0); } else { _glgsg->_current_shader_context->bind(); @@ -387,7 +387,7 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { // Get the name, size, and type of this attribute. name_buffer[0] = 0; - _glgsg->_glGetActiveAttrib(_glsl_program, i, name_buflen, NULL, + _glgsg->_glGetActiveAttrib(_glsl_program, i, name_buflen, nullptr, ¶m_size, ¶m_type, name_buffer); // Get the attrib location. @@ -415,7 +415,7 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { Shader::ShaderVarSpec bind; bind._id = arg_id; - bind._name = NULL; + bind._name = nullptr; bind._append_uv = -1; bind._elements = 1; @@ -564,7 +564,7 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b name_buffer[0] = 0; GLint param_size; GLenum param_type; - _glgsg->_glGetActiveUniform(_glsl_program, indices[ui], name_buflen, NULL, ¶m_size, ¶m_type, name_buffer); + _glgsg->_glGetActiveUniform(_glsl_program, indices[ui], name_buflen, nullptr, ¶m_size, ¶m_type, name_buffer); // Strip off [0] suffix that some drivers append to arrays. size_t size = strlen(name_buffer); @@ -701,7 +701,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { // Get the name, location, type and size of this uniform. name_buffer[0] = 0; - _glgsg->_glGetActiveUniform(_glsl_program, i, name_buflen, NULL, ¶m_size, ¶m_type, name_buffer); + _glgsg->_glGetActiveUniform(_glsl_program, i, name_buflen, nullptr, ¶m_size, ¶m_type, name_buffer); GLint p = _glgsg->_glGetUniformLocation(_glsl_program, name_buffer); if (GLCAT.is_debug()) { @@ -785,8 +785,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { << "Matrix input p3d_" << matrix_name << " should be mat3 or mat4\n"; return; } - bind._arg[0] = NULL; - bind._arg[1] = NULL; + bind._arg[0] = nullptr; + bind._arg[1] = nullptr; if (matrix_name == "ModelViewProjectionMatrix") { if (inverse) { @@ -884,14 +884,14 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._part[0] = Shader::SMO_light_source_i_attrib; bind._arg[0] = InternalName::make(name_buffer); bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (strncmp(name_buffer, "shadowMatrix", 127) == 0) { // Only supported for backward compatibility: includes the model // matrix. Not very efficient to do this. bind._func = Shader::SMF_compose; bind._part[0] = Shader::SMO_model_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = Shader::SMO_light_source_i_attrib; bind._arg[1] = InternalName::make("shadowViewMatrix"); @@ -946,10 +946,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_attr_material; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_material | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (noprefix == "Material.baseColor") { @@ -1053,10 +1053,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_attr_colorscale; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_colorscale; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (param_type == GL_FLOAT_VEC3) { @@ -1077,10 +1077,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_attr_color; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_color; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (param_type == GL_FLOAT_VEC3) { @@ -1110,10 +1110,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._func = Shader::SMF_first; bind._index = i; bind._part[0] = Shader::SMO_apiview_clipplane_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_clip_planes; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; _shader->_mat_spec.push_back(bind); _shader->_mat_deps |= bind._dep[0]; @@ -1125,10 +1125,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_light_ambient; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_light; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (param_type == GL_FLOAT_VEC3) { @@ -1183,7 +1183,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._arg[0] = InternalName::make(member_name); bind._dep[0] = Shader::SSD_general | Shader::SSD_light | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (member_name == "position" || member_name == "halfVector" || @@ -1245,10 +1245,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._func = Shader::SMF_first; bind._index = 0; bind._part[0] = Shader::SMO_tex_is_alpha_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_texture | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; bind._piece = Shader::SMP_row3; _shader->_mat_spec.push_back(bind); @@ -1265,8 +1265,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { Shader::ShaderMatSpec bind; bind._id = arg_id; - bind._arg[0] = NULL; - bind._arg[1] = NULL; + bind._arg[0] = nullptr; + bind._arg[1] = nullptr; if (noprefix == "ViewMatrix") { bind._piece = Shader::SMP_whole; @@ -1395,7 +1395,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._arg[0] = InternalName::make(param_name); bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; _shader->_mat_spec.push_back(bind); _shader->_mat_deps |= bind._dep[0]; @@ -1407,7 +1407,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._piece = Shader::SMP_whole; bind._func = Shader::SMF_first; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; PT(InternalName) iname = InternalName::make(param_name); if (iname->get_parent() != InternalName::get_root()) { @@ -1428,7 +1428,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { } bind._func = Shader::SMF_compose; bind._part[0] = Shader::SMO_model_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; bind._part[1] = Shader::SMO_mat_constant_x_attrib; bind._arg[1] = iname->get_parent()->append("shadowViewMatrix"); @@ -1478,7 +1478,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { // position) have to be transformed to view space. bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs | Shader::SSD_frame | Shader::SSD_view_transform; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; _shader->_mat_spec.push_back(bind); _shader->_mat_deps |= bind._dep[0]; @@ -1568,7 +1568,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { ImageInput input; input._name = InternalName::make(param_name); input._writable = false; - input._gtc = NULL; + input._gtc = nullptr; _glsl_img_inputs.push_back(input); } return; @@ -1987,7 +1987,7 @@ issue_parameters(int altered) { Shader::ShaderPtrSpec &spec = _shader->_ptr_spec[i]; const Shader::ShaderPtrData* ptr_data = _glgsg->fetch_ptr_parameter(spec); - if (ptr_data == NULL) { //the input is not contained in ShaderPtrData + if (ptr_data == nullptr) { //the input is not contained in ShaderPtrData release_resources(); return; } @@ -1997,7 +1997,7 @@ issue_parameters(int altered) { switch (spec._type) { case Shader::SPT_float: { - float *data = NULL; + float *data = nullptr; switch (ptr_data->_type) { case Shader::SPT_int: @@ -2149,7 +2149,7 @@ update_transform_table(const TransformTable *table) { LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); size_t i = 0; - if (table != NULL) { + if (table != nullptr) { size_t num_transforms = min((size_t)_transform_table_size, table->get_num_transforms()); for (; i < num_transforms; ++i) { #ifdef STDFLOAT_DOUBLE @@ -2177,7 +2177,7 @@ update_slider_table(const SliderTable *table) { float *sliders = (float *)alloca(_slider_table_size * 4); memset(sliders, 0, _slider_table_size * 4); - if (table != NULL) { + if (table != nullptr) { size_t num_sliders = min((size_t)_slider_table_size, table->get_num_sliders()); for (size_t i = 0; i < num_sliders; ++i) { sliders[i] = table->get_slider(i)->get_slider(); @@ -2236,7 +2236,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Make sure the vertex buffer is up-to-date. CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), array_reader->prepare_now(_glgsg->get_prepared_objects(), _glgsg)); - nassertr(gvbc != (CLP(VertexBufferContext) *)NULL, false); + nassertr(gvbc != (CLP(VertexBufferContext) *)nullptr, false); if (!_glgsg->update_vertex_buffer(gvbc, array_reader, force)) { return false; @@ -2409,7 +2409,7 @@ disable_shader_texture_bindings() { // There are non-bindless textures to unbind, and we're lazy, so let's // go and unbind everything after this point using one multi-bind call, // and then break out of the loop. - _glgsg->_glBindTextures(i, _shader->_tex_spec.size() - i, NULL); + _glgsg->_glBindTextures(i, _shader->_tex_spec.size() - i, nullptr); break; } #endif @@ -2453,7 +2453,7 @@ disable_shader_texture_bindings() { if (num_image_units > 0) { #ifndef OPENGLES if (_glgsg->_supports_multi_bind) { - _glgsg->_glBindImageTextures(0, num_image_units, NULL); + _glgsg->_glBindImageTextures(0, num_image_units, nullptr); } else #endif { @@ -2466,9 +2466,9 @@ disable_shader_texture_bindings() { for (int i = 0; i < num_image_units; ++i) { ImageInput &input = _glsl_img_inputs[i]; - if (input._gtc != NULL) { + if (input._gtc != nullptr) { input._gtc->mark_incoherent(input._writable); - input._gtc = NULL; + input._gtc = nullptr; } } } @@ -2501,7 +2501,7 @@ update_shader_texture_bindings(ShaderContext *prev) { if (num_image_units > 0) { for (int i = 0; i < num_image_units; ++i) { ImageInput &input = _glsl_img_inputs[i]; - const ParamTextureImage *param = NULL; + const ParamTextureImage *param = nullptr; Texture *tex; const ShaderInput &sinp = _glgsg->_target_shader->get_shader_input(input._name); @@ -2531,11 +2531,11 @@ update_shader_texture_bindings(ShaderContext *prev) { GLuint gl_tex = 0; CLP(TextureContext) *gtc; - if (tex != NULL) { + if (tex != nullptr) { int view = _glgsg->get_current_tex_view_offset(); gtc = DCAST(CLP(TextureContext), tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg)); - if (gtc != (TextureContext*)NULL) { + if (gtc != nullptr) { input._gtc = gtc; _glgsg->update_texture(gtc, true); @@ -2569,7 +2569,7 @@ update_shader_texture_bindings(ShaderContext *prev) { GLint bind_layer = 0; GLboolean layered = GL_TRUE; - if (param != NULL) { + if (param != nullptr) { layered = param->get_bind_layered(); bind_level = param->get_bind_level(); bind_layer = param->get_bind_layer(); @@ -2638,7 +2638,7 @@ update_shader_texture_bindings(ShaderContext *prev) { } if (tex->get_texture_type() != spec._desired_type) { - if (id != NULL) { + if (id != nullptr) { GLCAT.error() << "Sampler type of GLSL shader input '" << *id << "' does not " "match type of texture " << *tex << ".\n"; @@ -2652,7 +2652,7 @@ update_shader_texture_bindings(ShaderContext *prev) { } CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg)); - if (gtc == NULL) { + if (gtc == nullptr) { if (multi_bind) { textures[i] = 0; samplers[i] = 0; @@ -2660,9 +2660,9 @@ update_shader_texture_bindings(ShaderContext *prev) { continue; } +#ifndef OPENGLES GLint p = spec._id._seqno; -#ifndef OPENGLES // If it was recently written to, we will have to issue a memory barrier // soon. if (gtc->needs_barrier(GL_TEXTURE_FETCH_BARRIER_BIT)) { @@ -2715,7 +2715,7 @@ update_shader_texture_bindings(ShaderContext *prev) { } SamplerContext *sc = sampler.prepare_now(_glgsg->get_prepared_objects(), _glgsg); - if (sc == NULL) { + if (sc == nullptr) { samplers[i] = 0; } else { CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc); @@ -2801,7 +2801,7 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { // instead of source indices. istringstream log(info_log); string line; - while (getline(log, line)) { + while (std::getline(log, line)) { int fileno, lineno, colno; int prefixlen = 0; @@ -2935,7 +2935,7 @@ glsl_compile_shader(Shader::ShaderType type) { string text_str = _shader->get_text(type); const char* text = text_str.c_str(); - _glgsg->_glShaderSource(handle, 1, &text, NULL); + _glgsg->_glShaderSource(handle, 1, &text, nullptr); _glgsg->_glCompileShader(handle); GLint status; _glgsg->_glGetShaderiv(handle, GL_COMPILE_STATUS, &status); diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.cxx b/panda/src/glxdisplay/glxGraphicsBuffer.cxx index fb70d352dc..835adeed97 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.cxx +++ b/panda/src/glxdisplay/glxGraphicsBuffer.cxx @@ -64,7 +64,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL || + if (_gsg == nullptr || _pbuffer == None) { return false; } @@ -105,7 +105,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void glxGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -124,8 +124,8 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void glxGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - glXMakeCurrent(_display, None, NULL); + if (_gsg != nullptr) { + glXMakeCurrent(_display, None, nullptr); if (_pbuffer != None) { glxGraphicsStateGuardian *glxgsg; @@ -152,9 +152,9 @@ open_buffer() { // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. - glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, NULL); + glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, nullptr); glxgsg->choose_pixel_format(_fb_properties, glx_pipe->get_display(), glx_pipe->get_screen(), true, false); _gsg = glxgsg; } else { diff --git a/panda/src/glxdisplay/glxGraphicsPipe.cxx b/panda/src/glxdisplay/glxGraphicsPipe.cxx index cd2f082c91..06266e6e96 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.cxx +++ b/panda/src/glxdisplay/glxGraphicsPipe.cxx @@ -78,14 +78,14 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } // This may not be a GLX GSG; it might be a callback GSG. - PosixGraphicsStateGuardian *posixgsg = NULL; - glxGraphicsStateGuardian *glxgsg = NULL; - if (gsg != NULL) { - DCAST_INTO_R(posixgsg, gsg, NULL); + PosixGraphicsStateGuardian *posixgsg = nullptr; + glxGraphicsStateGuardian *glxgsg = nullptr; + if (gsg != nullptr) { + DCAST_INTO_R(posixgsg, gsg, nullptr); glxgsg = DCAST(glxGraphicsStateGuardian, posixgsg); } @@ -103,9 +103,9 @@ make_output(const string &name, // First thing to try: a glxGraphicsWindow if (retry == 0) { - if (gsg != NULL && glxgsg == NULL) { + if (gsg != nullptr && glxgsg == nullptr) { // We can't use a non-GLX GSG. - return NULL; + return nullptr; } if (((flags&BF_require_parasite)!=0)|| ((flags&BF_refuse_window)!=0)|| @@ -115,7 +115,7 @@ make_output(const string &name, ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } return new glxGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -124,9 +124,9 @@ make_output(const string &name, // Second thing to try: a GLGraphicsBuffer if (retry == 1) { - if (!gl_support_fbo || host == NULL || + if (!gl_support_fbo || host == nullptr || (flags & (BF_require_parasite | BF_require_window)) != 0) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -134,13 +134,13 @@ make_output(const string &name, if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || fb_prop.get_accum_bits() > 0) { - return NULL; + return nullptr; } } - if (posixgsg != NULL && posixgsg->is_valid() && !posixgsg->needs_reset()) { + if (posixgsg != nullptr && posixgsg->is_valid() && !posixgsg->needs_reset()) { if (!posixgsg->_supports_framebuffer_object || - posixgsg->_glDrawBuffers == NULL) { - return NULL; + posixgsg->_glDrawBuffers == nullptr) { + return nullptr; } else { // Early success - if we are sure that this buffer WILL meet specs, we // can precertify it. @@ -152,10 +152,10 @@ make_output(const string &name, } // Third thing to try: a glxGraphicsBuffer - if (glxgsg == NULL || glxgsg->_supports_fbconfig) { + if (glxgsg == nullptr || glxgsg->_supports_fbconfig) { if (retry == 2) { if (!glx_support_pbuffer) { - return NULL; + return nullptr; } if (((flags&BF_require_parasite)!=0)|| @@ -163,7 +163,7 @@ make_output(const string &name, ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if (!support_rtt) { @@ -171,7 +171,7 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { // If we require Render-to-Texture, but can't be sure we support it, // bail. - return NULL; + return nullptr; } } @@ -183,7 +183,7 @@ make_output(const string &name, // Third thing to try: a glxGraphicsPixmap. if (retry == 3) { if (!glx_support_pixmap) { - return NULL; + return nullptr; } if (((flags&BF_require_parasite)!=0)|| @@ -191,12 +191,12 @@ make_output(const string &name, ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new glxGraphicsPixmap(engine, this, name, fb_prop, win_prop, @@ -204,7 +204,7 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } /** diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.cxx b/panda/src/glxdisplay/glxGraphicsPixmap.cxx index 8c8c5a330d..8c9c317b2c 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.cxx +++ b/panda/src/glxdisplay/glxGraphicsPixmap.cxx @@ -67,7 +67,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL || + if (_gsg == nullptr || _glx_pixmap == None) { return false; } @@ -108,7 +108,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void glxGraphicsPixmap:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -127,8 +127,8 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void glxGraphicsPixmap:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - glXMakeCurrent(_display, None, NULL); + if (_gsg != nullptr) { + glXMakeCurrent(_display, None, nullptr); _gsg.clear(); } @@ -156,9 +156,9 @@ open_buffer() { // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. - glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, NULL); + glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, nullptr); glxgsg->choose_pixel_format(_fb_properties, _display, glx_pipe->get_screen(), false, true); _gsg = glxgsg; } else { @@ -179,7 +179,7 @@ open_buffer() { } XVisualInfo *visual_info = glxgsg->_visual; - if (visual_info == NULL) { + if (visual_info == nullptr) { // No X visual for this fbconfig; how can we create the pixmap? glxdisplay_cat.error() << "No X visual: cannot create pixmap.\n"; @@ -187,7 +187,7 @@ open_buffer() { } _drawable = glx_pipe->get_root(); - if (_host != NULL) { + if (_host != nullptr) { if (_host->is_of_type(glxGraphicsWindow::get_class_type())) { glxGraphicsWindow *win = DCAST(glxGraphicsWindow, _host); _drawable = win->get_xwindow(); @@ -208,7 +208,7 @@ open_buffer() { if (glxgsg->_fbconfig) { // Use the FBConfig to create the pixmap. - _glx_pixmap = glxgsg->_glXCreatePixmap(_display, glxgsg->_fbconfig, _x_pixmap, NULL); + _glx_pixmap = glxgsg->_glXCreatePixmap(_display, glxgsg->_fbconfig, _x_pixmap, nullptr); } else { // Use the XVisual to create the pixmap. _glx_pixmap = glXCreateGLXPixmap(_display, visual_info, _x_pixmap); diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index e79f80be3e..2b877b2168 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -29,13 +29,13 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, glxGraphicsStateGuardian *share_with) : PosixGraphicsStateGuardian(engine, pipe) { - _share_context=0; - _context=0; - _display=0; + _share_context=nullptr; + _context=nullptr; + _display=nullptr; _screen=0; - _visual=0; - _visuals=0; - _fbconfig=0; + _visual=nullptr; + _visuals=nullptr; + _fbconfig=nullptr; _context_has_pbuffer = false; _context_has_pixmap = false; _slow = false; @@ -45,16 +45,16 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _supports_pbuffer = false; _uses_sgix_pbuffer = false; - if (share_with != (glxGraphicsStateGuardian *)NULL) { + if (share_with != nullptr) { _prepared_objects = share_with->get_prepared_objects(); _share_context = share_with->_context; } _checked_get_proc_address = false; - _glXGetProcAddress = NULL; - _temp_context = (GLXContext)NULL; - _temp_xwindow = (X11_Window)NULL; - _temp_colormap = (Colormap)NULL; + _glXGetProcAddress = nullptr; + _temp_context = (GLXContext)nullptr; + _temp_xwindow = (X11_Window)nullptr; + _temp_colormap = (Colormap)nullptr; } /** @@ -63,12 +63,12 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, glxGraphicsStateGuardian:: ~glxGraphicsStateGuardian() { destroy_temp_xwindow(); - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); } - if (_context != (GLXContext)NULL) { + if (_context != (GLXContext)nullptr) { glXDestroyContext(_display, _context); - _context = (GLXContext)NULL; + _context = (GLXContext)nullptr; } } @@ -224,12 +224,12 @@ choose_pixel_format(const FrameBufferProperties &properties, _display = display; _screen = screen; - _context = 0; - _fbconfig = 0; - _visual = 0; - if (_visuals != (XVisualInfo *)NULL) { + _context = nullptr; + _fbconfig = nullptr; + _visual = nullptr; + if (_visuals != nullptr) { XFree(_visuals); - _visuals = NULL; + _visuals = nullptr; } _fbprops.clear(); @@ -239,7 +239,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // OpenGL context to get the required extension function pointers. destroy_temp_xwindow(); choose_temp_visual(properties); - if (_temp_context == NULL) { + if (_temp_context == nullptr) { // No good. return; } @@ -257,7 +257,7 @@ choose_pixel_format(const FrameBufferProperties &properties, << _fbprops << "\n"; _context = _temp_context; - _temp_context = (GLXContext)NULL; + _temp_context = (GLXContext)nullptr; // By convention, every indirect XVisual that can render to a window can // also render to a GLXPixmap. Direct visuals we're not as sure about. @@ -297,7 +297,7 @@ choose_pixel_format(const FrameBufferProperties &properties, GLXFBConfig *configs = _glXChooseFBConfig(_display, _screen, attrib_list, &num_configs); - if (configs != 0) { + if (configs != nullptr) { bool context_has_pbuffer, context_has_pixmap, slow; int quality, i; for (i = 0; i < num_configs; ++i) { @@ -332,7 +332,7 @@ choose_pixel_format(const FrameBufferProperties &properties, if (best_quality > 0) { _fbconfig = configs[best_result]; - if (_glXCreateContextAttribs != NULL) { + if (_glXCreateContextAttribs != nullptr) { // NB. This is a wholly different type of attrib list than below, the // same values are not used! n = 0; @@ -362,9 +362,9 @@ choose_pixel_format(const FrameBufferProperties &properties, if (_context) { mark_new(); - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); - _visuals = NULL; + _visuals = nullptr; } _visuals = _glXGetVisualFromFBConfig(_display, _fbconfig); _visual = _visuals; @@ -391,10 +391,10 @@ choose_pixel_format(const FrameBufferProperties &properties, // This really shouldn't happen, so I'm not too careful about cleanup. glxdisplay_cat.error() << "Could not create FBConfig context!\n"; - _fbconfig = 0; - _context = 0; - _visual = 0; - _visuals = 0; + _fbconfig = nullptr; + _context = nullptr; + _visual = nullptr; + _visuals = nullptr; } glxdisplay_cat.warning() @@ -402,7 +402,7 @@ choose_pixel_format(const FrameBufferProperties &properties, << _fbprops << "\n"; _context = _temp_context; - _temp_context = (GLXContext)NULL; + _temp_context = (GLXContext)nullptr; // By convention, every indirect XVisual that can render to a window can // also render to a GLXPixmap. Direct visuals we're not as sure about. @@ -492,7 +492,7 @@ get_extra_extensions() { */ void *glxGraphicsStateGuardian:: do_get_extension_func(const char *name) { - nassertr(name != NULL, NULL); + nassertr(name != nullptr, nullptr); if (glx_get_proc_address) { // First, check if we have glXGetProcAddress available. This will be @@ -514,7 +514,7 @@ do_get_extension_func(const char *name) { // Otherwise, we have to fiddle around with the dynamic runtime. if (!_checked_get_proc_address) { - const char *funcName = NULL; + const char *funcName = nullptr; if (glx_is_at_least_version(1, 4)) { funcName = "glXGetProcAddress"; @@ -523,9 +523,9 @@ do_get_extension_func(const char *name) { funcName = "glXGetProcAddressARB"; } - if (funcName != NULL) { + if (funcName != nullptr) { _glXGetProcAddress = (PFNGLXGETPROCADDRESSPROC)get_system_func(funcName); - if (_glXGetProcAddress == NULL) { + if (_glXGetProcAddress == nullptr) { glxdisplay_cat.warning() << "Couldn't load function " << funcName << ", GL extensions may be unavailable.\n"; @@ -536,7 +536,7 @@ do_get_extension_func(const char *name) { } // Use glxGetProcAddress() if we've got it; it should be more robust. - if (_glXGetProcAddress != NULL) { + if (_glXGetProcAddress != nullptr) { return (void *)_glXGetProcAddress((const GLubyte *)name); } #endif // HAVE_GLXGETPROCADDRESS @@ -556,7 +556,7 @@ query_glx_extensions() { if (_supports_swap_control) { _glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)get_extension_func("glXSwapIntervalSGI"); - if (_glXSwapIntervalSGI == NULL) { + if (_glXSwapIntervalSGI == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_SGI_swap_control extension, but does not define all functions.\n"; _supports_swap_control = false; @@ -585,11 +585,11 @@ query_glx_extensions() { _glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)get_extension_func("glXCreatePixmap"); - if (_glXChooseFBConfig == NULL || - _glXCreateNewContext == NULL || - _glXGetVisualFromFBConfig == NULL || - _glXGetFBConfigAttrib == NULL || - _glXCreatePixmap == NULL) { + if (_glXChooseFBConfig == nullptr || + _glXCreateNewContext == nullptr || + _glXGetVisualFromFBConfig == nullptr || + _glXGetFBConfigAttrib == nullptr || + _glXCreatePixmap == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_fbconfig extension, but does not define all functions.\n"; _supports_fbconfig = false; @@ -611,11 +611,11 @@ query_glx_extensions() { _glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)get_extension_func("glXCreateGLXPixmapWithConfigSGIX"); - if (_glXChooseFBConfig == NULL || - _glXCreateNewContext == NULL || - _glXGetVisualFromFBConfig == NULL || - _glXGetFBConfigAttrib == NULL || - _glXCreatePixmap == NULL) { + if (_glXChooseFBConfig == nullptr || + _glXCreateNewContext == nullptr || + _glXGetVisualFromFBConfig == nullptr || + _glXGetFBConfigAttrib == nullptr || + _glXCreatePixmap == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_SGIX_fbconfig extension, but does not define all functions.\n"; _supports_fbconfig = false; @@ -629,11 +629,11 @@ query_glx_extensions() { _glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)get_extension_func("glXCreatePbuffer"); - _glXCreateGLXPbufferSGIX = NULL; + _glXCreateGLXPbufferSGIX = nullptr; _glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)get_extension_func("glXDestroyPbuffer"); - if (_glXCreatePbuffer == NULL || - _glXDestroyPbuffer == NULL) { + if (_glXCreatePbuffer == nullptr || + _glXDestroyPbuffer == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_pbuffer extension, but does not define all functions.\n"; _supports_pbuffer = false; @@ -646,13 +646,13 @@ query_glx_extensions() { // CreatePbuffer has a different form between SGIX and 1.3, however, so // we must treat it specially. But we can use the same function pointer // for DestroyPbuffer. - _glXCreatePbuffer = NULL; + _glXCreatePbuffer = nullptr; _glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)get_extension_func("glXCreateGLXPbufferSGIX"); _glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)get_extension_func("glXDestroyGLXPbufferSGIX"); - if (_glXCreateGLXPbufferSGIX == NULL || - _glXDestroyPbuffer == NULL) { + if (_glXCreateGLXPbufferSGIX == nullptr || + _glXDestroyPbuffer == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_SGIX_pbuffer extension, but does not define all functions.\n"; _supports_pbuffer = false; @@ -663,7 +663,7 @@ query_glx_extensions() { _glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC)get_extension_func("glXCreateContextAttribsARB"); } else { - _glXCreateContextAttribs = NULL; + _glXCreateContextAttribs = nullptr; } } @@ -697,7 +697,7 @@ void glxGraphicsStateGuardian:: show_glx_client_string(const string &name, int id) { if (glgsg_cat.is_debug()) { const char *text = glXGetClientString(_display, id); - if (text == (const char *)NULL) { + if (text == nullptr) { glgsg_cat.debug() << "Unable to query " << name << " (client)\n"; } else { @@ -714,7 +714,7 @@ void glxGraphicsStateGuardian:: show_glx_server_string(const string &name, int id) { if (glgsg_cat.is_debug()) { const char *text = glXQueryServerString(_display, _screen, id); - if (text == (const char *)NULL) { + if (text == nullptr) { glgsg_cat.debug() << "Unable to query " << name << " (server)\n"; } else { @@ -732,20 +732,20 @@ show_glx_server_string(const string &name, int id) { */ void glxGraphicsStateGuardian:: choose_temp_visual(const FrameBufferProperties &properties) { - nassertv(_temp_context == (GLXContext)NULL); + nassertv(_temp_context == (GLXContext)nullptr); int best_quality = 0; int best_result = 0; FrameBufferProperties best_props; // Scan available visuals. - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); - _visuals = NULL; + _visuals = nullptr; } int nvisuals = 0; - _visuals = XGetVisualInfo(_display, 0, 0, &nvisuals); - if (_visuals != 0) { + _visuals = XGetVisualInfo(_display, 0, nullptr, &nvisuals); + if (_visuals != nullptr) { for (int i = 0; i < nvisuals; i++) { FrameBufferProperties fbprops; get_properties(fbprops, _visuals + i); @@ -794,7 +794,7 @@ init_temp_context() { (_display, root_window, 0, 0, 100, 100, 0, _visual->depth, InputOutput, visual, attrib_mask, &wa); - if (_temp_xwindow == (X11_Window)NULL) { + if (_temp_xwindow == (X11_Window)nullptr) { glxdisplay_cat.error() << "Could not create temporary window for context\n"; return; @@ -812,19 +812,19 @@ init_temp_context() { */ void glxGraphicsStateGuardian:: destroy_temp_xwindow() { - glXMakeCurrent(_display, None, NULL); + glXMakeCurrent(_display, None, nullptr); - if (_temp_colormap != (Colormap)NULL) { + if (_temp_colormap != (Colormap)nullptr) { XFreeColormap(_display, _temp_colormap); - _temp_colormap = (Colormap)NULL; + _temp_colormap = (Colormap)nullptr; } - if (_temp_xwindow != (X11_Window)NULL) { + if (_temp_xwindow != (X11_Window)nullptr) { XDestroyWindow(_display, _temp_xwindow); - _temp_xwindow = (X11_Window)NULL; + _temp_xwindow = (X11_Window)nullptr; } - if (_temp_context != (GLXContext)NULL) { + if (_temp_context != (GLXContext)nullptr) { glXDestroyContext(_display, _temp_context); - _temp_context = (GLXContext)NULL; + _temp_context = (GLXContext)nullptr; } } diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 7dd43c8675..28f4652266 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -57,7 +57,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -106,7 +106,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { */ void glxGraphicsWindow:: end_flip() { - if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { + if (_gsg != nullptr && _flip_ready) { // It doesn't appear to be necessary to ensure the graphics context is // current before flipping the windows, and insisting on doing so can be a @@ -125,8 +125,8 @@ end_flip() { */ void glxGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - glXMakeCurrent(_display, None, NULL); + if (_gsg != nullptr) { + glXMakeCurrent(_display, None, nullptr); _gsg.clear(); } @@ -144,9 +144,9 @@ open_window() { // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. - glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, NULL); + glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, nullptr); glxgsg->choose_pixel_format(_fb_properties, glx_pipe->get_display(), glx_pipe->get_screen(), false, false); _gsg = glxgsg; } else { @@ -160,7 +160,7 @@ open_window() { } } - if (glxgsg->_context == NULL) { + if (glxgsg->_context == nullptr) { // We're supposed to have a context at this point. glxdisplay_cat.error() << "No GLX context: cannot open window.\n"; @@ -168,7 +168,7 @@ open_window() { } _visual_info = glxgsg->_visual; - if (_visual_info == NULL) { + if (_visual_info == nullptr) { // No X visual for this fbconfig; how can we open the window? glxdisplay_cat.error() << "No X visual: cannot open window.\n"; @@ -212,7 +212,7 @@ setup_colormap(GLXFBConfig fbconfig) { nassertv(glxgsg->_supports_fbconfig); XVisualInfo *visual_info = glxgsg->_glXGetVisualFromFBConfig(_display, fbconfig); - if (visual_info == NULL) { + if (visual_info == nullptr) { // No X visual; no need to set up a colormap. return; } diff --git a/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx b/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx index 8bf738b3c2..ac5f10f8a1 100644 --- a/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx @@ -24,7 +24,7 @@ PosixGraphicsStateGuardian:: PosixGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe) : GLGraphicsStateGuardian(engine, pipe) { - _libgl_handle = NULL; + _libgl_handle = nullptr; } /** @@ -32,7 +32,7 @@ PosixGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe) : */ PosixGraphicsStateGuardian:: ~PosixGraphicsStateGuardian() { - if (_libgl_handle != (void *)NULL) { + if (_libgl_handle != nullptr) { dlclose(_libgl_handle); } } @@ -45,13 +45,13 @@ PosixGraphicsStateGuardian:: */ void *PosixGraphicsStateGuardian:: do_get_extension_func(const char *name) { - nassertr(name != NULL, NULL); + nassertr(name != nullptr, nullptr); if (glx_get_os_address) { return get_system_func(name); } - return NULL; + return nullptr; } /** @@ -61,23 +61,23 @@ do_get_extension_func(const char *name) { */ void *PosixGraphicsStateGuardian:: get_system_func(const char *name) { - if (_libgl_handle == (void *)NULL) { + if (_libgl_handle == nullptr) { // We open the current executable, rather than naming a particular // library. Presumably libGL.so (or whatever the library should be // called) is already available in the current executable address space, // so this is more portable than insisting on a particular shared library // name. - _libgl_handle = dlopen(NULL, RTLD_LAZY); - nassertr(_libgl_handle != (void *)NULL, NULL); + _libgl_handle = dlopen(nullptr, RTLD_LAZY); + nassertr(_libgl_handle != nullptr, nullptr); // If that doesn't locate the symbol we expected, then fall back to // loading the GL library by its usual name. - if (dlsym(_libgl_handle, name) == NULL) { + if (dlsym(_libgl_handle, name) == nullptr) { dlclose(_libgl_handle); glxdisplay_cat.warning() << name << " not found in executable; looking in libGL.so instead.\n"; _libgl_handle = dlopen("libGL.so", RTLD_LAZY); - nassertr(_libgl_handle != (void *)NULL, NULL); + nassertr(_libgl_handle != nullptr, nullptr); } } diff --git a/panda/src/gobj/adaptiveLru.I b/panda/src/gobj/adaptiveLru.I index 77c3fcd5de..41acf47c38 100644 --- a/panda/src/gobj/adaptiveLru.I +++ b/panda/src/gobj/adaptiveLru.I @@ -134,7 +134,7 @@ get_lru() const { */ INLINE void AdaptiveLruPage:: dequeue_lru() { - enqueue_lru(NULL); + enqueue_lru(nullptr); } /** @@ -146,7 +146,7 @@ dequeue_lru() { */ INLINE void AdaptiveLruPage:: mark_used_lru() const { - if (_lru != (AdaptiveLru *)NULL) { + if (_lru != nullptr) { ((AdaptiveLruPage *)this)->mark_used_lru(_lru); } } @@ -174,7 +174,7 @@ get_lru_size() const { */ INLINE void AdaptiveLruPage:: set_lru_size(size_t lru_size) { - if (_lru != (AdaptiveLru *)NULL) { + if (_lru != nullptr) { LightMutexHolder holder(_lru->_lock); _lru->_total_size -= _lru_size; _lru->_total_size += lru_size; diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index eb2d945177..85bb3ab36c 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -55,10 +55,10 @@ AdaptiveLru:: // to disk unnecessarily). while (_static_list._next != &_static_list) { - nassertv(_static_list._next != (LinkedListNode *)NULL); + nassertv(_static_list._next != nullptr); AdaptiveLruPage *page = (AdaptiveLruPage *)(AdaptiveLruPageStaticList *)_static_list._next; - page->_lru = NULL; + page->_lru = nullptr; ((AdaptiveLruPageDynamicList *)page)->remove_from_list(); ((AdaptiveLruPageStaticList *)page)->remove_from_list(); } @@ -170,19 +170,19 @@ update_page(AdaptiveLruPage *page) { */ void AdaptiveLruPage:: enqueue_lru(AdaptiveLru *lru) { - if (lru != _lru && _lru != (AdaptiveLru *)NULL) { + if (lru != _lru && _lru != nullptr) { // It was previously on a different LRU. Remove it first. _lru->do_remove_page(this); - _lru = NULL; + _lru = nullptr; } if (lru == _lru) { - if (_lru != (AdaptiveLru *)NULL) { + if (_lru != nullptr) { // It's already on this LRU. Access it. _lru->do_access_page(this); } } else { - nassertv(lru != (AdaptiveLru *)NULL); + nassertv(lru != nullptr); // Add it to a new LRU. _lru = lru; @@ -281,7 +281,7 @@ write(ostream &out, int indent_level) const { */ void AdaptiveLru:: do_add_page(AdaptiveLruPage *page) { - nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); + nassertv(page != nullptr && page->_lru == this); LightMutexHolder holder(_lock); _total_size += page->_lru_size; @@ -294,7 +294,7 @@ do_add_page(AdaptiveLruPage *page) { */ void AdaptiveLru:: do_remove_page(AdaptiveLruPage *page) { - nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); + nassertv(page != nullptr && page->_lru == this); LightMutexHolder holder(_lock); _total_size -= page->_lru_size; @@ -307,7 +307,7 @@ do_remove_page(AdaptiveLruPage *page) { */ void AdaptiveLru:: do_access_page(AdaptiveLruPage *page) { - nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); + nassertv(page != nullptr && page->_lru == this); LightMutexHolder holder(_lock); if (page->_current_frame_identifier == _current_frame_identifier) { @@ -447,7 +447,7 @@ do_validate() { */ AdaptiveLruPage:: AdaptiveLruPage(size_t lru_size) : - _lru(NULL), + _lru(nullptr), _lru_size(lru_size), _priority(0), _first_frame_identifier(0), @@ -455,7 +455,6 @@ AdaptiveLruPage(size_t lru_size) : _update_frame_identifier(0), _current_frame_usage(0), _last_frame_usage(0), - _total_usage(0), _update_total_usage(0), _average_frame_utilization(1.0f) { @@ -466,7 +465,7 @@ AdaptiveLruPage(size_t lru_size) : */ AdaptiveLruPage:: AdaptiveLruPage(const AdaptiveLruPage ©) : - _lru(NULL), + _lru(nullptr), _lru_size(copy._lru_size), _priority(0), _first_frame_identifier(0), @@ -474,7 +473,6 @@ AdaptiveLruPage(const AdaptiveLruPage ©) : _update_frame_identifier(0), _current_frame_usage(0), _last_frame_usage(0), - _total_usage(0), _update_total_usage(0), _average_frame_utilization(1.0f) { @@ -493,7 +491,7 @@ operator = (const AdaptiveLruPage ©) { */ AdaptiveLruPage:: ~AdaptiveLruPage() { - if (_lru != NULL) { + if (_lru != nullptr) { dequeue_lru(); } } @@ -535,7 +533,7 @@ write(ostream &out, int indent_level) const { */ unsigned int AdaptiveLruPage:: get_num_frames() const { - if (_lru == (AdaptiveLru *)NULL) { + if (_lru == nullptr) { return 0; } return _lru->_current_frame_identifier - _first_frame_identifier; @@ -547,7 +545,7 @@ get_num_frames() const { */ unsigned int AdaptiveLruPage:: get_num_inactive_frames() const { - if (_lru == (AdaptiveLru *)NULL) { + if (_lru == nullptr) { return 0; } return _lru->_current_frame_identifier - _current_frame_identifier; diff --git a/panda/src/gobj/adaptiveLru.h b/panda/src/gobj/adaptiveLru.h index 99b78b482d..4729f63f2c 100644 --- a/panda/src/gobj/adaptiveLru.h +++ b/panda/src/gobj/adaptiveLru.h @@ -172,7 +172,6 @@ private: int _current_frame_usage; int _last_frame_usage; - int _total_usage; int _update_total_usage; PN_stdfloat _average_frame_utilization; diff --git a/panda/src/gobj/animateVerticesRequest.h b/panda/src/gobj/animateVerticesRequest.h index be20651a13..0d804a927d 100644 --- a/panda/src/gobj/animateVerticesRequest.h +++ b/panda/src/gobj/animateVerticesRequest.h @@ -30,7 +30,7 @@ * requests are being run (presumably on multiple CPUs/cores), to ensure that * the data has been computed by the time it's needed. */ -class EXPCL_PANDA_PGRAPH AnimateVerticesRequest : public AsyncTask { +class EXPCL_PANDA_GOBJ AnimateVerticesRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(AnimateVerticesRequest); diff --git a/panda/src/gobj/bufferContext.I b/panda/src/gobj/bufferContext.I index 978e3b73da..3c34d93a8a 100644 --- a/panda/src/gobj/bufferContext.I +++ b/panda/src/gobj/bufferContext.I @@ -85,9 +85,9 @@ set_resident(bool flag) { */ INLINE BufferContext *BufferContext:: get_next() const { - nassertr(_owning_chain != (BufferContextChain *)NULL, NULL); + nassertr(_owning_chain != nullptr, nullptr); if ((BufferContextChain *)_next == _owning_chain) { - return NULL; + return nullptr; } return (BufferContext *)_next; } @@ -98,7 +98,7 @@ get_next() const { */ INLINE void BufferContext:: update_data_size_bytes(size_t new_data_size_bytes) { - if (_owning_chain != (BufferContextChain *)NULL) { + if (_owning_chain != nullptr) { _owning_chain->adjust_bytes((int)new_data_size_bytes - (int)_data_size_bytes); } _data_size_bytes = new_data_size_bytes; diff --git a/panda/src/gobj/bufferContext.cxx b/panda/src/gobj/bufferContext.cxx index b8d7ed4ba8..52cac06ce4 100644 --- a/panda/src/gobj/bufferContext.cxx +++ b/panda/src/gobj/bufferContext.cxx @@ -23,7 +23,7 @@ BufferContext(BufferResidencyTracker *residency) : _residency(residency), _residency_state(0), _data_size_bytes(0), - _owning_chain(NULL) + _owning_chain(nullptr) { set_owning_chain(&residency->_chains[0]); } @@ -33,7 +33,7 @@ BufferContext(BufferResidencyTracker *residency) : */ BufferContext:: ~BufferContext() { - set_owning_chain(NULL); + set_owning_chain(nullptr); } /** @@ -42,7 +42,7 @@ BufferContext:: void BufferContext:: set_owning_chain(BufferContextChain *chain) { if (chain != _owning_chain) { - if (_owning_chain != (BufferContextChain *)NULL){ + if (_owning_chain != nullptr){ --(_owning_chain->_count); _owning_chain->adjust_bytes(-(int)_data_size_bytes); remove_from_list(); @@ -50,7 +50,7 @@ set_owning_chain(BufferContextChain *chain) { _owning_chain = chain; - if (_owning_chain != (BufferContextChain *)NULL) { + if (_owning_chain != nullptr) { ++(_owning_chain->_count); _owning_chain->adjust_bytes((int)_data_size_bytes); insert_before(_owning_chain); diff --git a/panda/src/gobj/bufferContextChain.cxx b/panda/src/gobj/bufferContextChain.cxx index a5f9d782b5..9a94ff2919 100644 --- a/panda/src/gobj/bufferContextChain.cxx +++ b/panda/src/gobj/bufferContextChain.cxx @@ -25,7 +25,7 @@ get_first() { // This method is declared non-inline so we can include bufferContext.h, // which is necessary for proper downcasting of the _next pointer. if (_next == this) { - return NULL; + return nullptr; } return (BufferContext *)_next; } diff --git a/panda/src/gobj/bufferResidencyTracker.cxx b/panda/src/gobj/bufferResidencyTracker.cxx index 00f0a4e5be..abb51610e6 100644 --- a/panda/src/gobj/bufferResidencyTracker.cxx +++ b/panda/src/gobj/bufferResidencyTracker.cxx @@ -118,7 +118,7 @@ write(ostream &out, int indent_level) const { void BufferResidencyTracker:: move_inactive(BufferContextChain &inactive, BufferContextChain &active) { BufferContext *node = active.get_first(); - while (node != (BufferContext *)NULL) { + while (node != nullptr) { nassertv((node->_residency_state & S_active) != 0); node->_residency_state &= ~S_active; node = node->get_next(); diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 0f504f4dac..81a545d6b6 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -98,7 +98,7 @@ INLINE PT(GeomPrimitive) Geom:: modify_primitive(size_t i) { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true, current_thread); - nassertr(i < cdata->_primitives.size(), NULL); + nassertr(i < cdata->_primitives.size(), nullptr); cdata->_modified = Geom::get_next_modified(); clear_cache_stage(current_thread); return cdata->_primitives[i].get_write_pointer(); @@ -285,8 +285,8 @@ get_bounds_type() const { INLINE void Geom:: set_bounds(const BoundingVolume *volume) { CDWriter cdata(_cycler, true); - if (volume == NULL) { - cdata->_user_bounds = NULL; + if (volume == nullptr) { + cdata->_user_bounds = nullptr; } else { cdata->_user_bounds = volume->make_copy(); } @@ -303,7 +303,7 @@ set_bounds(const BoundingVolume *volume) { INLINE void Geom:: clear_bounds() { CDWriter cdata(_cycler, true); - cdata->_user_bounds = NULL; + cdata->_user_bounds = nullptr; mark_internal_bounds_stale(cdata); } @@ -385,9 +385,9 @@ mark_internal_bounds_stale(CData *cdata) { */ INLINE Geom::CDataCache:: CDataCache() : - _source(NULL), - _geom_result(NULL), - _data_result(NULL) + _source(nullptr), + _geom_result(nullptr), + _data_result(nullptr) { } @@ -400,7 +400,7 @@ CDataCache(const Geom::CDataCache ©) : _geom_result(copy._geom_result), _data_result(copy._data_result) { - if (_geom_result != _source && _geom_result != (Geom *)NULL) { + if (_geom_result != _source && _geom_result != nullptr) { _geom_result->ref(); } } @@ -412,11 +412,11 @@ CDataCache(const Geom::CDataCache ©) : INLINE void Geom::CDataCache:: set_result(const Geom *geom_result, const GeomVertexData *data_result) { if (geom_result != _geom_result) { - if (_geom_result != _source && _geom_result != (Geom *)NULL) { + if (_geom_result != _source && _geom_result != nullptr) { unref_delete(_geom_result); } _geom_result = geom_result; - if (_geom_result != _source && _geom_result != (Geom *)NULL) { + if (_geom_result != _source && _geom_result != nullptr) { _geom_result->ref(); } } @@ -577,8 +577,8 @@ INLINE GeomPipelineReader:: #endif // DO_PIPELINING #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -591,7 +591,7 @@ set_object(const Geom *object) { // _object->_cycler.release_read(_cdata); #ifdef DO_PIPELINING - if (_cdata != NULL) { + if (_cdata != nullptr) { unref_delete((CycleData *)_cdata); } #endif // DO_PIPELINING @@ -667,7 +667,7 @@ get_num_primitives() const { */ INLINE CPT(GeomPrimitive) GeomPipelineReader:: get_primitive(int i) const { - nassertr(i >= 0 && i < (int)_cdata->_primitives.size(), NULL); + nassertr(i >= 0 && i < (int)_cdata->_primitives.size(), nullptr); return _cdata->_primitives[i].get_read_pointer(); } diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 26dd3c942c..0c627d6e5b 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -301,7 +301,7 @@ set_primitive(size_t i, const GeomPrimitive *primitive) { // They also should have a compatible shade model. CPT(GeomPrimitive) compat = primitive->match_shade_model(cdata->_shade_model); - nassertv_always(compat != (GeomPrimitive *)NULL); + nassertv_always(compat != nullptr); cdata->_primitives[i] = (GeomPrimitive *)compat.p(); PrimitiveType new_primitive_type = compat->get_primitive_type(); @@ -1030,7 +1030,7 @@ check_valid(const GeomVertexData *vertex_data) const { CPT(BoundingVolume) Geom:: get_bounds(Thread *current_thread) const { CDLockedReader cdata(_cycler, current_thread); - if (cdata->_user_bounds != (BoundingVolume *)NULL) { + if (cdata->_user_bounds != nullptr) { return cdata->_user_bounds; } @@ -1133,7 +1133,7 @@ clear_cache_stage(Thread *current_thread) { ++ci) { CacheEntry *entry = (*ci).second; CDCacheWriter cdata(entry->_cycler, current_thread); - cdata->set_result(NULL, NULL); + cdata->set_result(nullptr, nullptr); } } @@ -1231,7 +1231,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } GeomContext *gc = prepared_objects->prepare_geom_now(this, gsg); - if (gc != (GeomContext *)NULL) { + if (gc != nullptr) { _contexts[prepared_objects] = gc; } return gc; @@ -1597,7 +1597,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { */ TypedWritable *Geom:: make_from_bam(const FactoryParams ¶ms) { - Geom *object = new Geom(NULL); + Geom *object = new Geom(nullptr); DatagramIterator scan; BamReader *manager; @@ -1644,7 +1644,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { */ Geom::CDataCache:: ~CDataCache() { - set_result(NULL, NULL); + set_result(nullptr, nullptr); } /** @@ -1740,7 +1740,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _primitives.reserve(num_primitives); for (int i = 0; i < num_primitives; ++i) { manager->read_pointer(scan); - _primitives.push_back(NULL); + _primitives.push_back(nullptr); } _primitive_type = (PrimitiveType)scan.get_uint8(); diff --git a/panda/src/gobj/geomCacheEntry.I b/panda/src/gobj/geomCacheEntry.I index 9c7987d855..6d9f2dd2cc 100644 --- a/panda/src/gobj/geomCacheEntry.I +++ b/panda/src/gobj/geomCacheEntry.I @@ -17,8 +17,8 @@ INLINE GeomCacheEntry:: GeomCacheEntry() { #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -31,8 +31,8 @@ remove_from_list() { _prev->_next = _next; _next->_prev = _prev; #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -43,8 +43,8 @@ remove_from_list() { INLINE void GeomCacheEntry:: insert_before(GeomCacheEntry *node) { nassertv(node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (GeomCacheEntry *)NULL && - _next == (GeomCacheEntry *)NULL); + nassertv(_prev == nullptr && + _next == nullptr); _prev = node->_prev; _next = node; _prev->_next = this; diff --git a/panda/src/gobj/geomCacheEntry.cxx b/panda/src/gobj/geomCacheEntry.cxx index d16a7f6a08..608ebbdac4 100644 --- a/panda/src/gobj/geomCacheEntry.cxx +++ b/panda/src/gobj/geomCacheEntry.cxx @@ -31,7 +31,7 @@ GeomCacheEntry:: */ PT(GeomCacheEntry) GeomCacheEntry:: record(Thread *current_thread) { - nassertr(_next == (GeomCacheEntry *)NULL && _prev == (GeomCacheEntry *)NULL, NULL); + nassertr(_next == nullptr && _prev == nullptr, nullptr); PT(GeomCacheEntry) keepme = this; GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); @@ -72,7 +72,7 @@ void GeomCacheEntry:: refresh(Thread *current_thread) { GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); LightMutexHolder holder(cache_mgr->_lock); - nassertv(_next != (GeomCacheEntry *)NULL && _prev != (GeomCacheEntry *)NULL); + nassertv(_next != nullptr && _prev != nullptr); remove_from_list(); insert_before(cache_mgr->_list); @@ -93,7 +93,7 @@ refresh(Thread *current_thread) { */ PT(GeomCacheEntry) GeomCacheEntry:: erase() { - nassertr(_next != (GeomCacheEntry *)NULL && _prev != (GeomCacheEntry *)NULL, NULL); + nassertr(_next != nullptr && _prev != nullptr, nullptr); PT(GeomCacheEntry) keepme; keepme.cheat() = this; diff --git a/panda/src/gobj/geomCacheManager.cxx b/panda/src/gobj/geomCacheManager.cxx index b0d2624a2d..7fef373373 100644 --- a/panda/src/gobj/geomCacheManager.cxx +++ b/panda/src/gobj/geomCacheManager.cxx @@ -16,7 +16,7 @@ #include "lightMutexHolder.h" #include "clockObject.h" -GeomCacheManager *GeomCacheManager::_global_ptr = NULL; +GeomCacheManager *GeomCacheManager::_global_ptr = nullptr; PStatCollector GeomCacheManager::_geom_cache_size_pcollector("Geom cache size"); PStatCollector GeomCacheManager::_geom_cache_active_pcollector("Geom cache size:Active"); @@ -62,7 +62,7 @@ flush() { */ GeomCacheManager *GeomCacheManager:: get_global_ptr() { - if (_global_ptr == (GeomCacheManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GeomCacheManager; } return _global_ptr; diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index 20c9aa198b..dee3c89ccf 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -182,7 +182,7 @@ rotate_impl() const { to.set_data1i(from.get_data1i()); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -194,7 +194,7 @@ rotate_impl() const { to.set_data1i(begin + first_vertex); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index 8a3365a201..0b54de3410 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -231,7 +231,7 @@ decompose_impl() const { } ++li; } - nassertr(vi == get_num_vertices(), NULL); + nassertr(vi == get_num_vertices(), nullptr); return lines.p(); } @@ -262,7 +262,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -279,7 +279,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; } diff --git a/panda/src/gobj/geomMunger.I b/panda/src/gobj/geomMunger.I index 8cbd51aa91..f1c28bb451 100644 --- a/panda/src/gobj/geomMunger.I +++ b/panda/src/gobj/geomMunger.I @@ -177,7 +177,7 @@ unregister_myself() { */ INLINE GeomMunger::Registry *GeomMunger:: get_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { make_registry(); } return _registry; diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index bbbc9e3522..83d57467c1 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -18,7 +18,7 @@ #include "lightReMutexHolder.h" #include "pStatTimer.h" -GeomMunger::Registry *GeomMunger::_registry = NULL; +GeomMunger::Registry *GeomMunger::_registry = nullptr; TypeHandle GeomMunger::_type_handle; PStatCollector GeomMunger::_munge_pcollector("*:Munge"); @@ -116,7 +116,7 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, // Now check that it's fresh. Geom::CDCacheReader cdata(entry->_cycler, current_thread); if (cdata->_source == geom && - cdata->_geom_result != (Geom *)NULL && + cdata->_geom_result != nullptr && geom->get_modified(current_thread) <= cdata->_geom_result->get_modified(current_thread) && data->get_modified(current_thread) <= cdata->_data_result->get_modified(current_thread)) { // The cache entry is still good; use it. @@ -145,7 +145,7 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, munge_geom_impl(geom, data, current_thread); // Record the new result in the cache. - if (entry == (Geom::CacheEntry *)NULL) { + if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. entry = new Geom::CacheEntry(orig_geom, move(key)); @@ -179,8 +179,8 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, CPT(GeomVertexFormat) GeomMunger:: do_munge_format(const GeomVertexFormat *format, const GeomVertexAnimationSpec &animation) { - nassertr(_is_registered, NULL); - nassertr(format->is_registered(), NULL); + nassertr(_is_registered, nullptr); + nassertr(format->is_registered(), nullptr); LightMutexHolder holder(_formats_lock); @@ -195,11 +195,11 @@ do_munge_format(const GeomVertexFormat *format, // We have to munge this format for the first time. CPT(GeomVertexFormat) derived_format = munge_format_impl(format, animation); - nassertr(derived_format->is_registered(), NULL); + nassertr(derived_format->is_registered(), nullptr); // Store the answer in the map, so we can quickly get it next time. bool inserted = formats.insert(Formats::value_type(format, derived_format)).second; - nassertr(inserted, NULL); + nassertr(inserted, nullptr); return derived_format; } @@ -218,7 +218,7 @@ munge_format_impl(const GeomVertexFormat *orig, const GeomVertexAnimationSpec &) */ CPT(GeomVertexData) GeomMunger:: munge_data_impl(const GeomVertexData *data) { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); CPT(GeomVertexFormat) orig_format = data->get_format(); CPT(GeomVertexFormat) new_format = @@ -247,8 +247,8 @@ munge_geom_impl(CPT(Geom) &, CPT(GeomVertexData) &, Thread *) { */ CPT(GeomVertexFormat) GeomMunger:: do_premunge_format(const GeomVertexFormat *format) { - nassertr(_is_registered, NULL); - nassertr(format->is_registered(), NULL); + nassertr(_is_registered, nullptr); + nassertr(format->is_registered(), nullptr); LightMutexHolder holder(_formats_lock); @@ -261,11 +261,11 @@ do_premunge_format(const GeomVertexFormat *format) { // We have to munge this format for the first time. CPT(GeomVertexFormat) derived_format = premunge_format_impl(format); - nassertr(derived_format->is_registered(), NULL); + nassertr(derived_format->is_registered(), nullptr); // Store the answer in the map, so we can quickly get it next time. bool inserted = _premunge_formats.insert(Formats::value_type(format, derived_format)).second; - nassertr(inserted, NULL); + nassertr(inserted, nullptr); return derived_format; } @@ -284,7 +284,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { */ CPT(GeomVertexData) GeomMunger:: premunge_data_impl(const GeomVertexData *data) { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); CPT(GeomVertexFormat) orig_format = data->get_format(); CPT(GeomVertexFormat) new_format = premunge_format(orig_format); @@ -332,7 +332,7 @@ geom_compare_to_impl(const GeomMunger *other) const { */ void GeomMunger:: make_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { _registry = new Registry; } } diff --git a/panda/src/gobj/geomPrimitive.I b/panda/src/gobj/geomPrimitive.I index 9863701e21..061a49c527 100644 --- a/panda/src/gobj/geomPrimitive.I +++ b/panda/src/gobj/geomPrimitive.I @@ -450,7 +450,7 @@ GeomPrimitivePipelineReader(CPT(GeomPrimitive) object, #ifndef CPPPARSER _cdata(_object->_cycler.read_unlocked(current_thread)), #endif - _vertices_cdata(NULL) + _vertices_cdata(nullptr) { nassertv(_object->test_ref_count_nonzero()); #ifdef DO_PIPELINING @@ -494,8 +494,8 @@ INLINE GeomPrimitivePipelineReader:: } #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -635,8 +635,8 @@ get_ends() const { */ INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader:: get_mins() const { - nassertr(is_indexed(), NULL); - nassertr(_cdata->_got_minmax, NULL); + nassertr(is_indexed(), nullptr); + nassertr(_cdata->_got_minmax, nullptr); return _cdata->_mins.get_read_pointer(); } @@ -645,8 +645,8 @@ get_mins() const { */ INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader:: get_maxs() const { - nassertr(is_indexed(), NULL); - nassertr(_cdata->_got_minmax, NULL); + nassertr(is_indexed(), nullptr); + nassertr(_cdata->_got_minmax, nullptr); return _cdata->_maxs.get_read_pointer(); } diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index b85747a945..db939d3bef 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -789,7 +789,7 @@ rotate() const { PStatTimer timer(_rotate_pcollector); CPT(GeomVertexArrayData) rotated_vertices = rotate_impl(); - if (rotated_vertices == (GeomVertexArrayData *)NULL) { + if (rotated_vertices == nullptr) { // This primitive type can't be rotated. return this; } @@ -882,13 +882,13 @@ match_shade_model(GeomPrimitive::ShadeModel shade_model) const { CPT(GeomPrimitive) rotated = rotate(); if (rotated.p() == this) { // Oops, can't be rotated, sorry. - return NULL; + return nullptr; } return rotated; } // Not compatible, sorry. - return NULL; + return nullptr; } /** @@ -1195,7 +1195,7 @@ void GeomPrimitive:: set_nonindexed_vertices(int first_vertex, int num_vertices) { nassertv(num_vertices != -1); CDWriter cdata(_cycler, true); - cdata->_vertices = (GeomVertexArrayData *)NULL; + cdata->_vertices = nullptr; cdata->_first_vertex = first_vertex; cdata->_num_vertices = num_vertices; @@ -1391,7 +1391,7 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { IndexBufferContext *GeomPrimitive:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - nassertr(is_indexed(), NULL); + nassertr(is_indexed(), nullptr); Contexts::const_iterator ci; ci = _contexts.find(prepared_objects); @@ -1400,7 +1400,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } IndexBufferContext *ibc = prepared_objects->prepare_index_buffer_now(this, gsg); - if (ibc != (IndexBufferContext *)NULL) { + if (ibc != nullptr) { _contexts[prepared_objects] = ibc; } return ibc; @@ -1460,24 +1460,24 @@ get_index_format(NumericType index_type) { switch (index_type) { case NT_uint8: { - static CPT(GeomVertexArrayFormat) cformat = NULL; - if (cformat == NULL) { + static CPT(GeomVertexArrayFormat) cformat = nullptr; + if (cformat == nullptr) { cformat = make_index_format(NT_uint8); } return cformat; } case NT_uint16: { - static CPT(GeomVertexArrayFormat) cformat = NULL; - if (cformat == NULL) { + static CPT(GeomVertexArrayFormat) cformat = nullptr; + if (cformat == nullptr) { cformat = make_index_format(NT_uint16); } return cformat; } case NT_uint32: { - static CPT(GeomVertexArrayFormat) cformat = NULL; - if (cformat == NULL) { + static CPT(GeomVertexArrayFormat) cformat = nullptr; + if (cformat == nullptr) { cformat = make_index_format(NT_uint32); } return cformat; @@ -1486,10 +1486,10 @@ get_index_format(NumericType index_type) { default: gobj_cat.error() << "Not a valid index type: " << index_type << "\n"; - return NULL; + return nullptr; } - return NULL; + return nullptr; } /** @@ -1791,8 +1791,8 @@ decompose_impl() const { CPT(GeomVertexArrayData) GeomPrimitive:: rotate_impl() const { // The default implementation doesn't even try to do anything. - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** @@ -2074,7 +2074,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { void GeomPrimitive:: finalize(BamReader *manager) { const GeomVertexArrayData *vertices = get_vertices(); - if (vertices != (GeomVertexArrayData *)NULL) { + if (vertices != nullptr) { set_usage_hint(vertices->get_usage_hint()); } } diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index a6e3b9480f..494f59be74 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -73,6 +73,8 @@ get_primitive_type() const { */ CPT(GeomPrimitive) GeomTriangles:: make_adjacency() const { + using std::make_pair; + Thread *current_thread = Thread::get_current_thread(); PT(GeomTrianglesAdjacency) adj = new GeomTrianglesAdjacency(get_usage_hint()); @@ -281,7 +283,7 @@ rotate_impl() const { nassertr(false, vertices); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -313,10 +315,10 @@ rotate_impl() const { default: // This shouldn't get called with any other shade model. - nassertr(false, NULL); + nassertr(false, nullptr); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; diff --git a/panda/src/gobj/geomTrifans.cxx b/panda/src/gobj/geomTrifans.cxx index 3808da40bb..0c5d87f53a 100644 --- a/panda/src/gobj/geomTrifans.cxx +++ b/panda/src/gobj/geomTrifans.cxx @@ -127,7 +127,7 @@ decompose_impl() const { ++li; } - nassertr(vi == num_vertices, NULL); + nassertr(vi == num_vertices, nullptr); return triangles.p(); } @@ -139,8 +139,8 @@ CPT(GeomVertexArrayData) GeomTrifans:: rotate_impl() const { // Actually, we can't rotate fans without chaging the winding order. It's // an error to define a flat shade model for a GeomTrifan. - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index ae7bf0bc25..7c8eff61f9 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -87,6 +87,8 @@ get_geom_rendering() const { */ CPT(GeomPrimitive) GeomTristrips:: make_adjacency() const { + using std::make_pair; + Thread *current_thread = Thread::get_current_thread(); PT(GeomTristripsAdjacency) adj = new GeomTristripsAdjacency(get_usage_hint()); CPTA_int ends = get_ends(); @@ -278,7 +280,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 2 <= end, NULL); + nassertr(vi + 2 <= end, nullptr); int v0 = get_vertex(vi); ++vi; int v1 = get_vertex(vi); @@ -309,7 +311,7 @@ decompose_impl() const { } ++li; } - nassertr(vi == num_vertices, NULL); + nassertr(vi == num_vertices, nullptr); } else { // Preserve the last vertex of each component triangle as the last vertex @@ -320,7 +322,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 2 <= end, NULL); + nassertr(vi + 2 <= end, nullptr); int v0 = get_vertex(vi); ++vi; int v1 = get_vertex(vi); @@ -351,7 +353,7 @@ decompose_impl() const { } ++li; } - nassertr(vi == num_vertices, NULL); + nassertr(vi == num_vertices, nullptr); } return triangles.p(); @@ -414,7 +416,7 @@ rotate_impl() const { // If this assertion is triggered, there was a triangle strip with an // odd number of vertices, which is not allowed. - nassertr((num_vertices & 1) == 0, NULL); + nassertr((num_vertices & 1) == 0, nullptr); for (int vi = end - 1; vi >= begin; --vi) { from.set_row_unsafe(vi); last_added = from.get_data1i(); @@ -424,7 +426,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -447,7 +449,7 @@ rotate_impl() const { // If this assertion is triggered, there was a triangle strip with an // odd number of vertices, which is not allowed. - nassertr((num_vertices & 1) == 0, NULL); + nassertr((num_vertices & 1) == 0, nullptr); for (int vi = end - 1; vi >= begin; --vi) { last_added = vi + first_vertex; to.set_data1i(last_added); @@ -456,7 +458,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; } diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index a9005fde12..a4b3f51397 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -393,8 +393,8 @@ INLINE GeomVertexArrayDataHandle:: #endif // DO_PIPELINING #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -493,7 +493,7 @@ get_modified() const { */ INLINE bool GeomVertexArrayDataHandle:: request_resident() const { - return (get_read_pointer(false) != (const unsigned char *)NULL); + return (get_read_pointer(false) != nullptr); } /** diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index 50a4529159..9b4803d3bf 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -57,7 +57,7 @@ ALLOC_DELETED_CHAIN_DEF(GeomVertexArrayDataHandle); */ GeomVertexArrayData:: GeomVertexArrayData() : SimpleLruPage(0) { - _contexts = NULL; + _contexts = nullptr; // Can't put it in the LRU until it has been read in and made valid. } @@ -207,7 +207,7 @@ prepare(PreparedGraphicsObjects *prepared_objects) { */ bool GeomVertexArrayData:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { return false; } Contexts::const_iterator ci; @@ -232,7 +232,7 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { VertexBufferContext *GeomVertexArrayData:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { _contexts = new Contexts; } Contexts::const_iterator ci; @@ -242,7 +242,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } VertexBufferContext *vbc = prepared_objects->prepare_vertex_buffer_now(this, gsg); - if (vbc != (VertexBufferContext *)NULL) { + if (vbc != nullptr) { (*_contexts)[prepared_objects] = vbc; } return vbc; @@ -254,7 +254,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, */ bool GeomVertexArrayData:: release(PreparedGraphicsObjects *prepared_objects) { - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { Contexts::iterator ci; ci = _contexts->find(prepared_objects); if (ci != _contexts->end()) { @@ -276,7 +276,7 @@ int GeomVertexArrayData:: release_all() { int num_freed = 0; - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { // We have to traverse a copy of the _contexts list, because the // PreparedGraphicsObjects object will call clear_prepared() in response // to each release_vertex_buffer(), and we don't want to be modifying the @@ -293,7 +293,7 @@ release_all() { // Now that we've called release_vertex_buffer() on every known context, // the _contexts list should have completely emptied itself. - nassertr(_contexts == NULL, num_freed); + nassertr(_contexts == nullptr, num_freed); } return num_freed; @@ -335,7 +335,7 @@ evict_lru() { */ void GeomVertexArrayData:: clear_prepared(PreparedGraphicsObjects *prepared_objects) { - nassertv(_contexts != (Contexts *)NULL); + nassertv(_contexts != nullptr); Contexts::iterator ci; ci = _contexts->find(prepared_objects); @@ -343,7 +343,7 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { _contexts->erase(ci); if (_contexts->empty()) { delete _contexts; - _contexts = NULL; + _contexts = nullptr; } } else { // If this assertion fails, clear_prepared() was given a prepared_objects @@ -457,7 +457,7 @@ finalize(BamReader *manager) { _array_format = new_array_format; PT(BamAuxData) aux_data = (BamAuxData *)manager->get_aux_data(this, ""); - if (aux_data != (BamAuxData *)NULL) { + if (aux_data != nullptr) { if (aux_data->_endian_reversed) { // Now is the time to endian-reverse the data. VertexDataBuffer new_buffer(cdata->_buffer.get_size()); @@ -571,7 +571,7 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { if (manager->get_file_endian() != BamReader::BE_native) { // For non-native endian files, we have to convert the data. - if (array_data->_array_format == (GeomVertexArrayFormat *)NULL) { + if (array_data->_array_format == nullptr) { // But we can't do that until we've completed the _array_format pointer, // which tells us how to convert it. endian_reversed = true; @@ -600,7 +600,7 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { */ unsigned char *GeomVertexArrayDataHandle:: get_write_pointer() { - nassertr(_writable, NULL); + nassertr(_writable, nullptr); mark_used(); _cdata->_modified = Geom::get_next_modified(); return _cdata->_buffer.get_write_pointer(); diff --git a/panda/src/gobj/geomVertexArrayData_ext.cxx b/panda/src/gobj/geomVertexArrayData_ext.cxx index 72b206c469..f35d96ae3a 100644 --- a/panda/src/gobj/geomVertexArrayData_ext.cxx +++ b/panda/src/gobj/geomVertexArrayData_ext.cxx @@ -54,7 +54,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { view->internal = (void*) data; - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -62,20 +62,20 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { view->len = row_size * handle->get_num_rows(); view->readonly = 0; view->itemsize = row_size; - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) data->_format.c_str(); } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { view->shape = &data->_num_rows; } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &data->_stride; } - view->suboffsets = NULL; + view->suboffsets = nullptr; return 0; #else @@ -120,7 +120,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->internal = (void*) data; - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -128,20 +128,20 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->len = row_size * handle->get_num_rows(); view->readonly = 1; view->itemsize = row_size; - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) data->_format.c_str(); } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { view->shape = &data->_num_rows; } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &data->_stride; } - view->suboffsets = NULL; + view->suboffsets = nullptr; return 0; #else @@ -158,11 +158,11 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const { // Note: PyBuffer_Release automatically decrements view->obj. InternalBufferData *data; data = (InternalBufferData *) view->internal; - if (data == NULL) { + if (data == nullptr) { return; } delete data; - view->internal = NULL; + view->internal = nullptr; #endif } diff --git a/panda/src/gobj/geomVertexArrayFormat.I b/panda/src/gobj/geomVertexArrayFormat.I index 1765b0fcc4..94e62b109b 100644 --- a/panda/src/gobj/geomVertexArrayFormat.I +++ b/panda/src/gobj/geomVertexArrayFormat.I @@ -126,7 +126,7 @@ get_num_columns() const { */ INLINE const GeomVertexColumn *GeomVertexArrayFormat:: get_column(int i) const { - nassertr(i >= 0 && i < (int)_columns.size(), NULL); + nassertr(i >= 0 && i < (int)_columns.size(), nullptr); consider_sort_columns(); return _columns[(size_t)i]; } @@ -136,7 +136,7 @@ get_column(int i) const { */ INLINE bool GeomVertexArrayFormat:: has_column(const InternalName *name) const { - return (get_column(name) != (GeomVertexColumn *)NULL); + return (get_column(name) != nullptr); } /** @@ -144,7 +144,7 @@ has_column(const InternalName *name) const { */ INLINE GeomVertexArrayFormat::Registry *GeomVertexArrayFormat:: get_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { make_registry(); } return _registry; diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index c8adfa81eb..9e0d35cccd 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -21,7 +21,7 @@ #include "indirectLess.h" #include "lightMutexHolder.h" -GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = NULL; +GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = nullptr; TypeHandle GeomVertexArrayFormat::_type_handle; /** @@ -243,7 +243,7 @@ add_column(const GeomVertexColumn &column) { // Also make sure there aren't any columns that overlap with this one. const GeomVertexColumn *orig_column = get_column(column.get_start(), column.get_total_bytes()); - while (orig_column != (const GeomVertexColumn *)NULL) { + while (orig_column != nullptr) { remove_column(orig_column->get_name()); orig_column = get_column(column.get_start(), column.get_total_bytes()); } @@ -381,7 +381,7 @@ get_column(const InternalName *name) const { if (ni != _columns_by_name.end()) { return (*ni).second; } - return NULL; + return nullptr; } /** @@ -399,7 +399,7 @@ get_column(int start_byte, int num_bytes) const { } } - return NULL; + return nullptr; } /** @@ -603,7 +603,7 @@ get_format_string(bool pad) const { default: gobj_cat.error() << "Unknown numeric type " << column->get_numeric_type() << "!\n"; - return NULL; + return nullptr; } memset((void*) (fmt + fi), fmt_code, column->get_num_components()); offset += column->get_total_bytes(); @@ -667,7 +667,7 @@ sort_columns() { */ void GeomVertexArrayFormat:: make_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { _registry = new Registry; } } diff --git a/panda/src/gobj/geomVertexColumn.I b/panda/src/gobj/geomVertexColumn.I index 262c19c3a2..c9e4a2fb8a 100644 --- a/panda/src/gobj/geomVertexColumn.I +++ b/panda/src/gobj/geomVertexColumn.I @@ -16,7 +16,7 @@ */ INLINE GeomVertexColumn:: GeomVertexColumn() : - _packer(NULL) + _packer(nullptr) { } @@ -36,7 +36,7 @@ GeomVertexColumn(CPT_InternalName name, int num_components, _column_alignment(column_alignment), _num_elements(num_elements), _element_stride(element_stride), - _packer(NULL) + _packer(nullptr) { setup(); } @@ -54,7 +54,7 @@ GeomVertexColumn(const GeomVertexColumn ©) : _column_alignment(copy._column_alignment), _num_elements(copy._num_elements), _element_stride(copy._element_stride), - _packer(NULL) + _packer(nullptr) { setup(); } diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index 3227eb7b42..b43930d3b5 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -225,7 +225,7 @@ setup() { } _total_bytes = _element_stride * _num_elements; - if (_packer != NULL) { + if (_packer != nullptr) { delete _packer; } @@ -3869,9 +3869,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { { LVecBase3f scaled = data * 4294967295.0f; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; } break; @@ -3960,10 +3960,10 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { { LVecBase4f scaled = data * 4294967295.0f; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; - pi[3] = (unsigned int)data[3]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; + pi[3] = (unsigned int)scaled[3]; } break; @@ -4072,9 +4072,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { { LVecBase3d scaled = data * 4294967295.0; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; } break; @@ -4163,10 +4163,10 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { { LVecBase4d scaled = data * 4294967295.0; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; - pi[3] = (unsigned int)data[3]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; + pi[3] = (unsigned int)scaled[3]; } break; diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index 849a3548f3..6575397fa2 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -220,7 +220,7 @@ get_transform_table() const { */ INLINE void GeomVertexData:: clear_transform_table() { - set_transform_table(NULL); + set_transform_table(nullptr); } /** @@ -245,7 +245,7 @@ get_transform_blend_table() const { */ INLINE void GeomVertexData:: clear_transform_blend_table() { - set_transform_blend_table(NULL); + set_transform_blend_table(nullptr); } /** @@ -268,7 +268,7 @@ get_slider_table() const { */ INLINE void GeomVertexData:: clear_slider_table() { - set_slider_table(NULL); + set_slider_table(nullptr); } /** @@ -637,8 +637,8 @@ INLINE GeomVertexDataPipelineBase:: #endif // DO_PIPELINING #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -687,7 +687,7 @@ get_num_arrays() const { */ INLINE CPT(GeomVertexArrayData) GeomVertexDataPipelineBase:: get_array(int i) const { - nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), NULL); + nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), nullptr); return _cdata->_arrays[i].get_read_pointer(); } @@ -751,7 +751,7 @@ GeomVertexDataPipelineReader(const GeomVertexData *object, INLINE void GeomVertexDataPipelineReader:: set_object(const GeomVertexData *object) { #ifdef DO_PIPELINING - if (_cdata != NULL) { + if (_cdata != nullptr) { unref_delete((CycleData *)_cdata); } #endif // DO_PIPELINING @@ -787,8 +787,8 @@ check_array_readers() const { */ INLINE const GeomVertexArrayDataHandle *GeomVertexDataPipelineReader:: get_array_reader(int i) const { - nassertr(_got_array_readers, NULL); - nassertr(i >= 0 && i < (int)_array_readers.size(), NULL); + nassertr(_got_array_readers, nullptr); + nassertr(i >= 0 && i < (int)_array_readers.size(), nullptr); return _array_readers[i]; } @@ -797,7 +797,7 @@ get_array_reader(int i) const { */ INLINE bool GeomVertexDataPipelineReader:: has_vertex() const { - return (_cdata->_format->get_vertex_column() != (GeomVertexColumn *)NULL); + return (_cdata->_format->get_vertex_column() != nullptr); } /** @@ -806,7 +806,7 @@ has_vertex() const { INLINE bool GeomVertexDataPipelineReader:: is_vertex_transformed() const { const GeomVertexColumn *column = _cdata->_format->get_vertex_column(); - if (column != (GeomVertexColumn *)NULL) { + if (column != nullptr) { return column->get_contents() == C_clip_point; } @@ -818,7 +818,7 @@ is_vertex_transformed() const { */ INLINE bool GeomVertexDataPipelineReader:: has_normal() const { - return (_cdata->_format->get_normal_column() != (GeomVertexColumn *)NULL); + return (_cdata->_format->get_normal_column() != nullptr); } /** @@ -826,7 +826,7 @@ has_normal() const { */ INLINE bool GeomVertexDataPipelineReader:: has_color() const { - return (_cdata->_format->get_color_column() != (GeomVertexColumn *)NULL); + return (_cdata->_format->get_color_column() != nullptr); } /** @@ -837,7 +837,6 @@ GeomVertexDataPipelineWriter(GeomVertexData *object, bool force_to_0, Thread *current_thread) : GeomVertexDataPipelineBase(object, current_thread, object->_cycler.write_upstream(force_to_0, current_thread)), - _force_to_0(force_to_0), _got_array_writers(false) { #ifdef _DEBUG @@ -882,7 +881,7 @@ check_array_writers() const { */ INLINE GeomVertexArrayDataHandle *GeomVertexDataPipelineWriter:: get_array_writer(size_t i) const { - nassertr(_got_array_writers, NULL); + nassertr(_got_array_writers, nullptr); nassertr(i < _array_writers.size(), nullptr); return _array_writers[i]; } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 05992e5378..f2597614ef 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -89,7 +89,7 @@ GeomVertexData(const GeomVertexData ©) : OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); // It's important that we *not* copy the animated_vertices pointer. - cdata->_animated_vertices = NULL; + cdata->_animated_vertices = nullptr; cdata->_animated_vertices_modified = UpdateSeq(); } CLOSE_ITERATE_ALL_STAGES(_cycler); @@ -128,7 +128,7 @@ GeomVertexData(const GeomVertexData ©, } // It's important that we *not* copy the animated_vertices pointer. - cdata->_animated_vertices = NULL; + cdata->_animated_vertices = nullptr; cdata->_animated_vertices_modified = UpdateSeq(); } CLOSE_ITERATE_ALL_STAGES(_cycler); @@ -155,7 +155,7 @@ operator = (const GeomVertexData ©) { OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); cdata->_modified = Geom::get_next_modified(); - cdata->_animated_vertices = NULL; + cdata->_animated_vertices = nullptr; cdata->_animated_vertices_modified = UpdateSeq(); } CLOSE_ITERATE_ALL_STAGES(_cycler); @@ -367,7 +367,7 @@ clear_rows() { void GeomVertexData:: set_transform_table(const TransformTable *table) { Thread *current_thread = Thread::get_current_thread(); - nassertv(table == (TransformTable *)NULL || table->is_registered()); + nassertv(table == nullptr || table->is_registered()); CDWriter cdata(_cycler, true, current_thread); cdata->_transform_table = (TransformTable *)table; @@ -425,7 +425,7 @@ set_transform_blend_table(const TransformBlendTable *table) { */ void GeomVertexData:: set_slider_table(const SliderTable *table) { - nassertv(table == (SliderTable *)NULL || table->is_registered()); + nassertv(table == nullptr || table->is_registered()); CDWriter cdata(_cycler, true); cdata->_slider_table = (SliderTable *)table; @@ -540,7 +540,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, dest_format->get_array(dest_i); const GeomVertexColumn *dest_column = dest_array_format->get_column(source_column->get_name()); - nassertv(dest_column != (const GeomVertexColumn *)NULL); + nassertv(dest_column != nullptr); if (dest_column->is_bytewise_equivalent(*source_column)) { // We can do a quick bytewise copy. @@ -604,7 +604,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, // Convert Panda-style animation tables to hardware-style animation // tables. CPT(TransformBlendTable) blend_table = source->get_transform_blend_table(); - if (blend_table != (TransformBlendTable *)NULL) { + if (blend_table != nullptr) { PT(TransformTable) transform_table = new TransformTable; TransformMap already_added; @@ -725,14 +725,14 @@ convert_to(const GeomVertexFormat *new_format) const { } else { entry = (*ci).second; _cache_lock.release(); - nassertr(entry->_source == this, NULL); + nassertr(entry->_source == this, nullptr); // Here's an element in the cache for this computation. Record a cache // hit, so this element will stay in the cache a while longer. entry->refresh(current_thread); CDCacheReader cdata(entry->_cycler); - if (cdata->_result != (GeomVertexData *)NULL) { + if (cdata->_result != nullptr) { return cdata->_result; } @@ -758,7 +758,7 @@ convert_to(const GeomVertexFormat *new_format) const { new_data->copy_from(this, false); // Record the new result in the cache. - if (entry == (CacheEntry *)NULL) { + if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. entry = new CacheEntry((GeomVertexData *)this, move(key)); @@ -795,7 +795,7 @@ CPT(GeomVertexData) GeomVertexData:: scale_color(const LVecBase4 &color_scale) const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_color()); - if (old_column == (GeomVertexColumn *)NULL) { + if (old_column == nullptr) { return this; } @@ -866,7 +866,7 @@ CPT(GeomVertexData) GeomVertexData:: set_color(const LColor &color) const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_color()); - if (old_column == (GeomVertexColumn *)NULL) { + if (old_column == nullptr) { return this; } @@ -910,7 +910,7 @@ CPT(GeomVertexData) GeomVertexData:: reverse_normals() const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_normal()); - if (old_column == (GeomVertexColumn *)NULL) { + if (old_column == nullptr) { return this; } @@ -967,7 +967,7 @@ animate_vertices(bool force, Thread *current_thread) const { { PStatTimer timer2(((GeomVertexData *)this)->_blends_pcollector, current_thread); if (!cdata->_transform_blend_table.is_null()) { - if (cdata->_slider_table != (SliderTable *)NULL) { + if (cdata->_slider_table != nullptr) { modified = max(cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread), cdata->_slider_table->get_modified(current_thread)); @@ -975,7 +975,7 @@ animate_vertices(bool force, Thread *current_thread) const { modified = cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread); } - } else if (cdata->_slider_table != (SliderTable *)NULL) { + } else if (cdata->_slider_table != nullptr) { modified = cdata->_slider_table->get_modified(current_thread); } else { @@ -985,14 +985,14 @@ animate_vertices(bool force, Thread *current_thread) const { } if (cdata->_animated_vertices_modified == modified && - cdata->_animated_vertices != (GeomVertexData *)NULL) { + cdata->_animated_vertices != nullptr) { // No changes. return cdata->_animated_vertices; } if (!force && !request_resident()) { // The vertex data isn't resident. Return the best information we've got. - if (cdata->_animated_vertices != (GeomVertexData *)NULL) { + if (cdata->_animated_vertices != nullptr) { return cdata->_animated_vertices; } return this; @@ -1112,7 +1112,7 @@ do_set_color(GeomVertexData *vdata, const LColor &color) { size_t stride = format->get_array(array_index)->get_stride(); GeomVertexColumn::Packer *packer = column->_packer; - nassertv(packer != NULL); + nassertv(packer != nullptr); // Pack into a buffer, which we will then copy. unsigned char buffer[32]; @@ -1284,7 +1284,7 @@ write(ostream &out, int indent_level) const { } get_format()->write_with_data(out, indent_level + 2, this); CPT(TransformBlendTable) table = get_transform_blend_table(); - if (table != (TransformBlendTable *)NULL) { + if (table != nullptr) { indent(out, indent_level) << "Transform blend table:\n"; table->write(out, indent_level + 2); @@ -1305,7 +1305,7 @@ describe_vertex(ostream &out, int row) const { reader.set_row_unsafe(row); const GeomVertexFormat *format = get_format(); - const TransformBlendTable *tb_table = NULL; + const TransformBlendTable *tb_table = nullptr; if (format->get_animation().get_animation_type() == AT_panda) { tb_table = get_transform_blend_table(); } @@ -1326,7 +1326,7 @@ describe_vertex(ostream &out, int row) const { out << "\n"; if (column->get_name() == InternalName::get_transform_blend() && - tb_table != NULL) { + tb_table != nullptr) { // This is an index into the transform blend table. Look up the index // and report the vertex weighting. reader.set_column(ai, column); @@ -1344,15 +1344,15 @@ describe_vertex(ostream &out, int row) const { for (int ai = 0; ai < num_arrays; ++ai) { const GeomVertexArrayData *array = get_array(ai); const GeomVertexArrayFormat *aformat = format->get_array(ai); - nassertv(array != NULL && aformat != NULL); + nassertv(array != nullptr && aformat != nullptr); out << " " << *aformat << "\n"; CPT(GeomVertexArrayDataHandle) handle = array->get_handle(); - nassertv(handle != (const GeomVertexArrayDataHandle *)NULL); + nassertv(handle != nullptr); const unsigned char *data = handle->get_read_pointer(true); - nassertv(data != NULL); + nassertv(data != nullptr); int stride = aformat->get_stride(); int start = stride * row; - if (data != NULL) { + if (data != nullptr) { Datagram dg(data + start, stride); dg.dump_hex(out, 4); } @@ -1393,7 +1393,7 @@ clear_cache_stage() { ++ci) { CacheEntry *entry = (*ci).second; CDCacheWriter cdata(entry->_cycler); - cdata->_result = NULL; + cdata->_result = nullptr; } } @@ -1466,7 +1466,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { const GeomVertexFormat *orig_format = cdata->_format; CPT(GeomVertexFormat) new_format = orig_format; - if (cdata->_animated_vertices == (GeomVertexData *)NULL) { + if (cdata->_animated_vertices == nullptr) { new_format = orig_format->get_post_animated_format(); cdata->_animated_vertices = new GeomVertexData(get_name(), new_format, @@ -1482,7 +1482,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // First, apply all of the morphs. CPT(SliderTable) slider_table = cdata->_slider_table; - if (slider_table != (SliderTable *)NULL) { + if (slider_table != nullptr) { PStatTimer timer2(_morphs_pcollector); int num_morphs = orig_format->get_num_morphs(); for (int mi = 0; mi < num_morphs; mi++) { @@ -1565,7 +1565,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // Then apply the transforms. CPT(TransformBlendTable) tb_table = cdata->_transform_blend_table.get_read_pointer(current_thread); - if (tb_table != (TransformBlendTable *)NULL) { + if (tb_table != nullptr) { // Recompute all the blends up front, so we don't have to test each one // for staleness at each vertex. { @@ -2072,14 +2072,14 @@ finalize(BamReader *manager) { array_obj->_array_format = new_array_format; } - if (cdata->_transform_table != (TransformTable *)NULL) { + if (cdata->_transform_table != nullptr) { CPT(TransformTable) new_transform_table = TransformTable::register_table(cdata->_transform_table); manager->change_pointer(cdata->_transform_table, new_transform_table); cdata->_transform_table = new_transform_table; } - if (cdata->_slider_table != (SliderTable *)NULL) { + if (cdata->_slider_table != nullptr) { CPT(SliderTable) new_slider_table = SliderTable::register_table(cdata->_slider_table); manager->change_pointer(cdata->_slider_table, new_slider_table); @@ -2186,7 +2186,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { CPT(GeomVertexArrayData) adata = _arrays[0].get_read_pointer(); all_rows.set_range(0, adata->get_num_rows()); - if (_slider_table != (SliderTable *)NULL) { + if (_slider_table != nullptr) { int num_sliders = _slider_table->get_num_sliders(); for (int i = 0; i < num_sliders; ++i) { ((SliderTable *)_slider_table.p())->set_slider_rows(i, all_rows); @@ -2213,7 +2213,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _arrays.reserve(num_arrays); for (size_t i = 0; i < num_arrays; ++i) { manager->read_pointer(scan); - _arrays.push_back(NULL); + _arrays.push_back(nullptr); } manager->read_pointer(scan); diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 2a7db8115b..806f5887d3 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -530,7 +530,6 @@ private: void make_array_writers(); void delete_array_writers(); - bool _force_to_0; bool _got_array_writers; typedef pvector ArrayWriters; ArrayWriters _array_writers; diff --git a/panda/src/gobj/geomVertexFormat.I b/panda/src/gobj/geomVertexFormat.I index 2879599cc5..680f779447 100644 --- a/panda/src/gobj/geomVertexFormat.I +++ b/panda/src/gobj/geomVertexFormat.I @@ -88,7 +88,7 @@ get_num_arrays() const { */ INLINE const GeomVertexArrayFormat *GeomVertexFormat:: get_array(size_t array) const { - nassertr(array < _arrays.size(), NULL); + nassertr(array < _arrays.size(), nullptr); return _arrays[array]; } @@ -97,7 +97,7 @@ get_array(size_t array) const { */ INLINE bool GeomVertexFormat:: has_column(const InternalName *name) const { - return (get_column(name) != (GeomVertexColumn *)NULL); + return (get_column(name) != nullptr); } /** @@ -120,8 +120,8 @@ get_num_points() const { */ INLINE const InternalName *GeomVertexFormat:: get_point(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _points.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _points.size(), nullptr); return _points[n]; } @@ -146,8 +146,8 @@ get_num_vectors() const { */ INLINE const InternalName *GeomVertexFormat:: get_vector(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _vectors.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _vectors.size(), nullptr); return _vectors[n]; } @@ -171,8 +171,8 @@ get_num_texcoords() const { */ INLINE const InternalName *GeomVertexFormat:: get_texcoord(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _texcoords.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _texcoords.size(), nullptr); return _texcoords[n]; } @@ -198,8 +198,8 @@ get_num_morphs() const { */ INLINE const InternalName *GeomVertexFormat:: get_morph_slider(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _morphs.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _morphs.size(), nullptr); return _morphs[n]._slider; } @@ -213,8 +213,8 @@ get_morph_slider(size_t n) const { */ INLINE const InternalName *GeomVertexFormat:: get_morph_base(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _morphs.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _morphs.size(), nullptr); return _morphs[n]._base; } @@ -229,8 +229,8 @@ get_morph_base(size_t n) const { */ INLINE const InternalName *GeomVertexFormat:: get_morph_delta(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _morphs.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _morphs.size(), nullptr); return _morphs[n]._delta; } @@ -373,7 +373,7 @@ get_vertex_array_index() const { */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_vertex_column() const { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); return _vertex_column; } @@ -397,7 +397,7 @@ get_normal_array_index() const { */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_normal_column() const { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); return _normal_column; } @@ -421,7 +421,7 @@ get_color_array_index() const { */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_color_column() const { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); return _color_column; } @@ -430,7 +430,7 @@ get_color_column() const { */ INLINE GeomVertexFormat::Registry *GeomVertexFormat:: get_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { make_registry(); } return _registry; diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index f3652e8321..05814c5bd8 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -19,7 +19,7 @@ #include "bamReader.h" #include "bamWriter.h" -GeomVertexFormat::Registry *GeomVertexFormat::_registry = NULL; +GeomVertexFormat::Registry *GeomVertexFormat::_registry = nullptr; TypeHandle GeomVertexFormat::_type_handle; /** @@ -28,7 +28,7 @@ TypeHandle GeomVertexFormat::_type_handle; GeomVertexFormat:: GeomVertexFormat() : _is_registered(false), - _post_animated_format(NULL) + _post_animated_format(nullptr) { } @@ -38,7 +38,7 @@ GeomVertexFormat() : GeomVertexFormat:: GeomVertexFormat(const GeomVertexArrayFormat *array_format) : _is_registered(false), - _post_animated_format(NULL) + _post_animated_format(nullptr) { add_array(array_format); } @@ -51,7 +51,7 @@ GeomVertexFormat(const GeomVertexFormat ©) : _is_registered(false), _animation(copy._animation), _arrays(copy._arrays), - _post_animated_format(NULL) + _post_animated_format(nullptr) { } @@ -105,9 +105,9 @@ unref() const { */ CPT(GeomVertexFormat) GeomVertexFormat:: get_post_animated_format() const { - nassertr(is_registered(), NULL); + nassertr(is_registered(), nullptr); - if (_post_animated_format == (GeomVertexFormat *)NULL) { + if (_post_animated_format == nullptr) { PT(GeomVertexFormat) new_format = new GeomVertexFormat(*this); new_format->remove_column(InternalName::get_transform_blend()); @@ -145,7 +145,7 @@ get_post_animated_format() const { */ CPT(GeomVertexFormat) GeomVertexFormat:: get_union_format(const GeomVertexFormat *other) const { - nassertr(is_registered() && other->is_registered(), NULL); + nassertr(is_registered() && other->is_registered(), nullptr); PT(GeomVertexFormat) new_format = new GeomVertexFormat; @@ -186,7 +186,7 @@ get_union_format(const GeomVertexFormat *other) const { bool inserted = column_names.insert(column_a->get_name()).second; if (inserted) { const GeomVertexColumn *column_b = other->get_column(column_a->get_name()); - if (column_b != (GeomVertexColumn *)NULL && + if (column_b != nullptr && column_b->get_total_bytes() > column_a->get_total_bytes()) { // Column b is larger. Keep it. new_array->add_column(column_b->get_name(), @@ -213,7 +213,7 @@ get_union_format(const GeomVertexFormat *other) const { bool inserted = column_names.insert(column_a->get_name()).second; if (inserted) { const GeomVertexColumn *column_b = get_column(column_a->get_name()); - if (column_b != (GeomVertexColumn *)NULL && + if (column_b != nullptr && column_b->get_total_bytes() > column_a->get_total_bytes()) { // Column b is larger. Keep it. new_array->add_column(column_b->get_name(), @@ -248,8 +248,8 @@ get_union_format(const GeomVertexFormat *other) const { */ GeomVertexArrayFormat *GeomVertexFormat:: modify_array(size_t array) { - nassertr(!is_registered(), NULL); - nassertr(array < _arrays.size(), NULL); + nassertr(!is_registered(), nullptr); + nassertr(array < _arrays.size(), nullptr); if (_arrays[array]->is_registered() || _arrays[array]->get_ref_count() > 1) { @@ -376,7 +376,7 @@ get_column(size_t i) const { i -= (*ai)->get_num_columns(); } - return NULL; + return nullptr; } /** @@ -450,11 +450,11 @@ get_column(const InternalName *name) const { Arrays::const_iterator ai; for (ai = _arrays.begin(); ai != _arrays.end(); ++ai) { const GeomVertexColumn *column = (*ai)->get_column(name); - if (column != (GeomVertexColumn *)NULL) { + if (column != nullptr) { return column; } } - return NULL; + return nullptr; } else { // If the format has been registered, we can just check the toplevel @@ -466,10 +466,10 @@ get_column(const InternalName *name) const { int array_index = (*ai).second._array_index; int column_index = (*ai).second._column_index; - nassertr(array_index >= 0 && array_index < (int)_arrays.size(), NULL); + nassertr(array_index >= 0 && array_index < (int)_arrays.size(), nullptr); return _arrays[array_index]->get_column(column_index); } - return NULL; + return nullptr; } } @@ -491,7 +491,7 @@ remove_column(const InternalName *name, bool keep_empty_array) { for (int array = 0; array < (int)_arrays.size(); ++array) { GeomVertexArrayFormat *array_format = _arrays[array]; - if (array_format->get_column(name) != (GeomVertexColumn *)NULL) { + if (array_format->get_column(name) != nullptr) { // Here's the array with the named column! if (array_format->is_registered() || array_format->get_ref_count() > 1) { @@ -642,7 +642,7 @@ get_array_info(const InternalName *name, int &array_index, } array_index = -1; - column = NULL; + column = nullptr; return false; } @@ -676,7 +676,7 @@ compare_to(const GeomVertexFormat &other) const { */ void GeomVertexFormat:: make_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { _registry = new Registry; _registry->make_standard_formats(); } @@ -813,11 +813,11 @@ do_unregister() { _texcoords.clear(); _morphs.clear(); - if (_post_animated_format != (GeomVertexFormat *)NULL && + if (_post_animated_format != nullptr && _post_animated_format != this) { unref_delete(_post_animated_format); } - _post_animated_format = NULL; + _post_animated_format = nullptr; } /** @@ -892,7 +892,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _arrays.reserve(num_arrays); for (int i = 0; i < num_arrays; i++) { manager->read_pointer(scan); - _arrays.push_back(NULL); + _arrays.push_back(nullptr); } } diff --git a/panda/src/gobj/geomVertexReader.I b/panda/src/gobj/geomVertexReader.I index 412bfa611d..893d6458cf 100644 --- a/panda/src/gobj/geomVertexReader.I +++ b/panda/src/gobj/geomVertexReader.I @@ -18,7 +18,7 @@ */ INLINE GeomVertexReader:: GeomVertexReader(Thread *current_thread) : - _vertex_data(NULL), + _vertex_data(nullptr), _current_thread(current_thread) { initialize(); @@ -227,7 +227,7 @@ get_force() const { */ INLINE bool GeomVertexReader:: set_column(int column) { - if (_vertex_data != (const GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineReader reader(_vertex_data, _current_thread); reader.check_array_readers(); const GeomVertexFormat *format = reader.get_format(); @@ -235,7 +235,7 @@ set_column(int column) { format->get_column(column), &reader); } - if (_array_data != (const GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(column)); } return false; @@ -252,7 +252,7 @@ set_column(int column) { */ INLINE bool GeomVertexReader:: set_column(CPT_InternalName name) { - if (_vertex_data != (const GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineReader reader(_vertex_data, _current_thread); reader.check_array_readers(); const GeomVertexFormat *format = reader.get_format(); @@ -260,7 +260,7 @@ set_column(CPT_InternalName name) { format->get_column(name), &reader); } - if (_array_data != (const GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(name)); } @@ -282,7 +282,7 @@ clear() { */ INLINE bool GeomVertexReader:: has_column() const { - return (_packer != (GeomVertexColumn::Packer *)NULL); + return (_packer != nullptr); } /** @@ -299,10 +299,10 @@ get_array() const { */ INLINE const GeomVertexColumn *GeomVertexReader:: get_column() const { - if (_packer != (GeomVertexColumn::Packer *)NULL) { + if (_packer != nullptr) { return _packer->_column; } - return NULL; + return nullptr; } /** @@ -683,9 +683,9 @@ get_packer() const { INLINE bool GeomVertexReader:: set_pointer(int row) { _pointer_begin = _handle->get_read_pointer(_force); - if (_pointer_begin == NULL && _handle->get_data_size_bytes() != 0) { + if (_pointer_begin == nullptr && _handle->get_data_size_bytes() != 0) { // Vertex data is not resident. - set_column(0, NULL); + set_column(0, nullptr); return false; } @@ -701,7 +701,7 @@ set_pointer(int row) { */ INLINE void GeomVertexReader:: quick_set_pointer(int row) { - nassertv(has_column() && (_pointer_begin != NULL || row == 0)); + nassertv(has_column() && (_pointer_begin != nullptr || row == 0)); #if defined(_DEBUG) // Make sure we still have the same pointer as stored in the array. diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index 054e7df942..b803095915 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/panda/src/gobj/geomVertexReader.cxx @@ -32,23 +32,23 @@ const unsigned char GeomVertexReader::empty_buffer[100] = { 0 }; */ bool GeomVertexReader:: set_column(int array, const GeomVertexColumn *column) { - if (column == (const GeomVertexColumn *)NULL) { + if (column == nullptr) { // Clear the data type. _array = -1; - _packer = NULL; + _packer = nullptr; _stride = 0; - _pointer = NULL; - _pointer_end = NULL; + _pointer = nullptr; + _pointer_end = nullptr; return false; } - if (_vertex_data != (const GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineReader reader(_vertex_data, _current_thread); reader.check_array_readers(); return set_vertex_column(array, column, &reader); } - if (_array_data != (const GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(column); } @@ -62,7 +62,7 @@ set_column(int array, const GeomVertexColumn *column) { void GeomVertexReader:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { out << "GeomVertexReader()"; } else { @@ -79,10 +79,10 @@ output(ostream &out) const { void GeomVertexReader:: initialize() { _array = 0; - _packer = NULL; - _pointer_begin = NULL; - _pointer_end = NULL; - _pointer = NULL; + _packer = nullptr; + _pointer_begin = nullptr; + _pointer_end = nullptr; + _pointer = nullptr; _start_row = 0; _force = true; } @@ -94,15 +94,15 @@ initialize() { bool GeomVertexReader:: set_vertex_column(int array, const GeomVertexColumn *column, const GeomVertexDataPipelineReader *data_reader) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_vertex_data != (const GeomVertexData *)NULL, false); + nassertr(_vertex_data != nullptr, false); #ifndef NDEBUG _array = -1; - _packer = NULL; + _packer = nullptr; nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); #endif @@ -120,11 +120,11 @@ set_vertex_column(int array, const GeomVertexColumn *column, */ bool GeomVertexReader:: set_array_column(const GeomVertexColumn *column) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_array_data != (const GeomVertexArrayData *)NULL, false); + nassertr(_array_data != nullptr, false); _handle = _array_data->get_handle(); _stride = _handle->get_array_format()->get_stride(); diff --git a/panda/src/gobj/geomVertexRewriter.I b/panda/src/gobj/geomVertexRewriter.I index ac092d6979..077dc3963c 100644 --- a/panda/src/gobj/geomVertexRewriter.I +++ b/panda/src/gobj/geomVertexRewriter.I @@ -104,7 +104,7 @@ INLINE GeomVertexRewriter:: INLINE GeomVertexData *GeomVertexRewriter:: get_vertex_data() const { nassertr(GeomVertexWriter::get_vertex_data() == - GeomVertexReader::get_vertex_data(), NULL); + GeomVertexReader::get_vertex_data(), nullptr); return GeomVertexWriter::get_vertex_data(); } @@ -115,7 +115,7 @@ get_vertex_data() const { INLINE GeomVertexArrayData *GeomVertexRewriter:: get_array_data() const { nassertr(GeomVertexWriter::get_array_data() == - GeomVertexReader::get_array_data(), NULL); + GeomVertexReader::get_array_data(), nullptr); return GeomVertexWriter::get_array_data(); } @@ -148,7 +148,7 @@ get_stride() const { INLINE Thread *GeomVertexRewriter:: get_current_thread() const { nassertr(GeomVertexWriter::get_current_thread() == - GeomVertexReader::get_current_thread(), NULL); + GeomVertexReader::get_current_thread(), nullptr); return GeomVertexWriter::get_current_thread(); } @@ -242,7 +242,7 @@ get_array() const { INLINE const GeomVertexColumn *GeomVertexRewriter:: get_column() const { nassertr(GeomVertexWriter::get_column() == - GeomVertexReader::get_column(), NULL); + GeomVertexReader::get_column(), nullptr); return GeomVertexWriter::get_column(); } diff --git a/panda/src/gobj/geomVertexRewriter.cxx b/panda/src/gobj/geomVertexRewriter.cxx index 304606a9c3..e1743ca39d 100644 --- a/panda/src/gobj/geomVertexRewriter.cxx +++ b/panda/src/gobj/geomVertexRewriter.cxx @@ -19,7 +19,7 @@ void GeomVertexRewriter:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { out << "GeomVertexRewriter()"; } else { diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index f21280c3ad..cc25e79531 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/panda/src/gobj/geomVertexWriter.I @@ -18,7 +18,7 @@ */ INLINE GeomVertexWriter:: GeomVertexWriter(Thread *current_thread) : - _vertex_data(NULL), + _vertex_data(nullptr), _current_thread(current_thread) { initialize(); @@ -199,7 +199,7 @@ get_current_thread() const { */ INLINE bool GeomVertexWriter:: set_column(int column) { - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); const GeomVertexFormat *format = writer.get_format(); @@ -207,7 +207,7 @@ set_column(int column) { format->get_column(column), &writer); } - if (_array_data != (GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(column)); } return false; @@ -223,7 +223,7 @@ set_column(int column) { */ INLINE bool GeomVertexWriter:: set_column(CPT_InternalName name) { - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); const GeomVertexFormat *format = writer.get_format(); @@ -231,7 +231,7 @@ set_column(CPT_InternalName name) { format->get_column(name), &writer); } - if (_array_data != (GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(name)); } return false; @@ -251,7 +251,7 @@ clear() { */ INLINE bool GeomVertexWriter:: has_column() const { - return (_packer != (GeomVertexColumn::Packer *)NULL); + return (_packer != nullptr); } /** @@ -268,10 +268,10 @@ get_array() const { */ INLINE const GeomVertexColumn *GeomVertexWriter:: get_column() const { - if (_packer != (GeomVertexColumn::Packer *)NULL) { + if (_packer != nullptr) { return _packer->_column; } - return NULL; + return nullptr; } /** @@ -1376,10 +1376,10 @@ inc_add_pointer() { // Reset the data pointer. int write_row = get_write_row(); - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { // If we have a whole GeomVertexData, we must set the length of all its // arrays at once. - _handle = NULL; + _handle = nullptr; GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); writer.set_num_rows(max(write_row + 1, writer.get_num_rows())); diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index ef05c3bc44..51e8b91bf5 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/panda/src/gobj/geomVertexWriter.cxx @@ -32,28 +32,28 @@ unsigned char GeomVertexWriter::empty_buffer[100] = { 0 }; */ bool GeomVertexWriter:: set_column(int array, const GeomVertexColumn *column) { - if (_vertex_data == (GeomVertexData *)NULL && - _array_data == (GeomVertexArrayData *)NULL) { + if (_vertex_data == nullptr && + _array_data == nullptr) { return false; } - if (column == (const GeomVertexColumn *)NULL) { + if (column == nullptr) { // Clear the data type. _array = -1; - _packer = NULL; + _packer = nullptr; _stride = 0; - _pointer = NULL; - _pointer_end = NULL; + _pointer = nullptr; + _pointer_end = nullptr; return false; } - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); return set_vertex_column(array, column, &writer); } - if (_array_data != (GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(column); } @@ -71,7 +71,7 @@ bool GeomVertexWriter:: reserve_num_rows(int num_rows) { bool result; - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { // If we have a whole GeomVertexData, we must set the length of all its // arrays at once. GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); @@ -94,7 +94,7 @@ reserve_num_rows(int num_rows) { void GeomVertexWriter:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { out << "GeomVertexWriter()"; } else { @@ -111,10 +111,10 @@ output(ostream &out) const { void GeomVertexWriter:: initialize() { _array = 0; - _packer = NULL; - _pointer_begin = NULL; - _pointer_end = NULL; - _pointer = NULL; + _packer = nullptr; + _pointer_begin = nullptr; + _pointer_end = nullptr; + _pointer = nullptr; _start_row = 0; } @@ -125,15 +125,15 @@ initialize() { bool GeomVertexWriter:: set_vertex_column(int array, const GeomVertexColumn *column, GeomVertexDataPipelineWriter *data_writer) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_vertex_data != (GeomVertexData *)NULL, false); + nassertr(_vertex_data != nullptr, false); #ifndef NDEBUG _array = -1; - _packer = NULL; + _packer = nullptr; nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); #endif @@ -153,11 +153,11 @@ set_vertex_column(int array, const GeomVertexColumn *column, */ bool GeomVertexWriter:: set_array_column(const GeomVertexColumn *column) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_array_data != (GeomVertexArrayData *)NULL, false); + nassertr(_array_data != nullptr, false); _handle = _array_data->modify_handle(); _stride = _handle->get_array_format()->get_stride(); diff --git a/panda/src/gobj/internalName.I b/panda/src/gobj/internalName.I index d7475550e9..644ed998d3 100644 --- a/panda/src/gobj/internalName.I +++ b/panda/src/gobj/internalName.I @@ -75,8 +75,8 @@ get_basename() const { */ INLINE PT(InternalName) InternalName:: get_root() { - if (_root == (InternalName *)NULL) { - _root = new InternalName(NULL, ""); + if (_root == nullptr) { + _root = new InternalName(nullptr, ""); } return _root; } @@ -86,7 +86,7 @@ get_root() { */ INLINE PT(InternalName) InternalName:: get_error() { - if (_error == (InternalName *)NULL) { + if (_error == nullptr) { _error = InternalName::make("error"); } return _error; @@ -98,7 +98,7 @@ get_error() { */ INLINE PT(InternalName) InternalName:: get_vertex() { - if (_vertex == (InternalName *)NULL) { + if (_vertex == nullptr) { _vertex = InternalName::make("vertex"); } return _vertex; @@ -110,7 +110,7 @@ get_vertex() { */ INLINE PT(InternalName) InternalName:: get_normal() { - if (_normal == (InternalName *)NULL) { + if (_normal == nullptr) { _normal = InternalName::make("normal"); } return _normal; @@ -124,7 +124,7 @@ get_normal() { */ INLINE PT(InternalName) InternalName:: get_tangent() { - if (_tangent == (InternalName *)NULL) { + if (_tangent == nullptr) { _tangent = InternalName::make("tangent"); } return _tangent; @@ -149,7 +149,7 @@ get_tangent_name(const string &name) { */ INLINE PT(InternalName) InternalName:: get_binormal() { - if (_binormal == (InternalName *)NULL) { + if (_binormal == nullptr) { _binormal = InternalName::make("binormal"); } return _binormal; @@ -172,7 +172,7 @@ get_binormal_name(const string &name) { */ INLINE PT(InternalName) InternalName:: get_texcoord() { - if (_texcoord == (InternalName *)NULL) { + if (_texcoord == nullptr) { _texcoord = InternalName::make("texcoord"); } return _texcoord; @@ -195,7 +195,7 @@ get_texcoord_name(const string &name) { */ INLINE PT(InternalName) InternalName:: get_color() { - if (_color == (InternalName *)NULL) { + if (_color == nullptr) { _color = InternalName::make("color"); } return _color; @@ -208,7 +208,7 @@ get_color() { */ INLINE PT(InternalName) InternalName:: get_rotate() { - if (_rotate == (InternalName *)NULL) { + if (_rotate == nullptr) { _rotate = InternalName::make("rotate"); } return _rotate; @@ -221,7 +221,7 @@ get_rotate() { */ INLINE PT(InternalName) InternalName:: get_size() { - if (_size == (InternalName *)NULL) { + if (_size == nullptr) { _size = InternalName::make("size"); } return _size; @@ -235,7 +235,7 @@ get_size() { */ INLINE PT(InternalName) InternalName:: get_aspect_ratio() { - if (_aspect_ratio == (InternalName *)NULL) { + if (_aspect_ratio == nullptr) { _aspect_ratio = InternalName::make("aspect_ratio"); } return _aspect_ratio; @@ -249,7 +249,7 @@ get_aspect_ratio() { */ INLINE PT(InternalName) InternalName:: get_transform_blend() { - if (_transform_blend == (InternalName *)NULL) { + if (_transform_blend == nullptr) { _transform_blend = InternalName::make("transform_blend"); } return _transform_blend; @@ -266,7 +266,7 @@ get_transform_blend() { */ INLINE PT(InternalName) InternalName:: get_transform_weight() { - if (_transform_weight == (InternalName *)NULL) { + if (_transform_weight == nullptr) { _transform_weight = InternalName::make("transform_weight"); } return _transform_weight; @@ -282,7 +282,7 @@ get_transform_weight() { */ INLINE PT(InternalName) InternalName:: get_transform_index() { - if (_transform_index == (InternalName *)NULL) { + if (_transform_index == nullptr) { _transform_index = InternalName::make("transform_index"); } return _transform_index; @@ -312,7 +312,7 @@ get_morph(InternalName *column, const string &slider) { */ INLINE PT(InternalName) InternalName:: get_index() { - if (_index == (InternalName *)NULL) { + if (_index == nullptr) { _index = InternalName::make("index"); } return _index; @@ -324,7 +324,7 @@ get_index() { */ INLINE PT(InternalName) InternalName:: get_world() { - if (_world == (InternalName *)NULL) { + if (_world == nullptr) { _world = InternalName::make("world"); } return _world; @@ -336,7 +336,7 @@ get_world() { */ INLINE PT(InternalName) InternalName:: get_camera() { - if (_camera == (InternalName *)NULL) { + if (_camera == nullptr) { _camera = InternalName::make("camera"); } return _camera; @@ -348,7 +348,7 @@ get_camera() { */ INLINE PT(InternalName) InternalName:: get_model() { - if (_model == (InternalName *)NULL) { + if (_model == nullptr) { _model = InternalName::make("model"); } return _model; @@ -360,7 +360,7 @@ get_model() { */ INLINE PT(InternalName) InternalName:: get_view() { - if (_view == (InternalName *)NULL) { + if (_view == nullptr) { _view = InternalName::make("view"); } return _view; diff --git a/panda/src/gobj/internalName.cxx b/panda/src/gobj/internalName.cxx index dcebada06e..828b6db97a 100644 --- a/panda/src/gobj/internalName.cxx +++ b/panda/src/gobj/internalName.cxx @@ -65,7 +65,7 @@ InternalName(InternalName *parent, const string &basename) : InternalName:: ~InternalName() { #ifndef NDEBUG - if (_parent != (const InternalName *)NULL) { + if (_parent != nullptr) { // unref() should have removed us from our parent's table already. LightMutexHolder holder(_parent->_name_table_lock); NameTable::iterator ni = _parent->_name_table.find(_basename); @@ -80,7 +80,7 @@ InternalName:: */ bool InternalName:: unref() const { - if (_parent == (const InternalName *)NULL) { + if (_parent == nullptr) { // No parent; no problem. This is the root InternalName. Actually, this // probably shouldn't be destructing, but I guess it might at application // shutdown. @@ -140,7 +140,7 @@ get_name() const { if (_parent == get_root()) { return _basename; - } else if (_parent == (InternalName *)NULL) { + } else if (_parent == nullptr) { return string(); } else { @@ -156,7 +156,7 @@ join(const string &sep) const { if (_parent == get_root()) { return _basename; - } else if (_parent == (InternalName *)NULL) { + } else if (_parent == nullptr) { return string(); } else { @@ -178,7 +178,7 @@ find_ancestor(const string &basename) const { if (_basename == basename) { return 0; - } else if (_parent != (InternalName *)NULL) { + } else if (_parent != nullptr) { int index = _parent->find_ancestor(basename); if (index >= 0) { return index + 1; @@ -200,7 +200,7 @@ get_ancestor(int n) const { if (n == 0) { return this; - } else if (_parent != (InternalName *)NULL) { + } else if (_parent != nullptr) { return _parent->get_ancestor(n - 1); } else { @@ -217,7 +217,7 @@ const InternalName *InternalName:: get_top() const { test_ref_count_integrity(); - if (_parent != (InternalName *)NULL && _parent != get_root()) { + if (_parent != nullptr && _parent != get_root()) { return _parent->get_top(); } return this; @@ -236,7 +236,7 @@ get_net_basename(int n) const { } else if (n == 0) { return _basename; - } else if (_parent != (InternalName *)NULL && _parent != get_root()) { + } else if (_parent != nullptr && _parent != get_root()) { return _parent->get_net_basename(n - 1) + "." + _basename; } else { @@ -252,7 +252,7 @@ output(ostream &out) const { if (_parent == get_root()) { out << _basename; - } else if (_parent == (InternalName *)NULL) { + } else if (_parent == nullptr) { out << "(root)"; } else { diff --git a/panda/src/gobj/internalName.h b/panda/src/gobj/internalName.h index 7706723021..1c8b942a5b 100644 --- a/panda/src/gobj/internalName.h +++ b/panda/src/gobj/internalName.h @@ -196,7 +196,7 @@ typedef ConstPointerTo CPT_InternalName; #else class CPT_InternalName : public ConstPointerTo { public: - INLINE CPT_InternalName(const To *ptr = (const To *)NULL); + INLINE CPT_InternalName(const To *ptr = nullptr); INLINE CPT_InternalName(const PointerTo ©); INLINE CPT_InternalName(PointerTo &&from) noexcept; INLINE CPT_InternalName(const ConstPointerTo ©); diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index b98bcd9c12..a03651dbf5 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -27,8 +27,8 @@ make(PyUnicodeObject *str) { // Not an interned string; don't bother. Py_ssize_t len = 0; const char *c_str = PyUnicode_AsUTF8AndSize((PyObject *)str, &len); - if (c_str == NULL) { - return NULL; + if (c_str == nullptr) { + return nullptr; } string name(c_str, len); @@ -73,7 +73,7 @@ make(PyStringObject *str) { Py_INCREF(str); iname->ref(); - InternalName::_py_intern_table.insert(make_pair((PyObject *)str, iname.p())); + InternalName::_py_intern_table.insert(std::make_pair((PyObject *)str, iname.p())); return iname.p(); } diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index 8b7df0b5ac..cb7a496e97 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -41,7 +41,7 @@ Lens:: Lens(const Lens ©) : _cycler(copy._cycler) { // We don't copy the _geom_data. That's unique to each Lens. CDWriter cdata(_cycler, true); - cdata->_geom_data = NULL; + cdata->_geom_data = nullptr; } /** @@ -53,7 +53,7 @@ operator = (const Lens ©) { // We don't copy the _geom_data. That's unique to each Lens. CDWriter cdata(_cycler, true); - cdata->_geom_data = NULL; + cdata->_geom_data = nullptr; } /** @@ -577,7 +577,7 @@ make_geometry() { if (num_segments == 0) { // Can't do a frustum. cdata->_geom_data.clear(); - return (Geom *)NULL; + return nullptr; } // Now string together the line segments. @@ -648,25 +648,25 @@ make_bounds() const { // Upper left. corner.set(-1.0f, 1.0f, 0.0f); if (!do_extrude(cdata, corner, nul, ful)) { - return (BoundingVolume *)NULL; + return nullptr; } // Upper right. corner.set(1.0f, 1.0f, 0.0f); if (!do_extrude(cdata, corner, nur, fur)) { - return (BoundingVolume *)NULL; + return nullptr; } // Lower right. corner.set(1.0f, -1.0f, 0.0f); if (!do_extrude(cdata, corner, nlr, flr)) { - return (BoundingVolume *)NULL; + return nullptr; } // Lower left. corner.set(-1.0f, -1.0f, 0.0f); if (!do_extrude(cdata, corner, nll, fll)) { - return (BoundingVolume *)NULL; + return nullptr; } return new BoundingHexahedron(fll, flr, fur, ful, nll, nlr, nur, nul); @@ -1613,7 +1613,7 @@ do_define_geom_data(CData *cdata) { num_segments = lens_geom_segments; } - if (cdata->_geom_data == (GeomVertexData *)NULL) { + if (cdata->_geom_data == nullptr) { cdata->_geom_data = new GeomVertexData ("lens", GeomVertexFormat::get_v3(), Geom::UH_dynamic); diff --git a/panda/src/gobj/materialPool.cxx b/panda/src/gobj/materialPool.cxx index 22b8f9c5ee..58fec6dcbc 100644 --- a/panda/src/gobj/materialPool.cxx +++ b/panda/src/gobj/materialPool.cxx @@ -15,7 +15,7 @@ #include "config_gobj.h" #include "lightMutexHolder.h" -MaterialPool *MaterialPool::_global_ptr = (MaterialPool *)NULL; +MaterialPool *MaterialPool::_global_ptr = nullptr; /** @@ -119,7 +119,7 @@ ns_list_contents(ostream &out) const { */ MaterialPool *MaterialPool:: get_global_ptr() { - if (_global_ptr == (MaterialPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new MaterialPool; } return _global_ptr; diff --git a/panda/src/gobj/paramTexture.cxx b/panda/src/gobj/paramTexture.cxx index 0710f506f2..7250cab5ec 100644 --- a/panda/src/gobj/paramTexture.cxx +++ b/panda/src/gobj/paramTexture.cxx @@ -24,7 +24,7 @@ void ParamTextureSampler:: output(ostream &out) const { out << "texture "; - if (_texture != (Texture *)NULL) { + if (_texture != nullptr) { out << _texture->get_name(); } else { out << "(empty)"; @@ -99,7 +99,7 @@ void ParamTextureImage:: output(ostream &out) const { out << "texture "; - if (_texture != (Texture *)NULL) { + if (_texture != nullptr) { out << _texture->get_name(); } else { out << "(empty)"; diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 233edb46b3..a77a8837d7 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -274,7 +274,7 @@ release_texture(TextureContext *tc) { // We have to set the Texture pointer to NULL at this point, since the // Texture itself might destruct at any time after it has been released. - tc->_texture = (Texture *)NULL; + tc->_texture = nullptr; bool removed = (_prepared_textures.erase(tc) != 0); nassertv(removed); @@ -308,7 +308,7 @@ release_all_textures() { ++tci) { TextureContext *tc = (*tci); tc->_texture->clear_prepared(tc->get_view(), this); - tc->_texture = (Texture *)NULL; + tc->_texture = nullptr; _released_textures.insert(tc); } @@ -372,7 +372,7 @@ prepare_texture_now(Texture *tex, int view, GraphicsStateGuardianBase *gsg) { // them creates the context (since they're all shared anyway). TextureContext *tc = gsg->prepare_texture(tex, view); - if (tc != (TextureContext *)NULL) { + if (tc != nullptr) { bool prepared = _prepared_textures.insert(tc).second; nassertr(prepared, tc); } @@ -532,7 +532,7 @@ prepare_sampler_now(const SamplerState &sampler, GraphicsStateGuardianBase *gsg) // Ask the GSG to create a brand new SamplerContext. SamplerContext *sc = gsg->prepare_sampler(sampler); - if (sc != (SamplerContext *)NULL) { + if (sc != nullptr) { _prepared_samplers[sampler] = sc; } @@ -608,7 +608,7 @@ release_geom(GeomContext *gc) { // We have to set the Geom pointer to NULL at this point, since the Geom // itself might destruct at any time after it has been released. - gc->_geom = (Geom *)NULL; + gc->_geom = nullptr; bool removed = (_prepared_geoms.erase(gc) != 0); nassertv(removed); @@ -633,7 +633,7 @@ release_all_geoms() { ++gci) { GeomContext *gc = (*gci); gc->_geom->clear_prepared(this); - gc->_geom = (Geom *)NULL; + gc->_geom = nullptr; _released_geoms.insert(gc); } @@ -686,7 +686,7 @@ prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg) { // them creates the context (since they're all shared anyway). GeomContext *gc = gsg->prepare_geom(geom); - if (gc != (GeomContext *)NULL) { + if (gc != nullptr) { bool prepared = _prepared_geoms.insert(gc).second; nassertr(prepared, gc); } @@ -783,7 +783,7 @@ release_shader(ShaderContext *sc) { // We have to set the Shader pointer to NULL at this point, since the Shader // itself might destruct at any time after it has been released. - sc->_shader = (Shader *)NULL; + sc->_shader = nullptr; bool removed = (_prepared_shaders.erase(sc) != 0); nassertv(removed); @@ -808,7 +808,7 @@ release_all_shaders() { ++sci) { ShaderContext *sc = (*sci); sc->_shader->clear_prepared(this); - sc->_shader = (Shader *)NULL; + sc->_shader = nullptr; _released_shaders.insert(sc); } @@ -872,7 +872,7 @@ prepare_shader_now(Shader *se, GraphicsStateGuardianBase *gsg) { // them creates the context (since they're all shared anyway). ShaderContext *sc = gsg->prepare_shader(se); - if (sc != (ShaderContext *)NULL) { + if (sc != nullptr) { bool prepared = _prepared_shaders.insert(sc).second; nassertr(prepared, sc); } @@ -953,7 +953,7 @@ release_vertex_buffer(VertexBufferContext *vbc) { // We have to set the Data pointer to NULL at this point, since the Data // itself might destruct at any time after it has been released. - vbc->_data = (GeomVertexArrayData *)NULL; + vbc->_data = nullptr; bool removed = (_prepared_vertex_buffers.erase(vbc) != 0); nassertv(removed); @@ -986,7 +986,7 @@ release_all_vertex_buffers() { ++vbci) { VertexBufferContext *vbc = (VertexBufferContext *)(*vbci); vbc->_data->clear_prepared(this); - vbc->_data = (GeomVertexArrayData *)NULL; + vbc->_data = nullptr; _released_vertex_buffers.insert(vbc); } @@ -1060,7 +1060,7 @@ prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase * get_cached_buffer(data_size_bytes, usage_hint, _vertex_buffer_cache, _vertex_buffer_cache_lru, _vertex_buffer_cache_size); - if (vbc != (VertexBufferContext *)NULL) { + if (vbc != nullptr) { vbc->_data = data; } else { @@ -1070,7 +1070,7 @@ prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase * vbc = gsg->prepare_vertex_buffer(data); } - if (vbc != (VertexBufferContext *)NULL) { + if (vbc != nullptr) { bool prepared = _prepared_vertex_buffers.insert(vbc).second; nassertr(prepared, vbc); } @@ -1151,7 +1151,7 @@ release_index_buffer(IndexBufferContext *ibc) { // We have to set the Data pointer to NULL at this point, since the Data // itself might destruct at any time after it has been released. - ibc->_data = (GeomPrimitive *)NULL; + ibc->_data = nullptr; bool removed = (_prepared_index_buffers.erase(ibc) != 0); nassertv(removed); @@ -1184,7 +1184,7 @@ release_all_index_buffers() { ++ibci) { IndexBufferContext *ibc = (IndexBufferContext *)(*ibci); ibc->_data->clear_prepared(this); - ibc->_data = (GeomPrimitive *)NULL; + ibc->_data = nullptr; _released_index_buffers.insert(ibc); } @@ -1257,7 +1257,7 @@ prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { get_cached_buffer(data_size_bytes, usage_hint, _index_buffer_cache, _index_buffer_cache_lru, _index_buffer_cache_size); - if (ibc != (IndexBufferContext *)NULL) { + if (ibc != nullptr) { ibc->_data = data; } else { @@ -1267,7 +1267,7 @@ prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { ibc = gsg->prepare_index_buffer(data); } - if (ibc != (IndexBufferContext *)NULL) { + if (ibc != nullptr) { bool prepared = _prepared_index_buffers.insert(ibc).second; nassertr(prepared, ibc); } @@ -1416,7 +1416,7 @@ prepare_shader_buffer_now(ShaderBuffer *data, GraphicsStateGuardianBase *gsg) { // which of them creates the context (since they're all shared anyway). BufferContext *bc = gsg->prepare_shader_buffer(data); - if (bc != (BufferContext *)NULL) { + if (bc != nullptr) { bool prepared = _prepared_shader_buffers.insert(bc).second; nassertr(prepared, bc); } @@ -1580,7 +1580,6 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { qti != _enqueued_textures.end(); ++qti) { Texture *tex = qti->first; - TextureContext *first_tc = nullptr; for (int view = 0; view < tex->get_num_views(); ++view) { TextureContext *tc = tex->prepare_now(view, this, gsg); if (tc != nullptr) { @@ -1743,11 +1742,11 @@ get_cached_buffer(size_t data_size_bytes, GeomEnums::UsageHint usage_hint, BufferCache::iterator bci = buffer_cache.find(key); if (bci == buffer_cache.end()) { - return NULL; + return nullptr; } BufferList &buffer_list = (*bci).second; - nassertr(!buffer_list.empty(), NULL); + nassertr(!buffer_list.empty(), nullptr); BufferContext *buffer = buffer_list.back(); buffer_list.pop_back(); diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index fcefc1e235..080fd46860 100644 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -205,7 +205,7 @@ operator == (const ShaderCaps &other) const { */ INLINE Shader::ShaderPtrData:: ShaderPtrData() : - _ptr(NULL), + _ptr(nullptr), _type(SPT_unknown), _updated(true), _size(0) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 35fd3ce560..4f41cf57f1 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -338,7 +338,7 @@ cp_parse_coord_sys(ShaderArgInfo &p, if (fromflag) { if (word2 == "") { bind._part[0] = from_single; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else { if (from_double == SMO_INVALID) { cp_report_error(p, "Could not parse coordinate system name"); @@ -350,7 +350,7 @@ cp_parse_coord_sys(ShaderArgInfo &p, } else { if (word2 == "") { bind._part[1] = to_single; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else { if (to_double == SMO_INVALID) { cp_report_error(p, "Could not parse coordinate system name"); @@ -505,7 +505,7 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) { if (spec._func == SMF_first) { spec._part[1] = SMO_INVALID; - spec._arg[1] = 0; + spec._arg[1] = nullptr; } if (spec._func == SMF_compose) { if (spec._part[1] == SMO_identity) { @@ -750,7 +750,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[1] = SMO_light_source_i_attrib; bind._arg[1] = InternalName::make("shadowViewMatrix"); bind._part[0] = SMO_view_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._index = atoi(pieces[2].c_str()); cp_optimize_mat_spec(bind); @@ -863,7 +863,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[1] = SMO_light_source_i_attrib; bind._arg[1] = InternalName::make("shadowViewMatrix"); bind._part[0] = SMO_view_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._index = atoi(pieces[2].c_str()); int next = 1; @@ -931,9 +931,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_transpose; bind._func = SMF_first; bind._part[0] = SMO_attr_material; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "color") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -942,9 +942,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_color; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "colorscale") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -953,9 +953,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_colorscale; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "fog") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -964,9 +964,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_fog; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "fogcolor") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -975,9 +975,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_fogcolor; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "ambient") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -986,9 +986,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_light_ambient; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1].compare(0, 5, "light") == 0) { if (!cp_errchk_parameter_float(p,16,16)) { return false; @@ -997,9 +997,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_transpose; bind._func = SMF_first; bind._part[0] = SMO_light_source_i_packed; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str() + 5); } else if (pieces[1].compare(0, 5, "lspec") == 0) { if (!cp_errchk_parameter_float(p,3,4)) { @@ -1011,7 +1011,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_light_source_i_attrib; bind._arg[0] = InternalName::make("specular"); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str() + 5); } else { cp_report_error(p,"Unknown attr parameter."); @@ -1054,7 +1054,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_alight_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1076,7 +1076,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_satten_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1138,9 +1138,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_whole; bind._func = SMF_first; bind._part[0] = SMO_texmat_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str()); cp_optimize_mat_spec(bind); @@ -1161,9 +1161,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_texscale_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str()); cp_optimize_mat_spec(bind); @@ -1184,9 +1184,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_texcolor_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str()); cp_optimize_mat_spec(bind); @@ -1209,7 +1209,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_plane_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1231,7 +1231,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_clipplane_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1252,20 +1252,20 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; if (pieces[1] == "pixelsize") { if (!cp_errchk_parameter_float(p, 2, 2)) { return false; } bind._part[0] = SMO_pixel_size; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else if (pieces[1] == "windowsize") { if (!cp_errchk_parameter_float(p, 2, 2)) { return false; } bind._part[0] = SMO_window_size; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else if (pieces[1] == "time") { if (!cp_errchk_parameter_float(p, 1, 1)) { @@ -1273,7 +1273,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { } bind._piece = SMP_row3x1; bind._part[0] = SMO_frame_time; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else { cp_report_error(p, "unknown system parameter"); @@ -1299,7 +1299,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { } ShaderTexSpec bind; bind._id = p._id; - bind._name = 0; + bind._name = nullptr; bind._stage = atoi(pieces[1].c_str()); bind._part = STO_stage_i; switch (p._type) { @@ -1364,7 +1364,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_texpad_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); _mat_deps |= bind._dep[0] | bind._dep[1]; @@ -1385,7 +1385,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_texpix_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); _mat_deps |= bind._dep[0] | bind._dep[1]; @@ -1777,7 +1777,7 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, << "Compilation with active profile failed: " << cgGetErrorString(err) << "\n"; if (err == CG_COMPILER_ERROR) { const char *listing = cgGetLastListing(context); - if (listing != NULL) { + if (listing != nullptr) { shader_cat.debug(false) << listing; } } @@ -1792,13 +1792,13 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, // The active profile failed, so recompile it with the ultimate profile. prog = cgCreateProgram(context, CG_SOURCE, text.c_str(), - (CGprofile)ultimate, entry, (const char **)NULL); + (CGprofile)ultimate, entry, nullptr); // Extract the output listing. err = cgGetError(); const char *listing = cgGetLastListing(context); - if (err == CG_NO_ERROR && listing != NULL && strlen(listing) > 1) { + if (err == CG_NO_ERROR && listing != nullptr && strlen(listing) > 1) { shader_cat.warning() << "Encountered warnings during compilation of " << get_filename(type) << ":\n" << listing; @@ -1806,7 +1806,7 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, } else if (err == CG_COMPILER_ERROR) { shader_cat.error() << "Failed to compile Cg shader " << get_filename(type); - if (listing != NULL) { + if (listing != nullptr) { shader_cat.error(false) << ":\n" << listing; } else { shader_cat.error(false) << "!\n"; @@ -1915,7 +1915,7 @@ cg_compile_shader(const ShaderCaps &caps, CGcontext context) { CGprogram new_program; new_program = cgCreateProgram(context, CG_OBJECT, result.c_str(), (CGprofile)_cg_fprofile, "fshader", - (const char**)NULL); + nullptr); if (new_program) { cgDestroyProgram(_cg_fprogram); _cg_fprogram = new_program; @@ -2245,7 +2245,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, if (shader_cat.is_debug()) { const char *resource = cgGetParameterResourceName(map[id._seqno]); - if (resource != NULL) { + if (resource != nullptr) { shader_cat.debug() << "Uniform parameter " << id._name << " is bound to resource " << resource << "\n"; } @@ -2258,7 +2258,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, if (shader_cat.is_debug()) { const char *resource = cgGetParameterResourceName(p); - if (resource != NULL) { + if (resource != nullptr) { shader_cat.debug() << "Texture parameter " << id._name << " is bound to resource " << resource << "\n"; } @@ -2271,7 +2271,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, CGparameter p = cgGetNamedParameter(programs_by_type[id._type], id._name.c_str()); const char *resource = cgGetParameterResourceName(p); - if (shader_cat.is_debug() && resource != NULL) { + if (shader_cat.is_debug() && resource != nullptr) { if (cgGetParameterResource(p) == CG_GLSL_ATTRIB) { shader_cat.debug() << "Varying parameter " << id._name << " is bound to GLSL attribute " @@ -2293,7 +2293,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, if (shader_cat.is_debug()) { const char *resource = cgGetParameterResourceName(map[id._seqno]); - if (resource != NULL) { + if (resource != nullptr) { shader_cat.debug() << "Uniform ptr parameter " << id._name << " is bound to resource " << resource << "\n"; } @@ -2467,7 +2467,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vf = vfs->find_file(fn, get_model_path()); - if (vf == NULL) { + if (vf == nullptr) { shader_cat.error() << "Could not find shader file: " << fn << "\n"; return false; @@ -2479,7 +2479,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { return false; } - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(vf); } _last_modified = max(_last_modified, vf->get_timestamp()); @@ -2521,7 +2521,7 @@ r_preprocess_source(ostream &out, const Filename &fn, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vf = vfs->find_file(fn, path); - if (vf == NULL) { + if (vf == nullptr) { shader_cat.error() << "Could not find shader file: " << fn << "\n"; return false; @@ -2534,13 +2534,13 @@ r_preprocess_source(ostream &out, const Filename &fn, } istream *source = vf->open_read_file(true); - if (source == NULL) { + if (source == nullptr) { shader_cat.error() << "Could not open shader file: " << fn << "\n"; return false; } - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(vf); } _last_modified = max(_last_modified, vf->get_timestamp()); @@ -2575,7 +2575,7 @@ r_preprocess_source(ostream &out, const Filename &fn, int ext_google_line = 0; bool had_include = false; int lineno = 0; - while (getline(*source, line)) { + while (std::getline(*source, line)) { ++lineno; if (line.empty()) { @@ -2589,7 +2589,7 @@ r_preprocess_source(ostream &out, const Filename &fn, line.resize(line.size() - 1); string line2; - if (getline(*source, line2)) { + if (std::getline(*source, line2)) { line += line2; out.put('\n'); ++lineno; @@ -2618,7 +2618,7 @@ r_preprocess_source(ostream &out, const Filename &fn, size_t block_end = line2.find("*/"); while (block_end == string::npos) { // Didn't find it - look in the next line. - if (getline(*source, line2)) { + if (std::getline(*source, line2)) { out.put('\n'); ++lineno; block_end = line2.find("*/"); @@ -2709,7 +2709,6 @@ r_preprocess_source(ostream &out, const Filename &fn, // Check for an #endif after an include. We have to restore the line // number in case the include happened under an #if block. out << line << "\n"; - int nread = 0; if (had_include) { out << "#line " << (lineno + 1) << " " << fileno << "\n"; } @@ -2857,7 +2856,7 @@ check_modified() const { const Filename &fn = (*it); PT(VirtualFile) vfile = vfs->get_file(fn, true); - if (vfile == (VirtualFile *)NULL || vfile->get_timestamp() > _last_modified) { + if (vfile == nullptr || vfile->get_timestamp() > _last_modified) { return true; } } @@ -3052,7 +3051,7 @@ load(const Filename &file, ShaderLanguage lang) { PT(Shader) shader = new Shader(lang); if (!shader->read(sfile)) { - return NULL; + return nullptr; } _load_table[sfile] = shader; @@ -3090,7 +3089,7 @@ load(ShaderLanguage lang, const Filename &vertex, PT(Shader) shader = new Shader(lang); if (!shader->read(sfile)) { - return NULL; + return nullptr; } _load_table[sfile] = shader; @@ -3113,7 +3112,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { if (lang != SL_GLSL) { shader_cat.error() << "Only GLSL compute shaders are currently supported.\n"; - return NULL; + return nullptr; } Filename fullpath(fn); @@ -3121,7 +3120,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { if (!vfs->resolve_filename(fullpath, get_model_path())) { shader_cat.error() << "Could not find compute shader file: " << fn << "\n"; - return NULL; + return nullptr; } ShaderFile sfile; @@ -3143,7 +3142,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { BamCache *cache = BamCache::get_global_ptr(); PT(BamCacheRecord) record = cache->lookup(fullpath, "sho"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { if (record->has_data()) { shader_cat.info() << "Compute shader " << fn << " was found in disk cache.\n"; @@ -3155,7 +3154,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { PT(Shader) shader = new Shader(lang); if (!shader->read(sfile, record)) { - return NULL; + return nullptr; } _load_table[sfile] = shader; @@ -3183,7 +3182,7 @@ make(string body, ShaderLanguage lang) { if (lang == SL_GLSL) { shader_cat.error() << "GLSL shaders must have separate shader bodies!\n"; - return NULL; + return nullptr; } else if (lang == SL_none) { shader_cat.warning() @@ -3193,7 +3192,7 @@ make(string body, ShaderLanguage lang) { #ifndef HAVE_CG if (lang == SL_Cg) { shader_cat.error() << "Support for Cg shaders is not enabled.\n"; - return NULL; + return nullptr; } #endif @@ -3217,7 +3216,7 @@ make(string body, ShaderLanguage lang) { if (!shader->cg_analyze_shader(_default_caps)) { shader_cat.error() << "Shader encountered an error.\n"; - return NULL; + return nullptr; } } #endif @@ -3250,13 +3249,13 @@ make(ShaderLanguage lang, string vertex, string fragment, string geometry, #ifndef HAVE_CG if (lang == SL_Cg) { shader_cat.error() << "Support for Cg shaders is not enabled.\n"; - return NULL; + return nullptr; } #endif if (lang == SL_none) { shader_cat.error() << "Shader::make() requires an explicit shader language.\n"; - return NULL; + return nullptr; } ShaderFile sbody(move(vertex), move(fragment), move(geometry), @@ -3278,7 +3277,7 @@ make(ShaderLanguage lang, string vertex, string fragment, string geometry, if (!shader->cg_analyze_shader(_default_caps)) { shader_cat.error() << "Shader encountered an error.\n"; - return NULL; + return nullptr; } } #endif @@ -3298,7 +3297,7 @@ make_compute(ShaderLanguage lang, string body) { if (lang != SL_GLSL) { shader_cat.error() << "Only GLSL compute shaders are currently supported.\n"; - return NULL; + return nullptr; } ShaderFile sbody; @@ -3437,7 +3436,7 @@ release(PreparedGraphicsObjects *prepared_objects) { ci = _contexts.find(prepared_objects); if (ci != _contexts.end()) { ShaderContext *sc = (*ci).second; - if (sc != (ShaderContext *)NULL) { + if (sc != nullptr) { prepared_objects->release_shader(sc); } else { _contexts.erase(ci); @@ -3511,7 +3510,7 @@ release_all() { for (ci = temp.begin(); ci != temp.end(); ++ci) { PreparedGraphicsObjects *prepared_objects = (*ci).first; ShaderContext *sc = (*ci).second; - if (sc != (ShaderContext *)NULL) { + if (sc != nullptr) { prepared_objects->release_shader(sc); } } diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 996ee1b7aa..07e1e8b46e 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -614,7 +614,7 @@ private: Shader(ShaderLanguage lang); - bool read(const ShaderFile &sfile, BamCacheRecord *record = NULL); + bool read(const ShaderFile &sfile, BamCacheRecord *record = nullptr); bool do_read_source(string &into, const Filename &fn, BamCacheRecord *record); bool r_preprocess_source(ostream &out, const Filename &fn, const Filename &source_dir, diff --git a/panda/src/gobj/shaderBuffer.I b/panda/src/gobj/shaderBuffer.I index fbd0b42e46..8e328e933e 100644 --- a/panda/src/gobj/shaderBuffer.I +++ b/panda/src/gobj/shaderBuffer.I @@ -58,7 +58,7 @@ get_usage_hint() const { INLINE const unsigned char *ShaderBuffer:: get_initial_data() const { if (_initial_data.empty()) { - return NULL; + return nullptr; } else { return &_initial_data[0]; } diff --git a/panda/src/gobj/shaderBuffer.cxx b/panda/src/gobj/shaderBuffer.cxx index f0b45df540..da9dc37d4d 100644 --- a/panda/src/gobj/shaderBuffer.cxx +++ b/panda/src/gobj/shaderBuffer.cxx @@ -51,7 +51,7 @@ prepare(PreparedGraphicsObjects *prepared_objects) { */ bool ShaderBuffer:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { return false; } Contexts::const_iterator ci; @@ -76,7 +76,7 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { BufferContext *ShaderBuffer:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { _contexts = new Contexts; } Contexts::const_iterator ci; @@ -86,7 +86,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } BufferContext *vbc = prepared_objects->prepare_shader_buffer_now(this, gsg); - if (vbc != (BufferContext *)NULL) { + if (vbc != nullptr) { (*_contexts)[prepared_objects] = vbc; } return vbc; @@ -98,7 +98,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, */ bool ShaderBuffer:: release(PreparedGraphicsObjects *prepared_objects) { - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { Contexts::iterator ci; ci = _contexts->find(prepared_objects); if (ci != _contexts->end()) { @@ -120,7 +120,7 @@ int ShaderBuffer:: release_all() { int num_freed = 0; - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { // We have to traverse a copy of the _contexts list, because the // PreparedGraphicsObjects object will call clear_prepared() in response // to each release_shader_buffer(), and we don't want to be modifying the @@ -137,7 +137,7 @@ release_all() { // Now that we've called release_shader_buffer() on every known context, // the _contexts list should have completely emptied itself. - nassertr(_contexts == NULL, num_freed); + nassertr(_contexts == nullptr, num_freed); } return num_freed; diff --git a/panda/src/gobj/simpleAllocator.I b/panda/src/gobj/simpleAllocator.I index e537526d8a..2129ba6681 100644 --- a/panda/src/gobj/simpleAllocator.I +++ b/panda/src/gobj/simpleAllocator.I @@ -95,7 +95,7 @@ get_contiguous() const { INLINE SimpleAllocatorBlock *SimpleAllocator:: get_first_block() const { MutexHolder holder(_lock); - return (_next == this) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; + return (_next == this) ? nullptr : (SimpleAllocatorBlock *)_next; } /** @@ -161,7 +161,7 @@ INLINE SimpleAllocatorBlock:: */ INLINE void SimpleAllocatorBlock:: free() { - if (_allocator != (SimpleAllocator *)NULL) { + if (_allocator != nullptr) { MutexHolder holder(_allocator->_lock); do_free(); } @@ -182,7 +182,7 @@ get_allocator() const { */ INLINE size_t SimpleAllocatorBlock:: get_start() const { - nassertr(_allocator != (SimpleAllocator *)NULL, 0); + nassertr(_allocator != nullptr, 0); return _start; } @@ -192,7 +192,7 @@ get_start() const { */ INLINE size_t SimpleAllocatorBlock:: get_size() const { - nassertr(_allocator != (SimpleAllocator *)NULL, 0); + nassertr(_allocator != nullptr, 0); return _size; } @@ -201,7 +201,7 @@ get_size() const { */ INLINE bool SimpleAllocatorBlock:: is_free() const { - return (_allocator != (SimpleAllocator *)NULL); + return (_allocator != nullptr); } /** @@ -210,7 +210,7 @@ is_free() const { */ INLINE size_t SimpleAllocatorBlock:: get_max_size() const { - nassertr(_allocator != (SimpleAllocator *)NULL, 0); + nassertr(_allocator != nullptr, 0); MutexHolder holder(_allocator->_lock); return do_get_max_size(); } @@ -221,7 +221,7 @@ get_max_size() const { */ INLINE bool SimpleAllocatorBlock:: realloc(size_t size) { - nassertr(_allocator != (SimpleAllocator *)NULL, false); + nassertr(_allocator != nullptr, false); MutexHolder holder(_allocator->_lock); return do_realloc(size); } @@ -232,9 +232,9 @@ realloc(size_t size) { */ INLINE SimpleAllocatorBlock *SimpleAllocatorBlock:: get_next_block() const { - nassertr(_allocator != (SimpleAllocator *)NULL, NULL); + nassertr(_allocator != nullptr, nullptr); MutexHolder holder(_allocator->_lock); - return (_next == _allocator) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; + return (_next == _allocator) ? nullptr : (SimpleAllocatorBlock *)_next; } /** @@ -244,13 +244,13 @@ get_next_block() const { */ INLINE void SimpleAllocatorBlock:: do_free() { - nassertv(_allocator != (SimpleAllocator *)NULL); + nassertv(_allocator != nullptr); _allocator->_total_size -= _size; LinkedListNode *prev = _prev; remove_from_list(); _allocator->mark_contiguous(prev); - _allocator = NULL; + _allocator = nullptr; } /** diff --git a/panda/src/gobj/simpleAllocator.cxx b/panda/src/gobj/simpleAllocator.cxx index ddae004ee8..5790f35428 100644 --- a/panda/src/gobj/simpleAllocator.cxx +++ b/panda/src/gobj/simpleAllocator.cxx @@ -22,7 +22,7 @@ SimpleAllocator:: if (_next != (LinkedListNode *)this) { MutexHolder holder(_lock); while (_next != (LinkedListNode *)this) { - nassertv(_next != (LinkedListNode *)NULL); + nassertv(_next != nullptr); ((SimpleAllocatorBlock *)_next)->do_free(); } } @@ -69,13 +69,13 @@ SimpleAllocatorBlock *SimpleAllocator:: do_alloc(size_t size) { if (size > _contiguous) { // Don't even bother. - return NULL; + return nullptr; } // First fit algorithm: walk through all the empty blocks until we find one // that has enough room. - SimpleAllocatorBlock *block = NULL; + SimpleAllocatorBlock *block = nullptr; size_t end = 0; size_t best = 0; if (_next != this) { @@ -89,7 +89,7 @@ do_alloc(size_t size) { size_t free_size = next->_start - end; if (size <= free_size) { SimpleAllocatorBlock *new_block = make_block(end, size); - nassertr(new_block->get_allocator() == this, NULL); + nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(next); _total_size += size; @@ -116,7 +116,7 @@ do_alloc(size_t size) { size_t free_size = _max_size - end; if (size <= free_size) { SimpleAllocatorBlock *new_block = make_block(end, size); - nassertr(new_block->get_allocator() == this, NULL); + nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(this); _total_size += size; @@ -143,7 +143,7 @@ do_alloc(size_t size) { } // No room for this block. - return NULL; + return nullptr; } /** @@ -169,7 +169,7 @@ changed_contiguous() { */ void SimpleAllocatorBlock:: output(ostream &out) const { - if (_allocator == (SimpleAllocator *)NULL) { + if (_allocator == nullptr) { out << "free block\n"; } else { MutexHolder holder(_allocator->_lock); diff --git a/panda/src/gobj/simpleLru.I b/panda/src/gobj/simpleLru.I index fa872c7829..5ba8f342f6 100644 --- a/panda/src/gobj/simpleLru.I +++ b/panda/src/gobj/simpleLru.I @@ -94,7 +94,7 @@ validate() { */ INLINE SimpleLruPage:: SimpleLruPage(size_t lru_size) : - _lru(NULL), + _lru(nullptr), _lru_size(lru_size) { } @@ -104,7 +104,7 @@ SimpleLruPage(size_t lru_size) : */ INLINE SimpleLruPage:: SimpleLruPage(const SimpleLruPage ©) : - _lru(NULL), + _lru(nullptr), _lru_size(copy._lru_size) { } @@ -134,10 +134,10 @@ INLINE void SimpleLruPage:: dequeue_lru() { LightMutexHolder holder(SimpleLru::_global_lock); - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { remove_from_list(); _lru->_total_size -= _lru_size; - _lru = NULL; + _lru = nullptr; } } @@ -150,7 +150,7 @@ dequeue_lru() { */ INLINE void SimpleLruPage:: mark_used_lru() const { - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { ((SimpleLruPage *)this)->mark_used_lru(_lru); } } @@ -179,7 +179,7 @@ get_lru_size() const { INLINE void SimpleLruPage:: set_lru_size(size_t lru_size) { LightMutexHolder holder(SimpleLru::_global_lock); - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { _lru->_total_size -= _lru_size; _lru->_total_size += lru_size; _lru_size = lru_size; diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index 8531c321bc..b24b48146c 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -45,8 +45,8 @@ SimpleLru:: // explicitly evict it (that would force vertex buffers to write themselves // to disk unnecessarily). while (_next != (LinkedListNode *)this) { - nassertv(_next != (LinkedListNode *)NULL); - ((SimpleLruPage *)_next)->_lru = NULL; + nassertv(_next != nullptr); + ((SimpleLruPage *)_next)->_lru = nullptr; ((SimpleLruPage *)_next)->remove_from_list(); } #endif @@ -63,22 +63,22 @@ enqueue_lru(SimpleLru *lru) { LightMutexHolder holder(SimpleLru::_global_lock); if (_lru == lru) { - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { remove_from_list(); insert_before(_lru); } return; } - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { remove_from_list(); _lru->_total_size -= _lru_size; - _lru = NULL; + _lru = nullptr; } _lru = lru; - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { _lru->_total_size += _lru_size; insert_before(_lru); } @@ -208,7 +208,7 @@ do_validate() { */ SimpleLruPage:: ~SimpleLruPage() { - if (_lru != NULL) { + if (_lru != nullptr) { dequeue_lru(); } } diff --git a/panda/src/gobj/sliderTable.I b/panda/src/gobj/sliderTable.I index 959c2e8651..be2d86f12f 100644 --- a/panda/src/gobj/sliderTable.I +++ b/panda/src/gobj/sliderTable.I @@ -59,7 +59,7 @@ get_num_sliders() const { */ INLINE const VertexSlider *SliderTable:: get_slider(size_t n) const { - nassertr(n < _sliders.size(), NULL); + nassertr(n < _sliders.size(), nullptr); return _sliders[n]._slider; } diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 8f3a91a54c..17023fce5c 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2454,6 +2454,6 @@ inc_simple_image_modified() { INLINE Texture::RamImage:: RamImage() : _page_size(0), - _pointer_image(NULL) + _pointer_image(nullptr) { } diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index d48c6a7c73..2479105093 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -546,7 +546,7 @@ read(const Filename &fullpath, const LoaderOptions &options) { cdata->inc_properties_modified(); cdata->inc_image_modified(); return do_read(cdata, fullpath, Filename(), 0, 0, 0, 0, false, false, - options, NULL); + options, nullptr); } /** @@ -566,7 +566,7 @@ read(const Filename &fullpath, const Filename &alpha_fullpath, cdata->inc_image_modified(); return do_read(cdata, fullpath, alpha_fullpath, primary_file_num_channels, alpha_file_channel, 0, 0, false, false, - options, NULL); + options, nullptr); } /** @@ -584,7 +584,7 @@ read(const Filename &fullpath, int z, int n, cdata->inc_properties_modified(); cdata->inc_image_modified(); return do_read(cdata, fullpath, Filename(), 0, 0, z, n, read_pages, read_mipmaps, - options, NULL); + options, nullptr); } /** @@ -817,7 +817,7 @@ get_aux_data(const string &key) const { if (di != _aux_data.end()) { return (*di).second; } - return NULL; + return nullptr; } /** @@ -850,30 +850,30 @@ make_from_txo(istream &in, const string &filename) { if (!din.open(in, filename)) { gobj_cat.error() << "Could not read texture object: " << filename << "\n"; - return NULL; + return nullptr; } string head; if (!din.read_header(head, _bam_header.size())) { gobj_cat.error() << filename << " is not a texture object file.\n"; - return NULL; + return nullptr; } if (head != _bam_header) { gobj_cat.error() << filename << " is not a texture object file.\n"; - return NULL; + return nullptr; } BamReader reader(&din); if (!reader.init()) { - return NULL; + return nullptr; } TypedWritable *object = reader.read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's really a cache data file and not a true txo file; @@ -882,23 +882,23 @@ make_from_txo(istream &in, const string &filename) { object = reader.read_object(); } - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { gobj_cat.error() << "Texture object " << filename << " is empty.\n"; - return NULL; + return nullptr; } else if (!object->is_of_type(Texture::get_class_type())) { gobj_cat.error() << "Texture object " << filename << " contains a " << object->get_type() << ", not a Texture.\n"; - return NULL; + return nullptr; } PT(Texture) other = DCAST(Texture, object); if (!reader.resolve()) { gobj_cat.error() << "Unable to fully resolve texture object file.\n"; - return NULL; + return nullptr; } return other; @@ -967,7 +967,7 @@ load_related(const InternalName *suffix) const { return (*ti).second; } if (cdata->_fullpath.empty()) { - return (Texture*)NULL; + return nullptr; } Filename main = cdata->_fullpath; main.set_basename_wo_extension(main.get_basename_wo_extension() + @@ -1216,7 +1216,7 @@ get_ram_mipmap_pointer(int n) const { if (n < (int)cdata->_ram_images.size()) { return cdata->_ram_images[n]._pointer_image; } - return NULL; + return nullptr; } /** @@ -1267,7 +1267,7 @@ clear_ram_mipmap_image(int n) { } cdata->_ram_images[n]._page_size = 0; cdata->_ram_images[n]._image.clear(); - cdata->_ram_images[n]._pointer_image = NULL; + cdata->_ram_images[n]._pointer_image = nullptr; } /** @@ -1277,7 +1277,7 @@ clear_ram_mipmap_image(int n) { PTA_uchar Texture:: modify_simple_ram_image() { CDWriter cdata(_cycler, true); - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); return cdata->_simple_ram_image._image; } @@ -1295,7 +1295,7 @@ new_simple_ram_image(int x_size, int y_size) { cdata->_simple_y_size = y_size; cdata->_simple_ram_image._image = PTA_uchar::empty_array(expected_page_size); cdata->_simple_ram_image._page_size = expected_page_size; - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); cdata->inc_simple_image_modified(); return cdata->_simple_ram_image._image; @@ -1381,7 +1381,7 @@ generate_simple_ram_image() { convert_from_pnmimage(image, expected_page_size, x_size, 0, 0, 0, scaled, 4, 1); do_set_simple_ram_image(cdata, image, x_size, y_size); - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); } /** @@ -1405,7 +1405,7 @@ peek() { return peeker; } - return NULL; + return nullptr; } /** @@ -1567,7 +1567,7 @@ release(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; for (ci = temp.begin(); ci != temp.end(); ++ci) { TextureContext *tc = (*ci).second; - if (tc != (TextureContext *)NULL) { + if (tc != nullptr) { prepared_objects->release_texture(tc); } } @@ -1602,7 +1602,7 @@ release_all() { Contexts::iterator ci; for (ci = temp.begin(); ci != temp.end(); ++ci) { TextureContext *tc = (*ci).second; - if (tc != (TextureContext *)NULL) { + if (tc != nullptr) { prepared_objects->release_texture(tc); } } @@ -2706,7 +2706,7 @@ adjust_size(int &x_size, int &y_size, const string &name, if (max_dimension < 0) { GraphicsStateGuardianBase *gsg = GraphicsStateGuardianBase::get_default_gsg(); - if (gsg != (GraphicsStateGuardianBase *)NULL) { + if (gsg != nullptr) { max_dimension = gsg->get_max_texture_dimension(); } } @@ -2778,7 +2778,7 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, } bool header_only = ((options.get_texture_flags() & (LoaderOptions::TF_preload | LoaderOptions::TF_preload_simple)) == 0); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { header_only = false; } @@ -2789,21 +2789,21 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, } if (is_txo_filename(fullpath)) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } return do_read_txo_file(cdata, fullpath); } if (is_dds_filename(fullpath)) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } return do_read_dds_file(cdata, fullpath, header_only); } if (is_ktx_filename(fullpath)) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } return do_read_ktx_file(cdata, fullpath, header_only); @@ -3013,15 +3013,15 @@ bool Texture:: do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, int z, int n, int primary_file_num_channels, int alpha_file_channel, const LoaderOptions &options, bool header_only, BamCacheRecord *record) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { nassertr(!header_only, false); record->add_dependent_file(fullpath); } PNMImage image; PfmFile pfm; - PNMReader *image_reader = image.make_reader(fullpath, NULL, false); - if (image_reader == NULL) { + PNMReader *image_reader = image.make_reader(fullpath, nullptr, false); + if (image_reader == nullptr) { gobj_cat.error() << "Texture::read() - couldn't read: " << fullpath << endl; return false; @@ -3125,15 +3125,15 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa PNMImage alpha_image; if (!alpha_fullpath.empty()) { - PNMReader *alpha_image_reader = alpha_image.make_reader(alpha_fullpath, NULL, false); - if (alpha_image_reader == NULL) { + PNMReader *alpha_image_reader = alpha_image.make_reader(alpha_fullpath, nullptr, false); + if (alpha_image_reader == nullptr) { gobj_cat.error() << "Texture::read() - couldn't read: " << alpha_fullpath << endl; return false; } alpha_image.copy_header_from(*alpha_image_reader); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(alpha_fullpath); } @@ -3468,7 +3468,7 @@ do_read_txo_file(CData *cdata, const Filename &fullpath) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << fullpath << "\n"; @@ -3497,7 +3497,7 @@ do_read_txo_file(CData *cdata, const Filename &fullpath) { bool Texture:: do_read_txo(CData *cdata, istream &in, const string &filename) { PT(Texture) other = make_from_txo(in, filename); - if (other == (Texture *)NULL) { + if (other == nullptr) { return false; } @@ -3523,7 +3523,7 @@ do_read_dds_file(CData *cdata, const Filename &fullpath, bool header_only) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << fullpath << "\n"; @@ -3632,7 +3632,7 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) // Determine the function to use to read the DDS image. typedef PTA_uchar (*ReadDDSLevelFunc)(Texture *tex, Texture::CData *cdata, const DDSHeader &header, int n, istream &in); - ReadDDSLevelFunc func = NULL; + ReadDDSLevelFunc func = nullptr; Format format = F_rgb; ComponentType component_type = T_unsigned_byte; @@ -4173,7 +4173,7 @@ do_read_ktx_file(CData *cdata, const Filename &fullpath, bool header_only) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << fullpath << "\n"; @@ -5144,7 +5144,7 @@ do_write_txo_file(const CData *cdata, const Filename &fullpath) const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); Filename filename = Filename::binary_filename(fullpath); ostream *out = vfs->open_write_file(filename, true, true); - if (out == NULL) { + if (out == nullptr) { gobj_cat.error() << "Unable to open " << filename << "\n"; return false; @@ -5234,7 +5234,7 @@ unlocked_ensure_ram_image(bool allow_compression) { } // We need to reload. - nassertr(!_reloading, NULL); + nassertr(!_reloading, nullptr); _reloading = true; PT(Texture) tex = do_make_copy(cdata); @@ -5288,7 +5288,7 @@ unlocked_ensure_ram_image(bool allow_compression) { cdataw->_ram_image_compression = cdata_tex->_ram_image_compression; cdataw->_ram_images = cdata_tex->_ram_images; - nassertr(_reloading, NULL); + nassertr(_reloading, nullptr); _reloading = false; // We don't generally increment the cdata->_image_modified semaphore, @@ -5322,7 +5322,7 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { // See if the texture can be found in the on-disk cache, if it is active. record = cache->lookup(cdata->_fullpath, "txo"); - if (record != (BamCacheRecord *)NULL && + if (record != nullptr && record->has_data()) { PT(Texture) tex = DCAST(Texture, record->get_data()); @@ -5413,7 +5413,7 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { } do_read(cdata, cdata->_fullpath, cdata->_alpha_fullpath, cdata->_primary_file_num_channels, cdata->_alpha_file_channel, - z, n, cdata->_has_read_pages, cdata->_has_read_mipmaps, options, NULL); + z, n, cdata->_has_read_pages, cdata->_has_read_mipmaps, options, nullptr); if (orig_num_components == cdata->_num_components) { // Restore the original format, in case it was needlessly changed during @@ -5421,10 +5421,10 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { cdata->_format = orig_format; } - if (do_has_ram_image(cdata) && record != (BamCacheRecord *)NULL) { + if (do_has_ram_image(cdata) && record != nullptr) { if (cache->get_cache_textures() || (cdata->_ram_image_compression != CM_off && cache->get_cache_compressed_textures())) { // Update the cache. - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(cdata->_fullpath); } record->set_data(this, this); @@ -5459,7 +5459,7 @@ do_make_ram_image(CData *cdata) { cdata->_ram_images.push_back(RamImage()); cdata->_ram_images[0]._page_size = do_get_expected_ram_page_size(cdata); cdata->_ram_images[0]._image = PTA_uchar::empty_array(image_size, get_class_type()); - cdata->_ram_images[0]._pointer_image = NULL; + cdata->_ram_images[0]._pointer_image = nullptr; cdata->_ram_image_compression = CM_off; if (cdata->_has_clear_color) { @@ -5502,7 +5502,7 @@ do_set_ram_image(CData *cdata, CPTA_uchar image, Texture::CompressionMode compre cdata->_ram_image_compression != compression) { cdata->_ram_images[0]._image = image.cast_non_const(); cdata->_ram_images[0]._page_size = page_size; - cdata->_ram_images[0]._pointer_image = NULL; + cdata->_ram_images[0]._pointer_image = nullptr; cdata->_ram_image_compression = compression; cdata->inc_image_modified(); } @@ -5536,7 +5536,7 @@ do_make_ram_mipmap_image(CData *cdata, int n) { size_t image_size = do_get_expected_ram_mipmap_image_size(cdata, n); cdata->_ram_images[n]._image = PTA_uchar::empty_array(image_size, get_class_type()); - cdata->_ram_images[n]._pointer_image = NULL; + cdata->_ram_images[n]._pointer_image = nullptr; cdata->_ram_images[n]._page_size = do_get_expected_ram_mipmap_page_size(cdata, n); if (cdata->_has_clear_color) { @@ -5571,7 +5571,7 @@ do_set_ram_mipmap_image(CData *cdata, int n, CPTA_uchar image, size_t page_size) if (cdata->_ram_images[n]._image != image || cdata->_ram_images[n]._page_size != page_size) { cdata->_ram_images[n]._image = image.cast_non_const(); - cdata->_ram_images[n]._pointer_image = NULL; + cdata->_ram_images[n]._pointer_image = nullptr; cdata->_ram_images[n]._page_size = page_size; cdata->inc_image_modified(); } @@ -5841,7 +5841,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, case Texture::F_rgb16: case Texture::F_rgb32: case Texture::F_rgb10_a2: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt1)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_dxt1)) { compression = CM_dxt1; } else if (gsg->get_supports_compressed_texture_format(CM_dxt3)) { compression = CM_dxt3; @@ -5855,7 +5855,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, break; case Texture::F_rgba4: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt3)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_dxt3)) { compression = CM_dxt3; } else if (gsg->get_supports_compressed_texture_format(CM_dxt5)) { compression = CM_dxt5; @@ -5869,7 +5869,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, case Texture::F_rgba12: case Texture::F_rgba16: case Texture::F_rgba32: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt5)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_dxt5)) { compression = CM_dxt5; } else if (gsg->get_supports_compressed_texture_format(CM_etc2)) { compression = CM_etc2; @@ -5878,7 +5878,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, case Texture::F_red: case Texture::F_rg: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_rgtc)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_rgtc)) { compression = CM_rgtc; } else if (gsg->get_supports_compressed_texture_format(CM_eac)) { compression = CM_eac; @@ -7289,7 +7289,7 @@ get_ram_image_as(const string &requested_format) { // Make sure we can grab something that's uncompressed. CPTA_uchar data = do_get_uncompressed_ram_image(cdata); - if (data == NULL) { + if (data == nullptr) { gobj_cat.error() << "Couldn't find an uncompressed RAM image!\n"; return CPTA_uchar(get_class_type()); } @@ -7495,7 +7495,7 @@ do_set_simple_ram_image(CData *cdata, CPTA_uchar image, int x_size, int y_size) cdata->_simple_y_size = y_size; cdata->_simple_ram_image._image = image.cast_non_const(); cdata->_simple_ram_image._page_size = image.size(); - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); cdata->inc_simple_image_modified(); } @@ -7697,7 +7697,7 @@ do_generate_ram_mipmap_images(CData *cdata, bool allow_recompress) { RamImage uncompressed_image = cdata->_ram_images[0]; cdata->_ram_images.erase(cdata->_ram_images.begin()); - bool success = do_compress_ram_image(cdata, orig_compression_mode, QL_default, NULL); + bool success = do_compress_ram_image(cdata, orig_compression_mode, QL_default, nullptr); // Now restore the toplevel image. if (success) { if (gobj_cat.is_debug()) { @@ -10159,7 +10159,7 @@ make_this_from_bam(const FactoryParams ¶ms) { has_read_mipmaps = scan.get_bool(); } - Texture *me = NULL; + Texture *me = nullptr; if (has_rawdata) { // If the raw image data is included, then just load the texture directly // from the stream, and return it. In this case we return the "this" @@ -10252,7 +10252,7 @@ make_this_from_bam(const FactoryParams ¶ms) { } } - if (me != (Texture *)NULL) { + if (me != nullptr) { me->set_name(name); CDWriter cdata_me(me->_cycler, true); me->do_fillin_from(cdata_me, dummy); diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 890710a216..7e7f5ad57f 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -279,7 +279,7 @@ PUBLISHED: BLOCKING bool read(const Filename &fullpath, const Filename &alpha_fullpath, int primary_file_num_channels, int alpha_file_channel, int z, int n, bool read_pages, bool read_mipmaps, - BamCacheRecord *record = NULL, + BamCacheRecord *record = nullptr, const LoaderOptions &options = LoaderOptions()); BLOCKING INLINE bool write(const Filename &fullpath); @@ -466,7 +466,7 @@ PUBLISHED: BLOCKING INLINE bool compress_ram_image(CompressionMode compression = CM_on, QualityLevel quality_level = QL_default, - GraphicsStateGuardianBase *gsg = NULL); + GraphicsStateGuardianBase *gsg = nullptr); BLOCKING INLINE bool uncompress_ram_image(); INLINE int get_num_ram_mipmap_images() const; diff --git a/panda/src/gobj/textureCollection.cxx b/panda/src/gobj/textureCollection.cxx index ce2eee4519..16c6a908f6 100644 --- a/panda/src/gobj/textureCollection.cxx +++ b/panda/src/gobj/textureCollection.cxx @@ -189,7 +189,7 @@ find_texture(const string &name) const { return texture; } } - return NULL; + return nullptr; } /** @@ -205,7 +205,7 @@ get_num_textures() const { */ Texture *TextureCollection:: get_texture(int index) const { - nassertr(index >= 0 && index < (int)_textures.size(), NULL); + nassertr(index >= 0 && index < (int)_textures.size(), nullptr); return _textures[index]; } @@ -216,7 +216,7 @@ get_texture(int index) const { */ Texture *TextureCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_textures.size(), NULL); + nassertr(index >= 0 && index < (int)_textures.size(), nullptr); return _textures[index]; } diff --git a/panda/src/gobj/textureCollection_ext.cxx b/panda/src/gobj/textureCollection_ext.cxx index de104e775c..233249ee6f 100644 --- a/panda/src/gobj/textureCollection_ext.cxx +++ b/panda/src/gobj/textureCollection_ext.cxx @@ -27,7 +27,7 @@ extern struct Dtool_PyTypedObject Dtool_Texture; void Extension:: __init__(PyObject *self, PyObject *sequence) { PyObject *fast = PySequence_Fast(sequence, "TextureCollection constructor requires a sequence"); - if (fast == NULL) { + if (fast == nullptr) { return; } @@ -36,13 +36,13 @@ __init__(PyObject *self, PyObject *sequence) { for (int i = 0; i < size; ++i) { PyObject *item = PySequence_Fast_GET_ITEM(fast, i); - if (item == NULL) { + if (item == nullptr) { return; } Texture *tex; DTOOL_Call_ExtractThisPointerForType(item, &Dtool_Texture, (void **)&tex); - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // Unable to add item--probably it wasn't of the appropriate type. ostringstream stream; stream << "Element " << i << " in sequence passed to TextureCollection constructor is not a Texture"; @@ -72,8 +72,8 @@ __reduce__(PyObject *self) const { // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } // Since a TextureCollection is itself an iterator, we can simply pass it as diff --git a/panda/src/gobj/texturePool.I b/panda/src/gobj/texturePool.I index 499ab04a83..d8b1e96c9d 100644 --- a/panda/src/gobj/texturePool.I +++ b/panda/src/gobj/texturePool.I @@ -30,7 +30,7 @@ has_texture(const Filename &filename) { */ INLINE bool TexturePool:: verify_texture(const Filename &filename) { - return load_texture(filename) != (Texture *)NULL; + return load_texture(filename) != nullptr; } /** diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index 6b4c0a5168..1b39a24273 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -90,14 +90,14 @@ get_texture_type(const string &extension) const { // Check the PNM type registry. PNMFileTypeRegistry *pnm_reg = PNMFileTypeRegistry::get_global_ptr(); PNMFileType *type = pnm_reg->get_type_from_extension(c); - if (type != (PNMFileType *)NULL || c == "txo" || c == "dds" || c == "ktx") { + if (type != nullptr || c == "txo" || c == "dds" || c == "ktx") { // This is a known image type; create an ordinary Texture. ((TexturePool *)this)->_type_registry[c] = Texture::make_texture; return Texture::make_texture; } // This is an unknown texture type. - return NULL; + return nullptr; } /** @@ -124,7 +124,7 @@ write_texture_types(ostream &out, int indent_level) const { string extension = (*ti).first; MakeTextureFunc *func = (*ti).second; - if (pnm_reg->get_type_from_extension(extension) == NULL) { + if (pnm_reg->get_type_from_extension(extension) == nullptr) { PT(Texture) tex = func(); string name = tex->get_type().get_name(); indent(out, indent_level) << name; @@ -140,7 +140,7 @@ write_texture_types(ostream &out, int indent_level) const { */ TexturePool *TexturePool:: get_global_ptr() { - if (_global_ptr == (TexturePool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TexturePool; // We have to call this here, not in the constructor, so that the @@ -221,7 +221,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() @@ -236,11 +236,11 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, filename.set_binary(); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << filename << "\n"; - return NULL; + return nullptr; } if (gobj_cat.is_debug()) { @@ -252,8 +252,8 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, tex = Texture::make_from_txo(*in, filename); vfs->close_read_file(in); - if (tex == (Texture *)NULL) { - return NULL; + if (tex == nullptr) { + return nullptr; } tex->set_fullpath(filename); tex->clear_alpha_fullpath(); @@ -266,7 +266,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, 0, 0, false, read_mipmaps, record, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } } @@ -274,7 +274,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, tex->generate_simple_ram_image(); } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -298,7 +298,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); tex->set_fullpath(filename); tex->_texture_pool_key = filename; @@ -384,7 +384,7 @@ ns_load_texture(const Filename &orig_filename, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() @@ -392,18 +392,18 @@ ns_load_texture(const Filename &orig_filename, << alpha_filename << endl; tex = ns_make_texture(filename.get_extension()); if (!tex->read(filename, alpha_filename, primary_file_num_channels, - alpha_file_channel, 0, 0, false, read_mipmaps, NULL, + alpha_file_channel, 0, 0, false, read_mipmaps, nullptr, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } if (options.get_texture_flags() & LoaderOptions::TF_preload_simple) { tex->generate_simple_ram_image(); } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -427,7 +427,7 @@ ns_load_texture(const Filename &orig_filename, } // Set the original filenames, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); tex->set_fullpath(filename); tex->set_alpha_filename(orig_alpha_filename); @@ -502,7 +502,7 @@ ns_load_3d_texture(const Filename &filename_pattern, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == nullptr || tex->get_texture_type() != Texture::TT_3d_texture) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). @@ -513,9 +513,9 @@ ns_load_3d_texture(const Filename &filename_pattern, if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -539,7 +539,7 @@ ns_load_3d_texture(const Filename &filename_pattern, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); tex->set_fullpath(filename); tex->_texture_pool_key = filename; @@ -606,7 +606,7 @@ ns_load_2d_texture_array(const Filename &filename_pattern, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == nullptr || tex->get_texture_type() != Texture::TT_2d_texture_array) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). @@ -617,9 +617,9 @@ ns_load_2d_texture_array(const Filename &filename_pattern, if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -643,7 +643,7 @@ ns_load_2d_texture_array(const Filename &filename_pattern, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); tex->set_fullpath(filename); tex->_texture_pool_key = unique_filename; @@ -705,7 +705,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == nullptr || tex->get_texture_type() != Texture::TT_cube_map) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). @@ -716,9 +716,9 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -742,7 +742,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); tex->set_fullpath(filename); tex->_texture_pool_key = filename; @@ -778,7 +778,7 @@ Texture *TexturePool:: ns_get_normalization_cube_map(int size) { MutexHolder holder(_lock); - if (_normalization_cube_map == (Texture *)NULL) { + if (_normalization_cube_map == nullptr) { _normalization_cube_map = new Texture("normalization_cube_map"); } if (_normalization_cube_map->get_x_size() < size || @@ -796,7 +796,7 @@ Texture *TexturePool:: ns_get_alpha_scale_map() { MutexHolder holder(_lock); - if (_alpha_scale_map == (Texture *)NULL) { + if (_alpha_scale_map == nullptr) { _alpha_scale_map = new Texture("alpha_scale_map"); _alpha_scale_map->generate_alpha_scale_map(); } @@ -860,7 +860,7 @@ ns_release_all_textures() { } _textures.clear(); - _normalization_cube_map = NULL; + _normalization_cube_map = nullptr; // Blow away the cache of resolved relative filenames. _relpath_lookup.clear(); @@ -893,14 +893,14 @@ ns_garbage_collect() { _textures.swap(new_set); - if (_normalization_cube_map != (Texture *)NULL && + if (_normalization_cube_map != nullptr && _normalization_cube_map->get_ref_count() == 1) { if (gobj_cat.is_debug()) { gobj_cat.debug() << "Releasing normalization cube map\n"; } ++num_released; - _normalization_cube_map = NULL; + _normalization_cube_map = nullptr; } return num_released; @@ -957,7 +957,7 @@ ns_find_texture(const string &name) const { } } - return NULL; + return nullptr; } /** @@ -988,7 +988,7 @@ ns_find_all_textures(const string &name) const { PT(Texture) TexturePool:: ns_make_texture(const string &extension) const { MakeTextureFunc *func = get_texture_type(extension); - if (func != NULL) { + if (func != nullptr) { return func(); } @@ -1034,7 +1034,7 @@ void TexturePool:: try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, PT(BamCacheRecord) &record, bool &compressed_cache_record, const LoaderOptions &options) { - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // The texture was not supplied by a texture filter. See if it can be // found in the on-disk cache, if it is active. if ((cache->get_cache_textures() || cache->get_cache_compressed_textures()) && !textures_header_only) { @@ -1049,7 +1049,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, dummy.clear(); record = cache->lookup(filename, "txo"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { if (record->has_data()) { tex = DCAST(Texture, record->get_data()); compressed_cache_record = (tex->get_ram_image_compression() != Texture::CM_off); @@ -1063,8 +1063,8 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, gobj_cat.debug() << "Not caching uncompressed texture " << *tex << "\n"; } - tex = NULL; - record = NULL; + tex = nullptr; + record = nullptr; } else if (x_size != tex->get_x_size() || y_size != tex->get_y_size()) { @@ -1079,7 +1079,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, << " instead of " << x_size << " x " << y_size << "; dropping cache.\n"; } - tex = NULL; + tex = nullptr; } else if (!tex->has_compression() && tex->get_ram_image_compression() != Texture::CM_off) { // This texture shouldn't be compressed, but it is. Go reload it. @@ -1088,7 +1088,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, << "Cached texture " << *tex << " is compressed in cache; dropping cache.\n"; } - tex = NULL; + tex = nullptr; } else { gobj_cat.info() @@ -1127,7 +1127,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, gobj_cat.debug() << "Not caching uncompressed texture\n"; } - record = NULL; + record = nullptr; } } } @@ -1170,7 +1170,7 @@ report_texture_unreadable(const Filename &filename) const { // Maybe the filename extension is unknown. MakeTextureFunc *func = get_texture_type(filename.get_extension()); - if (func == (MakeTextureFunc *)NULL) { + if (func == nullptr) { gobj_cat.error() << "Texture extension \"" << filename.get_extension() << "\" is unknown. Supported texture types:\n"; @@ -1199,7 +1199,7 @@ pre_load(const Filename &orig_filename, const Filename &orig_alpha_filename, tex = (*fi)->pre_load(orig_filename, orig_alpha_filename, primary_file_num_channels, alpha_file_channel, read_mipmaps, options); - if (tex != (Texture *)NULL) { + if (tex != nullptr) { return tex; } } @@ -1247,7 +1247,7 @@ load_filters() { gobj_cat->info() << "loading texture filter: " << dlname.to_os_specific() << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { gobj_cat.info() << "Unable to load: " << load_dso_error() << endl; } diff --git a/panda/src/gobj/texturePoolFilter.cxx b/panda/src/gobj/texturePoolFilter.cxx index 6d752dd7c7..f0b98c877e 100644 --- a/panda/src/gobj/texturePoolFilter.cxx +++ b/panda/src/gobj/texturePoolFilter.cxx @@ -32,7 +32,7 @@ TexturePoolFilter:: PT(Texture) TexturePoolFilter:: pre_load(const Filename &, const Filename &, int, int, bool, const LoaderOptions &) { - return NULL; + return nullptr; } /** diff --git a/panda/src/gobj/textureReloadRequest.I b/panda/src/gobj/textureReloadRequest.I index d17bdc72b4..a4e4e6fd7b 100644 --- a/panda/src/gobj/textureReloadRequest.I +++ b/panda/src/gobj/textureReloadRequest.I @@ -24,8 +24,8 @@ TextureReloadRequest(const string &name, _texture(texture), _allow_compressed(allow_compressed) { - nassertv(_pgo != (PreparedGraphicsObjects *)NULL); - nassertv(_texture != (Texture *)NULL); + nassertv(_pgo != nullptr); + nassertv(_texture != nullptr); } /** diff --git a/panda/src/gobj/textureStage.I b/panda/src/gobj/textureStage.I index 17034231a3..dd8e24bce2 100644 --- a/panda/src/gobj/textureStage.I +++ b/panda/src/gobj/textureStage.I @@ -139,7 +139,7 @@ get_texcoord_name() const { */ INLINE InternalName *TextureStage:: get_tangent_name() const { - if (_texcoord_name->get_parent() == NULL) { + if (_texcoord_name->get_parent() == nullptr) { return InternalName::get_tangent(); } else { return InternalName::get_tangent_name(_texcoord_name->get_basename()); @@ -152,7 +152,7 @@ get_tangent_name() const { */ INLINE InternalName *TextureStage:: get_binormal_name() const { - if (_texcoord_name->get_parent() == NULL) { + if (_texcoord_name->get_parent() == nullptr) { return InternalName::get_binormal(); } else { return InternalName::get_binormal_name(_texcoord_name->get_basename()); @@ -659,7 +659,7 @@ operator < (const TextureStage &other) const { */ INLINE TextureStage *TextureStage:: get_default() { - if (_default_stage == (TextureStage *)NULL) { + if (_default_stage == nullptr) { _default_stage = new TextureStage("default"); } return _default_stage; diff --git a/panda/src/gobj/textureStagePool.cxx b/panda/src/gobj/textureStagePool.cxx index 2d9b33a036..f47addd52b 100644 --- a/panda/src/gobj/textureStagePool.cxx +++ b/panda/src/gobj/textureStagePool.cxx @@ -17,7 +17,7 @@ #include "configVariableEnum.h" #include "string_utils.h" -TextureStagePool *TextureStagePool::_global_ptr = (TextureStagePool *)NULL; +TextureStagePool *TextureStagePool::_global_ptr = nullptr; /** @@ -86,7 +86,7 @@ ns_get_stage(TextureStage *temp) { } } - return NULL; + return nullptr; } /** @@ -258,7 +258,7 @@ ns_list_contents(ostream &out) const { */ TextureStagePool *TextureStagePool:: get_global_ptr() { - if (_global_ptr == (TextureStagePool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TextureStagePool; } return _global_ptr; diff --git a/panda/src/gobj/transformBlend.I b/panda/src/gobj/transformBlend.I index 936ca57cc4..aed8e95ca7 100644 --- a/panda/src/gobj/transformBlend.I +++ b/panda/src/gobj/transformBlend.I @@ -128,7 +128,7 @@ get_num_transforms() const { */ INLINE const VertexTransform *TransformBlend:: get_transform(size_t n) const { - nassertr(n < _entries.size(), NULL); + nassertr(n < _entries.size(), nullptr); return _entries[n]._transform; } diff --git a/panda/src/gobj/transformTable.I b/panda/src/gobj/transformTable.I index ce8fe2d196..acf7aa95fb 100644 --- a/panda/src/gobj/transformTable.I +++ b/panda/src/gobj/transformTable.I @@ -59,7 +59,7 @@ get_num_transforms() const { */ INLINE const VertexTransform *TransformTable:: get_transform(size_t n) const { - nassertr(n < _transforms.size(), NULL); + nassertr(n < _transforms.size(), nullptr); return _transforms[n]; } diff --git a/panda/src/gobj/transformTable.cxx b/panda/src/gobj/transformTable.cxx index 73d0665079..df66f7a696 100644 --- a/panda/src/gobj/transformTable.cxx +++ b/panda/src/gobj/transformTable.cxx @@ -221,7 +221,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _transforms.reserve(num_transforms); for (size_t i = 0; i < num_transforms; ++i) { manager->read_pointer(scan); - _transforms.push_back(NULL); + _transforms.push_back(nullptr); } manager->read_cdata(scan, _cycler); diff --git a/panda/src/gobj/vertexDataBlock.I b/panda/src/gobj/vertexDataBlock.I index 61aa8e3a14..7660bd315f 100644 --- a/panda/src/gobj/vertexDataBlock.I +++ b/panda/src/gobj/vertexDataBlock.I @@ -38,10 +38,10 @@ get_page() const { */ INLINE unsigned char *VertexDataBlock:: get_pointer(bool force) const { - nassertr(get_page() != (VertexDataPage *)NULL, NULL); + nassertr(get_page() != nullptr, nullptr); unsigned char *page_data = get_page()->get_page_data(force); - if (page_data == (unsigned char *)NULL) { - return NULL; + if (page_data == nullptr) { + return nullptr; } else { return page_data + get_start(); } diff --git a/panda/src/gobj/vertexDataBook.cxx b/panda/src/gobj/vertexDataBook.cxx index 5be3a0718a..555033da3c 100644 --- a/panda/src/gobj/vertexDataBook.cxx +++ b/panda/src/gobj/vertexDataBook.cxx @@ -141,7 +141,7 @@ do_alloc(size_t size) { // This is why we've already computed pnext. VertexDataBlock *block = page->do_alloc(size); - if (block != (VertexDataBlock *)NULL) { + if (block != nullptr) { // This page worked. return block; } diff --git a/panda/src/gobj/vertexDataBuffer.I b/panda/src/gobj/vertexDataBuffer.I index 3bc1f85b80..f3770d3b21 100644 --- a/panda/src/gobj/vertexDataBuffer.I +++ b/panda/src/gobj/vertexDataBuffer.I @@ -16,7 +16,7 @@ */ INLINE VertexDataBuffer:: VertexDataBuffer() : - _resident_data(NULL), + _resident_data(nullptr), _size(0), _reserved_size(0) { @@ -27,7 +27,7 @@ VertexDataBuffer() : */ INLINE VertexDataBuffer:: VertexDataBuffer(size_t size) : - _resident_data(NULL), + _resident_data(nullptr), _size(0), _reserved_size(0) { @@ -40,7 +40,7 @@ VertexDataBuffer(size_t size) : */ INLINE VertexDataBuffer:: VertexDataBuffer(const VertexDataBuffer ©) : - _resident_data(NULL), + _resident_data(nullptr), _size(0), _reserved_size(0) { @@ -68,11 +68,11 @@ get_read_pointer(bool force) const { LightMutexHolder holder(_lock); const unsigned char *ptr; - if (_resident_data != (unsigned char *)NULL || _size == 0) { + if (_resident_data != nullptr || _size == 0) { ptr = _resident_data; } else { - nassertr(_block != (VertexDataBlock *)NULL, NULL); - nassertr(_reserved_size >= _size, NULL); + nassertr(_block != nullptr, nullptr); + nassertr(_reserved_size >= _size, nullptr); // We don't necessarily need to page the buffer all the way into independent // status; it's sufficient just to return the block's pointer, which will @@ -92,10 +92,10 @@ INLINE unsigned char *VertexDataBuffer:: get_write_pointer() { LightMutexHolder holder(_lock); - if (_resident_data == (unsigned char *)NULL && _reserved_size != 0) { + if (_resident_data == nullptr && _reserved_size != 0) { do_page_in(); } - nassertr(_reserved_size >= _size, NULL); + nassertr(_reserved_size >= _size, nullptr); #ifdef _DEBUG assert(((uintptr_t)_resident_data % MEMORY_HOOK_ALIGNMENT) == 0); #endif @@ -133,7 +133,7 @@ set_size(size_t size) { nassertv(size <= _reserved_size); if (size != _size) { - if (_resident_data == (unsigned char *)NULL && _reserved_size != 0) { + if (_resident_data == nullptr && _reserved_size != 0) { do_page_in(); } diff --git a/panda/src/gobj/vertexDataBuffer.cxx b/panda/src/gobj/vertexDataBuffer.cxx index 19f50b3013..a891811091 100644 --- a/panda/src/gobj/vertexDataBuffer.cxx +++ b/panda/src/gobj/vertexDataBuffer.cxx @@ -25,12 +25,12 @@ operator = (const VertexDataBuffer ©) { LightMutexHolder holder(_lock); LightMutexHolder holder2(copy._lock); - if (_resident_data != (unsigned char *)NULL) { + if (_resident_data != nullptr) { nassertv(_reserved_size != 0); get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; } - if (copy._resident_data != (unsigned char *)NULL && copy._size != 0) { + if (copy._resident_data != nullptr && copy._size != 0) { // We only allocate _size bytes, not the full _reserved_size allocated by // the original copy. _resident_data = (unsigned char *)get_class_type().allocate_array(copy._size); @@ -87,18 +87,18 @@ do_clean_realloc(size_t reserved_size) { } // Page in if we're currently paged out. - if (_reserved_size != 0 && _resident_data == (unsigned char *)NULL) { + if (_reserved_size != 0 && _resident_data == nullptr) { do_page_in(); } if (_reserved_size == 0) { - nassertv(_resident_data == (unsigned char *)NULL); + nassertv(_resident_data == nullptr); _resident_data = (unsigned char *)get_class_type().allocate_array(reserved_size); } else { - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); _resident_data = (unsigned char *)get_class_type().reallocate_array(_resident_data, reserved_size); } - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); _reserved_size = reserved_size; } @@ -113,25 +113,25 @@ do_clean_realloc(size_t reserved_size) { */ void VertexDataBuffer:: do_unclean_realloc(size_t reserved_size) { - if (reserved_size != _reserved_size || _resident_data == (unsigned char *)NULL) { + if (reserved_size != _reserved_size || _resident_data == nullptr) { if (gobj_cat.is_debug()) { gobj_cat.debug() << this << ".unclean_realloc(" << reserved_size << ")\n"; } // If we're paged out, discard the page. - _block = NULL; + _block = nullptr; - if (_resident_data != (unsigned char *)NULL) { + if (_resident_data != nullptr) { nassertv(_reserved_size != 0); get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; _reserved_size = 0; } if (reserved_size != 0) { - nassertv(_resident_data == (unsigned char *)NULL); + nassertv(_resident_data == nullptr); _resident_data = (unsigned char *)get_class_type().allocate_array(reserved_size); } @@ -151,30 +151,30 @@ do_unclean_realloc(size_t reserved_size) { */ void VertexDataBuffer:: do_page_out(VertexDataBook &book) { - if (_block != (VertexDataBlock *)NULL || _reserved_size == 0) { + if (_block != nullptr || _reserved_size == 0) { // We're already paged out. return; } - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); if (_size == 0) { // It's an empty buffer. Just deallocate it; don't bother to create a // block. get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; _reserved_size = 0; } else { // It's a nonempty buffer, so write _size bytes (but not the full // _reserved_size bytes) to a block. _block = book.alloc(_size); - nassertv(_block != (VertexDataBlock *)NULL); + nassertv(_block != nullptr); unsigned char *pointer = _block->get_pointer(true); - nassertv(pointer != (unsigned char *)NULL); + nassertv(pointer != nullptr); memcpy(pointer, _resident_data, _size); get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; _reserved_size = _size; } @@ -189,16 +189,16 @@ do_page_out(VertexDataBook &book) { */ void VertexDataBuffer:: do_page_in() { - if (_resident_data != (unsigned char *)NULL || _reserved_size == 0) { + if (_resident_data != nullptr || _reserved_size == 0) { // We're already paged in. return; } - nassertv(_block != (VertexDataBlock *)NULL); + nassertv(_block != nullptr); nassertv(_reserved_size == _size); _resident_data = (unsigned char *)get_class_type().allocate_array(_size); - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); memcpy(_resident_data, _block->get_pointer(true), _size); } diff --git a/panda/src/gobj/vertexDataPage.I b/panda/src/gobj/vertexDataPage.I index 0dd8109adb..d5dc44be9e 100644 --- a/panda/src/gobj/vertexDataPage.I +++ b/panda/src/gobj/vertexDataPage.I @@ -81,7 +81,7 @@ get_book() const { */ INLINE SimpleLru *VertexDataPage:: get_global_lru(RamClass rclass) { - nassertr(rclass >= 0 && rclass < RC_end_of_list, NULL); + nassertr(rclass >= 0 && rclass < RC_end_of_list, nullptr); return _global_lru[rclass]; } @@ -100,7 +100,7 @@ get_pending_lru() { */ INLINE VertexDataSaveFile *VertexDataPage:: get_save_file() { - if (_save_file == (VertexDataSaveFile *)NULL) { + if (_save_file == nullptr) { make_save_file(); } return _save_file; @@ -126,7 +126,7 @@ save_to_disk() { INLINE int VertexDataPage:: get_num_threads() { MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { return 0; } return _thread_mgr->get_num_threads(); @@ -139,7 +139,7 @@ get_num_threads() { INLINE int VertexDataPage:: get_num_pending_reads() { MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { return 0; } return _thread_mgr->get_num_pending_reads(); @@ -152,7 +152,7 @@ get_num_pending_reads() { INLINE int VertexDataPage:: get_num_pending_writes() { MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { return 0; } return _thread_mgr->get_num_pending_writes(); @@ -175,7 +175,7 @@ get_page_data(bool force) { } else { request_ram_class(RC_resident); if (_ram_class != RC_resident) { - return NULL; + return nullptr; } } } diff --git a/panda/src/gobj/vertexDataPage.cxx b/panda/src/gobj/vertexDataPage.cxx index ada598b9df..e7adb80d33 100644 --- a/panda/src/gobj/vertexDataPage.cxx +++ b/panda/src/gobj/vertexDataPage.cxx @@ -109,9 +109,9 @@ VertexDataPage(size_t book_size) : SimpleLruPage(book_size), _book_size(book_size), _block_size(0), - _book(NULL) + _book(nullptr) { - _page_data = NULL; + _page_data = nullptr; _size = 0; _uncompressed_size = 0; _ram_class = RC_resident; @@ -150,17 +150,17 @@ VertexDataPage:: { MutexHolder holder2(_tlock); if (_pending_ram_class != _ram_class) { - nassertv(_thread_mgr != (PageThreadManager *)NULL); + nassertv(_thread_mgr != nullptr); _thread_mgr->remove_page(this); } } - if (_page_data != NULL) { + if (_page_data != nullptr) { free_page_data(_page_data, _allocated_size); _size = 0; } - nassertv(_book == NULL); + nassertv(_book == nullptr); } /** @@ -176,7 +176,7 @@ stop_threads() { _thread_mgr.clear(); } - if (thread_mgr != (PageThreadManager *)NULL) { + if (thread_mgr != nullptr) { gobj_cat.info() << "Stopping vertex paging threads.\n"; thread_mgr->stop_threads(); @@ -200,7 +200,7 @@ flush_threads() { thread_mgr = _thread_mgr; } - if (thread_mgr != (PageThreadManager *)NULL) { + if (thread_mgr != nullptr) { thread_mgr->stop_threads(); MutexHolder holder(_tlock); thread_mgr->start_threads(num_threads); @@ -244,7 +244,7 @@ changed_contiguous() { VertexDataBook::Pages::iterator pi = _book->_pages.find(this); nassertv(pi != _book->_pages.end()); _book->_pages.erase(pi); - _book = NULL; + _book = nullptr; delete this; return; } @@ -301,7 +301,7 @@ VertexDataBlock *VertexDataPage:: do_alloc(size_t size) { VertexDataBlock *block = (VertexDataBlock *)SimpleAllocator::do_alloc(size); - if (block != (VertexDataBlock *)NULL && _ram_class != RC_disk) { + if (block != nullptr && _ram_class != RC_disk) { // When we allocate a new block within a resident page, we have to clear // the disk cache (since we have just invalidated it). _saved_block.clear(); @@ -321,7 +321,7 @@ void VertexDataPage:: make_resident_now() { MutexHolder holder(_tlock); if (_pending_ram_class != _ram_class) { - nassertv(_thread_mgr != (PageThreadManager *)NULL); + nassertv(_thread_mgr != nullptr); _thread_mgr->remove_page(this); } @@ -522,7 +522,7 @@ make_compressed() { size_t copied_size = 0; unsigned char *p = new_data; page = head; - while (page != NULL) { + while (page != nullptr) { memcpy(p, page->_buffer, page->_used_size); copied_size += page->_used_size; p += page->_used_size; @@ -573,7 +573,7 @@ make_disk() { } free_page_data(_page_data, _allocated_size); - _page_data = NULL; + _page_data = nullptr; _size = 0; set_ram_class(RC_disk); @@ -593,7 +593,7 @@ do_save_to_disk() { if (_ram_class == RC_resident || _ram_class == RC_compressed) { PStatTimer timer(_vdata_save_pcollector); - if (_saved_block == (VertexDataSaveBlock *)NULL) { + if (_saved_block == nullptr) { if (gobj_cat.is_debug()) { gobj_cat.debug() << "Storing page, " << _size << " bytes, to disk\n"; @@ -602,7 +602,7 @@ do_save_to_disk() { bool compressed = (_ram_class == RC_compressed); _saved_block = get_save_file()->write_data(_page_data, _allocated_size, compressed); - if (_saved_block == (VertexDataSaveBlock *)NULL) { + if (_saved_block == nullptr) { // Can't write it to disk. Too bad. return false; } @@ -626,8 +626,8 @@ do_save_to_disk() { void VertexDataPage:: do_restore_from_disk() { if (_ram_class == RC_disk) { - nassertv(_saved_block != (VertexDataSaveBlock *)NULL); - nassertv(_page_data == (unsigned char *)NULL && _size == 0); + nassertv(_saved_block != nullptr); + nassertv(_page_data == nullptr && _size == 0); PStatTimer timer(_vdata_restore_pcollector); @@ -643,7 +643,7 @@ do_restore_from_disk() { nassert_raise("read error"); } - nassertv(_page_data == (unsigned char *)NULL); + nassertv(_page_data == nullptr); _page_data = new_data; _size = buffer_size; _allocated_size = new_allocated_size; @@ -669,7 +669,7 @@ adjust_book_size() { new_size = 0; } - if (_book != (VertexDataBook *)NULL && new_size != _book_size) { + if (_book != nullptr && new_size != _book_size) { VertexDataBook::Pages::iterator pi = _book->_pages.find(this); nassertv(pi != _book->_pages.end()); _book->_pages.erase(pi); @@ -713,7 +713,7 @@ request_ram_class(RamClass ram_class) { } MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { // Create the thread manager. gobj_cat.info() << "Spawning " << num_threads << " vertex paging threads.\n"; @@ -812,7 +812,7 @@ add_page(VertexDataPage *page, RamClass ram_class) { */ void VertexDataPage::PageThreadManager:: remove_page(VertexDataPage *page) { - nassertv(page != (VertexDataPage *)NULL); + nassertv(page != nullptr); PageThreads::iterator ti; for (ti = _threads.begin(); ti != _threads.end(); ++ti) { @@ -980,7 +980,7 @@ thread_main() { _tlock.acquire(); - _working_page = NULL; + _working_page = nullptr; _working_cvar.notify(); Thread::consider_yield(); diff --git a/panda/src/gobj/vertexDataPage.h b/panda/src/gobj/vertexDataPage.h index 4c7fd02bf2..24cc6af7d0 100644 --- a/panda/src/gobj/vertexDataPage.h +++ b/panda/src/gobj/vertexDataPage.h @@ -176,7 +176,7 @@ private: public: DeflatePage() { _used_size = 0; - _next = NULL; + _next = nullptr; } ALLOC_DELETED_CHAIN(DeflatePage); diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index e602b51129..97a77688a8 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -70,7 +70,7 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, flags |= FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; #endif _handle = CreateFile(os_specific.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, CREATE_ALWAYS, flags, NULL); + 0, nullptr, CREATE_ALWAYS, flags, nullptr); if (_handle != INVALID_HANDLE_VALUE) { // The file was successfully opened and locked. break; @@ -167,7 +167,7 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, VertexDataSaveFile:: ~VertexDataSaveFile() { #ifdef _WIN32 - if (_handle != NULL) { + if (_handle != nullptr) { CloseHandle(_handle); } #else @@ -196,11 +196,11 @@ write_data(const unsigned char *data, size_t size, bool compressed) { MutexHolder holder(_lock); if (!_is_valid) { - return NULL; + return nullptr; } PT(VertexDataSaveBlock) block = (VertexDataSaveBlock *)SimpleAllocator::do_alloc(size); - if (block != (VertexDataSaveBlock *)NULL) { + if (block != nullptr) { _total_file_size = max(_total_file_size, block->get_start() + size); block->set_compressed(compressed); @@ -224,11 +224,11 @@ write_data(const unsigned char *data, size_t size, bool compressed) { << "Error writing " << size << " bytes to save file, windows error code 0x" << hex << error << dec << ". Disk full?\n"; - return NULL; + return nullptr; } success = GetOverlappedResult(_handle, &overlapped, &bytes_written, false); } - nassertr(bytes_written == size, NULL); + nassertr(bytes_written == size, nullptr); double finish_time = ClockObject::get_global_clock()->get_real_time(); if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -239,7 +239,7 @@ write_data(const unsigned char *data, size_t size, bool compressed) { if (lseek(_fd, block->get_start(), SEEK_SET) == -1) { gobj_cat.error() << "Error seeking to position " << block->get_start() << " in save file.\n"; - return NULL; + return nullptr; } while (size > 0) { @@ -250,7 +250,7 @@ write_data(const unsigned char *data, size_t size, bool compressed) { } else { gobj_cat.error() << "Error writing " << size << " bytes to save file. Disk full?\n"; - return NULL; + return nullptr; } continue; } @@ -306,11 +306,11 @@ read_data(unsigned char *data, size_t size, VertexDataSaveBlock *block) { << "Error reading " << size << " bytes from save file, windows error code 0x" << hex << error << dec << ".\n"; - return NULL; + return false; } success = GetOverlappedResult(_handle, &overlapped, &bytes_read, false); } - nassertr(bytes_read == size, NULL); + nassertr(bytes_read == size, nullptr); double finish_time = ClockObject::get_global_clock()->get_real_time(); if (gobj_cat.is_debug()) { gobj_cat.debug() diff --git a/panda/src/grutil/cardMaker.I b/panda/src/grutil/cardMaker.I index 8d051a72bc..c10991e92d 100644 --- a/panda/src/grutil/cardMaker.I +++ b/panda/src/grutil/cardMaker.I @@ -134,5 +134,5 @@ set_source_geometry(PandaNode *node, const LVecBase4 &frame) { */ INLINE void CardMaker:: clear_source_geometry() { - _source_geometry = (PandaNode *)NULL; + _source_geometry = nullptr; } diff --git a/panda/src/grutil/cardMaker.cxx b/panda/src/grutil/cardMaker.cxx index ddfeae6947..1b68d1482a 100644 --- a/panda/src/grutil/cardMaker.cxx +++ b/panda/src/grutil/cardMaker.cxx @@ -33,7 +33,7 @@ reset() { _color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_normals = true; - _source_geometry = (PandaNode *)NULL; + _source_geometry = nullptr; _source_frame.set(0.0f, 0.0f, 0.0f, 0.0f); } @@ -43,7 +43,7 @@ reset() { */ PT(PandaNode) CardMaker:: generate() { - if (_source_geometry != (PandaNode *)NULL) { + if (_source_geometry != nullptr) { return rescale_source_geometry(); } diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index 044a87a9a9..0b9fc9d1bb 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -58,7 +58,7 @@ FrameRateMeter(const string &name) : // calculation within TextAssembler. PN_stdfloat height = 1.0f; TextFont *font = get_font(); - if (font != NULL){ + if (font != nullptr){ height = font->get_line_height() * 0.8; } @@ -134,10 +134,10 @@ setup_window(GraphicsOutput *window) { */ void FrameRateMeter:: clear_window() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { _window->remove_display_region(_display_region); - _window = (GraphicsOutput *)NULL; - _display_region = (DisplayRegion *)NULL; + _window = nullptr; + _display_region = nullptr; } _root = NodePath(); } @@ -164,7 +164,7 @@ bool FrameRateMeter:: cull_callback(CullTraverser *trav, CullTraverserData &data) { // This triggers when you try to parent a frame rate meter into the scene // graph yourself. Instead, use setup_window(). - nassertr(_display_region != NULL, false); + nassertr(_display_region != nullptr, false); Thread *current_thread = trav->get_current_thread(); diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index 0df3787086..a627ac11f7 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -50,8 +50,8 @@ generate_block(unsigned short mx, unsigned short my, unsigned short level) { - nassertr(mx < (_xsize - 1) / _block_size, NULL); - nassertr(my < (_ysize - 1) / _block_size, NULL); + nassertr(mx < (_xsize - 1) / _block_size, nullptr); + nassertr(my < (_ysize - 1) / _block_size, nullptr); unsigned short center = _block_size / 2; unsigned int vcounter = 0; diff --git a/panda/src/grutil/geoMipTerrain.h b/panda/src/grutil/geoMipTerrain.h index 88727e9077..cc68450419 100644 --- a/panda/src/grutil/geoMipTerrain.h +++ b/panda/src/grutil/geoMipTerrain.h @@ -39,11 +39,11 @@ PUBLISHED: INLINE ~GeoMipTerrain(); INLINE PNMImage &heightfield(); - bool set_heightfield(const Filename &filename, PNMFileType *type = NULL); + bool set_heightfield(const Filename &filename, PNMFileType *type = nullptr); INLINE bool set_heightfield(const PNMImage &image); INLINE PNMImage &color_map(); INLINE bool set_color_map(const Filename &filename, - PNMFileType *type = NULL); + PNMFileType *type = nullptr); INLINE bool set_color_map(const PNMImage &image); INLINE bool set_color_map(const Texture *image); INLINE bool set_color_map(const string &path); diff --git a/panda/src/grutil/heightfieldTesselator.cxx b/panda/src/grutil/heightfieldTesselator.cxx index 8106071ed7..58d8324521 100644 --- a/panda/src/grutil/heightfieldTesselator.cxx +++ b/panda/src/grutil/heightfieldTesselator.cxx @@ -175,9 +175,9 @@ generate() { delete[] _vertex_index; delete[] _dirty_vertices; delete[] _triangle_totals; - _vertex_index =0; - _dirty_vertices =0; - _triangle_totals =0; + _vertex_index =nullptr; + _dirty_vertices =nullptr; + _triangle_totals =nullptr; return root; } @@ -257,7 +257,7 @@ generate_square(NodePath root, int scale, int x, int y, bool forceclose) { #define POINTH get_vertex(x+hsize,y+size) #define POINTI get_vertex(x+size ,y+size) - if (_triangles == 0) { + if (_triangles == nullptr) { open_geom(); } if (subdivide(scale, x, y)) { @@ -376,7 +376,7 @@ open_geom() { */ void HeightfieldTesselator:: close_geom(NodePath root) { - if (_triangles == 0) { + if (_triangles == nullptr) { return; } _triangles->close_primitive(); @@ -395,7 +395,7 @@ close_geom(NodePath root) { _next_index = 0; _last_vertex_a = -1; _last_vertex_b = -1; - _vertex_writer = 0; - _normal_writer = 0; - _triangles = 0; + _vertex_writer = nullptr; + _normal_writer = nullptr; + _triangles = nullptr; } diff --git a/panda/src/grutil/heightfieldTesselator.h b/panda/src/grutil/heightfieldTesselator.h index 247d1de218..cd39245e7b 100644 --- a/panda/src/grutil/heightfieldTesselator.h +++ b/panda/src/grutil/heightfieldTesselator.h @@ -61,7 +61,7 @@ PUBLISHED: INLINE ~HeightfieldTesselator(); INLINE PNMImage &heightfield(); - INLINE bool set_heightfield(const Filename &filename, PNMFileType *type = NULL); + INLINE bool set_heightfield(const Filename &filename, PNMFileType *type = nullptr); INLINE void set_poly_count(int n); INLINE void set_visibility_radius(int r); INLINE void set_focal_point(int x, int y); diff --git a/panda/src/grutil/lineSegs.I b/panda/src/grutil/lineSegs.I index d9e8101c1c..5236f13b74 100644 --- a/panda/src/grutil/lineSegs.I +++ b/panda/src/grutil/lineSegs.I @@ -117,7 +117,7 @@ create(bool dynamic) { */ INLINE int LineSegs:: get_num_vertices() const { - if (_created_data == (GeomVertexData *)NULL) { + if (_created_data == nullptr) { return 0; } return _created_data->get_num_rows(); diff --git a/panda/src/grutil/lineSegs.cxx b/panda/src/grutil/lineSegs.cxx index 9bb54f40ab..7e53416855 100644 --- a/panda/src/grutil/lineSegs.cxx +++ b/panda/src/grutil/lineSegs.cxx @@ -105,7 +105,7 @@ is_empty() { */ LVertex LineSegs:: get_vertex(int n) const { - nassertr(_created_data != (GeomVertexData *)NULL, LVertex::zero()); + nassertr(_created_data != nullptr, LVertex::zero()); GeomVertexReader vertex(_created_data, InternalName::get_vertex()); vertex.set_row_unsafe(n); return vertex.get_data3(); @@ -118,7 +118,7 @@ get_vertex(int n) const { */ void LineSegs:: set_vertex(int n, const LVertex &vert) { - nassertv(_created_data != (GeomVertexData *)NULL); + nassertv(_created_data != nullptr); GeomVertexWriter vertex(_created_data, InternalName::get_vertex()); vertex.set_row_unsafe(n); vertex.set_data3(vert); @@ -129,7 +129,7 @@ set_vertex(int n, const LVertex &vert) { */ LColor LineSegs:: get_vertex_color(int n) const { - nassertr(_created_data != (GeomVertexData *)NULL, LColor::zero()); + nassertr(_created_data != nullptr, LColor::zero()); GeomVertexReader color(_created_data, InternalName::get_color()); color.set_row_unsafe(n); return color.get_data4(); @@ -140,7 +140,7 @@ get_vertex_color(int n) const { */ void LineSegs:: set_vertex_color(int n, const LColor &c) { - nassertv(_created_data != (GeomVertexData *)NULL); + nassertv(_created_data != nullptr); GeomVertexWriter color(_created_data, InternalName::get_color()); color.set_row_unsafe(n); color.set_data4(c); diff --git a/panda/src/grutil/meshDrawer.I b/panda/src/grutil/meshDrawer.I index 72a21bd504..030f646cb9 100644 --- a/panda/src/grutil/meshDrawer.I +++ b/panda/src/grutil/meshDrawer.I @@ -20,13 +20,13 @@ INLINE MeshDrawer:: MeshDrawer() { _root = NodePath("MeshDrawer"); _at_start = 0; - _bv = NULL; - _vertex = NULL; - _normal = NULL; - _uv = NULL; - _color = NULL; + _bv = nullptr; + _vertex = nullptr; + _normal = nullptr; + _uv = nullptr; + _color = nullptr; _budget = 5000; - _vdata = NULL; + _vdata = nullptr; } /** @@ -35,10 +35,10 @@ MeshDrawer() { INLINE MeshDrawer:: ~MeshDrawer() { _root.remove_node(); - if (_vertex != NULL) delete _vertex; - if (_normal != NULL) delete _normal; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_normal != nullptr) delete _normal; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; } /** diff --git a/panda/src/grutil/meshDrawer.cxx b/panda/src/grutil/meshDrawer.cxx index 57ac0d9590..a727c15ced 100644 --- a/panda/src/grutil/meshDrawer.cxx +++ b/panda/src/grutil/meshDrawer.cxx @@ -71,7 +71,7 @@ void MeshDrawer::generator(int budget) { _prim->close_primitive(); _geom = new Geom(_vdata); _geom->add_primitive(_prim); - if (_geomnode == NULL) { + if (_geomnode == nullptr) { _geomnode = new GeomNode("__MeshDrawer_GeomNode"); _root.attach_new_node(_geomnode); } else { @@ -104,12 +104,12 @@ void MeshDrawer::begin(NodePath camera, NodePath render) { _b4 = - _right + _up; // recreate our rewriters - if (_vertex != NULL) delete _vertex; - if (_normal != NULL) delete _normal; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_normal != nullptr) delete _normal; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; - if (_vdata == NULL) { + if (_vdata == nullptr) { generator(_budget); } @@ -141,10 +141,10 @@ void MeshDrawer::end() { _last_clear_index = _clear_index; // delete the re writers - delete _vertex; _vertex = NULL; - delete _uv; _uv = NULL; - delete _normal; _normal = NULL; - delete _color; _color = NULL; + delete _vertex; _vertex = nullptr; + delete _uv; _uv = nullptr; + delete _normal; _normal = nullptr; + delete _color; _color = nullptr; } diff --git a/panda/src/grutil/meshDrawer.h b/panda/src/grutil/meshDrawer.h index 1b391210f6..e959b37c24 100644 --- a/panda/src/grutil/meshDrawer.h +++ b/panda/src/grutil/meshDrawer.h @@ -107,8 +107,6 @@ private: GeomVertexRewriter *_color; // billboard vectors - LVector4 _colorv; - LVector3 _normalv; LVector3 _eyePos; LVector3 _b1, _b2, _b3, _b4; LVector3 _up, _right; diff --git a/panda/src/grutil/meshDrawer2D.I b/panda/src/grutil/meshDrawer2D.I index 9846eda7ee..4ff460c567 100644 --- a/panda/src/grutil/meshDrawer2D.I +++ b/panda/src/grutil/meshDrawer2D.I @@ -19,10 +19,10 @@ INLINE MeshDrawer2D:: MeshDrawer2D() { _root = NodePath("MeshDrawer"); - _bv = NULL; - _vertex = NULL; - _uv = NULL; - _color = NULL; + _bv = nullptr; + _vertex = nullptr; + _uv = nullptr; + _color = nullptr; _budget = 5000; _clip_x = -1000000; @@ -37,9 +37,9 @@ MeshDrawer2D() { INLINE MeshDrawer2D:: ~MeshDrawer2D() { _root.remove_node(); - if (_vertex != NULL) delete _vertex; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; } /** diff --git a/panda/src/grutil/meshDrawer2D.cxx b/panda/src/grutil/meshDrawer2D.cxx index fbf99a2778..a34f4b7d34 100644 --- a/panda/src/grutil/meshDrawer2D.cxx +++ b/panda/src/grutil/meshDrawer2D.cxx @@ -88,9 +88,9 @@ void MeshDrawer2D::generator(int budget) { void MeshDrawer2D::begin() { // recreate our rewriters - if (_vertex != NULL) delete _vertex; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; _vertex = new GeomVertexRewriter(_vdata, "vertex"); _uv = new GeomVertexRewriter(_vdata, "texcoord"); @@ -120,9 +120,9 @@ void MeshDrawer2D::end() { _last_clear_index = _clear_index; // delete the re writers - delete _vertex; _vertex = NULL; - delete _uv; _uv = NULL; - delete _color; _color = NULL; + delete _vertex; _vertex = nullptr; + delete _uv; _uv = nullptr; + delete _color; _color = nullptr; } diff --git a/panda/src/grutil/movieTexture.I b/panda/src/grutil/movieTexture.I index d52220695e..9b3f6eceb8 100644 --- a/panda/src/grutil/movieTexture.I +++ b/panda/src/grutil/movieTexture.I @@ -49,7 +49,7 @@ get_video_height() const { INLINE MovieVideoCursor *MovieTexture:: get_color_cursor(int page) { CDReader cdata(_cycler); - nassertr(page >= 0 && page < (int)cdata->_pages.size(), NULL); + nassertr(page >= 0 && page < (int)cdata->_pages.size(), nullptr); return cdata->_pages[page]._color; } @@ -60,6 +60,6 @@ get_color_cursor(int page) { INLINE MovieVideoCursor *MovieTexture:: get_alpha_cursor(int page) { CDReader cdata(_cycler); - nassertr(page >= 0 && page < (int)cdata->_pages.size(), NULL); + nassertr(page >= 0 && page < (int)cdata->_pages.size(), nullptr); return cdata->_pages[page]._alpha; } diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index 8f2850380b..c62eb23715 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -48,7 +48,7 @@ MovieTexture(MovieVideo *video) : Texture(video->get_name()) { Texture::CDWriter cdata_tex(Texture::_cycler, true); - do_load_one(cdata_tex, video->open(), NULL, 0, LoaderOptions()); + do_load_one(cdata_tex, video->open(), nullptr, 0, LoaderOptions()); } /** @@ -211,7 +211,7 @@ do_read_one(Texture::CData *cdata_tex, } nassertr(z >= 0 && z < cdata_tex->_z_size * cdata_tex->_num_views, false); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } @@ -219,12 +219,12 @@ do_read_one(Texture::CData *cdata_tex, PT(MovieVideoCursor) alpha; color = MovieVideo::get(fullpath)->open(); - if (color == 0) { + if (color == nullptr) { return false; } if (!alpha_fullpath.empty()) { alpha = MovieVideo::get(alpha_fullpath)->open(); - if (alpha == 0) { + if (alpha == nullptr) { return false; } } @@ -326,7 +326,7 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { // compute a new one. double offset; int true_loop_count = 1; - if (cdata->_synchronize != 0) { + if (cdata->_synchronize != nullptr) { offset = cdata->_synchronize->get_time(); } else { // Calculate the cursor position modulo the length of the movie. @@ -358,11 +358,11 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { MovieVideoCursor *alpha = page._alpha; size_t i = pi - cdata->_pages.begin(); - if (color != NULL && alpha != NULL) { + if (color != nullptr && alpha != nullptr) { color->apply_to_texture_rgb(page._cbuffer, (MovieTexture*)this, i); alpha->apply_to_texture_alpha(page._abuffer, (MovieTexture*)this, i, cdata_tex->_alpha_file_channel); - } else if (color != NULL) { + } else if (color != nullptr) { color->apply_to_texture(page._cbuffer, (MovieTexture*)this, i); } @@ -387,7 +387,7 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { * independently of the original. */ PT(Texture) MovieTexture:: -make_copy_impl() { +make_copy_impl() const { Texture::CDReader cdata_tex(Texture::_cycler); CDReader cdata(_cycler); PT(MovieTexture) copy = new MovieTexture(get_name()); @@ -634,7 +634,7 @@ synchronize_to(AudioSound *s) { void MovieTexture:: unsynchronize() { CDWriter cdata(_cycler); - cdata->_synchronize = 0; + cdata->_synchronize = nullptr; } @@ -657,12 +657,12 @@ do_update_frames(const CData *cdata) const { MovieVideoCursor *color = page._color; MovieVideoCursor *alpha = page._alpha; - if (color != NULL && page._cbuffer == NULL) { + if (color != nullptr && page._cbuffer == nullptr) { if (color->set_time(cdata->_offset, cdata->_true_loop_count)) { ((VideoPage &)page)._cbuffer = color->fetch_buffer(); } } - if (alpha != NULL && page._abuffer == NULL) { + if (alpha != nullptr && page._abuffer == nullptr) { if (alpha->set_time(cdata->_offset, cdata->_true_loop_count)) { ((VideoPage &)page)._abuffer = alpha->fetch_buffer(); } @@ -682,15 +682,15 @@ do_update_frames(const CData *cdata) const { PT(MovieVideoCursor::Buffer) newest; for (pi = cdata->_pages.begin(); pi != cdata->_pages.end(); ++pi) { const VideoPage &page = (*pi); - if (page._cbuffer == NULL) { - if (page._color != NULL) { + if (page._cbuffer == nullptr) { + if (page._color != nullptr) { // This page isn't ready at all. in_sync = false; } } else { - nassertr(page._color != NULL, true); + nassertr(page._color != nullptr, true); any_frames = true; - if (newest == NULL) { + if (newest == nullptr) { newest = page._cbuffer; } else { int ref = newest->compare_timestamp(page._cbuffer); @@ -704,14 +704,14 @@ do_update_frames(const CData *cdata) const { } } } - if (page._abuffer == NULL) { - if (page._alpha != NULL) { + if (page._abuffer == nullptr) { + if (page._alpha != nullptr) { in_sync = false; } } else { - nassertr(page._alpha != NULL, true); + nassertr(page._alpha != nullptr, true); any_frames = true; - if (newest == NULL) { + if (newest == nullptr) { newest = page._abuffer; } else { int ref = newest->compare_timestamp(page._abuffer); @@ -734,15 +734,15 @@ do_update_frames(const CData *cdata) const { if (!in_sync) { // If we're not in sync, throw away pages that are older than the newest // available frame. - if (newest != NULL) { + if (newest != nullptr) { Pages::const_iterator pi; for (pi = cdata->_pages.begin(); pi != cdata->_pages.end(); ++pi) { const VideoPage &page = (*pi); - if (page._cbuffer != NULL && newest->compare_timestamp(page._cbuffer) > 0) { + if (page._cbuffer != nullptr && newest->compare_timestamp(page._cbuffer) > 0) { ((VideoPage &)page)._cbuffer.clear(); any_dropped = true; } - if (page._abuffer != NULL && newest->compare_timestamp(page._abuffer) > 0) { + if (page._abuffer != nullptr && newest->compare_timestamp(page._abuffer) > 0) { ((VideoPage &)page)._abuffer.clear(); any_dropped = true; } diff --git a/panda/src/grutil/movieTexture.h b/panda/src/grutil/movieTexture.h index 0881552036..ab4d549b86 100644 --- a/panda/src/grutil/movieTexture.h +++ b/panda/src/grutil/movieTexture.h @@ -80,7 +80,7 @@ public: protected: class CData; - virtual PT(Texture) make_copy_impl(); + virtual PT(Texture) make_copy_impl() const; void do_assign(CData *cdata, Texture::CData *cdata_tex, const MovieTexture *copy, const CData *cdata_copy, const Texture::CData *cdata_copy_tex); diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index 8481444a2d..5d76ade23a 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -241,7 +241,7 @@ flatten(GraphicsOutput *window) { multitex_id++; GraphicsOutput *buffer = window->make_texture_buffer - (multitex_name_strm.str(), x_size, y_size, NULL, false); + (multitex_name_strm.str(), x_size, y_size, nullptr, false); // TODO: this no longer automatically deletes the buffer. We need to take // care of this explicitly now. @@ -323,7 +323,7 @@ flatten(GraphicsOutput *window) { // first texture layer to apply only. nassertv(bake_in_color); PT(GeomNode) geom_node = new GeomNode("background"); - transfer_geom(geom_node, NULL, geom_list, true); + transfer_geom(geom_node, nullptr, geom_list, true); render.attach_new_node(geom_node); } @@ -362,7 +362,7 @@ flatten(GraphicsOutput *window) { const RenderAttrib *attrib = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { geom_state = geom_state->add_attrib (attrib->invert_compose(ColorScaleAttrib::make_identity())); } @@ -372,7 +372,7 @@ flatten(GraphicsOutput *window) { CPT(TransformState) tex_mat = TransformState::make_identity(); const RenderAttrib *ra = geom_info._state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (ra != (const RenderAttrib *)NULL) { + if (ra != nullptr) { // There is a texture matrix inherited from above; put an inverse // matrix on the Geom to compensate. const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, ra); @@ -442,14 +442,14 @@ scan_geom_node(GeomNode *node, const RenderState *state, // Get out the net TextureAttrib and TexMatrixAttrib from the state. const RenderAttrib *attrib; - const TextureAttrib *ta = NULL; + const TextureAttrib *ta = nullptr; attrib = geom_net_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { ta = DCAST(TextureAttrib, attrib); } - if (ta == (TextureAttrib *)NULL) { + if (ta == nullptr) { // No texture should be on the Geom. CPT(RenderState) geom_state = node->get_geom_state(gi); geom_state = geom_state->remove_attrib(TextureAttrib::get_class_slot()); @@ -468,7 +468,7 @@ scan_geom_node(GeomNode *node, const RenderState *state, // Ok, we have multitexture. Record the Geom. CPT(TexMatrixAttrib) tma = DCAST(TexMatrixAttrib, TexMatrixAttrib::make()); attrib = geom_net_state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { tma = DCAST(TexMatrixAttrib, attrib); } @@ -880,13 +880,13 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, } } - if (texcoord_name != (const InternalName *)NULL && + if (texcoord_name != nullptr && texcoord_name != InternalName::get_texcoord()) { // Copy the texture coordinates from the indicated name over to the // default name. const GeomVertexColumn *column = vdata->get_format()->get_column(texcoord_name); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { vdata = vdata->replace_column (InternalName::get_texcoord(), column->get_num_components(), column->get_numeric_type(), column->get_contents()); @@ -904,11 +904,11 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, if (preserve_color) { // Be sure to preserve whatever colors are on the geom. const RenderAttrib *ca = geom_info._geom_net_state->get_attrib(ColorAttrib::get_class_slot()); - if (ca != (const RenderAttrib *)NULL) { + if (ca != nullptr) { geom_state = geom_state->add_attrib(ca); } const RenderAttrib *csa = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (csa != (const RenderAttrib *)NULL) { + if (csa != nullptr) { geom_state = geom_state->add_attrib(csa); } } @@ -938,7 +938,7 @@ scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, LColor color_scale(1.0f, 1.0f, 1.0f, 1.0f); const RenderAttrib *csa = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (csa != (const RenderAttrib *)NULL) { + if (csa != nullptr) { const ColorScaleAttrib *a = DCAST(ColorScaleAttrib, csa); if (a->has_scale()) { color_scale = a->get_scale(); @@ -947,7 +947,7 @@ scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, ColorAttrib::Type color_type = ColorAttrib::T_vertex; const RenderAttrib *ca = geom_info._geom_net_state->get_attrib(ColorAttrib::get_class_slot()); - if (ca != (const RenderAttrib *)NULL) { + if (ca != nullptr) { color_type = DCAST(ColorAttrib, ca)->get_color_type(); } diff --git a/panda/src/grutil/nodeVertexTransform.cxx b/panda/src/grutil/nodeVertexTransform.cxx index de5b14d0f0..5fb44d6cc1 100644 --- a/panda/src/grutil/nodeVertexTransform.cxx +++ b/panda/src/grutil/nodeVertexTransform.cxx @@ -32,7 +32,7 @@ NodeVertexTransform(const PandaNode *node, */ void NodeVertexTransform:: get_matrix(LMatrix4 &matrix) const { - if (_prev != (const VertexTransform *)NULL) { + if (_prev != nullptr) { LMatrix4 prev_matrix; _prev->get_matrix(prev_matrix); matrix.multiply(_node->get_transform()->get_mat(), prev_matrix); @@ -47,7 +47,7 @@ get_matrix(LMatrix4 &matrix) const { */ void NodeVertexTransform:: output(ostream &out) const { - if (_prev != (const VertexTransform *)NULL) { + if (_prev != nullptr) { _prev->output(out); out << " * "; } diff --git a/panda/src/grutil/nodeVertexTransform.h b/panda/src/grutil/nodeVertexTransform.h index 9f1d891615..55bb0bc6bf 100644 --- a/panda/src/grutil/nodeVertexTransform.h +++ b/panda/src/grutil/nodeVertexTransform.h @@ -29,7 +29,7 @@ class FactoryParams; class EXPCL_PANDA_GRUTIL NodeVertexTransform : public VertexTransform { PUBLISHED: NodeVertexTransform(const PandaNode *node, - const VertexTransform *prev = NULL); + const VertexTransform *prev = nullptr); INLINE const PandaNode *get_node() const; INLINE const VertexTransform *get_prev() const; diff --git a/panda/src/grutil/pfmVizzer.I b/panda/src/grutil/pfmVizzer.I index 2185248829..7af594088a 100644 --- a/panda/src/grutil/pfmVizzer.I +++ b/panda/src/grutil/pfmVizzer.I @@ -79,7 +79,7 @@ set_flat_texcoord_name(InternalName *flat_texcoord_name) { */ INLINE void PfmVizzer:: clear_flat_texcoord_name() { - _flat_texcoord_name = NULL; + _flat_texcoord_name = nullptr; } /** @@ -149,7 +149,7 @@ set_vis_blend(const PNMImage *vis_blend) { */ INLINE void PfmVizzer:: clear_vis_blend() { - _vis_blend = NULL; + _vis_blend = nullptr; } /** @@ -171,7 +171,7 @@ get_vis_blend() const { */ INLINE void PfmVizzer:: set_aux_pfm(const PfmFile *pfm) { - assert(pfm == NULL || (pfm->get_x_size() == _pfm.get_x_size() && + assert(pfm == nullptr || (pfm->get_x_size() == _pfm.get_x_size() && pfm->get_y_size() == _pfm.get_y_size())); _aux_pfm = pfm; } @@ -181,7 +181,7 @@ set_aux_pfm(const PfmFile *pfm) { */ INLINE void PfmVizzer:: clear_aux_pfm() { - _aux_pfm = NULL; + _aux_pfm = nullptr; } /** @@ -199,5 +199,5 @@ get_aux_pfm() const { */ INLINE PfmVizzer::VisColumn:: VisColumn() { - _undist_lut = NULL; + _undist_lut = nullptr; } diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 9bd440a0c3..4d1a65d416 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -34,8 +34,8 @@ PfmVizzer(PfmFile &pfm) : _pfm(pfm) { _vis_inverse = false; _vis_2d = false; _keep_beyond_lens = false; - _vis_blend = NULL; - _aux_pfm = NULL; + _vis_blend = nullptr; + _aux_pfm = nullptr; } /** @@ -73,7 +73,7 @@ project(const Lens *lens, const PfmFile *undist_lut) { // these to [0, 1]. LPoint3f uvw = LCAST(float, film * to_uv); - if (undist_lut != NULL) { + if (undist_lut != nullptr) { // Apply the undistortion map, if given. LPoint3f p2; undist_lut->calc_bilinear_point(p2, uvw[0], 1.0 - uvw[1]); @@ -244,7 +244,7 @@ generate_vis_points() const { nassertr(_pfm.is_valid(), NodePath()); bool check_aux_pfm = uses_aux_pfm(); - nassertr(!check_aux_pfm || (_aux_pfm != NULL && _aux_pfm->is_valid()), NodePath()); + nassertr(!check_aux_pfm || (_aux_pfm != nullptr && _aux_pfm->is_valid()), NodePath()); CPT(GeomVertexFormat) format; if (_vis_inverse) { @@ -323,8 +323,7 @@ generate_vis_points() const { NodePath PfmVizzer:: generate_vis_mesh(MeshFace face) const { nassertr(_pfm.is_valid(), NodePath()); - bool check_aux_pfm = uses_aux_pfm(); - nassertr(!check_aux_pfm || (_aux_pfm != NULL && _aux_pfm->is_valid()), NodePath()); + nassertr(!uses_aux_pfm() || (_aux_pfm != nullptr && _aux_pfm->is_valid()), NodePath()); nassertr(face != 0, NodePath()); if (_pfm.get_num_channels() == 1 && _vis_columns.empty()) { @@ -878,11 +877,11 @@ add_vis_column(VisColumns &vis_columns, ColumnType source, ColumnType target, column._target = target; column._name = name; column._transform = transform; - if (transform == NULL) { + if (transform == nullptr) { column._transform = TransformState::make_identity(); } column._lens = lens; - if (undist_lut != NULL && undist_lut->is_valid()) { + if (undist_lut != nullptr && undist_lut->is_valid()) { column._undist_lut = undist_lut; } vis_columns.push_back(column); @@ -923,12 +922,12 @@ build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const { } } - if (_flat_texcoord_name != (InternalName *)NULL) { + if (_flat_texcoord_name != nullptr) { // We need an additional texcoord column for the flat texcoords. add_vis_column(vis_columns, CT_texcoord2, CT_texcoord2, _flat_texcoord_name); } - if (_vis_blend != (PNMImage *)NULL) { + if (_vis_blend != nullptr) { // The blend map, if specified, also gets applied to the vertices. add_vis_column(vis_columns, CT_blend1, CT_blend1, InternalName::get_color()); } @@ -996,7 +995,7 @@ make_array_format(const VisColumns &vis_columns) const { contents = GeomEnums::C_color; break; } - nassertr(num_components != 0, NULL); + nassertr(num_components != 0, nullptr); array_format->add_column(name, num_components, numeric_type, contents); } @@ -1050,7 +1049,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo case CT_aux_vertex1: { - nassertr(vizzer.get_aux_pfm() != NULL, false); + nassertr(vizzer.get_aux_pfm() != nullptr, false); PN_float32 p = vizzer.get_aux_pfm()->get_point1(xi, yi); LPoint2f point(p, 0.0); if (!transform_point(point)) { @@ -1072,7 +1071,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo case CT_aux_vertex2: { - nassertr(vizzer.get_aux_pfm() != NULL, false); + nassertr(vizzer.get_aux_pfm() != nullptr, false); LPoint2f point = vizzer.get_aux_pfm()->get_point2(xi, yi); if (!transform_point(point)) { success = false; @@ -1156,7 +1155,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo case CT_blend1: { const PNMImage *vis_blend = vizzer.get_vis_blend(); - if (vis_blend != NULL) { + if (vis_blend != nullptr) { double gray = vis_blend->get_gray(xi, yi); vwriter.set_data3d(gray, gray, gray); } @@ -1189,7 +1188,7 @@ transform_point(LPoint3f &point) const { if (!_transform->is_identity()) { LCAST(PN_float32, _transform->get_mat()).xform_point_in_place(point); } - if (_lens != (Lens *)NULL) { + if (_lens != nullptr) { static LMatrix4f to_uv(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -1201,7 +1200,7 @@ transform_point(LPoint3f &point) const { point = to_uv.xform_point(LCAST(PN_float32, film)); } - if (_undist_lut != NULL) { + if (_undist_lut != nullptr) { LPoint3f p; if (!_undist_lut->calc_bilinear_point(p, point[0], 1.0 - point[1])) { // Point is missing. diff --git a/panda/src/grutil/pfmVizzer.h b/panda/src/grutil/pfmVizzer.h index e04e8a06bc..3f3fbeb62c 100644 --- a/panda/src/grutil/pfmVizzer.h +++ b/panda/src/grutil/pfmVizzer.h @@ -34,7 +34,7 @@ PUBLISHED: INLINE PfmFile &get_pfm(); INLINE const PfmFile &get_pfm() const; - BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = NULL); + BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = nullptr); BLOCKING void extrude(const Lens *lens); INLINE void set_vis_inverse(bool vis_inverse); @@ -70,8 +70,8 @@ PUBLISHED: void clear_vis_columns(); void add_vis_column(ColumnType source, ColumnType target, InternalName *name, - const TransformState *transform = NULL, const Lens *lens = NULL, - const PfmFile *undist_lut = NULL); + const TransformState *transform = nullptr, const Lens *lens = nullptr, + const PfmFile *undist_lut = nullptr); BLOCKING NodePath generate_vis_points() const; @@ -120,8 +120,8 @@ private: static void add_vis_column(VisColumns &vis_columns, ColumnType source, ColumnType target, InternalName *name, - const TransformState *transform = NULL, - const Lens *lens = NULL, const PfmFile *undist_lut = NULL); + const TransformState *transform = nullptr, + const Lens *lens = nullptr, const PfmFile *undist_lut = nullptr); void build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const; CPT(GeomVertexFormat) make_array_format(const VisColumns &vis_columns) const; diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.cxx b/panda/src/grutil/pipeOcclusionCullTraverser.cxx index d257611767..2a7f27a878 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.cxx +++ b/panda/src/grutil/pipeOcclusionCullTraverser.cxx @@ -103,14 +103,14 @@ PipeOcclusionCullTraverser(GraphicsOutput *host) { _buffer = engine->make_output(pipe, "occlusion", 0, fb_prop, win_prop, GraphicsPipe::BF_refuse_window, gsg, host->get_host()); - nassertv(_buffer != (GraphicsOutput *)NULL); + nassertv(_buffer != nullptr); // This buffer isn't really active--we render it by hand; we don't want the // GraphicsEngine to render it. _buffer->set_active(0); _display_region = _buffer->make_display_region(); - _internal_cull_handler = NULL; + _internal_cull_handler = nullptr; make_sphere(); make_box(); @@ -192,8 +192,8 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsgbase, _internal_trav->set_view_frustum(get_view_frustum()); _internal_trav->set_camera_mask(_occlusion_mask); - _current_query = NULL; - _next_query = NULL; + _current_query = nullptr; + _next_query = nullptr; // Begin by rendering all the occluders into our internal scene. PStatTimer timer2(_draw_occlusion_pcollector); @@ -214,13 +214,13 @@ end_traverse() { GraphicsStateGuardian *gsg = _buffer->get_gsg(); Thread *current_thread = get_current_thread(); - _current_query = NULL; - _next_query = NULL; + _current_query = nullptr; + _next_query = nullptr; PendingObjects::iterator oi; for (oi = _pending_objects.begin(); oi != _pending_objects.end(); ++oi) { PendingObject &pobj = (*oi); - if (pobj._query == (OcclusionQueryContext *)NULL) { + if (pobj._query == nullptr) { _occlusion_untested_pcollector.add_level(1); _true_cull_handler->record_object(pobj._object, this); } else { @@ -237,7 +237,7 @@ end_traverse() { // The CullableObject has by now either been recorded (which will // eventually delete it) or deleted directly. #ifndef NDEBUG - pobj._object = NULL; + pobj._object = nullptr; #endif // NDEBUG } _pending_objects.clear(); @@ -250,7 +250,7 @@ end_traverse() { _buffer->end_flip(); delete _internal_cull_handler; - _internal_cull_handler = NULL; + _internal_cull_handler = nullptr; _occlusion_untested_pcollector.flush_level(); _occlusion_passed_pcollector.flush_level(); @@ -264,7 +264,7 @@ end_traverse() { */ Texture *PipeOcclusionCullTraverser:: get_texture() { - if (_texture != (Texture *)NULL) { + if (_texture != nullptr) { return _texture; } @@ -288,7 +288,7 @@ get_texture() { */ bool PipeOcclusionCullTraverser:: is_in_view(CullTraverserData &data) { - _next_query = NULL; + _next_query = nullptr; if (!CullTraverser::is_in_view(data)) { return false; @@ -297,7 +297,7 @@ is_in_view(CullTraverserData &data) { return true; } - if (_current_query != (OcclusionQueryContext *)NULL) { + if (_current_query != nullptr) { // We've already performed an occlusion test for some ancestor of this // node; no need to perform another. return true; @@ -341,15 +341,15 @@ traverse_below(CullTraverserData &data) { // Save and restore _current_query, and clear _next_query, for traversing // the children of this node. PT(OcclusionQueryContext) prev_query = _current_query; - if (_next_query != (OcclusionQueryContext *)NULL) { + if (_next_query != nullptr) { _current_query = _next_query; } - _next_query = NULL; + _next_query = nullptr; CullTraverser::traverse_below(data); _current_query = prev_query; - _next_query = NULL; + _next_query = nullptr; } /** @@ -369,12 +369,12 @@ record_object(CullableObject *object, const CullTraverser *traverser) { Thread *current_thread = get_current_thread(); - if (_next_query != (OcclusionQueryContext *)NULL) { + if (_next_query != nullptr) { // We have just performed an occlusion query for this node. Don't perform // another one. pobj._query = _next_query; - } else if (_current_query != (OcclusionQueryContext *)NULL) { + } else if (_current_query != nullptr) { // We have previously performed an occlusion query for this node or some // ancestor. Don't perform another one. pobj._query = _current_query; diff --git a/panda/src/grutil/rigidBodyCombiner.cxx b/panda/src/grutil/rigidBodyCombiner.cxx index 7e3ccefd65..44f2971aa5 100644 --- a/panda/src/grutil/rigidBodyCombiner.cxx +++ b/panda/src/grutil/rigidBodyCombiner.cxx @@ -90,7 +90,7 @@ collect() { Children cr = get_children(); int num_children = cr.get_num_children(); for (int i = 0; i < num_children; i++) { - r_collect(cr.get_child(i), RenderState::make_empty(), NULL); + r_collect(cr.get_child(i), RenderState::make_empty(), nullptr); } _vd_table.clear(); @@ -179,7 +179,7 @@ r_collect(PandaNode *node, const RenderState *state, int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; ++i) { PT(Geom) geom = gnode->get_geom(i)->make_copy(); - if (next_transform != (const VertexTransform *)NULL) { + if (next_transform != nullptr) { geom->set_vertex_data(convert_vd(next_transform, geom->get_vertex_data())); } CPT(RenderState) gstate = next_state->compose(gnode->get_geom_state(i)); @@ -225,7 +225,7 @@ convert_vd(const VertexTransform *transform, const GeomVertexData *orig) { CPT(GeomVertexData) converted = orig->convert_to(new_format); PT(GeomVertexData) new_data = new GeomVertexData(*converted); - if (new_data->get_transform_blend_table() == (TransformBlendTable *)NULL) { + if (new_data->get_transform_blend_table() == nullptr) { // Create a new table that has just the one blend: all vertices hard- // assigned to the indicated transform. PT(TransformBlendTable) new_table = new TransformBlendTable; diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx index f5a14caed3..9881575f62 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx @@ -105,10 +105,10 @@ setup_window(GraphicsOutput *window) { */ void SceneGraphAnalyzerMeter:: clear_window() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { _window->remove_display_region(_display_region); - _window = (GraphicsOutput *)NULL; - _display_region = (DisplayRegion *)NULL; + _window = nullptr; + _display_region = nullptr; } _root = NodePath(); } diff --git a/panda/src/grutil/shaderTerrainMesh.I b/panda/src/grutil/shaderTerrainMesh.I index 91ac1035d3..f6a66bc7f5 100644 --- a/panda/src/grutil/shaderTerrainMesh.I +++ b/panda/src/grutil/shaderTerrainMesh.I @@ -153,7 +153,7 @@ INLINE bool ShaderTerrainMesh::get_update_enabled() const { INLINE void ShaderTerrainMesh::Chunk::clear_children() { for (size_t i = 0; i < 4; ++i) { delete children[i]; - children[i] = NULL; + children[i] = nullptr; } } @@ -163,7 +163,7 @@ INLINE void ShaderTerrainMesh::Chunk::clear_children() { */ INLINE ShaderTerrainMesh::Chunk::Chunk() { for (size_t i = 0; i < 4; ++i) - children[i] = NULL; + children[i] = nullptr; } /** diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index 8c9c7bd9b6..d5ecdf21e2 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -94,13 +94,13 @@ ShaderTerrainMesh::ShaderTerrainMesh() : _size(0), _chunk_size(32), _generate_patches(false), - _data_texture(NULL), - _chunk_geom(NULL), + _data_texture(nullptr), + _chunk_geom(nullptr), _current_view_index(0), _last_frame_count(-1), _target_triangle_width(10.0f), _update_enabled(true), - _heightfield_tex(NULL) + _heightfield_tex(nullptr) { set_final(true); set_bounds(new OmniBoundingVolume()); @@ -261,7 +261,7 @@ void ShaderTerrainMesh::do_init_chunk(Chunk* chunk) { } else { // Final chunk, initialize all children to zero for (size_t i = 0; i < 4; ++i) { - chunk->children[i] = NULL; + chunk->children[i] = nullptr; } } } @@ -375,7 +375,7 @@ void ShaderTerrainMesh::do_create_chunk_geom() { GeomVertexWriter vertex_writer(gvd, "vertex"); // Create primitive - PT(GeomPrimitive) triangles = NULL; + PT(GeomPrimitive) triangles = nullptr; if (_generate_patches) { triangles = new GeomPatches(3, Geom::UH_static); } else { @@ -460,8 +460,8 @@ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &dat // Make sure the terrain was properly initialized, and the geom was created // successfully - nassertv(_data_texture != NULL); - nassertv(_chunk_geom != NULL); + nassertv(_data_texture != nullptr); + nassertv(_chunk_geom != nullptr); _basic_collector.start(); @@ -524,7 +524,7 @@ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &dat } // Should never happen - nassertv(current_shader_attrib != NULL); + nassertv(current_shader_attrib != nullptr); current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_shader_input( ShaderInput("ShaderTerrainMesh.terrain_size", LVecBase2i(_size))); @@ -707,11 +707,11 @@ void ShaderTerrainMesh::do_emit_chunk(Chunk* chunk, TraversalData* data) { * @return World-Space point */ LPoint3 ShaderTerrainMesh::uv_to_world(const LTexCoord& coord) const { - nassertr(_heightfield_tex != NULL, LPoint3(0)); // Heightfield not set yet + nassertr(_heightfield_tex != nullptr, LPoint3(0)); // Heightfield not set yet nassertr(_heightfield_tex->has_ram_image(), LPoint3(0)); // Heightfield not in memory PT(TexturePeeker) peeker = _heightfield_tex->peek(); - nassertr(peeker != NULL, LPoint3(0)); + nassertr(peeker != nullptr, LPoint3(0)); LColor result; if (!peeker->lookup_bilinear(result, coord.get_x(), coord.get_y())) { diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.cxx b/panda/src/gsgbase/graphicsStateGuardianBase.cxx index fefd8037f2..5ac46dd4af 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.cxx +++ b/panda/src/gsgbase/graphicsStateGuardianBase.cxx @@ -30,9 +30,9 @@ TypeHandle GraphicsStateGuardianBase::_type_handle; GraphicsStateGuardianBase *GraphicsStateGuardianBase:: get_default_gsg() { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // Nobody created a GSG list, so we won't have any GSGs either. - return NULL; + return nullptr; } LightMutexHolder holder(gsg_list->_lock); return gsg_list->_default_gsg; @@ -45,7 +45,7 @@ get_default_gsg() { void GraphicsStateGuardianBase:: set_default_gsg(GraphicsStateGuardianBase *default_gsg) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // Nobody ever created a GSG list. How could we have a GSG? nassertv(false); return; @@ -67,7 +67,7 @@ set_default_gsg(GraphicsStateGuardianBase *default_gsg) { size_t GraphicsStateGuardianBase:: get_num_gsgs() { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // Nobody created a GSG list, so we won't have any GSGs either. return 0; } @@ -82,10 +82,10 @@ get_num_gsgs() { GraphicsStateGuardianBase *GraphicsStateGuardianBase:: get_gsg(size_t n) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - nassertr(gsg_list != NULL, NULL); + nassertr(gsg_list != nullptr, nullptr); LightMutexHolder holder(gsg_list->_lock); - nassertr(n < gsg_list->_gsgs.size(), NULL); + nassertr(n < gsg_list->_gsgs.size(), nullptr); return gsg_list->_gsgs[n]; } @@ -96,14 +96,14 @@ get_gsg(size_t n) { void GraphicsStateGuardianBase:: add_gsg(GraphicsStateGuardianBase *gsg) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { gsg_list = new GSGList; - gsg_list->_default_gsg = NULL; + gsg_list->_default_gsg = nullptr; GSGList *orig_gsg_list = (GSGList *) - AtomicAdjust::compare_and_exchange_ptr(_gsg_list, NULL, gsg_list); + AtomicAdjust::compare_and_exchange_ptr(_gsg_list, nullptr, gsg_list); - if (orig_gsg_list != NULL) { + if (orig_gsg_list != nullptr) { // Another thread beat us to it. No problem, we'll use that. delete gsg_list; gsg_list = orig_gsg_list; @@ -119,7 +119,7 @@ add_gsg(GraphicsStateGuardianBase *gsg) { gsg_list->_gsgs.push_back(gsg); - if (gsg_list->_default_gsg == (GraphicsStateGuardianBase *)NULL) { + if (gsg_list->_default_gsg == nullptr) { gsg_list->_default_gsg = gsg; } } @@ -130,7 +130,7 @@ add_gsg(GraphicsStateGuardianBase *gsg) { void GraphicsStateGuardianBase:: remove_gsg(GraphicsStateGuardianBase *gsg) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // No GSGs were added yet, or the program is destructing anyway. return; } @@ -150,7 +150,7 @@ remove_gsg(GraphicsStateGuardianBase *gsg) { if (!gsg_list->_gsgs.empty()) { gsg_list->_default_gsg = *gsg_list->_gsgs.begin(); } else { - gsg_list->_default_gsg = NULL; + gsg_list->_default_gsg = nullptr; } } } diff --git a/panda/src/linmath/configVariableColor.I b/panda/src/linmath/configVariableColor.I index 21a0af8660..c600d7246b 100644 --- a/panda/src/linmath/configVariableColor.I +++ b/panda/src/linmath/configVariableColor.I @@ -141,7 +141,7 @@ get_value() const { INLINE LColor ConfigVariableColor:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { switch (decl->get_num_words()) { case 1: return LColor((PN_stdfloat)decl->get_double_word(0), (PN_stdfloat)decl->get_double_word(0), diff --git a/panda/src/linmath/lmatrix3_ext_src.I b/panda/src/linmath/lmatrix3_ext_src.I index b1997ec746..a58a57c155 100644 --- a/panda/src/linmath/lmatrix3_ext_src.I +++ b/panda/src/linmath/lmatrix3_ext_src.I @@ -21,8 +21,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *result = Py_BuildValue("(O(fffffffff))", this_class, diff --git a/panda/src/linmath/lmatrix4_ext_src.I b/panda/src/linmath/lmatrix4_ext_src.I index 23a4a26518..928ce1c837 100644 --- a/panda/src/linmath/lmatrix4_ext_src.I +++ b/panda/src/linmath/lmatrix4_ext_src.I @@ -21,8 +21,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, diff --git a/panda/src/linmath/lvecBase2_ext_src.I b/panda/src/linmath/lvecBase2_ext_src.I index 40399dc327..3e0a35fff4 100644 --- a/panda/src/linmath/lvecBase2_ext_src.I +++ b/panda/src/linmath/lvecBase2_ext_src.I @@ -46,8 +46,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } #if FLOATTOKEN == 'i' @@ -133,7 +133,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Whoosh. PyObject* fast = PySequence_Fast(assign, ""); - nassertr(fast != NULL, -1); + nassertr(fast != nullptr, -1); // Let's be strict about size mismatches, to prevent user error. if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) { @@ -148,7 +148,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { for (size_t i = 0; i < attr_name.size(); ++i) { PyObject* fl = PYNUMBER_FLOATTYPE(items[i]); - if (fl == NULL) { + if (fl == nullptr) { // Oh darn. Not when we've come this far. #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "a sequence of integers is required"); @@ -169,7 +169,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { } else { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); - if (fl == NULL) { + if (fl == nullptr) { // It's not a floating-point value either? Sheesh, I don't know what to // do with it then. if (attr_name.size() == 1) { diff --git a/panda/src/linmath/lvecBase3_ext_src.I b/panda/src/linmath/lvecBase3_ext_src.I index a2705edbb6..871928da2f 100644 --- a/panda/src/linmath/lvecBase3_ext_src.I +++ b/panda/src/linmath/lvecBase3_ext_src.I @@ -47,8 +47,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } #if FLOATTOKEN == 'i' @@ -134,7 +134,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Whoosh. PyObject* fast = PySequence_Fast(assign, ""); - nassertr(fast != NULL, -1); + nassertr(fast != nullptr, -1); // Let's be strict about size mismatches, to prevent user error. if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) { @@ -149,7 +149,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { for (size_t i = 0; i < attr_name.size(); ++i) { PyObject* fl = PYNUMBER_FLOATTYPE(items[i]); - if (fl == NULL) { + if (fl == nullptr) { // Oh darn. Not when we've come this far. #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "a sequence of integers is required"); @@ -170,7 +170,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { } else { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); - if (fl == NULL) { + if (fl == nullptr) { // It's not a floating-point value either? Sheesh, I don't know what to // do with it then. if (attr_name.size() == 1) { diff --git a/panda/src/linmath/lvecBase4_ext_src.I b/panda/src/linmath/lvecBase4_ext_src.I index 76eee6b7bf..cab78609a3 100644 --- a/panda/src/linmath/lvecBase4_ext_src.I +++ b/panda/src/linmath/lvecBase4_ext_src.I @@ -48,8 +48,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } #if FLOATTOKEN == 'i' @@ -139,7 +139,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Whoosh. PyObject* fast = PySequence_Fast(assign, ""); - nassertr(fast != NULL, -1); + nassertr(fast != nullptr, -1); // Let's be strict about size mismatches, to prevent user error. if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) { @@ -154,7 +154,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { for (size_t i = 0; i < attr_name.size(); ++i) { PyObject* fl = PYNUMBER_FLOATTYPE(items[i]); - if (fl == NULL) { + if (fl == nullptr) { // Oh darn. Not when we've come this far. #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "a sequence of integers is required"); @@ -176,7 +176,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); - if (fl == NULL) { + if (fl == nullptr) { // It's not a floating-point value either? Sheesh, I don't know what to // do with it then. if (attr_name.size() == 1) { diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index 5ea6661aa7..a0754b9b55 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -363,17 +363,17 @@ around_finite(const BoundingVolume **first, const BoundingVolume **p = first; nassertr(!(*p)->is_empty() && !(*p)->is_infinite(), false); const FiniteBoundingVolume *vol = (*p)->as_finite_bounding_volume(); - nassertr(vol != (FiniteBoundingVolume *)NULL, false); + nassertr(vol != nullptr, false); LPoint3 min_box = vol->get_min(); LPoint3 max_box = vol->get_max(); - bool any_spheres = (vol->as_bounding_sphere() != NULL); + bool any_spheres = (vol->as_bounding_sphere() != nullptr); for (++p; p != last; ++p) { nassertr(!(*p)->is_infinite(), false); if (!(*p)->is_empty()) { vol = (*p)->as_finite_bounding_volume(); - if (vol == (FiniteBoundingVolume *)NULL) { + if (vol == nullptr) { set_infinite(); return true; } @@ -386,7 +386,7 @@ around_finite(const BoundingVolume **first, max(max_box[1], max1[1]), max(max_box[2], max1[2])); - if (vol->as_bounding_sphere() != NULL) { + if (vol->as_bounding_sphere() != nullptr) { any_spheres = true; } } @@ -407,7 +407,7 @@ around_finite(const BoundingVolume **first, for (p = first; p != last; ++p) { if (!(*p)->is_empty()) { const BoundingSphere *sphere = (*p)->as_bounding_sphere(); - if (sphere != (BoundingSphere *)NULL) { + if (sphere != nullptr) { // This is a sphere; consider its corner. PN_stdfloat dist = length(sphere->_center - _center); _radius = max(_radius, dist + sphere->_radius); @@ -415,7 +415,7 @@ around_finite(const BoundingVolume **first, } else { // This is a nonsphere. We fit around it. const FiniteBoundingVolume *vol = (*p)->as_finite_bounding_volume(); - nassertr(vol != (FiniteBoundingVolume *)NULL, false); + nassertr(vol != nullptr, false); BoundingBox box(vol->get_min(), vol->get_max()); box.local_object(); diff --git a/panda/src/mathutil/boundingVolume.cxx b/panda/src/mathutil/boundingVolume.cxx index 3a2bee0577..d81f905e25 100644 --- a/panda/src/mathutil/boundingVolume.cxx +++ b/panda/src/mathutil/boundingVolume.cxx @@ -84,7 +84,7 @@ write(ostream &out, int indent_level) const { */ GeometricBoundingVolume *BoundingVolume:: as_geometric_bounding_volume() { - return NULL; + return nullptr; } /** @@ -93,7 +93,7 @@ as_geometric_bounding_volume() { */ const GeometricBoundingVolume *BoundingVolume:: as_geometric_bounding_volume() const { - return NULL; + return nullptr; } /** @@ -102,7 +102,7 @@ as_geometric_bounding_volume() const { */ const FiniteBoundingVolume *BoundingVolume:: as_finite_bounding_volume() const { - return NULL; + return nullptr; } /** @@ -111,7 +111,7 @@ as_finite_bounding_volume() const { */ const BoundingSphere *BoundingVolume:: as_bounding_sphere() const { - return NULL; + return nullptr; } /** @@ -120,7 +120,7 @@ as_bounding_sphere() const { */ const BoundingBox *BoundingVolume:: as_bounding_box() const { - return NULL; + return nullptr; } /** @@ -129,7 +129,7 @@ as_bounding_box() const { */ const BoundingHexahedron *BoundingVolume:: as_bounding_hexahedron() const { - return NULL; + return nullptr; } /** @@ -138,7 +138,7 @@ as_bounding_hexahedron() const { */ const BoundingLine *BoundingVolume:: as_bounding_line() const { - return NULL; + return nullptr; } /** @@ -147,7 +147,7 @@ as_bounding_line() const { */ const BoundingPlane *BoundingVolume:: as_bounding_plane() const { - return NULL; + return nullptr; } /** diff --git a/panda/src/mathutil/fftCompressor.cxx b/panda/src/mathutil/fftCompressor.cxx index 0a5b7425e1..b8a9764d8f 100644 --- a/panda/src/mathutil/fftCompressor.cxx +++ b/panda/src/mathutil/fftCompressor.cxx @@ -386,9 +386,9 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { } if (length == 0) { - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &h[0], length); write_reals(datagram, &p[0], length); @@ -419,15 +419,15 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { } if (length == 0) { - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &m00[0], length); write_reals(datagram, &m01[0], length); @@ -513,16 +513,16 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { #ifndef NDEBUG if (_quality >= 102) { if (length == 0) { - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &qr[0], length); } } #endif if (length == 0) { - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &qi[0], length); write_reals(datagram, &qj[0], length); @@ -1060,7 +1060,7 @@ get_real_compress_plan(int length) { } fftw_plan plan; - plan = fftw_plan_dft_r2c_1d(length, NULL, NULL, FFTW_ESTIMATE); + plan = fftw_plan_dft_r2c_1d(length, nullptr, nullptr, FFTW_ESTIMATE); _real_compress_plans.insert(RealPlans::value_type(length, plan)); return plan; @@ -1079,7 +1079,7 @@ get_real_decompress_plan(int length) { } fftw_plan plan; - plan = fftw_plan_dft_c2r_1d(length, NULL, NULL, FFTW_ESTIMATE); + plan = fftw_plan_dft_c2r_1d(length, nullptr, nullptr, FFTW_ESTIMATE); _real_decompress_plans.insert(RealPlans::value_type(length, plan)); return plan; diff --git a/panda/src/mathutil/intersectionBoundingVolume.I b/panda/src/mathutil/intersectionBoundingVolume.I index 514c692333..4242446c1d 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.I +++ b/panda/src/mathutil/intersectionBoundingVolume.I @@ -32,6 +32,6 @@ get_num_components() const { */ INLINE_MATHUTIL const GeometricBoundingVolume *IntersectionBoundingVolume:: get_component(int n) const { - nassertr(n >= 0 && n < (int)_components.size(), NULL); + nassertr(n >= 0 && n < (int)_components.size(), nullptr); return _components[n]; } diff --git a/panda/src/mathutil/randomizer.I b/panda/src/mathutil/randomizer.I index 3cb30939b9..410d1c266e 100644 --- a/panda/src/mathutil/randomizer.I +++ b/panda/src/mathutil/randomizer.I @@ -68,7 +68,7 @@ random_real_unit() { INLINE unsigned long Randomizer:: get_next_seed() { if (!_got_first_seed) { - _next_seed = Mersenne((unsigned long)time(NULL)); + _next_seed = Mersenne((unsigned long)time(nullptr)); _got_first_seed = true; } return _next_seed.get_uint31(); diff --git a/panda/src/mathutil/triangulator.cxx b/panda/src/mathutil/triangulator.cxx index a0c1ad9ad5..fabfe31147 100644 --- a/panda/src/mathutil/triangulator.cxx +++ b/panda/src/mathutil/triangulator.cxx @@ -867,7 +867,7 @@ add_segment(int segnum) { int tfirstr = 0, tlastr = 0, tfirstl = 0, tlastl = 0; int i1, i2, t, tn; // t1, t2, point_t tpt; - int tritop = 0, tribot = 0, is_swapped = 0; + int tribot = 0, is_swapped = 0; int tmptriseg; s = seg[segnum]; @@ -939,7 +939,6 @@ add_segment(int segnum) { else /* v0 already present */ { /* Get the topmost intersecting trapezoid */ tfirst = locate_endpoint(&s.v0, &s.v1, s.root0); - tritop = 1; } @@ -1294,16 +1293,13 @@ add_segment(int segnum) { // int tmpseg = tr[tr[t].d0].rseg; double y0, yt; point_t tmppt; - int tnext, i_d0, i_d1; + int tnext, i_d0; - i_d1 = false; i_d0 = false; if (FP_EQUAL(tr[t].lo.y, s.v0.y)) { if (tr[t].lo.x > s.v0.x) i_d0 = true; - else - i_d1 = true; } else { @@ -1314,8 +1310,6 @@ add_segment(int segnum) { if (_less_than(&tmppt, &tr[t].lo)) i_d0 = true; - else - i_d1 = true; } /* check continuity from the top so that the lower-neighbour */ @@ -1792,7 +1786,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { int mnew; int v0, v1; //, v0next, v1next; int retval = 0; //, tmp; - int do_switch = false; // printf("visited size = %d, visited[trnum] = %d\n", visited.size(), // visited[trnum]); @@ -1817,7 +1810,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { v1 = t->lseg; if (from == t->d1) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); traverse_polygon(mnew, t->d0, trnum, TR_FROM_UP); @@ -1847,7 +1839,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { v1 = tr[t->u0].rseg; if (from == t->u1) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mnew, t->u0, trnum, TR_FROM_DN); @@ -1879,7 +1870,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { if (((dir == TR_FROM_DN) && (t->d1 == from)) || ((dir == TR_FROM_UP) && (t->u1 == from))) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); @@ -1905,7 +1895,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2UP_LEFT; if ((dir == TR_FROM_UP) && (t->u0 == from)) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u0, trnum, TR_FROM_DN); traverse_polygon(mnew, t->d0, trnum, TR_FROM_UP); @@ -1928,7 +1917,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2UP_RIGHT; if ((dir == TR_FROM_UP) && (t->u1 == from)) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mnew, t->d1, trnum, TR_FROM_UP); @@ -1957,7 +1945,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2DN_LEFT; if (!((dir == TR_FROM_DN) && (t->d0 == from))) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); @@ -1981,7 +1968,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2DN_RIGHT; if ((dir == TR_FROM_DN) && (t->d1 == from)) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); traverse_polygon(mnew, t->u1, trnum, TR_FROM_DN); @@ -2008,7 +1994,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_SIMPLE_LRDN; if (dir == TR_FROM_UP) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u0, trnum, TR_FROM_DN); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); @@ -2033,7 +2018,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_SIMPLE_LRUP; if (dir == TR_FROM_UP) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u0, trnum, TR_FROM_DN); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); diff --git a/panda/src/mathutil/unionBoundingVolume.I b/panda/src/mathutil/unionBoundingVolume.I index 6212b1f2b8..9c7e782b45 100644 --- a/panda/src/mathutil/unionBoundingVolume.I +++ b/panda/src/mathutil/unionBoundingVolume.I @@ -31,6 +31,6 @@ get_num_components() const { */ INLINE_MATHUTIL const GeometricBoundingVolume *UnionBoundingVolume:: get_component(int n) const { - nassertr(n >= 0 && n < (int)_components.size(), NULL); + nassertr(n >= 0 && n < (int)_components.size(), nullptr); return _components[n]; } diff --git a/panda/src/mathutil/unionBoundingVolume.cxx b/panda/src/mathutil/unionBoundingVolume.cxx index dfc96f8e92..ed575b518b 100644 --- a/panda/src/mathutil/unionBoundingVolume.cxx +++ b/panda/src/mathutil/unionBoundingVolume.cxx @@ -236,7 +236,7 @@ around_geometric(const BoundingVolume **first, nassertr(!(*p)->is_infinite(), false); if (!(*p)->is_empty()) { const GeometricBoundingVolume *volume = (*p)->as_geometric_bounding_volume(); - if (volume != (GeometricBoundingVolume *)NULL) { + if (volume != nullptr) { add_component(volume); } else { set_infinite(); diff --git a/panda/src/movies/flacAudio.cxx b/panda/src/movies/flacAudio.cxx index 8bfbd56ad2..b7c205b25b 100644 --- a/panda/src/movies/flacAudio.cxx +++ b/panda/src/movies/flacAudio.cxx @@ -43,12 +43,12 @@ open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *stream = vfs->open_read_file(_filename, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } else { PT(FlacAudioCursor) cursor = new FlacAudioCursor(this, stream); - if (cursor == NULL || !cursor->_is_valid) { - return NULL; + if (cursor == nullptr || !cursor->_is_valid) { + return nullptr; } else { return DCAST(MovieAudioCursor, cursor); } diff --git a/panda/src/movies/flacAudioCursor.cxx b/panda/src/movies/flacAudioCursor.cxx index a4c33822cd..e30fbfba8f 100644 --- a/panda/src/movies/flacAudioCursor.cxx +++ b/panda/src/movies/flacAudioCursor.cxx @@ -26,7 +26,7 @@ extern "C" { */ static size_t cb_read_proc(void *user, void *buffer, size_t size) { istream *stream = (istream *)user; - nassertr(stream != NULL, false); + nassertr(stream != nullptr, false); stream->read((char *)buffer, size); @@ -43,7 +43,7 @@ static size_t cb_read_proc(void *user, void *buffer, size_t size) { */ static bool cb_seek_proc(void *user, int offset) { istream *stream = (istream *)user; - nassertr(stream != NULL, false); + nassertr(stream != nullptr, false); stream->seekg(offset, ios::cur); return !stream->fail(); @@ -59,14 +59,14 @@ FlacAudioCursor:: FlacAudioCursor(FlacAudio *src, istream *stream) : MovieAudioCursor(src), _is_valid(false), - _drflac(NULL) + _drflac(nullptr) { - nassertv(stream != NULL); + nassertv(stream != nullptr); nassertv(stream->good()); _drflac = drflac_open(&cb_read_proc, &cb_seek_proc, (void *)stream); - if (_drflac == NULL) { + if (_drflac == nullptr) { movies_cat.error() << "Failed to open FLAC file.\n"; _is_valid = false; @@ -88,7 +88,7 @@ FlacAudioCursor(FlacAudio *src, istream *stream) : */ FlacAudioCursor:: ~FlacAudioCursor() { - if (_drflac != NULL) { + if (_drflac != nullptr) { drflac_close(_drflac); } } diff --git a/panda/src/movies/microphoneAudio.cxx b/panda/src/movies/microphoneAudio.cxx index bc21c758d9..65ff4010bf 100644 --- a/panda/src/movies/microphoneAudio.cxx +++ b/panda/src/movies/microphoneAudio.cxx @@ -69,6 +69,6 @@ get_num_options() { PT(MicrophoneAudio) MicrophoneAudio:: get_option(int n) { find_all_microphones(); - nassertr((n >= 0) && (n < (int)_all_microphones.size()), NULL); + nassertr((n >= 0) && (n < (int)_all_microphones.size()), nullptr); return _all_microphones[n]; } diff --git a/panda/src/movies/microphoneAudioDS.cxx b/panda/src/movies/microphoneAudioDS.cxx index 95412fb961..cea9c65f60 100644 --- a/panda/src/movies/microphoneAudioDS.cxx +++ b/panda/src/movies/microphoneAudioDS.cxx @@ -146,7 +146,7 @@ find_all_microphones_ds() { format.nBlockAlign = 2 * chan; format.wBitsPerSample = 16; format.cbSize = 0; - stat = waveInOpen(NULL, i, &format, NULL, NULL, WAVE_FORMAT_QUERY); + stat = waveInOpen(nullptr, i, &format, 0, 0, WAVE_FORMAT_QUERY); if (stat == MMSYSERR_NOERROR) { PT(MicrophoneAudioDS) p = new MicrophoneAudioDS(); ostringstream name; @@ -235,7 +235,7 @@ open() { if (failed) { delete_buffers(buffers); nassert_raise("Could not allocate audio input buffers."); - return NULL; + return nullptr; } WAVEFORMATEX format; @@ -248,12 +248,12 @@ open() { format.cbSize = 0; HWAVEIN hwav; - MMRESULT stat = waveInOpen(&hwav, _device_id, &format, NULL, NULL, CALLBACK_NULL); + MMRESULT stat = waveInOpen(&hwav, _device_id, &format, 0, 0, CALLBACK_NULL); if (stat != MMSYSERR_NOERROR) { delete_buffers(buffers); nassert_raise("Could not open audio input device."); - return NULL; + return nullptr; } for (int i=0; i<(int)buffers.size(); i++) { @@ -265,7 +265,7 @@ open() { waveInClose(hwav); delete_buffers(buffers); nassert_raise("Could not queue buffers for audio input device."); - return NULL; + return nullptr; } } stat = waveInStart(hwav); @@ -273,7 +273,7 @@ open() { waveInClose(hwav); delete_buffers(buffers); nassert_raise("Could not start recording on input device."); - return NULL; + return nullptr; } return new MicrophoneAudioCursorDS(this, buffers, hwav); } diff --git a/panda/src/movies/movieTypeRegistry.I b/panda/src/movies/movieTypeRegistry.I index a444d91d9b..901abca903 100644 --- a/panda/src/movies/movieTypeRegistry.I +++ b/panda/src/movies/movieTypeRegistry.I @@ -16,7 +16,7 @@ */ INLINE MovieTypeRegistry *MovieTypeRegistry:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new MovieTypeRegistry; } diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index 9c747b6fe3..024cf53634 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -17,7 +17,7 @@ #include "config_putil.h" #include "load_dso.h" -MovieTypeRegistry *MovieTypeRegistry::_global_ptr = NULL; +MovieTypeRegistry *MovieTypeRegistry::_global_ptr = nullptr; /** * Obtains a MovieVideo that references a file. @@ -104,7 +104,7 @@ load_audio_types() { movies_cat.info() << "loading audio type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { movies_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; @@ -220,7 +220,7 @@ load_video_types() { movies_cat.info() << "loading video type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { movies_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; @@ -261,7 +261,7 @@ load_movie_library(const string &name) { << "loading video type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { movies_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; diff --git a/panda/src/movies/movieVideo.cxx b/panda/src/movies/movieVideo.cxx index 9b6c970472..cdeb797213 100644 --- a/panda/src/movies/movieVideo.cxx +++ b/panda/src/movies/movieVideo.cxx @@ -44,7 +44,7 @@ MovieVideo:: */ PT(MovieVideoCursor) MovieVideo:: open() { - return NULL; + return nullptr; } /** diff --git a/panda/src/movies/movieVideoCursor.cxx b/panda/src/movies/movieVideoCursor.cxx index f1f531453a..761e7e2fa6 100644 --- a/panda/src/movies/movieVideoCursor.cxx +++ b/panda/src/movies/movieVideoCursor.cxx @@ -97,7 +97,7 @@ set_time(double timestamp, int loop_count) { */ PT(MovieVideoCursor::Buffer) MovieVideoCursor:: fetch_buffer() { - return NULL; + return nullptr; } /** @@ -105,7 +105,7 @@ fetch_buffer() { */ void MovieVideoCursor:: apply_to_texture(const Buffer *buffer, Texture *t, int page) { - if (buffer == NULL) { + if (buffer == nullptr) { return; } @@ -162,7 +162,7 @@ apply_to_texture(const Buffer *buffer, Texture *t, int page) { */ void MovieVideoCursor:: apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src) { - if (buffer == NULL) { + if (buffer == nullptr) { return; } @@ -216,7 +216,7 @@ apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src */ void MovieVideoCursor:: apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { - if (buffer == NULL) { + if (buffer == nullptr) { return; } @@ -259,7 +259,7 @@ apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { */ MovieVideoCursor::Buffer *MovieVideoCursor:: get_standard_buffer() { - if (_standard_buffer == NULL) { + if (_standard_buffer == nullptr) { _standard_buffer = make_new_buffer(); } return _standard_buffer; diff --git a/panda/src/movies/movieVideoCursor.h b/panda/src/movies/movieVideoCursor.h index 0fb11fe04b..8357f14693 100644 --- a/panda/src/movies/movieVideoCursor.h +++ b/panda/src/movies/movieVideoCursor.h @@ -40,7 +40,7 @@ class BamReader; */ class EXPCL_PANDA_MOVIES MovieVideoCursor : public TypedWritableReferenceCount { protected: - MovieVideoCursor(MovieVideo *src = NULL); + MovieVideoCursor(MovieVideo *src = nullptr); PUBLISHED: virtual ~MovieVideoCursor(); diff --git a/panda/src/movies/userDataAudio.cxx b/panda/src/movies/userDataAudio.cxx index 7575ad977b..81865e3b8b 100644 --- a/panda/src/movies/userDataAudio.cxx +++ b/panda/src/movies/userDataAudio.cxx @@ -25,7 +25,7 @@ UserDataAudio(int rate, int channels, bool remove_after_read) : MovieAudio("User Data Audio"), _desired_rate(rate), _desired_channels(channels), - _cursor(NULL), + _cursor(nullptr), _aborted(false), _remove_after_read(remove_after_read) { @@ -46,7 +46,7 @@ PT(MovieAudioCursor) UserDataAudio:: open() { if (_cursor) { nassert_raise("A UserDataAudio can only be opened by one consumer at a time."); - return NULL; + return nullptr; } _cursor = new UserDataAudioCursor(this); return _cursor; diff --git a/panda/src/movies/userDataAudioCursor.cxx b/panda/src/movies/userDataAudioCursor.cxx index e0494cf53e..93bab206fa 100644 --- a/panda/src/movies/userDataAudioCursor.cxx +++ b/panda/src/movies/userDataAudioCursor.cxx @@ -39,7 +39,7 @@ UserDataAudioCursor(UserDataAudio *src) : UserDataAudioCursor:: ~UserDataAudioCursor() { UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; - source->_cursor = NULL; + source->_cursor = nullptr; } /** diff --git a/panda/src/movies/vorbisAudio.cxx b/panda/src/movies/vorbisAudio.cxx index bd704e2bd1..b3e32c84f4 100644 --- a/panda/src/movies/vorbisAudio.cxx +++ b/panda/src/movies/vorbisAudio.cxx @@ -45,12 +45,12 @@ open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *stream = vfs->open_read_file(_filename, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } else { PT(VorbisAudioCursor) cursor = new VorbisAudioCursor(this, stream); - if (cursor == NULL || !cursor->_is_valid) { - return NULL; + if (cursor == nullptr || !cursor->_is_valid) { + return nullptr; } else { return DCAST(MovieAudioCursor, cursor); } diff --git a/panda/src/movies/vorbisAudioCursor.cxx b/panda/src/movies/vorbisAudioCursor.cxx index 9d751629c2..6f6002158f 100644 --- a/panda/src/movies/vorbisAudioCursor.cxx +++ b/panda/src/movies/vorbisAudioCursor.cxx @@ -28,7 +28,7 @@ VorbisAudioCursor(VorbisAudio *src, istream *stream) : _is_valid(false), _bitstream(0) { - nassertv(stream != NULL); + nassertv(stream != nullptr); nassertv(stream->good()); // Set up the callbacks to read via the VFS. @@ -40,10 +40,10 @@ VorbisAudioCursor(VorbisAudio *src, istream *stream) : if (vorbis_enable_seek) { callbacks.seek_func = &cb_seek_func; } else { - callbacks.seek_func = NULL; + callbacks.seek_func = nullptr; } - if (ov_open_callbacks((void*) stream, &_ov, NULL, 0, callbacks) != 0) { + if (ov_open_callbacks((void*) stream, &_ov, nullptr, 0, callbacks) != 0) { movies_cat.error() << "Failed to read Ogg Vorbis file.\n"; return; @@ -162,7 +162,7 @@ read_samples(int n, int16_t *data) { size_t VorbisAudioCursor:: cb_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) { istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); stream->read((char *)ptr, size * nmemb); @@ -185,7 +185,7 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { } istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); switch (whence) { case SEEK_SET: @@ -239,7 +239,7 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { int VorbisAudioCursor:: cb_close_func(void *datasource) { istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(stream); @@ -255,7 +255,7 @@ cb_close_func(void *datasource) { long VorbisAudioCursor:: cb_tell_func(void *datasource) { istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); return stream->tellg(); } diff --git a/panda/src/movies/wavAudio.cxx b/panda/src/movies/wavAudio.cxx index 0240c37a94..685a0a7d68 100644 --- a/panda/src/movies/wavAudio.cxx +++ b/panda/src/movies/wavAudio.cxx @@ -43,12 +43,12 @@ open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *stream = vfs->open_read_file(_filename, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } else { PT(WavAudioCursor) cursor = new WavAudioCursor(this, stream); - if (cursor == NULL || !cursor->_is_valid) { - return NULL; + if (cursor == nullptr || !cursor->_is_valid) { + return nullptr; } else { return DCAST(MovieAudioCursor, cursor); } diff --git a/panda/src/movies/wavAudioCursor.cxx b/panda/src/movies/wavAudioCursor.cxx index ccfaa9733e..5f6cf05047 100644 --- a/panda/src/movies/wavAudioCursor.cxx +++ b/panda/src/movies/wavAudioCursor.cxx @@ -103,7 +103,7 @@ WavAudioCursor(WavAudio *src, istream *stream) : _data_pos(0), _data_size(0) { - nassertv(stream != NULL); + nassertv(stream != nullptr); // Beginning of "RIFF" chunk. unsigned char magic[4]; @@ -279,7 +279,7 @@ WavAudioCursor(WavAudio *src, istream *stream) : */ WavAudioCursor:: ~WavAudioCursor() { - if (_stream != NULL) { + if (_stream != nullptr) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_stream); } diff --git a/panda/src/nativenet/membuffer.I b/panda/src/nativenet/membuffer.I index 157df8301a..a2e7ad6d1d 100644 --- a/panda/src/nativenet/membuffer.I +++ b/panda/src/nativenet/membuffer.I @@ -6,11 +6,11 @@ inline void MemBuffer:: ClearBuffer(void) { if (_BufferLocal == true) { - if (_Buffer != NULL) { + if (_Buffer != nullptr) { delete[] _Buffer; } - _Buffer = NULL; + _Buffer = nullptr; } } @@ -29,7 +29,7 @@ AllocBuffer(size_t len) { */ inline MemBuffer:: MemBuffer(void) { - _Buffer = NULL; + _Buffer = nullptr; _BufferLocal = false; _BufferLen = 0; } @@ -87,7 +87,7 @@ GrowBuffer(size_t new_len) { char *tmp = new char[len]; - if (_Buffer != NULL) { + if (_Buffer != nullptr) { memcpy(tmp,_Buffer,_BufferLen); } diff --git a/panda/src/nativenet/socket_address.cxx b/panda/src/nativenet/socket_address.cxx index cf27b0771c..3d7882aeed 100644 --- a/panda/src/nativenet/socket_address.cxx +++ b/panda/src/nativenet/socket_address.cxx @@ -26,12 +26,12 @@ set_host(const std::string &hostname, unsigned short port) { return set_broadcast(port); } - struct addrinfo hints, *res = NULL; + struct addrinfo hints, *res = nullptr; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_family = support_ipv6 ? AF_UNSPEC : AF_INET; - if (getaddrinfo(hostname.c_str(), NULL, &hints, &res)) { + if (getaddrinfo(hostname.c_str(), nullptr, &hints, &res)) { return false; } @@ -92,10 +92,10 @@ get_ip() const { buf[0] = 0; if (_storage.ss_family == AF_INET) { - getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), nullptr, 0, NI_NUMERICHOST); } else if (_storage.ss_family == AF_INET6) { - getnameinfo(&_addr, sizeof(sockaddr_in6), buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in6), buf, sizeof(buf), nullptr, 0, NI_NUMERICHOST); } else { nassertr(false, std::string()); @@ -114,13 +114,13 @@ get_ip_port() const { buf[0] = 0; if (_storage.ss_family == AF_INET) { - getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), nullptr, 0, NI_NUMERICHOST); sprintf(buf + strlen(buf), ":%hu", get_port()); } else if (_storage.ss_family == AF_INET6) { // Protect the IPv6 address within square brackets. buf[0] = '['; - getnameinfo(&_addr, sizeof(sockaddr_in6), buf + 1, sizeof(buf) - 1, NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in6), buf + 1, sizeof(buf) - 1, nullptr, 0, NI_NUMERICHOST); sprintf(buf + strlen(buf), "]:%hu", get_port()); } else { diff --git a/panda/src/nativenet/socket_fdset.h b/panda/src/nativenet/socket_fdset.h index 45c990bf27..7da876c0f8 100644 --- a/panda/src/nativenet/socket_fdset.h +++ b/panda/src/nativenet/socket_fdset.h @@ -90,13 +90,13 @@ inline int Socket_fdset::WaitForRead(bool zeroFds, uint32_t sleep_time) { int retVal = 0; if (sleep_time == 0xffffffff) { - retVal = DO_SELECT(_maxid + 1, &_the_set, NULL, NULL, NULL); + retVal = DO_SELECT(_maxid + 1, &_the_set, nullptr, nullptr, nullptr); } else { timeval timeoutValue; timeoutValue.tv_sec = sleep_time / 1000; timeoutValue.tv_usec = (sleep_time % 1000) * 1000; - retVal = DO_SELECT(_maxid + 1, &_the_set, NULL, NULL, &timeoutValue); + retVal = DO_SELECT(_maxid + 1, &_the_set, nullptr, nullptr, &timeoutValue); } if (zeroFds) clear(); @@ -111,7 +111,7 @@ inline int Socket_fdset::WaitForRead(bool zeroFds, const Time_Span & timeout) { timeval localtv = timeout.GetTval(); - int retVal = DO_SELECT(_maxid + 1, &_the_set, NULL, NULL, &localtv); + int retVal = DO_SELECT(_maxid + 1, &_the_set, nullptr, nullptr, &localtv); if (zeroFds) clear(); @@ -144,7 +144,7 @@ inline int Socket_fdset::WaitForWrite(bool zeroFds, uint32_t sleep_time) int retVal = 0; if (sleep_time == 0xffffffff) { - retVal = DO_SELECT(_maxid + 1, NULL, &_the_set, NULL, NULL); + retVal = DO_SELECT(_maxid + 1, nullptr, &_the_set, nullptr, nullptr); } else { @@ -152,7 +152,7 @@ inline int Socket_fdset::WaitForWrite(bool zeroFds, uint32_t sleep_time) timeoutValue.tv_sec = sleep_time / 1000; timeoutValue.tv_usec = (sleep_time % 1000) * 1000; - retVal = DO_SELECT(_maxid + 1, NULL, &_the_set, NULL, &timeoutValue); + retVal = DO_SELECT(_maxid + 1, nullptr, &_the_set, nullptr, &timeoutValue); } if (zeroFds) clear(); @@ -169,7 +169,7 @@ inline int Socket_fdset::WaitForError(bool zeroFds, uint32_t sleep_time) int retVal = 0; if (sleep_time == 0xffffffff) { - retVal = DO_SELECT(_maxid + 1, NULL, NULL, &_the_set, NULL); + retVal = DO_SELECT(_maxid + 1, nullptr, nullptr, &_the_set, nullptr); } else { @@ -177,7 +177,7 @@ inline int Socket_fdset::WaitForError(bool zeroFds, uint32_t sleep_time) timeoutValue.tv_sec = sleep_time / 1000; timeoutValue.tv_usec = (sleep_time % 1000) * 1000; - retVal = DO_SELECT(_maxid + 1, NULL, NULL, &_the_set, &timeoutValue); + retVal = DO_SELECT(_maxid + 1, nullptr, nullptr, &_the_set, &timeoutValue); } if (zeroFds) clear(); diff --git a/panda/src/nativenet/socket_tcp_ssl.h b/panda/src/nativenet/socket_tcp_ssl.h index 83b45b4389..8f16f188dc 100644 --- a/panda/src/nativenet/socket_tcp_ssl.h +++ b/panda/src/nativenet/socket_tcp_ssl.h @@ -30,10 +30,10 @@ struct SSlStartup { ~SSlStartup() { SSL_CTX_free (global_ssl_ctx); - global_ssl_ctx = NULL; + global_ssl_ctx = nullptr; } - bool isactive() { return global_ssl_ctx != NULL; }; + bool isactive() { return global_ssl_ctx != nullptr; }; }; /** @@ -42,7 +42,7 @@ struct SSlStartup { class EXPCL_PANDA_NATIVENET Socket_TCP_SSL : public Socket_IP { public: inline Socket_TCP_SSL(SOCKET); - inline Socket_TCP_SSL() : _ssl(NULL) {} + inline Socket_TCP_SSL() : _ssl(nullptr) {} virtual inline ~Socket_TCP_SSL() { @@ -67,10 +67,10 @@ private: SSL *_ssl; void CleanSslUp() { - if (_ssl != NULL) { + if (_ssl != nullptr) { SSL_shutdown(_ssl); SSL_free(_ssl); - _ssl = NULL; + _ssl = nullptr; } } @@ -101,7 +101,7 @@ Socket_TCP_SSL(SOCKET sck) : ::Socket_IP(sck) { SetNonBlocking(); // maybe should be blocking? _ssl = SSL_new(global_ssl_ctx); - if (_ssl == NULL) { + if (_ssl == nullptr) { return; } @@ -188,7 +188,7 @@ ActiveOpen(const Socket_Address &theaddress) { } _ssl = SSL_new(global_ssl_ctx); - if (_ssl == NULL) { + if (_ssl == nullptr) { return false; } SSL_set_fd(_ssl, (int)GetSocket()); @@ -206,7 +206,7 @@ ActiveOpen(const Socket_Address &theaddress) { */ inline int Socket_TCP_SSL:: SendData(const char *data, int size) { - if (_ssl == NULL) { + if (_ssl == nullptr) { return -1; } @@ -221,7 +221,7 @@ SendData(const char *data, int size) { */ inline int Socket_TCP_SSL:: RecvData(char *data, int len) { - if (_ssl == NULL) { + if (_ssl == nullptr) { return -1; } @@ -235,7 +235,7 @@ RecvData(char *data, int len) { */ inline bool Socket_TCP_SSL:: ErrorIs_WouldBlocking(int err) { - if (_ssl == NULL || err >= 0) { + if (_ssl == nullptr || err >= 0) { nativenet_cat.warning() << "Socket_TCP_SSL::ErrorIs_WouldBlocking->Called With Error number " << err << " or _ssl is NULL\n"; diff --git a/panda/src/nativenet/time_accumulator.h b/panda/src/nativenet/time_accumulator.h index 32d0747310..3b7959a018 100644 --- a/panda/src/nativenet/time_accumulator.h +++ b/panda/src/nativenet/time_accumulator.h @@ -26,7 +26,7 @@ inline void Time_Accumulator::Set(const Time_Span & in) // this seems to make the most since .. if you are running the clock right // know... assume the timespane you are passing in is inclusive.. but keep // clock running.. May need to rethink this... - if(_accum_start != NULL) + if(_accum_start != nullptr) { Stop(); Start(); @@ -35,7 +35,7 @@ inline void Time_Accumulator::Set(const Time_Span & in) /** * */ -inline Time_Accumulator::Time_Accumulator() : _total_time(0,0,0,0,0), _accum_start(NULL) +inline Time_Accumulator::Time_Accumulator() : _total_time(0,0,0,0,0), _accum_start(nullptr) { } /** @@ -43,7 +43,7 @@ inline Time_Accumulator::Time_Accumulator() : _total_time(0,0,0,0,0), _accum_sta */ inline Time_Accumulator::~Time_Accumulator() { - if(_accum_start != NULL) + if(_accum_start != nullptr) delete _accum_start; } /** @@ -51,7 +51,7 @@ inline Time_Accumulator::~Time_Accumulator() */ inline void Time_Accumulator::Start() { - if(_accum_start == NULL) + if(_accum_start == nullptr) _accum_start = new Time_Clock(); } /** @@ -59,12 +59,12 @@ inline void Time_Accumulator::Start() */ inline void Time_Accumulator::Stop() { - if(_accum_start != NULL) + if(_accum_start != nullptr) { Time_Span work1(Time_Clock::GetCurrentTime() - *_accum_start); _total_time += work1; delete _accum_start; - _accum_start = NULL; + _accum_start = nullptr; } } /** @@ -72,10 +72,10 @@ inline void Time_Accumulator::Stop() */ void Time_Accumulator::Reset() { - if(_accum_start != NULL) + if(_accum_start != nullptr) { delete _accum_start; - _accum_start = NULL; + _accum_start = nullptr; } _total_time.Set(0,0,0,0,0); } @@ -85,7 +85,7 @@ void Time_Accumulator::Reset() inline Time_Span Time_Accumulator::Report() { Time_Span answer(_total_time); - if(_accum_start != NULL) + if(_accum_start != nullptr) { Time_Span ww(Time_Clock::GetCurrentTime() - *_accum_start); answer += ww; diff --git a/panda/src/nativenet/time_clock.h b/panda/src/nativenet/time_clock.h index 2c326fd7da..08f3616377 100644 --- a/panda/src/nativenet/time_clock.h +++ b/panda/src/nativenet/time_clock.h @@ -134,7 +134,7 @@ GetCurrentTime() { */ inline Time_Clock:: Time_Clock() { - gettimeofday(&_my_time, NULL); + gettimeofday(&_my_time, nullptr); } /** @@ -142,7 +142,7 @@ Time_Clock() { */ inline void Time_Clock:: ToCurrentTime() { - gettimeofday(&_my_time, NULL); + gettimeofday(&_my_time, nullptr); } /** @@ -152,9 +152,9 @@ ToCurrentTime() { */ inline struct tm *Time_Clock:: GetGmtTm(struct tm *ptm) const { - nassertr(ptm != NULL, NULL); + nassertr(ptm != nullptr, nullptr); #ifdef _WIN32 - return (gmtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : NULL; + return (gmtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : nullptr; #else return gmtime_r((const time_t *)&_my_time.tv_sec, ptm); #endif @@ -165,9 +165,9 @@ GetGmtTm(struct tm *ptm) const { */ inline struct tm *Time_Clock:: GetLocalTm(struct tm *ptm) const { - nassertr(ptm != NULL, NULL); + nassertr(ptm != nullptr, nullptr); #ifdef _WIN32 - return (localtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : NULL; + return (localtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : nullptr; #else return localtime_r((const time_t *)&_my_time.tv_sec, ptm); #endif @@ -210,7 +210,7 @@ Format(const char *pFormat) const { char szBuffer1[maxTimeBufferSize]; struct tm tmTemp; - if (GetLocalTm(&tmTemp) == NULL || + if (GetLocalTm(&tmTemp) == nullptr || !strftime(szBuffer1, sizeof(szBuffer1), szBuffer, &tmTemp)) { szBuffer1[0] = '\0'; } @@ -253,7 +253,7 @@ FormatGmt(const char *pFormat) const { char szBuffer1[maxTimeBufferSize]; struct tm tmTemp; - if (GetGmtTm(&tmTemp) == NULL || + if (GetGmtTm(&tmTemp) == nullptr || !strftime(szBuffer1, sizeof(szBuffer1), szBuffer, &tmTemp)) { szBuffer1[0] = '\0'; } diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index ae717bb580..9fcbdcbe91 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -40,9 +40,9 @@ ConfigureFn(config_net) { int get_net_max_write_queue() { - static ConfigVariableInt *net_max_write_queue = NULL; + static ConfigVariableInt *net_max_write_queue = nullptr; - if (net_max_write_queue == (ConfigVariableInt *)NULL) { + if (net_max_write_queue == nullptr) { net_max_write_queue = new ConfigVariableInt ("net-max-write-queue", 10000, PRC_DESC("This limits the number of datagrams in a ConnectionWriter's " @@ -54,9 +54,9 @@ get_net_max_write_queue() { int get_net_max_response_queue() { - static ConfigVariableInt *net_max_response_queue = NULL; + static ConfigVariableInt *net_max_response_queue = nullptr; - if (net_max_response_queue == (ConfigVariableInt *)NULL) { + if (net_max_response_queue == nullptr) { net_max_response_queue = new ConfigVariableInt ("net-max-response-queue", 50000, PRC_DESC("This limits the number of datagrams, messages, what have you, " @@ -69,9 +69,9 @@ get_net_max_response_queue() { bool get_net_error_abort() { - static ConfigVariableBool *net_error_abort = NULL; + static ConfigVariableBool *net_error_abort = nullptr; - if (net_error_abort == (ConfigVariableBool *)NULL) { + if (net_error_abort == nullptr) { net_error_abort = new ConfigVariableBool ("net-error-abort", false); } @@ -81,9 +81,9 @@ get_net_error_abort() { double get_net_max_poll_cycle() { - static ConfigVariableDouble *net_max_poll_cycle = NULL; + static ConfigVariableDouble *net_max_poll_cycle = nullptr; - if (net_max_poll_cycle == (ConfigVariableDouble *)NULL) { + if (net_max_poll_cycle == nullptr) { net_max_poll_cycle = new ConfigVariableDouble ("net-max-poll-cycle", 0.2, PRC_DESC("Specifies the maximum amount of time, in seconds, to " @@ -100,9 +100,9 @@ get_net_max_poll_cycle() { double get_net_max_block() { - static ConfigVariableDouble *net_max_block = NULL; + static ConfigVariableDouble *net_max_block = nullptr; - if (net_max_block == (ConfigVariableDouble *)NULL) { + if (net_max_block == nullptr) { net_max_block = new ConfigVariableDouble ("net-max-block", 0.01, PRC_DESC("Specifies the maximum amount of time, in seconds, to " diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index 4c42614f7c..1e96a758de 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -60,7 +60,7 @@ Connection:: net_cat.info() << "Deleting connection " << (void *)this << "\n"; - if (_socket != (Socket_IP *)NULL) { + if (_socket != nullptr) { flush(); _socket->Close(); @@ -294,7 +294,7 @@ set_max_segment(int size) { */ bool Connection:: send_datagram(const NetDatagram &datagram, int tcp_header_size) { - nassertr(_socket != (Socket_IP *)NULL, false); + nassertr(_socket != nullptr, false); if (_socket->is_exact_type(Socket_UDP::get_class_type())) { // We have to send UDP right away. @@ -367,7 +367,7 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { */ bool Connection:: send_raw_datagram(const NetDatagram &datagram) { - nassertr(_socket != (Socket_IP *)NULL, false); + nassertr(_socket != nullptr, false); if (_socket->is_exact_type(Socket_UDP::get_class_type())) { // We have to send UDP right away. @@ -483,7 +483,7 @@ check_send_error(bool okflag) { // Assume any error means the connection has been reset; tell our manager // about it and ignore it. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->flush_read_connection(this); _manager->connection_reset(this, okflag); } diff --git a/panda/src/net/connectionListener.cxx b/panda/src/net/connectionListener.cxx index c959051653..a48791b24d 100644 --- a/panda/src/net/connectionListener.cxx +++ b/panda/src/net/connectionListener.cxx @@ -82,7 +82,7 @@ process_incoming_data(SocketInfo *sinfo) { << "\n"; PT(Connection) new_connection = new Connection(_manager, session); - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->new_connection(new_connection); } connection_opened(sinfo->_connection, net_addr, new_connection); diff --git a/panda/src/net/connectionManager.cxx b/panda/src/net/connectionManager.cxx index 8a0bfc1e86..0d7da68000 100644 --- a/panda/src/net/connectionManager.cxx +++ b/panda/src/net/connectionManager.cxx @@ -328,7 +328,7 @@ open_TCP_client_connection(const string &hostname, uint16_t port, */ bool ConnectionManager:: close_connection(const PT(Connection) &connection) { - if (connection != (Connection *)NULL) { + if (connection != nullptr) { connection->flush(); } @@ -479,13 +479,13 @@ scan_interfaces() { int flags = GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER; ULONG family = support_ipv6 ? AF_UNSPEC : AF_INET; ULONG buffer_size = 0; - ULONG result = GetAdaptersAddresses(family, flags, NULL, NULL, &buffer_size); + ULONG result = GetAdaptersAddresses(family, flags, nullptr, nullptr, &buffer_size); if (result == ERROR_BUFFER_OVERFLOW) { IP_ADAPTER_ADDRESSES *addresses = (IP_ADAPTER_ADDRESSES *)PANDA_MALLOC_ARRAY(buffer_size); - result = GetAdaptersAddresses(family, flags, NULL, addresses, &buffer_size); + result = GetAdaptersAddresses(family, flags, nullptr, addresses, &buffer_size); if (result == ERROR_SUCCESS) { IP_ADAPTER_ADDRESSES *p = addresses; - while (p != NULL) { + while (p != nullptr) { // p->AdapterName appears to be a GUID. Not sure if this is actually // useful to anyone; we'll store the "friendly name" instead. TextEncoder encoder; @@ -505,7 +505,7 @@ scan_interfaces() { NetAddress addresses[3]; IP_ADAPTER_PREFIX *m = p->FirstPrefix; int mc = 0; - while (m != NULL && mc < 3) { + while (m != nullptr && mc < 3) { addresses[mc] = NetAddress(Socket_Address(*m->Address.lpSockaddr)); m = m->Next; ++mc; @@ -551,20 +551,20 @@ scan_interfaces() { } struct ifaddrs *p = ifa; - while (p != NULL) { + while (p != nullptr) { if (p->ifa_addr->sa_family == AF_INET || (support_ipv6 && p->ifa_addr->sa_family == AF_INET6)) { Interface iface; iface.set_name(p->ifa_name); - if (p->ifa_addr != NULL) { + if (p->ifa_addr != nullptr) { iface.set_ip(NetAddress(Socket_Address(*p->ifa_addr))); } - if (p->ifa_netmask != NULL) { + if (p->ifa_netmask != nullptr) { iface.set_netmask(NetAddress(Socket_Address(*p->ifa_netmask))); } - if ((p->ifa_flags & IFF_BROADCAST) && p->ifa_broadaddr != NULL) { + if ((p->ifa_flags & IFF_BROADCAST) && p->ifa_broadaddr != nullptr) { iface.set_broadcast(NetAddress(Socket_Address(*p->ifa_broadaddr))); - } else if ((p->ifa_flags & IFF_POINTOPOINT) && p->ifa_dstaddr != NULL) { + } else if ((p->ifa_flags & IFF_POINTOPOINT) && p->ifa_dstaddr != nullptr) { iface.set_p2p(NetAddress(Socket_Address(*p->ifa_dstaddr))); } _interfaces.push_back(iface); diff --git a/panda/src/net/connectionReader.cxx b/panda/src/net/connectionReader.cxx index 0ca114e476..4f9a31dca5 100644 --- a/panda/src/net/connectionReader.cxx +++ b/panda/src/net/connectionReader.cxx @@ -132,7 +132,7 @@ ConnectionReader(ConnectionManager *manager, int num_threads, */ ConnectionReader:: ~ConnectionReader() { - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->remove_reader(this); } @@ -172,7 +172,7 @@ ConnectionReader:: */ bool ConnectionReader:: add_connection(Connection *connection) { - nassertr(connection != (Connection *)NULL, false); + nassertr(connection != nullptr, false); LightMutexHolder holder(_sockets_mutex); @@ -261,11 +261,11 @@ poll() { } SocketInfo *sinfo = get_next_available_socket(false, -2); - if (sinfo != (SocketInfo *)NULL) { + if (sinfo != nullptr) { double max_poll_cycle = get_net_max_poll_cycle(); if (max_poll_cycle < 0.0) { // Continue to read all data. - while (sinfo != (SocketInfo *)NULL) { + while (sinfo != nullptr) { process_incoming_data(sinfo); sinfo = get_next_available_socket(false, -2); } @@ -275,7 +275,7 @@ poll() { TrueClock *global_clock = TrueClock::get_global_ptr(); double stop = global_clock->get_short_time() + max_poll_cycle; - while (sinfo != (SocketInfo *)NULL) { + while (sinfo != nullptr) { process_incoming_data(sinfo); if (global_clock->get_short_time() >= stop) { return; @@ -406,7 +406,7 @@ flush_read_connection(Connection *connection) { */ void ConnectionReader:: clear_manager() { - _manager = (ConnectionManager *)NULL; + _manager = nullptr; } /** @@ -465,7 +465,7 @@ process_incoming_udp_data(SocketInfo *sinfo) { } else if (bytes_read == 0) { // The socket was closed (!). This shouldn't happen with a UDP // connection. Oh well. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -547,7 +547,7 @@ process_incoming_tcp_data(SocketInfo *sinfo) { if (bytes_read <= 0) { // The socket was closed. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -601,7 +601,7 @@ process_incoming_tcp_data(SocketInfo *sinfo) { if (bytes_read <= 0) { // The socket was closed. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -674,7 +674,7 @@ process_raw_incoming_udp_data(SocketInfo *sinfo) { } else if (bytes_read == 0) { // The socket was closed (!). This shouldn't happen with a UDP // connection. Oh well. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -728,7 +728,7 @@ process_raw_incoming_tcp_data(SocketInfo *sinfo) { if (bytes_read <= 0) { // The socket was closed. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -772,7 +772,7 @@ thread_run(int thread_index) { while (!_shutdown) { SocketInfo *sinfo = get_next_available_socket(true, thread_index); - if (sinfo != (SocketInfo *)NULL) { + if (sinfo != nullptr) { process_incoming_data(sinfo); Thread::consider_yield(); } else { @@ -801,7 +801,7 @@ get_next_available_socket(bool allow_block, int current_thread_index) { // First, check the result from the previous select call. If there are // any sockets remaining there, process them first. while (!_shutdown && _num_results > 0) { - nassertr(_next_index < (int)_selecting_sockets.size(), NULL); + nassertr(_next_index < (int)_selecting_sockets.size(), nullptr); int i = _next_index; _next_index++; @@ -858,7 +858,7 @@ get_next_available_socket(bool allow_block, int current_thread_index) { } else if (_num_results < 0) { // If we had an error, just return. But yield the timeslice first. Thread::force_yield(); - return (SocketInfo *)NULL; + return nullptr; } } while (!_shutdown && interrupted); @@ -868,7 +868,7 @@ get_next_available_socket(bool allow_block, int current_thread_index) { // (b) return from PR_Poll() with no sockets available. } while (!_shutdown && _num_results > 0); - return (SocketInfo *)NULL; + return nullptr; } diff --git a/panda/src/net/connectionWriter.cxx b/panda/src/net/connectionWriter.cxx index a07b52fa63..554f8118c1 100644 --- a/panda/src/net/connectionWriter.cxx +++ b/panda/src/net/connectionWriter.cxx @@ -91,7 +91,7 @@ ConnectionWriter(ConnectionManager *manager, int num_threads, */ ConnectionWriter:: ~ConnectionWriter() { - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->remove_writer(this); } @@ -142,7 +142,7 @@ get_current_queue_size() const { bool ConnectionWriter:: send(const Datagram &datagram, const PT(Connection) &connection, bool block) { nassertr(!_shutdown, false); - nassertr(connection != (Connection *)NULL, false); + nassertr(connection != nullptr, false); nassertr(connection->get_socket()->is_exact_type(Socket_TCP::get_class_type()), false); NetDatagram copy(datagram); @@ -177,7 +177,7 @@ bool ConnectionWriter:: send(const Datagram &datagram, const PT(Connection) &connection, const NetAddress &address, bool block) { nassertr(!_shutdown, false); - nassertr(connection != (Connection *)NULL, false); + nassertr(connection != nullptr, false); nassertr(connection->get_socket()->is_exact_type(Socket_UDP::get_class_type()), false); if ((int)datagram.get_length() > maximum_udp_datagram) { @@ -309,7 +309,7 @@ shutdown() { */ void ConnectionWriter:: clear_manager() { - _manager = (ConnectionManager *)NULL; + _manager = nullptr; shutdown(); } diff --git a/panda/src/net/datagramSinkNet.cxx b/panda/src/net/datagramSinkNet.cxx index d09bc465ac..89e0d7c294 100644 --- a/panda/src/net/datagramSinkNet.cxx +++ b/panda/src/net/datagramSinkNet.cxx @@ -32,7 +32,7 @@ DatagramSinkNet(ConnectionManager *manager, int num_threads) : */ bool DatagramSinkNet:: put_datagram(const Datagram &data) { - if (_target == (Connection *)NULL) { + if (_target == nullptr) { return false; } return send(data, _target, true); @@ -44,7 +44,7 @@ put_datagram(const Datagram &data) { */ bool DatagramSinkNet:: is_error() { - return (_target == (Connection *)NULL || _target->get_socket() == (Socket_IP *)NULL); + return (_target == nullptr || _target->get_socket() == nullptr); } /** @@ -53,7 +53,7 @@ is_error() { */ void DatagramSinkNet:: flush() { - if (_target != (Connection *)NULL) { + if (_target != nullptr) { _target->flush(); } } diff --git a/panda/src/net/datagram_ui.cxx b/panda/src/net/datagram_ui.cxx index fb5fc1a958..fa9879bf86 100644 --- a/panda/src/net/datagram_ui.cxx +++ b/panda/src/net/datagram_ui.cxx @@ -31,8 +31,8 @@ operator >> (istream &in, NetDatagram &datagram) { datagram.clear(); // First, read a line of text. - string line; - getline(in, line); + std::string line; + std::getline(in, line); // Now parse the text. size_t p = 0; @@ -74,7 +74,7 @@ operator >> (istream &in, NetDatagram &datagram) { while (p < line.length() && line[p] != '"') { p++; } - string str = line.substr(start, p - start); + std::string str = line.substr(start, p - start); datagram.add_int8(DE_string); datagram.add_string(str); p++; @@ -85,7 +85,7 @@ operator >> (istream &in, NetDatagram &datagram) { while (p < line.length() && !isspace(line[p])) { p++; } - string str = line.substr(start, p - start); + std::string str = line.substr(start, p - start); datagram.add_int8(DE_string); datagram.add_string(str); } diff --git a/panda/src/net/test_raw_server.cxx b/panda/src/net/test_raw_server.cxx index 7811fdd446..aeec9b0aee 100644 --- a/panda/src/net/test_raw_server.cxx +++ b/panda/src/net/test_raw_server.cxx @@ -84,7 +84,7 @@ main(int argc, char *argv[]) { if (reader.get_data(datagram)) { string data = datagram.get_message(); nout.write(data.data(), data.length()); - nout << flush; + nout << std::flush; Clients::iterator ci; for (ci = clients.begin(); ci != clients.end(); ++ci) { diff --git a/panda/src/ode/odeAMotorJoint.cxx b/panda/src/ode/odeAMotorJoint.cxx index 8b7a16d6bc..8923453068 100644 --- a/panda/src/ode/odeAMotorJoint.cxx +++ b/panda/src/ode/odeAMotorJoint.cxx @@ -23,7 +23,7 @@ OdeAMotorJoint(dJointID id) : OdeAMotorJoint:: OdeAMotorJoint(OdeWorld &world) : - OdeJoint(dJointCreateAMotor(world.get_id(), 0)) { + OdeJoint(dJointCreateAMotor(world.get_id(), nullptr)) { } OdeAMotorJoint:: diff --git a/panda/src/ode/odeBallJoint.cxx b/panda/src/ode/odeBallJoint.cxx index b578c72c6b..f051c07c9a 100644 --- a/panda/src/ode/odeBallJoint.cxx +++ b/panda/src/ode/odeBallJoint.cxx @@ -23,7 +23,7 @@ OdeBallJoint(dJointID id) : OdeBallJoint:: OdeBallJoint(OdeWorld &world) : - OdeJoint(dJointCreateBall(world.get_id(), 0)) { + OdeJoint(dJointCreateBall(world.get_id(), nullptr)) { } OdeBallJoint:: diff --git a/panda/src/ode/odeBody.cxx b/panda/src/ode/odeBody.cxx index 4f70faff08..412759f8e7 100644 --- a/panda/src/ode/odeBody.cxx +++ b/panda/src/ode/odeBody.cxx @@ -63,8 +63,8 @@ get_data() const { OdeJoint OdeBody:: get_joint(int index) const { - nassertr(_id != 0, OdeJoint(0)); - nassertr(index < get_num_joints(), OdeJoint(0)); + nassertr(_id != nullptr, OdeJoint(nullptr)); + nassertr(index < get_num_joints(), OdeJoint(nullptr)); return OdeJoint(dBodyGetJoint(_id, index)); } @@ -77,5 +77,5 @@ write(ostream &out, unsigned int indent) const { OdeBody:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } diff --git a/panda/src/ode/odeBoxGeom.cxx b/panda/src/ode/odeBoxGeom.cxx index 77a594b552..2636da81da 100644 --- a/panda/src/ode/odeBoxGeom.cxx +++ b/panda/src/ode/odeBoxGeom.cxx @@ -23,7 +23,7 @@ OdeBoxGeom(dGeomID id) : OdeBoxGeom:: OdeBoxGeom(dReal lx, dReal ly, dReal lz) : - OdeGeom(dCreateBox(0, lx, ly, lz)) { + OdeGeom(dCreateBox(nullptr, lx, ly, lz)) { } OdeBoxGeom:: diff --git a/panda/src/ode/odeCappedCylinderGeom.cxx b/panda/src/ode/odeCappedCylinderGeom.cxx index 5b1a3b5b40..7fa7120f69 100644 --- a/panda/src/ode/odeCappedCylinderGeom.cxx +++ b/panda/src/ode/odeCappedCylinderGeom.cxx @@ -23,7 +23,7 @@ OdeCappedCylinderGeom(dGeomID id) : OdeCappedCylinderGeom:: OdeCappedCylinderGeom(dReal radius, dReal length) : - OdeGeom(dCreateCapsule(0, radius, length)) { + OdeGeom(dCreateCapsule(nullptr, radius, length)) { } OdeCappedCylinderGeom:: diff --git a/panda/src/ode/odeContactJoint.cxx b/panda/src/ode/odeContactJoint.cxx index b53694b1b3..10bf0b94ec 100644 --- a/panda/src/ode/odeContactJoint.cxx +++ b/panda/src/ode/odeContactJoint.cxx @@ -23,7 +23,7 @@ OdeContactJoint(dJointID id) : OdeContactJoint:: OdeContactJoint(OdeWorld &world, const OdeContact &contact) : - OdeJoint(dJointCreateContact(world.get_id(), 0, contact.get_contact_ptr())) { + OdeJoint(dJointCreateContact(world.get_id(), nullptr, contact.get_contact_ptr())) { } OdeContactJoint:: diff --git a/panda/src/ode/odeConvexGeom.cxx b/panda/src/ode/odeConvexGeom.cxx index 3160d343de..9a3b07d29a 100644 --- a/panda/src/ode/odeConvexGeom.cxx +++ b/panda/src/ode/odeConvexGeom.cxx @@ -23,7 +23,7 @@ OdeConvexGeom(dGeomID id) : OdeConvexGeom:: OdeConvexGeom(dReal radius, dReal length) : - OdeGeom(dCreateConvex(0, radius, length)) { + OdeGeom(dCreateConvex(nullptr, radius, length)) { } OdeConvexGeom:: diff --git a/panda/src/ode/odeCylinderGeom.cxx b/panda/src/ode/odeCylinderGeom.cxx index 7b7eccc49e..4076e3aa36 100644 --- a/panda/src/ode/odeCylinderGeom.cxx +++ b/panda/src/ode/odeCylinderGeom.cxx @@ -23,7 +23,7 @@ OdeCylinderGeom(dGeomID id) : OdeCylinderGeom:: OdeCylinderGeom(dReal radius, dReal length) : - OdeGeom(dCreateCylinder(0, radius, length)) { + OdeGeom(dCreateCylinder(nullptr, radius, length)) { } OdeCylinderGeom:: diff --git a/panda/src/ode/odeFixedJoint.cxx b/panda/src/ode/odeFixedJoint.cxx index 346a1dbdaa..a339776d60 100644 --- a/panda/src/ode/odeFixedJoint.cxx +++ b/panda/src/ode/odeFixedJoint.cxx @@ -23,7 +23,7 @@ OdeFixedJoint(dJointID id) : OdeFixedJoint:: OdeFixedJoint(OdeWorld &world) : - OdeJoint(dJointCreateFixed(world.get_id(), 0)) { + OdeJoint(dJointCreateFixed(world.get_id(), nullptr)) { } OdeFixedJoint:: diff --git a/panda/src/ode/odeGeom.I b/panda/src/ode/odeGeom.I index 883e367e70..e402b470e9 100644 --- a/panda/src/ode/odeGeom.I +++ b/panda/src/ode/odeGeom.I @@ -31,7 +31,7 @@ get_id() const { INLINE bool OdeGeom:: has_body() const { - return (dGeomGetBody(_id) != NULL); + return (dGeomGetBody(_id) != nullptr); } INLINE OdeBody OdeGeom:: diff --git a/panda/src/ode/odeGeom.cxx b/panda/src/ode/odeGeom.cxx index c1d4d0866f..c291025912 100644 --- a/panda/src/ode/odeGeom.cxx +++ b/panda/src/ode/odeGeom.cxx @@ -114,93 +114,93 @@ write(ostream &out, unsigned int indent) const { OdeBoxGeom OdeGeom:: convert_to_box() const { - nassertr(_id != 0, OdeBoxGeom((dGeomID)0)); - nassertr(get_class() == GC_box, OdeBoxGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeBoxGeom(nullptr)); + nassertr(get_class() == GC_box, OdeBoxGeom(nullptr)); return OdeBoxGeom(_id); } OdeCappedCylinderGeom OdeGeom:: convert_to_capped_cylinder() const { - nassertr(_id != 0, OdeCappedCylinderGeom((dGeomID)0)); - nassertr(get_class() == GC_capped_cylinder, OdeCappedCylinderGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeCappedCylinderGeom(nullptr)); + nassertr(get_class() == GC_capped_cylinder, OdeCappedCylinderGeom(nullptr)); return OdeCappedCylinderGeom(_id); } /* OdeConvexGeom OdeGeom:: convert_to_convex() const { - nassertr(_id != 0, OdeConvexGeom((dGeomID)0)); - nassertr(get_class() == GC_convex, OdeConvexGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeConvexGeom(nullptr)); + nassertr(get_class() == GC_convex, OdeConvexGeom(nullptr)); return OdeConvexGeom(_id); } */ OdeCylinderGeom OdeGeom:: convert_to_cylinder() const { - nassertr(_id != 0, OdeCylinderGeom((dGeomID)0)); - nassertr(get_class() == GC_cylinder, OdeCylinderGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeCylinderGeom(nullptr)); + nassertr(get_class() == GC_cylinder, OdeCylinderGeom(nullptr)); return OdeCylinderGeom(_id); } /* OdeHeightfieldGeom OdeGeom:: convert_to_heightfield() const { - nassertr(_id != 0, OdeHeightfieldGeom((dGeomID)0)); - nassertr(get_class() == GC_heightfield, OdeHeightfieldGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeHeightfieldGeom(nullptr)); + nassertr(get_class() == GC_heightfield, OdeHeightfieldGeom(nullptr)); return OdeHeightfieldGeom(_id); } */ OdePlaneGeom OdeGeom:: convert_to_plane() const { - nassertr(_id != 0, OdePlaneGeom((dGeomID)0)); - nassertr(get_class() == GC_plane, OdePlaneGeom((dGeomID)0)); + nassertr(_id != nullptr, OdePlaneGeom(nullptr)); + nassertr(get_class() == GC_plane, OdePlaneGeom(nullptr)); return OdePlaneGeom(_id); } OdeRayGeom OdeGeom:: convert_to_ray() const { - nassertr(_id != 0, OdeRayGeom((dGeomID)0)); - nassertr(get_class() == GC_ray, OdeRayGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeRayGeom(nullptr)); + nassertr(get_class() == GC_ray, OdeRayGeom(nullptr)); return OdeRayGeom(_id); } OdeSphereGeom OdeGeom:: convert_to_sphere() const { - nassertr(_id != 0, OdeSphereGeom((dGeomID)0)); - nassertr(get_class() == GC_sphere, OdeSphereGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeSphereGeom(nullptr)); + nassertr(get_class() == GC_sphere, OdeSphereGeom(nullptr)); return OdeSphereGeom(_id); } OdeTriMeshGeom OdeGeom:: convert_to_tri_mesh() const { - nassertr(_id != 0, OdeTriMeshGeom((dGeomID)0)); - nassertr(get_class() == GC_tri_mesh, OdeTriMeshGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeTriMeshGeom(nullptr)); + nassertr(get_class() == GC_tri_mesh, OdeTriMeshGeom(nullptr)); return OdeTriMeshGeom(_id); } OdeSimpleSpace OdeGeom:: convert_to_simple_space() const { - nassertr(_id != 0, OdeSimpleSpace((dSpaceID)0)); - nassertr(get_class() == GC_simple_space, OdeSimpleSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeSimpleSpace(nullptr)); + nassertr(get_class() == GC_simple_space, OdeSimpleSpace(nullptr)); return OdeSimpleSpace((dSpaceID)_id); } OdeHashSpace OdeGeom:: convert_to_hash_space() const { - nassertr(_id != 0, OdeHashSpace((dSpaceID)0)); - nassertr(get_class() == GC_hash_space, OdeHashSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeHashSpace(nullptr)); + nassertr(get_class() == GC_hash_space, OdeHashSpace(nullptr)); return OdeHashSpace((dSpaceID)_id); } OdeQuadTreeSpace OdeGeom:: convert_to_quad_tree_space() const { - nassertr(_id != 0, OdeQuadTreeSpace((dSpaceID)0)); - nassertr(get_class() == GC_quad_tree_space, OdeQuadTreeSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeQuadTreeSpace(nullptr)); + nassertr(get_class() == GC_quad_tree_space, OdeQuadTreeSpace(nullptr)); return OdeQuadTreeSpace((dSpaceID)_id); } OdeGeom:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } diff --git a/panda/src/ode/odeHashSpace.cxx b/panda/src/ode/odeHashSpace.cxx index af81c100a8..863bb1ae8d 100644 --- a/panda/src/ode/odeHashSpace.cxx +++ b/panda/src/ode/odeHashSpace.cxx @@ -23,7 +23,7 @@ OdeHashSpace(dSpaceID id) : OdeHashSpace:: OdeHashSpace() : - OdeSpace(dHashSpaceCreate(0)) { + OdeSpace(dHashSpaceCreate(nullptr)) { } OdeHashSpace:: diff --git a/panda/src/ode/odeHinge2Joint.cxx b/panda/src/ode/odeHinge2Joint.cxx index 157d642f2f..48b373ef21 100644 --- a/panda/src/ode/odeHinge2Joint.cxx +++ b/panda/src/ode/odeHinge2Joint.cxx @@ -23,7 +23,7 @@ OdeHinge2Joint(dJointID id) : OdeHinge2Joint:: OdeHinge2Joint(OdeWorld &world) : - OdeJoint(dJointCreateHinge2(world.get_id(), 0)) { + OdeJoint(dJointCreateHinge2(world.get_id(), nullptr)) { } OdeHinge2Joint:: diff --git a/panda/src/ode/odeHingeJoint.cxx b/panda/src/ode/odeHingeJoint.cxx index 352cf0ee32..3b2c1b509e 100644 --- a/panda/src/ode/odeHingeJoint.cxx +++ b/panda/src/ode/odeHingeJoint.cxx @@ -23,7 +23,7 @@ OdeHingeJoint(dJointID id) : OdeHingeJoint:: OdeHingeJoint(OdeWorld &world) : - OdeJoint(dJointCreateHinge(world.get_id(), 0)) { + OdeJoint(dJointCreateHinge(world.get_id(), nullptr)) { } OdeHingeJoint:: diff --git a/panda/src/ode/odeJoint.I b/panda/src/ode/odeJoint.I index a71fc8ac84..946dae9456 100644 --- a/panda/src/ode/odeJoint.I +++ b/panda/src/ode/odeJoint.I @@ -49,13 +49,13 @@ get_joint_type() const { INLINE void OdeJoint:: set_feedback(bool flag) { if (flag) { - if (dJointGetFeedback(_id) != NULL) { + if (dJointGetFeedback(_id) != nullptr) { return; } OdeJointFeedback* feedback = new OdeJointFeedback; dJointSetFeedback(_id, (dJointFeedback*) feedback); } else if (dJointFeedback* feedback = dJointGetFeedback(_id)) { - dJointSetFeedback(_id, NULL); + dJointSetFeedback(_id, nullptr); delete feedback; } } diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx index cdaa12e95f..a089a7b303 100644 --- a/panda/src/ode/odeJoint.cxx +++ b/panda/src/ode/odeJoint.cxx @@ -30,7 +30,7 @@ TypeHandle OdeJoint::_type_handle; OdeJoint:: OdeJoint() : - _id(0) { + _id(nullptr) { ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; } @@ -60,7 +60,7 @@ destroy() { void OdeJoint:: attach_bodies(const OdeBody &body1, const OdeBody &body2) { nassertv(_id); - nassertv(body1.get_id() != 0 || body2.get_id() != 0); + nassertv(body1.get_id() != nullptr || body2.get_id() != nullptr); dJointAttach(_id, body1.get_id(), body2.get_id()); } @@ -72,25 +72,25 @@ attach_bodies(const OdeBody &body1, const OdeBody &body2) { void OdeJoint:: attach_body(const OdeBody &body, int index) { nassertv(_id); - nassertv(body.get_id() != 0); + nassertv(body.get_id() != nullptr); nassertv(index == 0 || index == 1); if (index == 0) { - dJointAttach(_id, body.get_id(), 0); + dJointAttach(_id, body.get_id(), nullptr); } else { - dJointAttach(_id, 0, body.get_id()); + dJointAttach(_id, nullptr, body.get_id()); } } void OdeJoint:: detach() { nassertv(_id); - dJointAttach(_id, 0, 0); + dJointAttach(_id, nullptr, nullptr); } OdeBody OdeJoint:: get_body(int index) const { - nassertr(_id, OdeBody(0)); - nassertr(index == 0 || index == 1, OdeBody(0)); + nassertr(_id, OdeBody(nullptr)); + nassertr(index == 0 || index == 1, OdeBody(nullptr)); return OdeBody(dJointGetBody(_id, index)); } @@ -100,7 +100,7 @@ write(ostream &out, unsigned int indent) const { << "(id = " << _id \ << ", body1 = "; OdeBody body = get_body(0); - if (body.get_id() != 0) { + if (body.get_id() != nullptr) { body.write(out); } else { @@ -108,7 +108,7 @@ write(ostream &out, unsigned int indent) const { } out << ", body2 = "; body = get_body(1); - if (body.get_id() != 0) { + if (body.get_id() != nullptr) { body.write(out); } else { @@ -120,82 +120,82 @@ write(ostream &out, unsigned int indent) const { OdeJoint:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } OdeBallJoint OdeJoint:: convert_to_ball() const { - nassertr(_id != 0, OdeBallJoint(0)); - nassertr(get_joint_type() == JT_ball, OdeBallJoint(0)); + nassertr(_id != nullptr, OdeBallJoint(nullptr)); + nassertr(get_joint_type() == JT_ball, OdeBallJoint(nullptr)); return OdeBallJoint(_id); } OdeHingeJoint OdeJoint:: convert_to_hinge() const { - nassertr(_id != 0, OdeHingeJoint(0)); - nassertr(get_joint_type() == JT_hinge, OdeHingeJoint(0)); + nassertr(_id != nullptr, OdeHingeJoint(nullptr)); + nassertr(get_joint_type() == JT_hinge, OdeHingeJoint(nullptr)); return OdeHingeJoint(_id); } OdeSliderJoint OdeJoint:: convert_to_slider() const { - nassertr(_id != 0, OdeSliderJoint(0)); - nassertr(get_joint_type() == JT_slider, OdeSliderJoint(0)); + nassertr(_id != nullptr, OdeSliderJoint(nullptr)); + nassertr(get_joint_type() == JT_slider, OdeSliderJoint(nullptr)); return OdeSliderJoint(_id); } OdeContactJoint OdeJoint:: convert_to_contact() const { - nassertr(_id != 0, OdeContactJoint(0)); - nassertr(get_joint_type() == JT_contact, OdeContactJoint(0)); + nassertr(_id != nullptr, OdeContactJoint(nullptr)); + nassertr(get_joint_type() == JT_contact, OdeContactJoint(nullptr)); return OdeContactJoint(_id); } OdeUniversalJoint OdeJoint:: convert_to_universal() const { - nassertr(_id != 0, OdeUniversalJoint(0)); - nassertr(get_joint_type() == JT_universal, OdeUniversalJoint(0)); + nassertr(_id != nullptr, OdeUniversalJoint(nullptr)); + nassertr(get_joint_type() == JT_universal, OdeUniversalJoint(nullptr)); return OdeUniversalJoint(_id); } OdeHinge2Joint OdeJoint:: convert_to_hinge2() const { - nassertr(_id != 0, OdeHinge2Joint(0)); - nassertr(get_joint_type() == JT_hinge2, OdeHinge2Joint(0)); + nassertr(_id != nullptr, OdeHinge2Joint(nullptr)); + nassertr(get_joint_type() == JT_hinge2, OdeHinge2Joint(nullptr)); return OdeHinge2Joint(_id); } OdeFixedJoint OdeJoint:: convert_to_fixed() const { - nassertr(_id != 0, OdeFixedJoint(0)); - nassertr(get_joint_type() == JT_fixed, OdeFixedJoint(0)); + nassertr(_id != nullptr, OdeFixedJoint(nullptr)); + nassertr(get_joint_type() == JT_fixed, OdeFixedJoint(nullptr)); return OdeFixedJoint(_id); } OdeNullJoint OdeJoint:: convert_to_null() const { - nassertr(_id != 0, OdeNullJoint(0)); - nassertr(get_joint_type() == JT_null, OdeNullJoint(0)); + nassertr(_id != nullptr, OdeNullJoint(nullptr)); + nassertr(get_joint_type() == JT_null, OdeNullJoint(nullptr)); return OdeNullJoint(_id); } OdeAMotorJoint OdeJoint:: convert_to_a_motor() const { - nassertr(_id != 0, OdeAMotorJoint(0)); - nassertr(get_joint_type() == JT_a_motor, OdeAMotorJoint(0)); + nassertr(_id != nullptr, OdeAMotorJoint(nullptr)); + nassertr(get_joint_type() == JT_a_motor, OdeAMotorJoint(nullptr)); return OdeAMotorJoint(_id); } OdeLMotorJoint OdeJoint:: convert_to_l_motor() const { - nassertr(_id != 0, OdeLMotorJoint(0)); - nassertr(get_joint_type() == JT_l_motor, OdeLMotorJoint(0)); + nassertr(_id != nullptr, OdeLMotorJoint(nullptr)); + nassertr(get_joint_type() == JT_l_motor, OdeLMotorJoint(nullptr)); return OdeLMotorJoint(_id); } OdePlane2dJoint OdeJoint:: convert_to_plane2d() const { - nassertr(_id != 0, OdePlane2dJoint(0)); - nassertr(get_joint_type() == JT_plane2d, OdePlane2dJoint(0)); + nassertr(_id != nullptr, OdePlane2dJoint(nullptr)); + nassertr(get_joint_type() == JT_plane2d, OdePlane2dJoint(nullptr)); return OdePlane2dJoint(_id); } diff --git a/panda/src/ode/odeLMotorJoint.cxx b/panda/src/ode/odeLMotorJoint.cxx index 6c8abd2ee2..e1194603ac 100644 --- a/panda/src/ode/odeLMotorJoint.cxx +++ b/panda/src/ode/odeLMotorJoint.cxx @@ -23,7 +23,7 @@ OdeLMotorJoint(dJointID id) : OdeLMotorJoint:: OdeLMotorJoint(OdeWorld &world ) : - OdeJoint(dJointCreateLMotor(world.get_id(), 0)) { + OdeJoint(dJointCreateLMotor(world.get_id(), nullptr)) { } OdeLMotorJoint:: diff --git a/panda/src/ode/odeNullJoint.cxx b/panda/src/ode/odeNullJoint.cxx index 2cf348a6b2..214f101430 100644 --- a/panda/src/ode/odeNullJoint.cxx +++ b/panda/src/ode/odeNullJoint.cxx @@ -23,7 +23,7 @@ OdeNullJoint(dJointID id) : OdeNullJoint:: OdeNullJoint(OdeWorld &world) : - OdeJoint(dJointCreateNull(world.get_id(), 0)) { + OdeJoint(dJointCreateNull(world.get_id(), nullptr)) { } OdeNullJoint:: diff --git a/panda/src/ode/odePlane2dJoint.cxx b/panda/src/ode/odePlane2dJoint.cxx index 000f893ea6..1618452bb8 100644 --- a/panda/src/ode/odePlane2dJoint.cxx +++ b/panda/src/ode/odePlane2dJoint.cxx @@ -23,7 +23,7 @@ OdePlane2dJoint(dJointID id) : OdePlane2dJoint:: OdePlane2dJoint(OdeWorld &world) : - OdeJoint(dJointCreatePlane2D(world.get_id(), 0)) { + OdeJoint(dJointCreatePlane2D(world.get_id(), nullptr)) { } OdePlane2dJoint:: diff --git a/panda/src/ode/odePlaneGeom.cxx b/panda/src/ode/odePlaneGeom.cxx index a23d4961bb..5fe4b0bdb8 100644 --- a/panda/src/ode/odePlaneGeom.cxx +++ b/panda/src/ode/odePlaneGeom.cxx @@ -23,12 +23,12 @@ OdePlaneGeom(dGeomID id) : OdePlaneGeom:: OdePlaneGeom(dReal a, dReal b, dReal c, dReal d) : - OdeGeom(dCreatePlane(0, a, b, c, d)) { + OdeGeom(dCreatePlane(nullptr, a, b, c, d)) { } OdePlaneGeom:: OdePlaneGeom(const LVecBase4f ¶ms) : - OdeGeom(dCreatePlane(0, params[0], params[1], params[2], params[3])) { + OdeGeom(dCreatePlane(nullptr, params[0], params[1], params[2], params[3])) { } OdePlaneGeom:: diff --git a/panda/src/ode/odeQuadTreeSpace.cxx b/panda/src/ode/odeQuadTreeSpace.cxx index 2ced39a003..52b151e46e 100644 --- a/panda/src/ode/odeQuadTreeSpace.cxx +++ b/panda/src/ode/odeQuadTreeSpace.cxx @@ -38,7 +38,7 @@ OdeQuadTreeSpace:: OdeQuadTreeSpace(const LPoint3f ¢er, const LVecBase3f &extents, const int depth) : - OdeSpace(dQuadTreeSpaceCreate(0, + OdeSpace(dQuadTreeSpaceCreate(nullptr, LVec3_to_sdVector4(center).vec, LVec3_to_sdVector4(extents).vec, depth)) { diff --git a/panda/src/ode/odeRayGeom.cxx b/panda/src/ode/odeRayGeom.cxx index 10e727d76f..88a361948c 100644 --- a/panda/src/ode/odeRayGeom.cxx +++ b/panda/src/ode/odeRayGeom.cxx @@ -23,7 +23,7 @@ OdeRayGeom(dGeomID id) : OdeRayGeom:: OdeRayGeom(dReal length) : - OdeGeom(dCreateRay(0, length)) { + OdeGeom(dCreateRay(nullptr, length)) { } OdeRayGeom:: diff --git a/panda/src/ode/odeSimpleSpace.cxx b/panda/src/ode/odeSimpleSpace.cxx index a9e52d2015..1714d9af27 100644 --- a/panda/src/ode/odeSimpleSpace.cxx +++ b/panda/src/ode/odeSimpleSpace.cxx @@ -23,7 +23,7 @@ OdeSimpleSpace(dSpaceID id) : OdeSimpleSpace:: OdeSimpleSpace() : - OdeSpace(dSimpleSpaceCreate(0)) { + OdeSpace(dSimpleSpaceCreate(nullptr)) { } OdeSimpleSpace:: diff --git a/panda/src/ode/odeSliderJoint.cxx b/panda/src/ode/odeSliderJoint.cxx index 2976cbe65e..1e86396637 100644 --- a/panda/src/ode/odeSliderJoint.cxx +++ b/panda/src/ode/odeSliderJoint.cxx @@ -23,7 +23,7 @@ OdeSliderJoint(dJointID id) : OdeSliderJoint:: OdeSliderJoint(OdeWorld &world) : - OdeJoint(dJointCreateSlider(world.get_id(), 0)) { + OdeJoint(dJointCreateSlider(world.get_id(), nullptr)) { } OdeSliderJoint:: diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx index 6c4749f946..a07342b82f 100644 --- a/panda/src/ode/odeSpace.cxx +++ b/panda/src/ode/odeSpace.cxx @@ -31,8 +31,8 @@ dJointGroupID OdeSpace::_static_auto_collide_joint_group; OdeSpace:: OdeSpace(dSpaceID id) : _id(id) { - _auto_collide_world = NULL; - _auto_collide_joint_group = NULL; + _auto_collide_world = nullptr; + _auto_collide_joint_group = nullptr; } OdeSpace:: @@ -89,7 +89,7 @@ clean() { OdeGeom OdeSpace:: get_geom(int i) { - nassertr(_id, OdeGeom(0)); + nassertr(_id, OdeGeom(nullptr)); return OdeGeom(dSpaceGetGeom(_id, i)); } @@ -101,7 +101,7 @@ write(ostream &out, unsigned int indent) const { OdeSpace:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } void OdeSpace:: @@ -116,10 +116,10 @@ set_auto_collide_joint_group(OdeJointGroup &joint_group) { void OdeSpace:: auto_collide() { - if (_auto_collide_world == NULL) { + if (_auto_collide_world == nullptr) { odespace_cat.error() << "No collide world has been set!\n"; } else { - nassertv(_id != NULL); + nassertv(_id != nullptr); _static_auto_collide_space = this; _static_auto_collide_world = _auto_collide_world; _static_auto_collide_joint_group = _auto_collide_joint_group; @@ -140,7 +140,7 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { int surface1 = _static_auto_collide_space->get_surface_type(o1); int surface2 = _static_auto_collide_space->get_surface_type(o2); - nassertv(_static_auto_collide_world != NULL); + nassertv(_static_auto_collide_world != nullptr); sSurfaceParams collide_params; collide_params = _static_auto_collide_world->get_surface(surface1, surface2); @@ -191,22 +191,22 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { OdeSimpleSpace OdeSpace:: convert_to_simple_space() const { - nassertr(_id != 0, OdeSimpleSpace((dSpaceID)0)); - nassertr(get_class() == OdeGeom::GC_simple_space, OdeSimpleSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeSimpleSpace(nullptr)); + nassertr(get_class() == OdeGeom::GC_simple_space, OdeSimpleSpace(nullptr)); return OdeSimpleSpace(_id); } OdeHashSpace OdeSpace:: convert_to_hash_space() const { - nassertr(_id != 0, OdeHashSpace((dSpaceID)0)); - nassertr(get_class() == OdeGeom::GC_hash_space, OdeHashSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeHashSpace(nullptr)); + nassertr(get_class() == OdeGeom::GC_hash_space, OdeHashSpace(nullptr)); return OdeHashSpace(_id); } OdeQuadTreeSpace OdeSpace:: convert_to_quad_tree_space() const { - nassertr(_id != 0, OdeQuadTreeSpace((dSpaceID)0)); - nassertr(get_class() == OdeGeom::GC_quad_tree_space, OdeQuadTreeSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeQuadTreeSpace(nullptr)); + nassertr(get_class() == OdeGeom::GC_quad_tree_space, OdeQuadTreeSpace(nullptr)); return OdeQuadTreeSpace(_id); } diff --git a/panda/src/ode/odeSpace_ext.cxx b/panda/src/ode/odeSpace_ext.cxx index bed4a3e30b..97e841f30b 100644 --- a/panda/src/ode/odeSpace_ext.cxx +++ b/panda/src/ode/odeSpace_ext.cxx @@ -29,7 +29,7 @@ extern Dtool_PyTypedObject Dtool_OdeSpace; extern Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; #endif -PyObject *Extension::_python_callback = NULL; +PyObject *Extension::_python_callback = nullptr; /** * Do a sort of pseudo-downcast on this space in order to expose its @@ -69,13 +69,13 @@ convert() const { int Extension:: collide(PyObject* arg, PyObject* callback) { - nassertr(callback != NULL, -1); + nassertr(callback != nullptr, -1); if (!PyCallable_Check(callback)) { PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); return -1; - } else if (_this->get_id() == NULL) { + } else if (_this->get_id() == nullptr) { // Well, while we're in the mood of python exceptions, let's make this one // too. PyErr_Format(PyExc_TypeError, "OdeSpace is not valid!"); @@ -96,7 +96,7 @@ near_callback(void *data, dGeomID o1, dGeomID o2) { OdeGeom g2 (o2); PyObject* p1 = invoke_extension(&g1).convert(); PyObject* p2 = invoke_extension(&g2).convert(); - PyObject *result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, NULL); + PyObject *result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, nullptr); if (!result) { odespace_cat.error() << "An error occurred while calling python function!\n"; PyErr_Print(); diff --git a/panda/src/ode/odeSphereGeom.cxx b/panda/src/ode/odeSphereGeom.cxx index 96cb041495..eb49b7ea5e 100644 --- a/panda/src/ode/odeSphereGeom.cxx +++ b/panda/src/ode/odeSphereGeom.cxx @@ -23,7 +23,7 @@ OdeSphereGeom(dGeomID id) : OdeSphereGeom:: OdeSphereGeom(dReal radius) : - OdeGeom(dCreateSphere(0, radius)) { + OdeGeom(dCreateSphere(nullptr, radius)) { } OdeSphereGeom:: diff --git a/panda/src/ode/odeTriMeshData.I b/panda/src/ode/odeTriMeshData.I index e0cc754623..2aad3a2404 100644 --- a/panda/src/ode/odeTriMeshData.I +++ b/panda/src/ode/odeTriMeshData.I @@ -13,7 +13,7 @@ INLINE OdeTriMeshData::TriMeshDataMap &OdeTriMeshData:: get_tri_mesh_data_map() { - if (_tri_mesh_data_map == (TriMeshDataMap *)NULL) { + if (_tri_mesh_data_map == nullptr) { _tri_mesh_data_map = new TriMeshDataMap; } return *_tri_mesh_data_map; diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index a87853c4bb..07d265a41d 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -14,7 +14,7 @@ #include "odeTriMeshData.h" TypeHandle OdeTriMeshData::_type_handle; -OdeTriMeshData::TriMeshDataMap *OdeTriMeshData::_tri_mesh_data_map = NULL; +OdeTriMeshData::TriMeshDataMap *OdeTriMeshData::_tri_mesh_data_map = nullptr; void OdeTriMeshData:: link_data(dGeomID id, PT(OdeTriMeshData) data) { @@ -29,13 +29,13 @@ get_data(dGeomID id) { if (iter != data_map.end()) { return iter->second; } - return NULL; + return nullptr; } void OdeTriMeshData:: unlink_data(dGeomID id) { odetrimeshdata_cat.debug() << get_class_type() << "::unlink_data(" << id << ")" << "\n"; - nassertv(_tri_mesh_data_map != (TriMeshDataMap *)NULL); + nassertv(_tri_mesh_data_map != nullptr); TriMeshDataMap::iterator iter = _tri_mesh_data_map->find(id); if (iter != _tri_mesh_data_map->end()) { _tri_mesh_data_map->erase(iter); @@ -58,7 +58,7 @@ remove_data(OdeTriMeshData *data) { odetrimeshdata_cat.debug() << get_class_type() << "::remove_data(" << data->get_id() << ")" << "\n"; } - if (_tri_mesh_data_map == (TriMeshDataMap *)NULL) { + if (_tri_mesh_data_map == nullptr) { return; } @@ -88,9 +88,9 @@ remove_data(OdeTriMeshData *data) { OdeTriMeshData:: OdeTriMeshData(const NodePath& model, bool use_normals) : _id(dGeomTriMeshDataCreate()), - _vertices(0), - _faces(0), - _normals(0), + _vertices(nullptr), + _faces(nullptr), + _normals(nullptr), _num_vertices(0), _num_faces(0) { odetrimeshdata_cat.debug() << get_type() << "(" << _id << ")" << "\n"; @@ -131,16 +131,16 @@ OdeTriMeshData:: ~OdeTriMeshData() { odetrimeshdata_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n"; destroy(); - if (_vertices != 0) { + if (_vertices != nullptr) { PANDA_FREE_ARRAY(_vertices); - _vertices = 0; + _vertices = nullptr; _num_vertices = 0; } - if (_faces != 0) { + if (_faces != nullptr) { PANDA_FREE_ARRAY(_faces); - _faces = 0; + _faces = nullptr; } - if (_normals != 0) { + if (_normals != nullptr) { // This is never allocated? Until we use _normals, assert that we don't // accidentally free it here through some mistake. nassertv(false); @@ -151,10 +151,10 @@ OdeTriMeshData:: void OdeTriMeshData:: destroy() { odetrimeshdata_cat.debug() << get_type() << "::destroy(" << _id << ")" << "\n"; - if (_id != 0) { + if (_id != nullptr) { dGeomTriMeshDataDestroy(_id); remove_data(this); - _id = 0; + _id = nullptr; } } @@ -229,7 +229,7 @@ process_primitive(const GeomPrimitive *primitive, CPT(GeomVertexData) vData) { GeomVertexReader vReader(vData, "vertex"); GeomVertexReader nReader(vData, "normal"); - LVecBase3f vertex, normal; + LVecBase3f vertex; // CPT(GeomPrimitive) dPrimitive = primitive->decompose(); CPT(GeomPrimitive) dPrimitive = primitive; ostream &out = odetrimeshdata_cat.debug(); diff --git a/panda/src/ode/odeTriMeshGeom.I b/panda/src/ode/odeTriMeshGeom.I index b0a2e6177c..0a7dccaf53 100644 --- a/panda/src/ode/odeTriMeshGeom.I +++ b/panda/src/ode/odeTriMeshGeom.I @@ -34,7 +34,7 @@ set_tri_mesh_data(OdeTriMeshData &data) { INLINE PT(OdeTriMeshData) OdeTriMeshGeom:: get_tri_mesh_data() const { - nassertr(_id != 0, NULL); + nassertr(_id != 0, nullptr); return OdeTriMeshData::get_data(_id); } diff --git a/panda/src/ode/odeTriMeshGeom.cxx b/panda/src/ode/odeTriMeshGeom.cxx index f3e596d72b..257dbef3bb 100644 --- a/panda/src/ode/odeTriMeshGeom.cxx +++ b/panda/src/ode/odeTriMeshGeom.cxx @@ -23,19 +23,19 @@ OdeTriMeshGeom(dGeomID id) : OdeTriMeshGeom:: OdeTriMeshGeom(OdeTriMeshData &data) : - OdeGeom(dCreateTriMesh(0, data.get_id(), 0, 0, 0)) { + OdeGeom(dCreateTriMesh(nullptr, data.get_id(), nullptr, nullptr, nullptr)) { OdeTriMeshData::link_data(_id, &data); } OdeTriMeshGeom:: OdeTriMeshGeom(OdeSpace &space, OdeTriMeshData &data) : - OdeGeom(dCreateTriMesh(space.get_id(), data.get_id(), 0, 0, 0)) { + OdeGeom(dCreateTriMesh(space.get_id(), data.get_id(), nullptr, nullptr, nullptr)) { OdeTriMeshData::link_data(_id, &data); } OdeTriMeshGeom:: OdeTriMeshGeom(const OdeTriMeshGeom ©) : - OdeGeom(dCreateTriMesh(0, copy.get_data_id(), 0, 0, 0)) { + OdeGeom(dCreateTriMesh(nullptr, copy.get_data_id(), nullptr, nullptr, nullptr)) { OdeTriMeshData::link_data(_id, copy.get_data()); } diff --git a/panda/src/ode/odeUniversalJoint.cxx b/panda/src/ode/odeUniversalJoint.cxx index 4e9780bf92..ca8264e9ee 100644 --- a/panda/src/ode/odeUniversalJoint.cxx +++ b/panda/src/ode/odeUniversalJoint.cxx @@ -23,7 +23,7 @@ OdeUniversalJoint(dJointID id) : OdeUniversalJoint:: OdeUniversalJoint(OdeWorld &world) : - OdeJoint(dJointCreateUniversal(world.get_id(), 0)) { + OdeJoint(dJointCreateUniversal(world.get_id(), nullptr)) { } OdeUniversalJoint:: diff --git a/panda/src/ode/odeUtil_ext.cxx b/panda/src/ode/odeUtil_ext.cxx index 862e215eae..c5aabaa812 100644 --- a/panda/src/ode/odeUtil_ext.cxx +++ b/panda/src/ode/odeUtil_ext.cxx @@ -18,7 +18,7 @@ #ifdef HAVE_PYTHON -PyObject *Extension::_python_callback = NULL; +PyObject *Extension::_python_callback = nullptr; /** * Calls the callback for all potentially intersecting pairs that contain one @@ -26,7 +26,7 @@ PyObject *Extension::_python_callback = NULL; */ int Extension:: collide2(const OdeGeom &geom1, const OdeGeom &geom2, PyObject* arg, PyObject* callback) { - nassertr(callback != NULL, -1); + nassertr(callback != nullptr, -1); if (!PyCallable_Check(callback)) { PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); return -1; @@ -50,7 +50,7 @@ near_callback(void *data, dGeomID o1, dGeomID o2) { OdeGeom g2 (o2); PyObject* p1 = invoke_extension(&g1).convert(); PyObject* p2 = invoke_extension(&g2).convert(); - PyObject* result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, NULL); + PyObject* result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, nullptr); if (!result) { ode_cat.error() << "An error occurred while calling python function!\n"; PyErr_Print(); diff --git a/panda/src/ode/odeWorld.cxx b/panda/src/ode/odeWorld.cxx index 30b98ddd8b..f087c46374 100644 --- a/panda/src/ode/odeWorld.cxx +++ b/panda/src/ode/odeWorld.cxx @@ -178,5 +178,5 @@ apply_dampening(float dt, OdeBody& body) { OdeWorld:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.cxx b/panda/src/osxdisplay/osxGraphicsBuffer.cxx index 7b1beb26f8..d98b5d956a 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.cxx +++ b/panda/src/osxdisplay/osxGraphicsBuffer.cxx @@ -36,7 +36,7 @@ osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, osxGraphicsPipe *osx_pipe; DCAST_INTO_V(osx_pipe, _pipe); - _pbuffer = NULL; + _pbuffer = nullptr; // Since the pbuffer never gets flipped, we get screenshots from the same // buffer we draw into. @@ -48,7 +48,7 @@ osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, */ osxGraphicsBuffer:: ~osxGraphicsBuffer() { - nassertv(_pbuffer == NULL); + nassertv(_pbuffer == nullptr); } /** @@ -62,10 +62,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } - nassertr(_pbuffer != NULL, false); + nassertr(_pbuffer != nullptr, false); osxGraphicsStateGuardian *osxgsg; DCAST_INTO_R(osxgsg, _gsg, false); @@ -106,7 +106,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void osxGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -125,13 +125,13 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void osxGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { // aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0); _gsg.clear(); } - if (_pbuffer != NULL) { + if (_pbuffer != nullptr) { aglDestroyPBuffer(_pbuffer); - _pbuffer = NULL; + _pbuffer = nullptr; } _is_valid = false; } @@ -143,10 +143,10 @@ close_buffer() { bool osxGraphicsBuffer:: open_buffer() { if (_gsg == 0) { - _gsg = new osxGraphicsStateGuardian(_engine, _pipe, NULL); + _gsg = new osxGraphicsStateGuardian(_engine, _pipe, nullptr); } - if (_pbuffer == NULL) { + if (_pbuffer == nullptr) { GLenum target = GL_TEXTURE_RECTANGLE_ARB; if (_size[0] == Texture::up_to_power_2(_size[0]) && _size[1] == Texture::up_to_power_2(_size[1])) { diff --git a/panda/src/osxdisplay/osxGraphicsPipe.cxx b/panda/src/osxdisplay/osxGraphicsPipe.cxx index 721f54b585..9211c52515 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.cxx +++ b/panda/src/osxdisplay/osxGraphicsPipe.cxx @@ -34,7 +34,7 @@ Boolean GetDictionaryBoolean(CFDictionaryRef theDict, const void* key) { Boolean value = false; CFBooleanRef boolRef; boolRef = (CFBooleanRef)CFDictionaryGetValue(theDict, key); - if (boolRef != NULL) + if (boolRef != nullptr) value = CFBooleanGetValue(boolRef); return value; } @@ -44,7 +44,7 @@ long GetDictionaryLong(CFDictionaryRef theDict, const void* key) { long value = 0; CFNumberRef numRef; numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); - if (numRef != NULL) + if (numRef != nullptr) CFNumberGetValue(numRef, kCFNumberLongType, &value); return value; } @@ -94,7 +94,7 @@ CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) { unsigned int numberOfAvailableModes = CFArrayGetCount(availableModes); // creat mutable array to hold the display modes we are interested int. - CFMutableArrayRef usefulModes = CFArrayCreateMutable(kCFAllocatorDefault, numberOfAvailableModes, NULL); + CFMutableArrayRef usefulModes = CFArrayCreateMutable(kCFAllocatorDefault, numberOfAvailableModes, nullptr); // get the current bits per pixel. long currentModeBitsPerPixel = GetModeBitsPerPixel(CGDisplayCurrentMode(display)); @@ -152,7 +152,7 @@ CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) { // now sort the useful mode array, using the comparison callback. CFArraySortValues( usefulModes, CFRangeMake(0, CFArrayGetCount(usefulModes)), - (CFComparatorFunction) CompareModes, NULL); + (CFComparatorFunction) CompareModes, nullptr); // return the CFArray of the useful display modes. return usefulModes; } @@ -250,7 +250,7 @@ create_cg_image(const PNMImage &pnm_image) { bool has_alpha; bool is_grayscale; - CFStringRef color_space_name = NULL; + CFStringRef color_space_name = nullptr; switch (pnm_image.get_color_type()) { case PNMImage::CT_grayscale: color_space_name = kCGColorSpaceGenericGray; @@ -278,13 +278,13 @@ create_cg_image(const PNMImage &pnm_image) { case PNMImage::CT_invalid: // Shouldn't get here. - nassertr(false, NULL); + nassertr(false, nullptr); break; } - nassertr(color_space_name != NULL, NULL); + nassertr(color_space_name != nullptr, nullptr); CGColorSpaceRef color_space = CGColorSpaceCreateWithName(color_space_name); - nassertr(color_space != NULL, NULL); + nassertr(color_space != nullptr, nullptr); CGBitmapInfo bitmap_info = 0; #ifdef PGM_BIGGRAYS @@ -312,17 +312,17 @@ create_cg_image(const PNMImage &pnm_image) { } } } - nassertr((void *)dp == (void *)(char_array + num_bytes), NULL); + nassertr((void *)dp == (void *)(char_array + num_bytes), nullptr); CGDataProviderRef provider = - CGDataProviderCreateWithData(NULL, char_array, num_bytes, release_data); - nassertr(provider != NULL, NULL); + CGDataProviderCreateWithData(nullptr, char_array, num_bytes, release_data); + nassertr(provider != nullptr, nullptr); CGImageRef image = CGImageCreate (width, height, bits_per_component, bits_per_pixel, bytes_per_row, color_space, bitmap_info, provider, - NULL, false, kCGRenderingIntentDefault); - nassertr(image != NULL, NULL); + nullptr, false, kCGRenderingIntentDefault); + nassertr(image != nullptr, nullptr); CGColorSpaceRelease(color_space); CGDataProviderRelease(provider); @@ -354,12 +354,12 @@ make_output(const string &name, int retry, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } osxGraphicsStateGuardian *osxgsg = 0; if (gsg != 0) { - DCAST_INTO_R(osxgsg, gsg, NULL); + DCAST_INTO_R(osxgsg, gsg, nullptr); } // First thing to try: an osxGraphicsWindow @@ -372,15 +372,15 @@ make_output(const string &name, ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } WindowHandle *window_handle = win_prop.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { osxdisplay_cat.info() << "Got parent_window " << *window_handle << "\n"; #ifdef SUPPORT_SUBPROCESS_WINDOW WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL && + if (os_handle != nullptr && os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { return new SubprocessWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -394,9 +394,9 @@ make_output(const string &name, // Second thing to try: a GLGraphicsBuffer if (retry == 1) { - if (!osx_support_gl_buffer || !gl_support_fbo || host == NULL || + if (!osx_support_gl_buffer || !gl_support_fbo || host == nullptr || (flags & (BF_require_parasite | BF_require_window)) != 0) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -404,13 +404,13 @@ make_output(const string &name, if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || fb_prop.get_accum_bits() > 0) { - return NULL; + return nullptr; } } - if (osxgsg != NULL && osxgsg->is_valid() && !osxgsg->needs_reset()) { + if (osxgsg != nullptr && osxgsg->is_valid() && !osxgsg->needs_reset()) { if (!osxgsg->_supports_framebuffer_object || - osxgsg->_glDrawBuffers == NULL) { - return NULL; + osxgsg->_glDrawBuffers == nullptr) { + return nullptr; } else if (fb_prop.is_basic()) { // Early success - if we are sure that this buffer WILL meet specs, we // can precertify it. @@ -429,14 +429,14 @@ make_output(const string &name, ((flags&BF_size_track_host)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } return new osxGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } /** @@ -447,5 +447,5 @@ make_output(const string &name, */ PT(GraphicsStateGuardian) osxGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { - return new osxGraphicsStateGuardian(engine, this, NULL); + return new osxGraphicsStateGuardian(engine, this, nullptr); } diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index 8099eb5547..0ae735b055 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -36,13 +36,13 @@ TypeHandle osxGraphicsStateGuardian::_type_handle; void *osxGraphicsStateGuardian:: do_get_extension_func(const char *name) { string fullname = "_" + string(name); - NSSymbol symbol = NULL; + NSSymbol symbol = nullptr; if (NSIsSymbolNameDefined(fullname.c_str())) { symbol = NSLookupAndBindSymbol(fullname.c_str()); } - return symbol ? NSAddressOfSymbol(symbol) : NULL; + return symbol ? NSAddressOfSymbol(symbol) : nullptr; } /** @@ -53,8 +53,8 @@ osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, osxGraphicsStateGuardian *share_with) : GLGraphicsStateGuardian(engine, pipe), _share_with(share_with), - _aglPixFmt(NULL), - _aglcontext(NULL) + _aglPixFmt(nullptr), + _aglcontext(nullptr) { _shared_buffer = 1011; get_gamma_table(); @@ -65,11 +65,11 @@ osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ osxGraphicsStateGuardian:: ~osxGraphicsStateGuardian() { - if (_aglcontext != (AGLContext)NULL) { - aglSetCurrentContext(NULL); + if (_aglcontext != (AGLContext)nullptr) { + aglSetCurrentContext(nullptr); aglDestroyContext(_aglcontext); report_agl_error("aglDestroyContext"); - _aglcontext = (AGLContext)NULL; + _aglcontext = (AGLContext)nullptr; } } @@ -89,7 +89,7 @@ void osxGraphicsStateGuardian::reset() GLGraphicsStateGuardian::reset(); - if (_aglcontext != (AGLContext)NULL) { + if (_aglcontext != (AGLContext)nullptr) { // Apply the video-sync setting. GLint value = sync_video ? 1 : 0; aglSetInteger(_aglcontext, AGL_SWAP_INTERVAL, &value); @@ -106,7 +106,7 @@ void osxGraphicsStateGuardian:: draw_resize_box() { // This state is created, once, and never freed. static CPT(RenderState) state; - if (state == (RenderState *)NULL) { + if (state == nullptr) { state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha), DepthWriteAttrib::make(DepthWriteAttrib::M_off), DepthTestAttrib::make(DepthTestAttrib::M_none)); @@ -229,18 +229,18 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { attrib.push_back(AGL_NONE); // build context - _aglcontext = NULL; + _aglcontext = nullptr; _aglPixFmt = aglChoosePixelFormat(&display, 1, &attrib[0]); err = report_agl_error("aglChoosePixelFormat"); if (_aglPixFmt) { - if(_share_with == NULL) { - _aglcontext = aglCreateContext(_aglPixFmt, NULL); + if(_share_with == nullptr) { + _aglcontext = aglCreateContext(_aglPixFmt, nullptr); } else { _aglcontext = aglCreateContext(_aglPixFmt, ((osxGraphicsStateGuardian *)_share_with)->_aglcontext); } err = report_agl_error("aglCreateContext"); - if (_aglcontext == NULL) { + if (_aglcontext == nullptr) { osxdisplay_cat.error() << "osxGraphicsStateGuardian::build_gl Error Getting GL Context \n" ; if(err == noErr) { @@ -348,9 +348,9 @@ describe_pixel_format(FrameBufferProperties &fb_props) { GLint ndevs; AGLDevice *gdevs = aglDevicesOfPixelFormat(_aglPixFmt, &ndevs); - if (gdevs != (AGLDevice *)NULL) { + if (gdevs != nullptr) { AGLRendererInfo rinfo = aglQueryRendererInfo(gdevs, ndevs); - if (rinfo != NULL) { + if (rinfo != nullptr) { if (aglDescribeRenderer(rinfo, AGL_ACCELERATED, &value)) { // Now we know whether it's hardware or software. fb_props.set_force_hardware(value); diff --git a/panda/src/parametrics/curveFitter.cxx b/panda/src/parametrics/curveFitter.cxx index 6592d7aff2..e929ebd21e 100644 --- a/panda/src/parametrics/curveFitter.cxx +++ b/panda/src/parametrics/curveFitter.cxx @@ -152,7 +152,7 @@ remove_samples(int begin, int end) { */ void CurveFitter:: sample(ParametricCurveCollection *curves, int count) { - nassertv(curves != (ParametricCurveCollection *)NULL); + nassertv(curves != nullptr); PN_stdfloat max_t = curves->get_max_t(); PN_stdfloat t; DataPoint dp; @@ -166,10 +166,10 @@ sample(ParametricCurveCollection *curves, int count) { } } - if (curves->get_xyz_curve() != (ParametricCurve *)NULL) { + if (curves->get_xyz_curve() != nullptr) { _got_xyz = true; } - if (curves->get_hpr_curve() != (ParametricCurve *)NULL) { + if (curves->get_hpr_curve() != nullptr) { _got_hpr = true; } } diff --git a/panda/src/parametrics/curveFitter.h b/panda/src/parametrics/curveFitter.h index a83778951f..a07fd532a4 100644 --- a/panda/src/parametrics/curveFitter.h +++ b/panda/src/parametrics/curveFitter.h @@ -30,7 +30,7 @@ class NurbsCurve; /** * */ -class EXPCL_PANDA_GOBJ CurveFitter { +class EXPCL_PANDA_PARAMETRICS CurveFitter { PUBLISHED: CurveFitter(); ~CurveFitter(); diff --git a/panda/src/parametrics/nurbsCurveInterface.cxx b/panda/src/parametrics/nurbsCurveInterface.cxx index 9c9affa03d..b00edb3364 100644 --- a/panda/src/parametrics/nurbsCurveInterface.cxx +++ b/panda/src/parametrics/nurbsCurveInterface.cxx @@ -156,7 +156,7 @@ format_egg(ostream &out, const string &name, const string &curve_type, bool NurbsCurveInterface:: convert_to_nurbs(ParametricCurve *nc) const { NurbsCurveInterface *nurbs = nc->get_nurbs_interface(); - nassertr(nurbs != (NurbsCurveInterface *)NULL, false); + nassertr(nurbs != nullptr, false); nurbs->remove_all_cvs(); nurbs->set_order(get_order()); diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 403f9e8c04..5d3d014722 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -418,7 +418,7 @@ get_bezier_seg(ParametricCurve::BezierSeg &) const { */ NurbsCurveInterface *ParametricCurve:: get_nurbs_interface() { - return (NurbsCurveInterface *)NULL; + return nullptr; } /** @@ -497,7 +497,7 @@ convert_to_hermite(HermiteCurve *hc) const { bool ParametricCurve:: convert_to_nurbs(ParametricCurve *nc) const { NurbsCurveInterface *nurbs = nc->get_nurbs_interface(); - nassertr(nurbs != (NurbsCurveInterface *)NULL, false); + nassertr(nurbs != nullptr, false); BezierSegs bz_segs; if (!get_bezier_segs(bz_segs)) { diff --git a/panda/src/parametrics/parametricCurveCollection.I b/panda/src/parametrics/parametricCurveCollection.I index 07fd5e9f26..ba4cf949a0 100644 --- a/panda/src/parametrics/parametricCurveCollection.I +++ b/panda/src/parametrics/parametricCurveCollection.I @@ -31,7 +31,7 @@ get_num_curves() const { */ INLINE ParametricCurve *ParametricCurveCollection:: get_curve(int index) const { - nassertr(index >= 0 && index < (int)_curves.size(), (ParametricCurve *)NULL); + nassertr(index >= 0 && index < (int)_curves.size(), nullptr); return _curves[index]; } diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 45d61ccfe8..9e3d8b4a1b 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -150,8 +150,8 @@ clear() { */ void ParametricCurveCollection:: clear_timewarps() { - PT(ParametricCurve) xyz_curve = (ParametricCurve *)NULL; - PT(ParametricCurve) hpr_curve = (ParametricCurve *)NULL; + PT(ParametricCurve) xyz_curve = nullptr; + PT(ParametricCurve) hpr_curve = nullptr; ParametricCurves::iterator ci; for (ci = _curves.begin(); ci != _curves.end(); ++ci) { @@ -159,7 +159,7 @@ clear_timewarps() { switch (curve->get_curve_type()) { case PCT_XYZ: - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { xyz_curve = curve; } else { prepare_remove_curve(curve); @@ -167,7 +167,7 @@ clear_timewarps() { break; case PCT_HPR: - if (hpr_curve == (ParametricCurve *)NULL) { + if (hpr_curve == nullptr) { hpr_curve = curve; } else { prepare_remove_curve(curve); @@ -182,7 +182,7 @@ clear_timewarps() { _curves.clear(); _curves.push_back(xyz_curve); - if (hpr_curve != (ParametricCurve *)NULL) { + if (hpr_curve != nullptr) { _curves.push_back(hpr_curve); } @@ -202,7 +202,7 @@ get_xyz_curve() const { return curve; } } - return (ParametricCurve *)NULL; + return nullptr; } /** @@ -218,7 +218,7 @@ get_hpr_curve() const { return curve; } } - return (ParametricCurve *)NULL; + return nullptr; } /** @@ -229,7 +229,7 @@ get_hpr_curve() const { ParametricCurve *ParametricCurveCollection:: get_default_curve() const { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve != (ParametricCurve *)NULL) { + if (xyz_curve != nullptr) { return xyz_curve; } @@ -240,7 +240,7 @@ get_default_curve() const { return curve; } } - return (ParametricCurve *)NULL; + return nullptr; } /** @@ -276,8 +276,8 @@ get_timewarp_curve(int n) const { n--; } } - nassertr(false, (ParametricCurve *)NULL); - return (ParametricCurve *)NULL; + nassertr(false, nullptr); + return nullptr; } /** @@ -295,7 +295,7 @@ get_timewarp_curve(int n) const { void ParametricCurveCollection:: make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { parametrics_cat.error() << "No XYZ curve for make_even().\n"; return; @@ -349,7 +349,7 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { fitter.compute_tangents(1); PT(ParametricCurveCollection) fit = fitter.make_nurbs(); ParametricCurve *t_curve = fit->get_xyz_curve(); - nassertv(t_curve != (ParametricCurve *)NULL); + nassertv(t_curve != nullptr); t_curve->set_curve_type(PCT_T); add_curve(t_curve); } @@ -362,7 +362,7 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { void ParametricCurveCollection:: face_forward(PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { parametrics_cat.error() << "No XYZ curve for face_forward().\n"; return; @@ -412,7 +412,7 @@ face_forward(PN_stdfloat segments_per_unit) { fitter.compute_tangents(1); PT(ParametricCurveCollection) fit = fitter.make_nurbs(); ParametricCurve *hpr_curve = fit->get_hpr_curve(); - nassertv(hpr_curve != (ParametricCurve *)NULL); + nassertv(hpr_curve != nullptr); add_curve(hpr_curve, xyz_index + 1); } @@ -452,9 +452,9 @@ bool ParametricCurveCollection:: evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const { // First, apply all the timewarps in sequence, from back to front. Also // take note of the XYZ and HPR curves. - ParametricCurve *xyz_curve = (ParametricCurve *)NULL; - ParametricCurve *hpr_curve = (ParametricCurve *)NULL; - ParametricCurve *default_curve = (ParametricCurve *)NULL; + ParametricCurve *xyz_curve = nullptr; + ParametricCurve *hpr_curve = nullptr; + ParametricCurve *default_curve = nullptr; PN_stdfloat t0 = t; LVecBase3 point; @@ -484,18 +484,18 @@ evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const { } } - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { xyz_curve = default_curve; } // Now compute the position and orientation. - if (xyz_curve != (ParametricCurve *)NULL) { + if (xyz_curve != nullptr) { if (!xyz_curve->get_point(t0, xyz)) { return false; } } - if (hpr_curve != (ParametricCurve *)NULL) { + if (hpr_curve != nullptr) { if (!hpr_curve->get_point(t0, hpr)) { return false; } @@ -564,7 +564,7 @@ evaluate_t(PN_stdfloat t) const { bool ParametricCurveCollection:: adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz) { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { return false; } @@ -583,7 +583,7 @@ adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz) { bool ParametricCurveCollection:: adjust_hpr(PN_stdfloat t, const LVecBase3 &hpr) { ParametricCurve *hpr_curve = get_hpr_curve(); - if (hpr_curve == (ParametricCurve *)NULL) { + if (hpr_curve == nullptr) { return false; } @@ -631,7 +631,7 @@ stitch(const ParametricCurveCollection *a, clear(); - if (a_xyz != (ParametricCurve *)NULL && b_xyz != (ParametricCurve *)NULL) { + if (a_xyz != nullptr && b_xyz != nullptr) { PT(NurbsCurve) new_xyz = new NurbsCurve; if (!new_xyz->stitch(a_xyz, b_xyz)) { return false; @@ -640,7 +640,7 @@ stitch(const ParametricCurveCollection *a, add_curve(new_xyz); } - if (a_hpr != (ParametricCurve *)NULL && b_hpr != (ParametricCurve *)NULL) { + if (a_hpr != nullptr && b_hpr != nullptr) { PT(NurbsCurve) new_hpr = new NurbsCurve; if (!new_hpr->stitch(a_hpr, b_hpr)) { return false; diff --git a/panda/src/parametrics/piecewiseCurve.cxx b/panda/src/parametrics/piecewiseCurve.cxx index cbaa7497f6..d69b4f7025 100644 --- a/panda/src/parametrics/piecewiseCurve.cxx +++ b/panda/src/parametrics/piecewiseCurve.cxx @@ -68,7 +68,7 @@ bool PiecewiseCurve:: get_point(PN_stdfloat t, LVecBase3 &point) const { const ParametricCurve *curve; bool result = find_curve(curve, t); - if (curve == NULL){ + if (curve == nullptr){ return false; } // We use | instead of || so we won't short-circuit this calculation. @@ -438,7 +438,7 @@ find_curve(const ParametricCurve *&curve, PN_stdfloat &t) const { if (ti >= (int)_segs.size()) { if (_segs.empty()) { - curve = NULL; + curve = nullptr; t = 0.0f; return false; } else { @@ -523,7 +523,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for (i = 0; i < num_segs; i++) { Curveseg seg; manager->read_pointer(scan); - seg._curve = (ParametricCurve *)NULL; + seg._curve = nullptr; seg._tend = scan.get_float64(); _segs.push_back(seg); } diff --git a/panda/src/parametrics/ropeNode.cxx b/panda/src/parametrics/ropeNode.cxx index 365795adf7..5837bfd361 100644 --- a/panda/src/parametrics/ropeNode.cxx +++ b/panda/src/parametrics/ropeNode.cxx @@ -50,7 +50,7 @@ void RopeNode::CData:: write_datagram(BamWriter *writer, Datagram &dg) const { // For now, we write a NULL pointer. Eventually we will write out the // NurbsCurveEvaluator pointer. - writer->write_pointer(dg, (TypedWritable *)NULL); + writer->write_pointer(dg, nullptr); } /** @@ -129,7 +129,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Create some geometry on-the-fly to render the rope. if (get_num_subdiv() > 0) { NurbsCurveEvaluator *curve = get_curve(); - if (curve != (NurbsCurveEvaluator *)NULL) { + if (curve != nullptr) { PT(NurbsCurveResult) result; if (has_matrix()) { result = curve->evaluate(data.get_node_path(), get_matrix()); @@ -180,7 +180,7 @@ void RopeNode:: output(ostream &out) const { PandaNode::output(out); NurbsCurveEvaluator *curve = get_curve(); - if (curve != (NurbsCurveEvaluator *)NULL) { + if (curve != nullptr) { out << " " << *curve; } else { out << " (no curve)"; @@ -270,7 +270,7 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, PT(BoundingVolume) bound = new BoundingSphere; NurbsCurveEvaluator *curve = get_curve(); - if (curve != (NurbsCurveEvaluator *)NULL) { + if (curve != nullptr) { NurbsCurveEvaluator::Vert3Array verts; get_curve()->get_vertices(verts, rel_to); @@ -519,14 +519,14 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments, bool use_vertex_color = get_use_vertex_color(); bool use_vertex_thickness = get_use_vertex_thickness(); - CurveSegment *curve_segment = NULL; + CurveSegment *curve_segment = nullptr; LPoint3 last_point; for (int segment = 0; segment < num_segments; ++segment) { LPoint3 point; result->eval_segment_point(segment, 0.0f, point); - if (curve_segment == (CurveSegment *)NULL || + if (curve_segment == nullptr || !point.almost_equal(last_point)) { // If the first point of this segment is different from the last point // of the previous segment, end the previous segment and begin a new diff --git a/panda/src/parametrics/sheetNode.cxx b/panda/src/parametrics/sheetNode.cxx index b4e4cc5a4d..294c3a7ff4 100644 --- a/panda/src/parametrics/sheetNode.cxx +++ b/panda/src/parametrics/sheetNode.cxx @@ -48,7 +48,7 @@ void SheetNode::CData:: write_datagram(BamWriter *writer, Datagram &dg) const { // For now, we write a NULL pointer. Eventually we will write out the // NurbsSurfaceEvaluator pointer. - writer->write_pointer(dg, (TypedWritable *)NULL); + writer->write_pointer(dg, nullptr); } /** @@ -128,7 +128,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Create some geometry on-the-fly to render the sheet. if (get_num_u_subdiv() > 0 && get_num_v_subdiv() > 0) { NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { PT(NurbsSurfaceResult) result = surface->evaluate(data.get_node_path()); if (result->get_num_u_segments() > 0 && result->get_num_v_segments() > 0) { @@ -158,7 +158,7 @@ void SheetNode:: output(ostream &out) const { PandaNode::output(out); NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { out << " " << *surface; } else { out << " (no surface)"; @@ -172,7 +172,7 @@ void SheetNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { indent(out, indent_level + 2) << *surface << "\n"; } else { indent(out, indent_level + 2) << "(no surface)\n"; @@ -224,7 +224,7 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, PT(BoundingVolume) bound = new BoundingSphere; NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { NurbsSurfaceEvaluator::Vert3Array verts; get_surface()->get_vertices(verts, rel_to); diff --git a/panda/src/particlesystem/colorInterpolationManager.I b/panda/src/particlesystem/colorInterpolationManager.I index 4a76521cea..e9b087605f 100644 --- a/panda/src/particlesystem/colorInterpolationManager.I +++ b/panda/src/particlesystem/colorInterpolationManager.I @@ -231,7 +231,7 @@ get_segment(const int seg_id) { if( seg_id == (*iter)->get_id() ) return (*iter); - return NULL; + return nullptr; } /** diff --git a/panda/src/particlesystem/geomParticleRenderer.I b/panda/src/particlesystem/geomParticleRenderer.I index 25ce5035c3..cdb3906ac0 100644 --- a/panda/src/particlesystem/geomParticleRenderer.I +++ b/panda/src/particlesystem/geomParticleRenderer.I @@ -21,7 +21,7 @@ INLINE void GeomParticleRenderer:: set_geom_node(PandaNode *node) { - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); _geom_node = node; resize_pool(_pool_size); } diff --git a/panda/src/particlesystem/geomParticleRenderer.cxx b/panda/src/particlesystem/geomParticleRenderer.cxx index 92ebc5a218..74df181f2e 100644 --- a/panda/src/particlesystem/geomParticleRenderer.cxx +++ b/panda/src/particlesystem/geomParticleRenderer.cxx @@ -105,7 +105,7 @@ resize_pool(int new_size) { int i; for (i = 0; i < new_size; i++) { - _node_vector.push_back(NULL); + _node_vector.push_back(nullptr); } _pool_size = new_size; @@ -122,7 +122,7 @@ kill_nodes() { PandaNode *render_node = get_render_node(); for (; vec_iter != _node_vector.end(); vec_iter++) { PandaNode *node = *vec_iter; - if (node != (PandaNode *)NULL) { + if (node != nullptr) { render_node->remove_child(node); } } @@ -136,7 +136,7 @@ kill_nodes() { void GeomParticleRenderer:: birth_particle(int index) { - if (_node_vector[index] == (PandaNode *)NULL) { + if (_node_vector[index] == nullptr) { PandaNode *node = new PandaNode(""); get_render_node()->add_child(node); node->add_child(_geom_node); @@ -150,9 +150,9 @@ birth_particle(int index) { void GeomParticleRenderer:: kill_particle(int index) { - if (_node_vector[index] != (PandaNode *)NULL) { + if (_node_vector[index] != nullptr) { get_render_node()->remove_child(_node_vector[index]); - _node_vector[index] = (PandaNode *)NULL; + _node_vector[index] = nullptr; } } @@ -179,11 +179,11 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (cur_particle->get_alive()) { // living particle - if (cur_node == (PandaNode *)NULL) { + if (cur_node == nullptr) { birth_particle(i); cur_node = *cur_node_iter; } - nassertv(cur_node != (PandaNode *)NULL); + nassertv(cur_node != nullptr); cur_node->set_state(_render_state); diff --git a/panda/src/particlesystem/geomParticleRenderer.h b/panda/src/particlesystem/geomParticleRenderer.h index 54e58a2d65..1e4fccf320 100644 --- a/panda/src/particlesystem/geomParticleRenderer.h +++ b/panda/src/particlesystem/geomParticleRenderer.h @@ -26,7 +26,7 @@ class EXPCL_PANDAPHYSICS GeomParticleRenderer : public BaseParticleRenderer { PUBLISHED: explicit GeomParticleRenderer(ParticleRendererAlphaMode am = PR_ALPHA_NONE, - PandaNode *geom_node = (PandaNode *) NULL); + PandaNode *geom_node = nullptr); GeomParticleRenderer(const GeomParticleRenderer& copy); virtual ~GeomParticleRenderer(); diff --git a/panda/src/particlesystem/orientedParticleFactory.h b/panda/src/particlesystem/orientedParticleFactory.h index 0df2326ed4..5258d7e256 100644 --- a/panda/src/particlesystem/orientedParticleFactory.h +++ b/panda/src/particlesystem/orientedParticleFactory.h @@ -33,7 +33,7 @@ PUBLISHED: INLINE LOrientation get_final_orientation() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual void populate_child_particle(BaseParticle *bp) const; diff --git a/panda/src/particlesystem/spriteParticleRenderer.I b/panda/src/particlesystem/spriteParticleRenderer.I index 1f1d4e488b..ccdaa9977b 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.I +++ b/panda/src/particlesystem/spriteParticleRenderer.I @@ -21,7 +21,7 @@ */ INLINE void SpriteParticleRenderer:: set_texture(Texture *tex, PN_stdfloat texels_per_unit) { - if (tex != (Texture *)NULL) { + if (tex != nullptr) { // Clear all texture information _anims.clear(); @@ -46,8 +46,8 @@ add_texture(Texture *tex, PN_stdfloat texels_per_unit, bool resize) { if (_anims.size() == 0) { set_texture(tex, texels_per_unit); } else { - if(tex != (Texture *)NULL) { - if (tex != (Texture *)NULL) { + if(tex != nullptr) { + if (tex != nullptr) { _anims.push_back(new SpriteAnim(tex,LTexCoord(0.0f, 0.0f),LTexCoord(1.0f, 1.0f))); } if(resize) { @@ -269,9 +269,9 @@ get_texture() const { INLINE Texture *SpriteParticleRenderer:: get_texture(const int anim, const int frame) const { if(_anims.size() == 0) { - return (Texture*)NULL; + return nullptr; } - nassertr(anim < (int)_anims.size() && anim >= 0, (Texture*)NULL); + nassertr(anim < (int)_anims.size() && anim >= 0, nullptr); nassertr(frame < (int)_anims[anim]->get_num_frames() && frame >= 0,_anims[anim]->get_frame(0)); return _anims[anim]->get_frame(frame); } @@ -283,7 +283,7 @@ get_num_anims() const { INLINE SpriteAnim *SpriteParticleRenderer:: get_anim(const int n) const { - nassertr(n < (int)_anims.size(), (SpriteAnim*)NULL); + nassertr(n < (int)_anims.size(), nullptr); return _anims[n]; } @@ -292,7 +292,7 @@ get_last_anim() const { if (_anims.size()) { return *(_anims.end()-1); } else { - return (SpriteAnim *)NULL; + return nullptr; } } diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index 7c5756bc6f..58cec0e50a 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -272,7 +272,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { // Load the found textures into the renderer. if (extract_textures_from_node(node_path,np_col,tex_col)) { pvector< LTexCoord > ll,ur; - GeomNode *gnode = NULL; + GeomNode *gnode = nullptr; const Geom *geom; const GeomPrimitive *primitive; @@ -479,7 +479,7 @@ init_geoms() { _sprite_writer[i].push_back(SpriteWriter()); state = state->add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _base_y_scale * _height, true)); - if (anim->get_frame(j) != (Texture *)NULL) { + if (anim->get_frame(j) != nullptr) { state = state->add_attrib(TextureAttrib::make(anim->get_frame(j))); state = state->add_attrib(TexGenAttrib::make(TextureStage::get_default(), TexGenAttrib::M_point_sprite)); diff --git a/panda/src/particlesystem/spriteParticleRenderer.h b/panda/src/particlesystem/spriteParticleRenderer.h index 4ab65c02fb..ecb9f579fd 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.h +++ b/panda/src/particlesystem/spriteParticleRenderer.h @@ -153,7 +153,7 @@ private: */ class EXPCL_PANDAPHYSICS SpriteParticleRenderer : public BaseParticleRenderer { PUBLISHED: - explicit SpriteParticleRenderer(Texture *tex = (Texture *) NULL); + explicit SpriteParticleRenderer(Texture *tex = nullptr); SpriteParticleRenderer(const SpriteParticleRenderer ©); virtual ~SpriteParticleRenderer(); diff --git a/panda/src/pgraph/accumulatedAttribs.cxx b/panda/src/pgraph/accumulatedAttribs.cxx index ea35b495ab..f82ec15d03 100644 --- a/panda/src/pgraph/accumulatedAttribs.cxx +++ b/panda/src/pgraph/accumulatedAttribs.cxx @@ -90,35 +90,35 @@ write(ostream &out, int attrib_types, int indent_level) const { _transform->write(out, indent_level); } if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - if (_color == (const RenderAttrib *)NULL) { + if (_color == nullptr) { indent(out, indent_level) << "no color\n"; } else { _color->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (_color_scale == (const RenderAttrib *)NULL) { + if (_color_scale == nullptr) { indent(out, indent_level) << "no color scale\n"; } else { _color_scale->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { - if (_tex_matrix == (const RenderAttrib *)NULL) { + if (_tex_matrix == nullptr) { indent(out, indent_level) << "no tex matrix\n"; } else { _tex_matrix->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) { - if (_clip_plane == (const RenderAttrib *)NULL) { + if (_clip_plane == nullptr) { indent(out, indent_level) << "no clip plane\n"; } else { _clip_plane->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { - if (_cull_face == (const RenderAttrib *)NULL) { + if (_cull_face == nullptr) { indent(out, indent_level) << "no cull face\n"; } else { _cull_face->write(out, indent_level); @@ -137,7 +137,7 @@ void AccumulatedAttribs:: collect(PandaNode *node, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { // Collect the node's transform. - nassertv(_transform != (TransformState *)NULL); + nassertv(_transform != nullptr); _transform = _transform->compose(node->get_transform()); node->set_transform(TransformState::make_identity()); node->set_prev_transform(TransformState::make_identity()); @@ -158,12 +158,12 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_color) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(ColorAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int color_override = new_state->get_override(ColorAttrib::get_class_slot()); if (color_override >= _color_override || - _color == (const RenderAttrib *)NULL) { + _color == nullptr) { // The node has a color attribute; apply it. - if (_color == (const RenderAttrib *)NULL) { + if (_color == nullptr) { _color = node_attrib; } else { _color = _color->compose(node_attrib); @@ -177,11 +177,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int color_scale_override = new_state->get_override(ColorScaleAttrib::get_class_slot()); if (color_scale_override >= _color_scale_override || - _color_scale == (const RenderAttrib *)NULL) { - if (_color_scale == (const RenderAttrib *)NULL) { + _color_scale == nullptr) { + if (_color_scale == nullptr) { _color_scale = node_attrib; } else { _color_scale = _color_scale->compose(node_attrib); @@ -195,11 +195,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int tex_matrix_override = new_state->get_override(TexMatrixAttrib::get_class_slot()); if (tex_matrix_override >= _tex_matrix_override || - _tex_matrix == (const RenderAttrib *)NULL) { - if (_tex_matrix == (const RenderAttrib *)NULL) { + _tex_matrix == nullptr) { + if (_tex_matrix == nullptr) { _tex_matrix = node_attrib; } else { _tex_matrix = _tex_matrix->compose(node_attrib); @@ -213,11 +213,11 @@ collect(const RenderState *state, int attrib_types) { // texture matrix. const RenderAttrib *tex_attrib = new_state->get_attrib(TextureAttrib::get_class_slot()); - if (tex_attrib != (const RenderAttrib *)NULL) { + if (tex_attrib != nullptr) { int texture_override = new_state->get_override(TextureAttrib::get_class_slot()); if (texture_override >= _texture_override || - _texture == (const RenderAttrib *)NULL) { - if (_texture == (const RenderAttrib *)NULL) { + _texture == nullptr) { + if (_texture == nullptr) { _texture = tex_attrib; } else { _texture = _texture->compose(tex_attrib); @@ -234,11 +234,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int clip_plane_override = new_state->get_override(ClipPlaneAttrib::get_class_slot()); if (clip_plane_override >= _clip_plane_override || - _clip_plane == (const RenderAttrib *)NULL) { - if (_clip_plane == (const RenderAttrib *)NULL) { + _clip_plane == nullptr) { + if (_clip_plane == nullptr) { _clip_plane = node_attrib; } else { _clip_plane = _clip_plane->compose(node_attrib); @@ -252,11 +252,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(CullFaceAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int cull_face_override = new_state->get_override(CullFaceAttrib::get_class_slot()); if (cull_face_override >= _cull_face_override || - _cull_face == (const RenderAttrib *)NULL) { - if (_cull_face == (const RenderAttrib *)NULL) { + _cull_face == nullptr) { + if (_cull_face == nullptr) { _cull_face = node_attrib; } else { _cull_face = _cull_face->compose(node_attrib); @@ -269,7 +269,7 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_other) != 0) { // Collect everything else. - nassertr(_other != (RenderState *)NULL, new_state); + nassertr(_other != nullptr, new_state); _other = _other->compose(new_state); new_state = RenderState::make_empty(); } @@ -291,67 +291,67 @@ apply_to_node(PandaNode *node, int attrib_types) { } if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - if (_color != (RenderAttrib *)NULL) { + if (_color != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(ColorAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_color->compose(node_attrib)->get_unique()); } else { node->set_attrib(_color->get_unique()); } - _color = (RenderAttrib *)NULL; + _color = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (_color_scale != (RenderAttrib *)NULL) { + if (_color_scale != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(ColorScaleAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_color_scale->compose(node_attrib)->get_unique()); } else { node->set_attrib(_color_scale->get_unique()); } - _color_scale = (RenderAttrib *)NULL; + _color_scale = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { - if (_tex_matrix != (RenderAttrib *)NULL) { + if (_tex_matrix != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(TexMatrixAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_tex_matrix->compose(node_attrib)->get_unique()); } else { node->set_attrib(_tex_matrix->get_unique()); } - _tex_matrix = (RenderAttrib *)NULL; + _tex_matrix = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) { - if (_clip_plane != (RenderAttrib *)NULL) { + if (_clip_plane != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_clip_plane->compose(node_attrib)->get_unique()); } else { node->set_attrib(_clip_plane->get_unique()); } - _clip_plane = (RenderAttrib *)NULL; + _clip_plane = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { - if (_cull_face != (RenderAttrib *)NULL) { + if (_cull_face != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(CullFaceAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_cull_face->compose(node_attrib)->get_unique()); } else { node->set_attrib(_cull_face->get_unique()); } - _cull_face = (RenderAttrib *)NULL; + _cull_face = nullptr; } } diff --git a/panda/src/pgraph/attribNodeRegistry.I b/panda/src/pgraph/attribNodeRegistry.I index 30e66ca84c..b78c9bd78e 100644 --- a/panda/src/pgraph/attribNodeRegistry.I +++ b/panda/src/pgraph/attribNodeRegistry.I @@ -16,7 +16,7 @@ */ INLINE AttribNodeRegistry *AttribNodeRegistry:: get_global_ptr() { - if (_global_ptr == (AttribNodeRegistry *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/panda/src/pgraph/attribNodeRegistry.cxx b/panda/src/pgraph/attribNodeRegistry.cxx index 0d540c19d2..995fe2b63c 100644 --- a/panda/src/pgraph/attribNodeRegistry.cxx +++ b/panda/src/pgraph/attribNodeRegistry.cxx @@ -229,10 +229,10 @@ void AttribNodeRegistry:: make_global_ptr() { AttribNodeRegistry *ptr = new AttribNodeRegistry; void *result = AtomicAdjust::compare_and_exchange_ptr - ((void * TVOLATILE &)_global_ptr, (void *)NULL, (void *)ptr); - if (result != NULL) { + ((void * TVOLATILE &)_global_ptr, nullptr, (void *)ptr); + if (result != nullptr) { // Someone else got there first. delete ptr; } - assert(_global_ptr != (AttribNodeRegistry *)NULL); + assert(_global_ptr != nullptr); } diff --git a/panda/src/pgraph/audioVolumeAttrib.cxx b/panda/src/pgraph/audioVolumeAttrib.cxx index 1f545cef8e..52d12156d0 100644 --- a/panda/src/pgraph/audioVolumeAttrib.cxx +++ b/panda/src/pgraph/audioVolumeAttrib.cxx @@ -43,7 +43,7 @@ CPT(RenderAttrib) AudioVolumeAttrib:: make_identity() { // We make identity a special case and store a pointer forever once we find // it the first time. - if (_identity_attrib == (AudioVolumeAttrib *)NULL) { + if (_identity_attrib == nullptr) { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(false, 1.0f);; _identity_attrib = return_new(attrib); } diff --git a/panda/src/pgraph/auxBitplaneAttrib.cxx b/panda/src/pgraph/auxBitplaneAttrib.cxx index 8f8e2d8a9f..662ae36b19 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.cxx +++ b/panda/src/pgraph/auxBitplaneAttrib.cxx @@ -28,7 +28,7 @@ CPT(RenderAttrib) AuxBitplaneAttrib::_default; */ CPT(RenderAttrib) AuxBitplaneAttrib:: make() { - if (_default == 0) { + if (_default == nullptr) { AuxBitplaneAttrib *attrib = new AuxBitplaneAttrib(0); _default = return_new(attrib); } diff --git a/panda/src/pgraph/bamFile.I b/panda/src/pgraph/bamFile.I index b3305cbe48..70e264358e 100644 --- a/panda/src/pgraph/bamFile.I +++ b/panda/src/pgraph/bamFile.I @@ -17,7 +17,7 @@ */ INLINE bool BamFile:: is_valid_read() const { - return (_reader != (BamReader *)NULL); + return (_reader != nullptr); } @@ -27,5 +27,5 @@ is_valid_read() const { */ INLINE bool BamFile:: is_valid_write() const { - return (_writer != (BamWriter *)NULL); + return (_writer != nullptr); } diff --git a/panda/src/pgraph/bamFile.cxx b/panda/src/pgraph/bamFile.cxx index 871ec94587..fa8ae7f4c0 100644 --- a/panda/src/pgraph/bamFile.cxx +++ b/panda/src/pgraph/bamFile.cxx @@ -29,8 +29,8 @@ */ BamFile:: BamFile() { - _reader = NULL; - _writer = NULL; + _reader = nullptr; + _writer = nullptr; } /** @@ -81,8 +81,8 @@ open_read(istream &in, const string &bam_filename, bool report_errors) { */ TypedWritable *BamFile:: read_object() { - if (_reader == (BamReader *)NULL) { - return NULL; + if (_reader == nullptr) { + return nullptr; } return _reader->read_object(); @@ -94,7 +94,7 @@ read_object() { */ bool BamFile:: is_eof() const { - return _reader != (BamReader *)NULL && _reader->is_eof(); + return _reader != nullptr && _reader->is_eof(); } /** @@ -106,7 +106,7 @@ is_eof() const { */ bool BamFile:: resolve() { - if (_reader == (BamReader *)NULL) { + if (_reader == nullptr) { return false; } @@ -134,7 +134,7 @@ read_node(bool report_errors) { TypedWritable *object = read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's really a cache data file and not a true bam file; @@ -172,7 +172,7 @@ read_node(bool report_errors) { loader_cat.error() << "Unable to resolve Bam file.\n"; } - result = (PandaNode *)NULL; + result = nullptr; } return result; @@ -222,7 +222,7 @@ open_write(ostream &out, const string &bam_filename, bool report_errors) { */ bool BamFile:: write_object(const TypedWritable *object) { - if (_writer == (BamWriter *)NULL) { + if (_writer == nullptr) { return false; } @@ -239,14 +239,14 @@ write_object(const TypedWritable *object) { */ void BamFile:: close() { - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { // resolve(); delete _reader; - _reader = NULL; + _reader = nullptr; } - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { delete _writer; - _writer = NULL; + _writer = nullptr; } _din.close(); _dout.close(); @@ -260,7 +260,7 @@ close() { */ int BamFile:: get_file_major_ver() { - if (_reader == (BamReader *)NULL) { + if (_reader == nullptr) { return _bam_major_ver; } return _reader->get_file_major_ver(); @@ -273,7 +273,7 @@ get_file_major_ver() { */ int BamFile:: get_file_minor_ver() { - if (_reader == (BamReader *)NULL) { + if (_reader == nullptr) { return _bam_minor_ver; } return _reader->get_file_minor_ver(); @@ -285,10 +285,10 @@ get_file_minor_ver() { */ BamFile::BamEndian BamFile:: get_file_endian() const { - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { return _writer->get_file_endian(); } - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { return _reader->get_file_endian(); } @@ -301,10 +301,10 @@ get_file_endian() const { */ bool BamFile:: get_file_stdfloat_double() const { - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { return _writer->get_file_stdfloat_double(); } - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { return _reader->get_file_stdfloat_double(); } diff --git a/panda/src/pgraph/cacheStats.I b/panda/src/pgraph/cacheStats.I index a83e480757..e84ff83878 100644 --- a/panda/src/pgraph/cacheStats.I +++ b/panda/src/pgraph/cacheStats.I @@ -17,7 +17,7 @@ INLINE void CacheStats:: maybe_report(const char *name) { #ifndef NDEBUG - if (_cache_report) { + if (UNLIKELY(_cache_report)) { double now = ClockObject::get_global_clock()->get_real_time(); if (now - _last_reset < _cache_report_interval) { return; diff --git a/panda/src/pgraph/cacheStats.cxx b/panda/src/pgraph/cacheStats.cxx index 88a5498384..e16c14801e 100644 --- a/panda/src/pgraph/cacheStats.cxx +++ b/panda/src/pgraph/cacheStats.cxx @@ -22,10 +22,7 @@ void CacheStats:: init() { #ifndef NDEBUG // Let's not use the clock at static init time. - reset(0.0); - // reset(ClockObject::get_global_clock()->get_real_time()); - _total_cache_size = 0; - _num_states = 0; + //reset(ClockObject::get_global_clock()->get_real_time()); _cache_report = ConfigVariableBool("cache-report", false); _cache_report_interval = ConfigVariableDouble("cache-report-interval", 5.0); diff --git a/panda/src/pgraph/cacheStats.h b/panda/src/pgraph/cacheStats.h index 45fb1e6043..12707c4bf0 100644 --- a/panda/src/pgraph/cacheStats.h +++ b/panda/src/pgraph/cacheStats.h @@ -24,6 +24,7 @@ */ class EXPCL_PANDA_PGRAPH CacheStats { public: + constexpr CacheStats() = default; void init(); void reset(double now); void write(ostream &out, const char *name) const; @@ -38,17 +39,17 @@ public: private: #ifndef NDEBUG - int _cache_hits; - int _cache_misses; - int _cache_adds; - int _cache_new_adds; - int _cache_dels; - int _total_cache_size; - int _num_states; - double _last_reset; + int _cache_hits = 0; + int _cache_misses = 0; + int _cache_adds = 0; + int _cache_new_adds = 0; + int _cache_dels = 0; + int _total_cache_size = 0; + int _num_states = 0; + double _last_reset = 0.0; - bool _cache_report; - double _cache_report_interval; + bool _cache_report = false; + double _cache_report_interval = 0.0; #endif // NDEBUG }; diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx index aabf56eda2..4ab1039d05 100644 --- a/panda/src/pgraph/camera.cxx +++ b/panda/src/pgraph/camera.cxx @@ -153,7 +153,7 @@ get_tag_state(const string &tag_state) const { */ void Camera:: set_aux_scene_data(const NodePath &node_path, AuxSceneData *data) { - if (data == (AuxSceneData *)NULL) { + if (data == nullptr) { clear_aux_scene_data(node_path); } else { _aux_data[node_path] = data; @@ -188,7 +188,7 @@ get_aux_scene_data(const NodePath &node_path) const { return (*ai).second; } - return NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index 726b5472b7..f833d2dd94 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -35,7 +35,7 @@ public: nassertr(!a.is_empty() && !b.is_empty(), a < b); PlaneNode *pa = DCAST(PlaneNode, a.node()); PlaneNode *pb = DCAST(PlaneNode, b.node()); - nassertr(pa != (PlaneNode *)NULL && pb != (PlaneNode *)NULL, a < b); + nassertr(pa != nullptr && pb != nullptr, a < b); return pa->get_priority() > pb->get_priority(); } @@ -340,7 +340,7 @@ CPT(RenderAttrib) ClipPlaneAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new ClipPlaneAttrib); } @@ -355,7 +355,7 @@ CPT(RenderAttrib) ClipPlaneAttrib:: make_all_off() { // We make it a special case and store a pointer to the off attrib forever // once we find it the first time, as an optimization. - if (_all_off_attrib == (RenderAttrib *)NULL) { + if (_all_off_attrib == nullptr) { ClipPlaneAttrib *attrib = new ClipPlaneAttrib; attrib->_off_all_planes = true; _all_off_attrib = return_new(attrib); @@ -487,7 +487,7 @@ filter_to_max(int max_clip_planes) const { CPT(RenderAttrib) ClipPlaneAttrib:: compose_off(const RenderAttrib *other) const { const ClipPlaneAttrib *ta; - DCAST_INTO_R(ta, other, NULL); + DCAST_INTO_R(ta, other, nullptr); if (_off_all_planes || (!ta->_off_all_planes && ta->_off_planes.empty())) { // If we turn off all planes, or the other turns none off, the result is @@ -505,8 +505,8 @@ compose_off(const RenderAttrib *other) const { // Create a new ClipPlaneAttrib that will hold the result. ClipPlaneAttrib *new_attrib = new ClipPlaneAttrib; - back_insert_iterator result = - back_inserter(new_attrib->_on_planes); + std::back_insert_iterator result = + std::back_inserter(new_attrib->_on_planes); while (ai != _off_planes.end() && bi != ta->_off_planes.end()) { @@ -701,7 +701,7 @@ get_hash_impl() const { CPT(RenderAttrib) ClipPlaneAttrib:: compose_impl(const RenderAttrib *other) const { const ClipPlaneAttrib *ta; - DCAST_INTO_R(ta, other, NULL); + DCAST_INTO_R(ta, other, nullptr); if (ta->_off_all_planes) { // If the other type turns off all planes, it doesn't matter what we are. @@ -717,8 +717,8 @@ compose_impl(const RenderAttrib *other) const { // Create a new ClipPlaneAttrib that will hold the result. ClipPlaneAttrib *new_attrib = new ClipPlaneAttrib; - back_insert_iterator result = - back_inserter(new_attrib->_on_planes); + std::back_insert_iterator result = + std::back_inserter(new_attrib->_on_planes); while (ai != _on_planes.end() && bi != ta->_on_planes.end() && @@ -912,7 +912,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } else { BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "planes"); - nassertr(aux != NULL, pi); + nassertr(aux != nullptr, pi); int i; aux->_off_list.reserve(aux->_num_off_planes); @@ -964,7 +964,7 @@ finalize(BamReader *manager) { } else { // Now it's safe to convert our saved PandaNodes into NodePaths. BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "planes"); - nassertv(aux != NULL); + nassertv(aux != nullptr); nassertv(aux->_num_off_planes == (int)aux->_off_list.size()); nassertv(aux->_num_on_planes == (int)aux->_on_list.size()); diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index 42e7c5578d..5af6ace015 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -30,7 +30,7 @@ CPT(RenderAttrib) ColorAttrib::_vertex; */ CPT(RenderAttrib) ColorAttrib:: make_vertex() { - if (_vertex != 0) { + if (_vertex != nullptr) { return _vertex; } ColorAttrib *attrib = new ColorAttrib(T_vertex, LColor::zero()); @@ -54,7 +54,7 @@ make_flat(const LColor &color) { */ CPT(RenderAttrib) ColorAttrib:: make_off() { - if (_off != 0) { + if (_off != nullptr) { return _off; } ColorAttrib *attrib = new ColorAttrib(T_off, LColor(1.0f, 1.0f, 1.0f, 1.0f)); diff --git a/panda/src/pgraph/colorScaleAttrib.cxx b/panda/src/pgraph/colorScaleAttrib.cxx index 79394a51f1..572f3e0e14 100644 --- a/panda/src/pgraph/colorScaleAttrib.cxx +++ b/panda/src/pgraph/colorScaleAttrib.cxx @@ -45,7 +45,7 @@ CPT(RenderAttrib) ColorScaleAttrib:: make_identity() { // We make identity a special case and store a pointer forever once we find // it the first time. - if (_identity_attrib == (ColorScaleAttrib *)NULL) { + if (_identity_attrib == nullptr) { ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f));; _identity_attrib = return_new(attrib); } diff --git a/panda/src/pgraph/cullBin.cxx b/panda/src/pgraph/cullBin.cxx index 4d5cea887a..1c73c952b6 100644 --- a/panda/src/pgraph/cullBin.cxx +++ b/panda/src/pgraph/cullBin.cxx @@ -41,7 +41,7 @@ CullBin:: */ PT(CullBin) CullBin:: make_next() const { - return (CullBin *)NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/cullBinManager.I b/panda/src/pgraph/cullBinManager.I index 7bafdea5d6..603622ba2f 100644 --- a/panda/src/pgraph/cullBinManager.I +++ b/panda/src/pgraph/cullBinManager.I @@ -279,7 +279,7 @@ set_bin_flash_color(int bin_index, const LColor &color) { */ INLINE CullBinManager *CullBinManager:: get_global_ptr() { - if (_global_ptr == (CullBinManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new CullBinManager; } return _global_ptr; diff --git a/panda/src/pgraph/cullBinManager.cxx b/panda/src/pgraph/cullBinManager.cxx index 0d979cf7e7..56aed8c730 100644 --- a/panda/src/pgraph/cullBinManager.cxx +++ b/panda/src/pgraph/cullBinManager.cxx @@ -18,7 +18,7 @@ #include "string_utils.h" #include "configVariableColor.h" -CullBinManager *CullBinManager::_global_ptr = (CullBinManager *)NULL; +CullBinManager *CullBinManager::_global_ptr = nullptr; /** * The constructor is not intended to be called directly; there is only one @@ -185,8 +185,8 @@ write(ostream &out) const { PT(CullBin) CullBinManager:: make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { - nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), NULL); - nassertr(_bin_definitions[bin_index]._in_use, NULL); + nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), nullptr); + nassertr(_bin_definitions[bin_index]._in_use, nullptr); string name = get_bin_name(bin_index); BinType type = _bin_definitions[bin_index]._type; @@ -197,8 +197,8 @@ make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, } // Hmm, unknown (or unregistered) bin type. - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index 43a249403b..fcb7a0c532 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -24,7 +24,7 @@ CPT(CullPlanes) CullPlanes:: make_empty() { static CPT(CullPlanes) empty; - if (empty == NULL) { + if (empty == nullptr) { empty = new CullPlanes; // Artificially tick the reference count, just to ensure we won't // accidentally modify this object in any of the copy-on-write operations @@ -81,7 +81,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, const ClipPlaneAttrib *net_attrib, const ClipPlaneAttrib *off_attrib, const OccluderEffect *node_effect) const { - if (net_attrib == (ClipPlaneAttrib *)NULL && node_effect == (OccluderEffect *)NULL) { + if (net_attrib == nullptr && node_effect == nullptr) { return this; } @@ -92,9 +92,9 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, new_planes = new CullPlanes(*this); } - CPT(TransformState) net_transform = NULL; + CPT(TransformState) net_transform = nullptr; - if (net_attrib != (ClipPlaneAttrib *)NULL) { + if (net_attrib != nullptr) { int num_on_planes = net_attrib->get_num_on_planes(); for (int i = 0; i < num_on_planes; ++i) { NodePath clip_plane = net_attrib->get_on_plane(i); @@ -103,7 +103,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, if (!off_attrib->has_off_plane(clip_plane)) { // Here's a new clip plane; add it to the list. For this we need // the net transform to this node. - if (net_transform == (TransformState *)NULL) { + if (net_transform == nullptr) { net_transform = data->get_net_transform(trav); } @@ -118,8 +118,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, } } - if (node_effect != (OccluderEffect *)NULL) { - CPT(TransformState) center_transform = NULL; + if (node_effect != nullptr) { + CPT(TransformState) center_transform = nullptr; // We'll need to know the occluder's frustum in cull-center space. SceneSetup *scene = trav->get_scene(); const Lens *lens = scene->get_lens(); @@ -137,8 +137,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, // And the transform from cull-center space into the current node's // coordinate space. - if (center_transform == (TransformState *)NULL) { - if (net_transform == (TransformState *)NULL) { + if (center_transform == nullptr) { + if (net_transform == nullptr) { net_transform = data->get_net_transform(trav); } @@ -177,7 +177,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, occluder_gbv = new BoundingBox(ccp_min, ccp_max); - if (data->_view_frustum != (GeometricBoundingVolume *)NULL) { + if (data->_view_frustum != nullptr) { int occluder_result = data->_view_frustum->contains(occluder_gbv); if (occluder_result == BoundingVolume::IF_no_intersection) { // This occluder is outside the view frustum; ignore it. @@ -289,7 +289,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, if (show_occluder_volumes) { // Draw the frustum for visualization. - nassertr(net_transform != NULL, new_planes); + nassertr(net_transform != nullptr, new_planes); trav->draw_bounding_volume(frustum, data->get_internal_transform(trav)); } } diff --git a/panda/src/pgraph/cullResult.I b/panda/src/pgraph/cullResult.I index 92b60a88b4..303a06dfd8 100644 --- a/panda/src/pgraph/cullResult.I +++ b/panda/src/pgraph/cullResult.I @@ -26,7 +26,7 @@ INLINE CullResult:: INLINE CullBin *CullResult:: get_bin(int bin_index) { if (bin_index >= 0 && bin_index < (int)_bins.size() && - _bins[bin_index] != (CullBin *)NULL) { + _bins[bin_index] != nullptr) { return _bins[bin_index]; } return make_new_bin(bin_index); diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 7dbe002c9e..8f3e8dc19a 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -83,9 +83,9 @@ make_next() const { for (size_t i = 0; i < _bins.size(); ++i) { CullBin *old_bin = _bins[i]; - if (old_bin == (CullBin *)NULL || + if (old_bin == nullptr || old_bin->get_bin_type() != bin_manager->get_bin_type(i)) { - new_result->_bins.push_back((CullBin *)NULL); + new_result->_bins.push_back(nullptr); } else { new_result->_bins.push_back(old_bin->make_next()); } @@ -140,7 +140,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { traverser, force)) { int wireframe_bin_index = bin_manager->find_bin("fixed"); CullBin *bin = get_bin(wireframe_bin_index); - nassertv(bin != (CullBin *)NULL); + nassertv(bin != nullptr); check_flash_bin(wireframe_part->_state, bin_manager, wireframe_bin_index); bin->add_object(wireframe_part, current_thread); } else { @@ -211,7 +211,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { traverser, force)) { int transparent_bin_index = transparent_part->_state->get_bin_index(); CullBin *bin = get_bin(transparent_bin_index); - nassertv(bin != (CullBin *)NULL); + nassertv(bin != nullptr); check_flash_bin(transparent_part->_state, bin_manager, transparent_bin_index); bin->add_object(transparent_part, current_thread); } else { @@ -241,7 +241,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { int bin_index = object->_state->get_bin_index(); CullBin *bin = get_bin(bin_index); - nassertv(bin != (CullBin *)NULL); + nassertv(bin != nullptr); check_flash_bin(object->_state, bin_manager, bin_index); // Munge vertices as needed for the GSG's requirements, and the object's @@ -269,11 +269,11 @@ finish_cull(SceneSetup *scene_setup, Thread *current_thread) { if (!bin_manager->get_bin_active(i)) { // If the bin isn't active, don't sort it, and don't draw it. In fact, // clear it. - _bins[i] = NULL; + _bins[i] = nullptr; } else { CullBin *bin = _bins[i]; - if (bin != (CullBin *)NULL) { + if (bin != nullptr) { bin->finish_cull(scene_setup, current_thread); } } @@ -294,7 +294,7 @@ draw(Thread *current_thread) { int bin_index = bin_manager->get_bin(i); nassertv(bin_index >= 0); - if (bin_index < (int)_bins.size() && _bins[bin_index] != (CullBin *)NULL) { + if (bin_index < (int)_bins.size() && _bins[bin_index] != nullptr) { _bins[bin_index]->draw(force, current_thread); } } @@ -319,9 +319,9 @@ make_result_graph() { int num_bins = bin_manager->get_num_bins(); for (int i = 0; i < num_bins; i++) { int bin_index = bin_manager->get_bin(i); - nassertr(bin_index >= 0, NULL); + nassertr(bin_index >= 0, nullptr); - if (bin_index < (int)_bins.size() && _bins[bin_index] != (CullBin *)NULL) { + if (bin_index < (int)_bins.size() && _bins[bin_index] != nullptr) { root_node->add_child(_bins[bin_index]->make_result_graph()); } } @@ -351,12 +351,12 @@ make_new_bin(int bin_index) { _draw_region_pcollector); CullBin *bin_ptr = bin.p(); - if (bin_ptr != (CullBin *)NULL) { + if (bin_ptr != nullptr) { // Now store it in the vector. while (bin_index >= (int)_bins.size()) { - _bins.push_back((CullBin *)NULL); + _bins.push_back(nullptr); } - nassertr(bin_index >= 0 && bin_index < (int)_bins.size(), NULL); + nassertr(bin_index >= 0 && bin_index < (int)_bins.size(), nullptr); // Prevent unnecessary refunref by swapping the PointerTos. swap(_bins[bin_index], bin); @@ -384,8 +384,8 @@ get_rescale_normal_state(RescaleNormalAttrib::Mode mode) { */ const RenderState *CullResult:: get_alpha_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { // We don't monkey with the priority, since we want to allow the user to // override this if he desires. state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater, 0.0f)); @@ -398,8 +398,8 @@ get_alpha_state() { */ const RenderState *CullResult:: get_binary_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, 0.5f), TransparencyAttrib::make(TransparencyAttrib::M_none), RenderState::get_max_priority()); @@ -431,8 +431,8 @@ apply_flash_color(CPT(RenderState) &state, const LColor &flash_color) { */ const RenderState *CullResult:: get_dual_transparent_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { // The alpha test for > 0 prevents us from drawing empty pixels, and hence // filling up the depth buffer with large empty spaces that may obscure // other things. However, this does mean we draw pixels twice where the @@ -448,8 +448,8 @@ get_dual_transparent_state() { if (m_dual_flash) { int cycle = (int)(ClockObject::get_global_clock()->get_frame_time() * bin_color_flash_rate); if ((cycle & 1) == 0) { - static CPT(RenderState) flash_state = NULL; - if (flash_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_state = nullptr; + if (flash_state == nullptr) { flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.8f, 0.2, 0.2, 1.0f)), RenderState::get_max_priority()); @@ -473,8 +473,8 @@ get_dual_transparent_state() { */ const RenderState *CullResult:: get_dual_opaque_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, dual_opaque_level), TransparencyAttrib::make(TransparencyAttrib::M_none), RenderState::get_max_priority()); @@ -484,8 +484,8 @@ get_dual_opaque_state() { if (m_dual_flash) { int cycle = (int)(ClockObject::get_global_clock()->get_frame_time() * bin_color_flash_rate); if ((cycle & 1) == 0) { - static CPT(RenderState) flash_state = NULL; - if (flash_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_state = nullptr; + if (flash_state == nullptr) { flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.2, 0.2, 0.8f, 1.0f)), RenderState::get_max_priority()); flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)), diff --git a/panda/src/pgraph/cullTraverser.I b/panda/src/pgraph/cullTraverser.I index 5da999d673..137d8105b1 100644 --- a/panda/src/pgraph/cullTraverser.I +++ b/panda/src/pgraph/cullTraverser.I @@ -224,7 +224,7 @@ do_traverse(CullTraverserData &data) { const FogAttrib *fog = (const FogAttrib *) node_reader->get_state()->get_attrib(FogAttrib::get_class_slot()); - if (fog != (const FogAttrib *)NULL && fog->get_fog() != (Fog *)NULL) { + if (fog != nullptr && fog->get_fog() != nullptr) { // If we just introduced a FogAttrib here, call adjust_to_camera() // now. This maybe isn't the perfect time to call it, but it's good // enough; and at this time we have all the information we need for diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index 7ed990637b..50726c2ee7 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -47,14 +47,14 @@ TypeHandle CullTraverser::_type_handle; */ CullTraverser:: CullTraverser() : - _gsg(NULL), + _gsg(nullptr), _current_thread(Thread::get_current_thread()) { _camera_mask = DrawMask::all_on(); _has_tag_state_key = false; _initial_state = RenderState::make_empty(); - _cull_handler = (CullHandler *)NULL; - _portal_clipper = (PortalClipper *)NULL; + _cull_handler = nullptr; + _portal_clipper = nullptr; _effective_incomplete_render = true; } @@ -104,14 +104,14 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsg, */ void CullTraverser:: traverse(const NodePath &root) { - nassertv(_cull_handler != (CullHandler *)NULL); - nassertv(_scene_setup != (SceneSetup *)NULL); + nassertv(_cull_handler != nullptr); + nassertv(_scene_setup != nullptr); if (allow_portal_cull) { // This _view_frustum is in cull_center space Erik: obsolete? // PT(GeometricBoundingVolume) vf = _view_frustum; - GeometricBoundingVolume *local_frustum = NULL; + GeometricBoundingVolume *local_frustum = nullptr; PT(BoundingVolume) bv = _scene_setup->get_lens()->make_bounds(); if (bv != nullptr) { local_frustum = bv->as_geometric_bounding_volume(); @@ -229,7 +229,7 @@ draw_bounding_volume(const BoundingVolume *vol, const TransformState *internal_transform) const { PT(Geom) bounds_viz = make_bounds_viz(vol); - if (bounds_viz != (Geom *)NULL) { + if (bounds_viz != nullptr) { _geoms_pcollector.add_level(2); CullableObject *outer_viz = new CullableObject(bounds_viz, get_bounds_outer_viz_state(), @@ -264,7 +264,7 @@ show_bounds(CullTraverserData &data, bool tight) { if (tight) { PT(Geom) bounds_viz = make_tight_bounds_viz(node); - if (bounds_viz != (Geom *)NULL) { + if (bounds_viz != nullptr) { _geoms_pcollector.add_level(1); CullableObject *outer_viz = new CullableObject(move(bounds_viz), get_bounds_outer_viz_state(), @@ -489,8 +489,8 @@ CPT(RenderState) CullTraverser:: get_bounds_outer_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorAttrib::make_flat(LColor(0.3, 1.0f, 0.5f, 1.0f)), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -507,8 +507,8 @@ CPT(RenderState) CullTraverser:: get_bounds_inner_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorAttrib::make_flat(LColor(0.15f, 0.5f, 0.25f, 1.0f)), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -524,8 +524,8 @@ CPT(RenderState) CullTraverser:: get_depth_offset_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (DepthOffsetAttrib::make(1)); } diff --git a/panda/src/pgraph/cullTraverserData.I b/panda/src/pgraph/cullTraverserData.I index e2a9a64c95..c985e3bda9 100644 --- a/panda/src/pgraph/cullTraverserData.I +++ b/panda/src/pgraph/cullTraverserData.I @@ -31,7 +31,7 @@ CullTraverserData(const NodePath &start, _portal_depth(0) { // Only update the bounding volume if we're going to end up needing it. - bool check_bounds = (view_frustum != (GeometricBoundingVolume *)NULL); + bool check_bounds = (view_frustum != nullptr); _node_reader.check_cached(check_bounds); } @@ -55,7 +55,7 @@ CullTraverserData(const CullTraverserData &parent, PandaNode *child) : { // Only update the bounding volume if we're going to end up needing it. bool check_bounds = !_cull_planes->is_empty() || - (_view_frustum != (GeometricBoundingVolume *)NULL); + (_view_frustum != nullptr); _node_reader.check_cached(check_bounds); } @@ -140,7 +140,7 @@ is_in_view(const DrawMask &camera_mask) { return false; } - if (_view_frustum == (GeometricBoundingVolume *)NULL && + if (_view_frustum == nullptr && _cull_planes->is_empty()) { // If the transform is valid, but we don't have a frustum or any clip // planes or occluders, it's always in. diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index 1a8280948f..e0aed703e9 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -76,14 +76,14 @@ apply_transform(const TransformState *node_transform) { if (!node_transform->is_identity()) { _net_transform = _net_transform->compose(node_transform); - if ((_view_frustum != (GeometricBoundingVolume *)NULL) || + if ((_view_frustum != nullptr) || (!_cull_planes->is_empty())) { // We need to move the viewing frustums into the node's coordinate space // by applying the node's inverse transform. if (node_transform->is_singular()) { // But we can't invert a singular transform! Instead of trying, we'll // just give up on frustum culling from this point down. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; _cull_planes = CullPlanes::make_empty(); } else { @@ -92,9 +92,9 @@ apply_transform(const TransformState *node_transform) { // Copy the bounding volumes for the frustums so we can transform // them. - if (_view_frustum != (GeometricBoundingVolume *)NULL) { + if (_view_frustum != nullptr) { _view_frustum = _view_frustum->make_copy()->as_geometric_bounding_volume(); - nassertv(_view_frustum != (GeometricBoundingVolume *)NULL); + nassertv(_view_frustum != nullptr); _view_frustum->xform(inv_transform->get_mat()); } @@ -144,11 +144,11 @@ r_get_node_path() const { */ bool CullTraverserData:: is_in_view_impl() { - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; - if (_view_frustum != (GeometricBoundingVolume *)NULL) { + if (_view_frustum != nullptr) { node_gbv = _node_reader.get_bounds()->as_geometric_bounding_volume(); - nassertr(node_gbv != (const GeometricBoundingVolume *)NULL, false); + nassertr(node_gbv != nullptr, false); int result = _view_frustum->contains(node_gbv); @@ -168,14 +168,14 @@ is_in_view_impl() { // If we have fake view-frustum culling enabled, instead of actually // culling an object we simply force it to be drawn in red wireframe. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; _state = _state->compose(get_fake_view_frustum_cull_state()); #endif } else if ((result & BoundingVolume::IF_all) != 0) { // The node and its descendents are completely enclosed within the // frustum. No need to cull further. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; } else { // The node is partially, but not completely, within the viewing @@ -185,15 +185,15 @@ is_in_view_impl() { // down. But this node has the "final" flag, so the user is claiming // that there is some important reason we should consider everything // visible at this point. So be it. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; } } } if (!_cull_planes->is_empty()) { - if (node_gbv == (const GeometricBoundingVolume *)NULL) { + if (node_gbv == nullptr) { node_gbv = _node_reader.get_bounds()->as_geometric_bounding_volume(); - nassertr(node_gbv != (const GeometricBoundingVolume *)NULL, false); + nassertr(node_gbv != nullptr, false); } // Also cull against the current clip planes. diff --git a/panda/src/pgraph/cullableObject.I b/panda/src/pgraph/cullableObject.I index e5e7229d09..96564a4088 100644 --- a/panda/src/pgraph/cullableObject.I +++ b/panda/src/pgraph/cullableObject.I @@ -70,7 +70,7 @@ operator = (const CullableObject ©) { */ INLINE void CullableObject:: draw(GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { - if (_draw_callback != (CallbackObject *)NULL) { + if (_draw_callback != nullptr) { // It has a callback associated. gsg->clear_before_callback(); gsg->set_state_and_transform(_state, _internal_transform); @@ -82,7 +82,7 @@ draw(GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { } // Now the callback has taken care of drawing. } else { - nassertv(_geom != (Geom *)NULL); + nassertv(_geom != nullptr); gsg->set_state_and_transform(_state, _internal_transform); draw_inline(gsg, force, current_thread); } diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 8c8b24f1c0..3e6db8453c 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -188,7 +188,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, */ void CullableObject:: output(ostream &out) const { - if (_geom != (Geom *)NULL) { + if (_geom != nullptr) { out << *_geom; } else { out << "(null)"; @@ -243,7 +243,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { bool sprite_texcoord = false; const TexGenAttrib *tex_gen = DCAST(TexGenAttrib, _state->get_attrib(TexGenAttrib::get_class_slot())); - if (tex_gen != (TexGenAttrib *)NULL) { + if (tex_gen != nullptr) { if (tex_gen->get_mode(TextureStage::get_default()) == TexGenAttrib::M_point_sprite) { sprite_texcoord = true; @@ -255,7 +255,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { PN_stdfloat point_size = 1; bool perspective = false; const RenderModeAttrib *render_mode = DCAST(RenderModeAttrib, _state->get_attrib(RenderModeAttrib::get_class_slot())); - if (render_mode != (RenderModeAttrib *)NULL) { + if (render_mode != nullptr) { point_size = render_mode->get_thickness(); perspective = render_mode->get_perspective(); @@ -491,7 +491,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { // Determine the format we should use to store the indices. Don't choose // NT_uint8, as Direct3D 9 doesn't support it. - const GeomVertexArrayFormat *new_prim_format = NULL; + const GeomVertexArrayFormat *new_prim_format = nullptr; if (new_verts < 0xffff) { new_prim_format = GeomPrimitive::get_index_format(GeomEnums::NT_uint16); @@ -545,7 +545,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { // Now sort the points in order from back-to-front so they will render // properly with transparency, at least with each other. - sort(vertices, vertices_end, SortPoints(points)); + std::sort(vertices, vertices_end, SortPoints(points)); // Go through the points, now in sorted order, and generate a pair of // triangles for each one. We generate indexed triangles instead of @@ -575,7 +575,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { int min_vi = primitive->get_min_vertex(); int max_vi = primitive->get_max_vertex(); - new_primitive->set_minmax(min_vi * 4, max_vi * 4 + 3, NULL, NULL); + new_primitive->set_minmax(min_vi * 4, max_vi * 4 + 3, nullptr, nullptr); new_geom->add_primitive(new_primitive); } @@ -598,8 +598,8 @@ get_flash_cpu_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) flash_cpu_state = (const RenderState *)NULL; - if (flash_cpu_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_cpu_state = nullptr; + if (flash_cpu_state == nullptr) { flash_cpu_state = RenderState::make (LightAttrib::make_all_off(), TextureAttrib::make_off(), @@ -619,8 +619,8 @@ get_flash_hardware_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) flash_hardware_state = (const RenderState *)NULL; - if (flash_hardware_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_hardware_state = nullptr; + if (flash_hardware_state == nullptr) { flash_hardware_state = RenderState::make (LightAttrib::make_all_off(), TextureAttrib::make_off(), diff --git a/panda/src/pgraph/depthOffsetAttrib.cxx b/panda/src/pgraph/depthOffsetAttrib.cxx index ed6f942b1c..a04e72bffb 100644 --- a/panda/src/pgraph/depthOffsetAttrib.cxx +++ b/panda/src/pgraph/depthOffsetAttrib.cxx @@ -41,8 +41,8 @@ make(int offset) { */ CPT(RenderAttrib) DepthOffsetAttrib:: make(int offset, PN_stdfloat min_value, PN_stdfloat max_value) { - nassertr(min_value >= 0.0f && min_value <= 1.0f, NULL); - nassertr(max_value >= 0.0f && max_value <= 1.0f, NULL); + nassertr(min_value >= 0.0f && min_value <= 1.0f, nullptr); + nassertr(max_value >= 0.0f && max_value <= 1.0f, nullptr); DepthOffsetAttrib *attrib = new DepthOffsetAttrib(offset, min_value, max_value); return return_new(attrib); } diff --git a/panda/src/pgraph/findApproxLevelEntry.I b/panda/src/pgraph/findApproxLevelEntry.I index 6404f93be4..9a9fb61a49 100644 --- a/panda/src/pgraph/findApproxLevelEntry.I +++ b/panda/src/pgraph/findApproxLevelEntry.I @@ -20,7 +20,7 @@ FindApproxLevelEntry(const WorkingNodePath &node_path, FindApproxPath &approx_pa _approx_path(approx_path) { _i = 0; - _next = NULL; + _next = nullptr; nassertv(_node_path.is_valid()); } @@ -50,7 +50,7 @@ FindApproxLevelEntry(const FindApproxLevelEntry ©) : _i(copy._i), _approx_path(copy._approx_path) { - _next = NULL; + _next = nullptr; nassertv(_node_path.is_valid()); } diff --git a/panda/src/pgraph/findApproxLevelEntry.cxx b/panda/src/pgraph/findApproxLevelEntry.cxx index 2b5679e271..2ea72cd889 100644 --- a/panda/src/pgraph/findApproxLevelEntry.cxx +++ b/panda/src/pgraph/findApproxLevelEntry.cxx @@ -40,7 +40,7 @@ output(ostream &out) const { void FindApproxLevelEntry:: write_level(ostream &out, int indent_level) const { for (const FindApproxLevelEntry *entry = this; - entry != (const FindApproxLevelEntry *)NULL; + entry != nullptr; entry = entry->_next) { indent(out, indent_level); out << *entry << "\n"; @@ -92,7 +92,7 @@ consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, } PandaNode *this_node = _node_path.node(); - nassertr(this_node != (PandaNode *)NULL, false); + nassertr(this_node != nullptr, false); bool stashed_only = next_is_stashed(increment); diff --git a/panda/src/pgraph/fog.cxx b/panda/src/pgraph/fog.cxx index 06c831f337..654c6fd613 100644 --- a/panda/src/pgraph/fog.cxx +++ b/panda/src/pgraph/fog.cxx @@ -136,7 +136,6 @@ void Fog:: adjust_to_camera(const TransformState *camera_transform) { LVector3 forward = LVector3::forward(); - LPoint3 onset_point, opaque_point; if (get_num_parents() != 0) { // Linear fog is relative to the fog's net transform in the scene graph. NodePath this_np(this); diff --git a/panda/src/pgraph/fogAttrib.I b/panda/src/pgraph/fogAttrib.I index e19a72a376..863d5c153a 100644 --- a/panda/src/pgraph/fogAttrib.I +++ b/panda/src/pgraph/fogAttrib.I @@ -24,7 +24,7 @@ FogAttrib() { */ INLINE bool FogAttrib:: is_off() const { - return _fog == (const Fog *)NULL; + return _fog == nullptr; } /** diff --git a/panda/src/pgraph/fogAttrib.cxx b/panda/src/pgraph/fogAttrib.cxx index 87e12086d4..17016cd7b0 100644 --- a/panda/src/pgraph/fogAttrib.cxx +++ b/panda/src/pgraph/fogAttrib.cxx @@ -128,7 +128,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); TypedWritable *fog = p_list[pi++]; - if (fog != (TypedWritable *)NULL) { + if (fog != nullptr) { _fog = DCAST(Fog, fog); } diff --git a/panda/src/pgraph/geomNode.I b/panda/src/pgraph/geomNode.I index 7766631662..91c197d1d3 100644 --- a/panda/src/pgraph/geomNode.I +++ b/panda/src/pgraph/geomNode.I @@ -48,7 +48,7 @@ INLINE CPT(Geom) GeomNode:: get_geom(int n) const { CDReader cdata(_cycler); CPT(GeomList) geoms = cdata->get_geoms(); - nassertr(n >= 0 && n < (int)geoms->size(), NULL); + nassertr(n >= 0 && n < (int)geoms->size(), nullptr); return (*geoms)[n]._geom.get_read_pointer(); } @@ -68,7 +68,7 @@ INLINE PT(Geom) GeomNode:: modify_geom(int n) { CDWriter cdata(_cycler, true); PT(GeomList) geoms = cdata->modify_geoms(); - nassertr(n >= 0 && n < (int)geoms->size(), NULL); + nassertr(n >= 0 && n < (int)geoms->size(), nullptr); mark_internal_bounds_stale(); return (*geoms)[n]._geom.get_write_pointer(); } @@ -83,7 +83,7 @@ INLINE const RenderState *GeomNode:: get_geom_state(int n) const { CDReader cdata(_cycler); CPT(GeomList) geoms = cdata->get_geoms(); - nassertr(n >= 0 && n < (int)geoms->size(), NULL); + nassertr(n >= 0 && n < (int)geoms->size(), nullptr); return (*geoms)[n]._state; } @@ -287,8 +287,8 @@ get_num_geoms() const { */ INLINE CPT(Geom) GeomNode::Geoms:: get_geom(int n) const { - nassertr(!_geoms.is_null(), NULL); - nassertr(n >= 0 && n < (int)_geoms->size(), NULL); + nassertr(!_geoms.is_null(), nullptr); + nassertr(n >= 0 && n < (int)_geoms->size(), nullptr); return (*_geoms)[n]._geom.get_read_pointer(); } @@ -300,7 +300,7 @@ get_geom(int n) const { */ INLINE const RenderState *GeomNode::Geoms:: get_geom_state(int n) const { - nassertr(!_geoms.is_null(), NULL); - nassertr(n >= 0 && n < (int)_geoms->size(), NULL); + nassertr(!_geoms.is_null(), nullptr); + nassertr(n >= 0 && n < (int)_geoms->size(), nullptr); return (*_geoms)[n]._state; } diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index 8c9da5d331..cbbb7bb609 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -134,7 +134,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, if ((attrib_types & SceneGraphReducer::TT_color) != 0) { CPT(RenderAttrib) ra = geom_attribs._color; - if (ra != (const RenderAttrib *)NULL) { + if (ra != nullptr) { int override = geom_attribs._color_override; entry->_state = entry->_state->add_attrib(ra, override); } @@ -155,7 +155,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (geom_attribs._color_scale != (const RenderAttrib *)NULL) { + if (geom_attribs._color_scale != nullptr) { CPT(ColorScaleAttrib) csa = DCAST(ColorScaleAttrib, geom_attribs._color_scale); if (csa->get_scale() != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { @@ -198,7 +198,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { - if (geom_attribs._tex_matrix != (const RenderAttrib *)NULL) { + if (geom_attribs._tex_matrix != nullptr) { // Determine which texture coordinate names are used more than once. // This assumes we have discovered all of the textures that are in // effect on the GeomNode; this may not be true if there is a @@ -206,7 +206,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // started the flatten operation, but caveat programmer. NameCount name_count; - if (geom_attribs._texture != (RenderAttrib *)NULL) { + if (geom_attribs._texture != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, geom_attribs._texture); int num_on_stages = ta->get_num_on_stages(); for (int si = 0; si < num_on_stages; si++) { @@ -254,7 +254,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // applied in the above. if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { - if (geom_attribs._cull_face != (const RenderAttrib *)NULL) { + if (geom_attribs._cull_face != nullptr) { const CullFaceAttrib *cfa = DCAST(CullFaceAttrib, geom_attribs._cull_face); CullFaceAttrib::Mode mode = cfa->get_effective_mode(); switch (mode) { @@ -532,7 +532,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // otherwise the bounding volume of the GeomNode is (probably) the same as // that of the one Geom, and we've already culled against that. if (num_geoms > 1) { - if (data._view_frustum != (GeometricBoundingVolume *)NULL) { + if (data._view_frustum != nullptr) { // Cull the individual Geom against the view frustum. CPT(BoundingVolume) geom_volume = geom->get_bounds(); const GeometricBoundingVolume *geom_gbv = @@ -584,9 +584,9 @@ get_legal_collide_mask() const { */ void GeomNode:: add_geom(Geom *geom, const RenderState *state) { - nassertv(geom != (Geom *)NULL); + nassertv(geom != nullptr); nassertv(geom->check_valid()); - nassertv(state != (RenderState *)NULL); + nassertv(state != nullptr); Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { @@ -635,7 +635,7 @@ add_geoms_from(const GeomNode *other) { */ void GeomNode:: set_geom(int n, Geom *geom) { - nassertv(geom != (Geom *)NULL); + nassertv(geom != nullptr); nassertv(geom->check_valid()); CDWriter cdata(_cycler, true); @@ -1144,7 +1144,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for (int i = 0; i < num_geoms; i++) { manager->read_pointer(scan); manager->read_pointer(scan); - geoms->push_back(GeomEntry(NULL, NULL)); + geoms->push_back(GeomEntry(nullptr, nullptr)); } _geoms = geoms; } diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index 65c1ca6c80..c77fc35e28 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -108,7 +108,7 @@ bool GeomTransformer:: transform_vertices(Geom *geom, const LMatrix4 &mat) { PStatTimer timer(_apply_vertex_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceVertices sv; sv._mat = mat; sv._vertex_data = geom->get_vertex_data(); @@ -175,7 +175,7 @@ transform_texcoords(Geom *geom, const InternalName *from_name, InternalName *to_name, const LMatrix4 &mat) { PStatTimer timer(_apply_texcoord_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceTexCoords st; st._mat = mat; @@ -319,7 +319,7 @@ bool GeomTransformer:: transform_colors(Geom *geom, const LVecBase4 &scale) { PStatTimer timer(_apply_scale_color_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceColors sc; sc._color = scale; @@ -384,10 +384,10 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, bool keep_vertex_color) { PStatTimer timer(_apply_texture_color_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); PT(TexturePeeker) peeker = tex->peek(); - if (peeker == (TexturePeeker *)NULL) { + if (peeker == nullptr) { return false; } @@ -411,7 +411,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, bool got_mat = false; LMatrix4 mat = LMatrix4::ident_mat(); - if (tma != (TexMatrixAttrib *)NULL && tma->has_stage(ts)) { + if (tma != nullptr && tma->has_stage(ts)) { mat = tma->get_mat(ts); got_mat = !mat.almost_equal(LMatrix4::ident_mat()); } @@ -478,7 +478,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, // Check whether it has 2-d or 3-d texture coordinates. bool tex3d = false; const GeomVertexColumn *column = vdata->get_format()->get_column(ts->get_texcoord_name()); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { return false; } if (column->get_num_components() >= 3) { @@ -585,7 +585,7 @@ apply_texture_colors(GeomNode *node, const RenderState *state) { CPT(RenderState) geom_state = state->compose(entry._state); const TextureAttrib *ta = DCAST(TextureAttrib, geom_state->get_attrib(TextureAttrib::get_class_slot())); - if (ta != (TextureAttrib *)NULL) { + if (ta != nullptr) { CPT(TextureAttrib) ta2 = ta->filter_to_max(1); if (ta2->get_num_on_stages() > 0) { TextureStage *ts = ta2->get_on_stage(0); @@ -595,7 +595,7 @@ apply_texture_colors(GeomNode *node, const RenderState *state) { const ColorAttrib *ca = DCAST(ColorAttrib, geom_state->get_attrib(ColorAttrib::get_class_slot())); LColor base_color(1.0f, 1.0f, 1.0f, 1.0f); bool keep_vertex_color = true; - if (ca != (ColorAttrib *)NULL && ca->get_color_type() == ColorAttrib::T_flat) { + if (ca != nullptr && ca->get_color_type() == ColorAttrib::T_flat) { base_color = ca->get_color(); keep_vertex_color = false; } @@ -659,7 +659,7 @@ bool GeomTransformer:: set_format(Geom *geom, const GeomVertexFormat *new_format) { PStatTimer timer(_apply_set_format_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceFormat sf; sf._format = new_format; @@ -819,7 +819,7 @@ make_compatible_state(GeomNode *node) { */ bool GeomTransformer:: reverse_normals(Geom *geom) { - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); CPT(GeomVertexData) orig_data = geom->get_vertex_data(); NewVertexData &new_data = _reversed_normals[orig_data]; if (new_data._vdata.is_null()) { @@ -1047,7 +1047,7 @@ collect_vertex_data(Geom *geom, int collect_bits, bool format_only) { int GeomTransformer:: collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { int num_adjusted = 0; - GeomTransformer *dynamic = NULL; + GeomTransformer *dynamic = nullptr; GeomNode::CDWriter cdata(node->_cycler); GeomNode::GeomList::iterator gi; @@ -1061,7 +1061,7 @@ collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { new_geom->get_vertex_data()->get_usage_hint() < Geom::UH_static) { // This one has some dynamic properties. Collect it independently of // the outside world. - if (dynamic == (GeomTransformer *)NULL) { + if (dynamic == nullptr) { dynamic = new GeomTransformer(*this); } num_adjusted += dynamic->collect_vertex_data(new_geom, collect_bits, format_only); @@ -1071,7 +1071,7 @@ collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { } } - if (dynamic != (GeomTransformer *)NULL) { + if (dynamic != nullptr) { num_adjusted += dynamic->finish_collect(format_only); delete dynamic; } @@ -1222,7 +1222,7 @@ apply_collect_changes() { nassertr(vertex_offset == _num_vertices, 0); - if (_new_btable != (TransformBlendTable *)NULL) { + if (_new_btable != nullptr) { _new_btable->set_rows(_new_btable_rows); _new_data->set_transform_blend_table(_new_btable); } @@ -1258,11 +1258,11 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { // in the vertices. Each of these has a slightly different way to handle // the remapping, because they have slightly different kinds of data. - if (vdata->get_transform_table() != (TransformTable *)NULL || - _new_data->get_transform_table() != (TransformTable *)NULL) { + if (vdata->get_transform_table() != nullptr || + _new_data->get_transform_table() != nullptr) { // The TransformTable. CPT(TransformTable) old_table; - if (vdata->get_transform_table() != (TransformTable *)NULL) { + if (vdata->get_transform_table() != nullptr) { old_table = vdata->get_transform_table(); } else { PT(TransformTable) temp_table = new TransformTable; @@ -1287,7 +1287,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { // modifying the existing one, since a registered TransformTable cannot be // modified. PT(TransformTable) new_table; - if (_new_data->get_transform_table() != (TransformTable *)NULL) { + if (_new_data->get_transform_table() != nullptr) { new_table = new TransformTable(*_new_data->get_transform_table()); } else { new_table = new TransformTable; @@ -1335,7 +1335,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } } - if (vdata->get_transform_blend_table() != (TransformBlendTable *)NULL) { + if (vdata->get_transform_blend_table() != nullptr) { // The TransformBlendTable. This one is the easiest, because we can // modify it directly, and it will uniquify blend objects for us. @@ -1345,7 +1345,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { CPT(TransformBlendTable) old_btable = vdata->get_transform_blend_table(); - if (_new_btable == (TransformBlendTable *)NULL) { + if (_new_btable == nullptr) { _new_btable = new TransformBlendTable; _new_btable->add_blend(TransformBlend()); } @@ -1380,7 +1380,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } } - if (vdata->get_slider_table() != (SliderTable *)NULL) { + if (vdata->get_slider_table() != nullptr) { // The SliderTable. This one requires making a copy, like the // TransformTable (since it can't be modified once registered either), but // at least it uniquifies sliders added to it. Also, it doesn't require @@ -1388,7 +1388,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { // vertices with. const SliderTable *old_sliders = vdata->get_slider_table(); PT(SliderTable) new_sliders; - if (_new_data->get_slider_table() != (SliderTable *)NULL) { + if (_new_data->get_slider_table() != nullptr) { new_sliders = new SliderTable(*_new_data->get_slider_table()); } else { new_sliders = new SliderTable; diff --git a/panda/src/pgraph/internalNameCollection.cxx b/panda/src/pgraph/internalNameCollection.cxx index f1ab629206..93b92e3518 100644 --- a/panda/src/pgraph/internalNameCollection.cxx +++ b/panda/src/pgraph/internalNameCollection.cxx @@ -181,7 +181,7 @@ get_num_names() const { */ const InternalName *InternalNameCollection:: get_name(int index) const { - nassertr(index >= 0 && index < (int)_names.size(), NULL); + nassertr(index >= 0 && index < (int)_names.size(), nullptr); return _names[index]; } @@ -192,7 +192,7 @@ get_name(int index) const { */ const InternalName *InternalNameCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_names.size(), NULL); + nassertr(index >= 0 && index < (int)_names.size(), nullptr); return _names[index]; } diff --git a/panda/src/pgraph/lensNode.I b/panda/src/pgraph/lensNode.I index fd7c67f192..c1bb15afd1 100644 --- a/panda/src/pgraph/lensNode.I +++ b/panda/src/pgraph/lensNode.I @@ -45,12 +45,12 @@ set_lens(Lens *lens) { */ INLINE Lens *LensNode:: get_lens(int index) const { - nassertr(index >= 0 && index < max_lenses, NULL); // Sanity check + nassertr(index >= 0 && index < max_lenses, nullptr); // Sanity check if (index < (int)_lenses.size()) { return _lenses[index]._lens; } - return NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index 4fa15e2aa7..60307c2ce0 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -29,7 +29,7 @@ LensNode:: LensNode(const string &name, Lens *lens) : PandaNode(name) { - if (lens == NULL) { + if (lens == nullptr) { lens = new PerspectiveLens; } set_lens(0, lens); @@ -84,7 +84,7 @@ set_lens(int index, Lens *lens) { _lenses[index]._lens = lens; _lenses[index]._is_active = true; - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { show_frustum(); } } @@ -111,7 +111,7 @@ set_lens_active(int index, bool flag) { _lenses[index]._is_active = flag; - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { show_frustum(); } return true; @@ -124,9 +124,9 @@ set_lens_active(int index, bool flag) { bool LensNode:: is_in_view(int index, const LPoint3 &pos) { Lens *lens = get_lens(index); - nassertr(lens != (Lens *)NULL, false); + nassertr(lens != nullptr, false); PT(BoundingVolume) bv = lens->make_bounds(); - if (bv == (BoundingVolume *)NULL) { + if (bv == nullptr) { return false; } GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bv); @@ -140,7 +140,7 @@ is_in_view(int index, const LPoint3 &pos) { */ void LensNode:: show_frustum() { - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { hide_frustum(); } PT(GeomNode) geom_node = new GeomNode("frustum"); @@ -150,7 +150,7 @@ show_frustum() { for (Lenses::const_iterator li = _lenses.begin(); li != _lenses.end(); ++li) { - if ((*li)._is_active && (*li)._lens != (Lens *)NULL) { + if ((*li)._is_active && (*li)._lens != nullptr) { geom_node->add_geom((*li)._lens->make_geometry()); } } @@ -161,9 +161,9 @@ show_frustum() { */ void LensNode:: hide_frustum() { - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { remove_child(_shown_frustum); - _shown_frustum = (PandaNode *)NULL; + _shown_frustum = nullptr; } } @@ -178,7 +178,7 @@ output(ostream &out) const { for (Lenses::const_iterator li = _lenses.begin(); li != _lenses.end(); ++li) { - if ((*li)._is_active && (*li)._lens != (Lens *)NULL) { + if ((*li)._is_active && (*li)._lens != nullptr) { out << " "; (*li)._lens->output(out); } @@ -196,7 +196,7 @@ write(ostream &out, int indent_level) const { for (Lenses::const_iterator li = _lenses.begin(); li != _lenses.end(); ++li) { - if ((*li)._is_active && (*li)._lens != (Lens *)NULL) { + if ((*li)._is_active && (*li)._lens != nullptr) { (*li)._lens->write(out, indent_level + 2); } } @@ -245,7 +245,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { (*li)._lens = DCAST(Lens, p_list[pi++]); } - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { show_frustum(); } diff --git a/panda/src/pgraph/lensNode.h b/panda/src/pgraph/lensNode.h index da9d9ef5f6..9e1dd9fb00 100644 --- a/panda/src/pgraph/lensNode.h +++ b/panda/src/pgraph/lensNode.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDA_PGRAPH LensNode : public PandaNode { PUBLISHED: - explicit LensNode(const string &name, Lens *lens = NULL); + explicit LensNode(const string &name, Lens *lens = nullptr); protected: LensNode(const LensNode ©); diff --git a/panda/src/pgraph/lightAttrib.cxx b/panda/src/pgraph/lightAttrib.cxx index 40014c53ee..1ad177b1b4 100644 --- a/panda/src/pgraph/lightAttrib.cxx +++ b/panda/src/pgraph/lightAttrib.cxx @@ -38,7 +38,7 @@ public: nassertr(!a.is_empty() && !b.is_empty(), a < b); Light *la = a.node()->as_light(); Light *lb = b.node()->as_light(); - nassertr(la != (Light *)NULL && lb != (Light *)NULL, a < b); + nassertr(la != nullptr && lb != nullptr, a < b); if (la->get_priority() != lb->get_priority()) { return la->get_priority() > lb->get_priority(); @@ -384,7 +384,7 @@ CPT(RenderAttrib) LightAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new LightAttrib); } @@ -399,7 +399,7 @@ CPT(RenderAttrib) LightAttrib:: make_all_off() { // We make it a special case and store a pointer to the off attrib forever // once we find it the first time, as an optimization. - if (_all_off_attrib == (RenderAttrib *)NULL) { + if (_all_off_attrib == nullptr) { LightAttrib *attrib = new LightAttrib; attrib->_off_all_lights = true; _all_off_attrib = return_new(attrib); @@ -475,7 +475,7 @@ add_off_light(const NodePath &light) const { */ CPT(RenderAttrib) LightAttrib:: remove_off_light(const NodePath &light) const { - nassertr(!light.is_empty() && light.node()->as_light() != (Light *)NULL, this); + nassertr(!light.is_empty() && light.node()->as_light() != nullptr, this); LightAttrib *attrib = new LightAttrib(*this); attrib->_off_lights.erase(light); return return_new(attrib); @@ -734,8 +734,8 @@ compose_impl(const RenderAttrib *other) const { // Create a new LightAttrib that will hold the result. LightAttrib *new_attrib = new LightAttrib; - back_insert_iterator result = - back_inserter(new_attrib->_on_lights); + std::back_insert_iterator result = + std::back_inserter(new_attrib->_on_lights); while (ai != _on_lights.end() && bi != ta->_on_lights.end() && @@ -967,7 +967,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } else { BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "lights"); - nassertr(aux != NULL, pi); + nassertr(aux != nullptr, pi); int i; aux->_off_list.reserve(aux->_num_off_lights); @@ -1023,7 +1023,7 @@ finalize(BamReader *manager) { } else { // Now it's safe to convert our saved PandaNodes into NodePaths. BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "lights"); - nassertv(aux != NULL); + nassertv(aux != nullptr); nassertv(aux->_num_off_lights == (int)aux->_off_list.size()); nassertv(aux->_num_on_lights == (int)aux->_on_list.size()); diff --git a/panda/src/pgraph/lightRampAttrib.cxx b/panda/src/pgraph/lightRampAttrib.cxx index 7a7637a35f..93adfc305b 100644 --- a/panda/src/pgraph/lightRampAttrib.cxx +++ b/panda/src/pgraph/lightRampAttrib.cxx @@ -29,7 +29,7 @@ CPT(RenderAttrib) LightRampAttrib::_default; */ CPT(RenderAttrib) LightRampAttrib:: make_default() { - if (_default == 0) { + if (_default == nullptr) { LightRampAttrib *attrib = new LightRampAttrib(); _default = return_new(attrib); } diff --git a/panda/src/pgraph/loader.I b/panda/src/pgraph/loader.I index c86753b3be..eddac45376 100644 --- a/panda/src/pgraph/loader.I +++ b/panda/src/pgraph/loader.I @@ -72,7 +72,7 @@ get_file(int n) const { */ INLINE LoaderFileType *Loader::Results:: get_file_type(int n) const { - nassertr(n >= 0 && n < (int)_files.size(), NULL); + nassertr(n >= 0 && n < (int)_files.size(), nullptr); return _files[n]._type; } @@ -127,7 +127,7 @@ get_task_chain() const { INLINE void Loader:: stop_threads() { PT(AsyncTaskChain) chain = _task_manager->find_task_chain(_task_chain); - if (chain != (AsyncTaskChain *)NULL) { + if (chain != nullptr) { chain->stop_threads(); } } @@ -210,7 +210,7 @@ save_async(AsyncTask *request) { */ INLINE Loader *Loader:: get_global_ptr() { - if (_global_ptr == (Loader *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 7e8c201daf..866f3c2f14 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -46,7 +46,7 @@ Loader(const string &name) : _task_manager = AsyncTaskManager::get_global_ptr(); _task_chain = name; - if (_task_manager->find_task_chain(_task_chain) == NULL) { + if (_task_manager->find_task_chain(_task_chain) == nullptr) { PT(AsyncTaskChain) chain = _task_manager->make_task_chain(_task_chain); ConfigVariableInt loader_num_threads @@ -99,7 +99,7 @@ PT(PandaNode) Loader:: load_bam_stream(istream &in) { BamFile bam_file; if (!bam_file.open_read(in)) { - return NULL; + return nullptr; } return bam_file.read_node(); @@ -159,13 +159,13 @@ load_file(const Filename &filename, const LoaderOptions &options) const { "in your Config.prc to globally assume a particular model " "filename extension.\n"; } - return NULL; + return nullptr; } LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); LoaderFileType *requested_type = reg->get_type_from_extension(extension); - if (requested_type == (LoaderFileType *)NULL) { + if (requested_type == nullptr) { if (report_errors) { loader_cat.error() << "Extension of file " << this_filename @@ -174,21 +174,21 @@ load_file(const Filename &filename, const LoaderOptions &options) const { << "Currently known scene file types are:\n"; reg->write(loader_cat.error(false), 2); } - return NULL; + return nullptr; } else if (!requested_type->supports_load()) { if (report_errors) { loader_cat.error() << requested_type->get_name() << " file type (." << extension << ") does not support loading.\n"; } - return NULL; + return nullptr; } else if (compressed && !requested_type->supports_compressed()) { if (report_errors) { loader_cat.error() << requested_type->get_name() << " file type (." << extension << ") does not support in-line compression.\n"; } - return NULL; + return nullptr; } bool search = (this_options.get_flags() & LoaderOptions::LF_search) != 0; @@ -211,7 +211,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { Filename pathname(model_path.get_directory(i), this_filename); PT(PandaNode) result = try_load_file(pathname, this_options, requested_type); - if (result != (PandaNode *)NULL) { + if (result != nullptr) { return result; } } @@ -243,7 +243,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { // Look for the file only where it is. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(PandaNode) result = try_load_file(this_filename, this_options, requested_type); - if (result != (PandaNode *)NULL) { + if (result != nullptr) { return result; } if (report_errors) { @@ -256,7 +256,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { } } } - return NULL; + return nullptr; } /** @@ -273,7 +273,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, if (allow_ram_cache) { // If we're allowing a RAM cache, use the ModelPool to load the file. PT(PandaNode) node = ModelPool::get_model(pathname, true); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { if ((options.get_flags() & LoaderOptions::LF_allow_instance) == 0) { if (loader_cat.is_debug()) { loader_cat.debug() @@ -292,7 +292,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, if (cache->get_cache_models() && requested_type->get_allow_disk_cache(options)) { // See if the model can be found in the on-disk cache, if it is active. record = cache->lookup(pathname, "bam"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { if (record->has_data()) { if (report_errors) { loader_cat.info() @@ -334,8 +334,8 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, if (!cache_only) { // Load the model from disk. PT(PandaNode) result = requested_type->load_file(pathname, options, record); - if (result != (PandaNode *)NULL) { - if (record != (BamCacheRecord *)NULL) { + if (result != nullptr) { + if (record != nullptr) { // Store the loaded model in the model cache. record->set_data(result); cache->store(record); @@ -359,7 +359,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, } } - return NULL; + return nullptr; } /** @@ -403,7 +403,7 @@ save_file(const Filename &filename, const LoaderOptions &options, LoaderFileType *requested_type = reg->get_type_from_extension(extension); - if (requested_type == (LoaderFileType *)NULL) { + if (requested_type == nullptr) { if (report_errors) { loader_cat.error() << "Extension of file " << this_filename @@ -475,7 +475,7 @@ load_file_types() { loader_cat.info() << "loading file type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { loader_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; @@ -512,7 +512,7 @@ load_file_types() { */ void Loader:: make_global_ptr() { - nassertv(_global_ptr == (Loader *)NULL); + nassertv(_global_ptr == nullptr); _global_ptr = new Loader("loader"); } diff --git a/panda/src/pgraph/loaderFileType.cxx b/panda/src/pgraph/loaderFileType.cxx index 326dce8720..a7189526ed 100644 --- a/panda/src/pgraph/loaderFileType.cxx +++ b/panda/src/pgraph/loaderFileType.cxx @@ -101,7 +101,7 @@ load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { loader_cat.error() << get_type() << " cannot read PandaNode objects.\n"; - return NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/loaderFileTypeBam.cxx b/panda/src/pgraph/loaderFileTypeBam.cxx index 9394c69357..985ffb706a 100644 --- a/panda/src/pgraph/loaderFileTypeBam.cxx +++ b/panda/src/pgraph/loaderFileTypeBam.cxx @@ -80,7 +80,7 @@ supports_save() const { PT(PandaNode) LoaderFileTypeBam:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(path); } @@ -88,13 +88,13 @@ load_file(const Filename &path, const LoaderOptions &options, BamFile bam_file; if (!bam_file.open_read(path, report_errors)) { - return NULL; + return nullptr; } bam_file.get_reader()->set_loader_options(options); time_t timestamp = bam_file.get_reader()->get_source()->get_timestamp(); PT(PandaNode) node = bam_file.read_node(report_errors); - if (node != (PandaNode *)NULL && node->is_of_type(ModelRoot::get_class_type())) { + if (node != nullptr && node->is_of_type(ModelRoot::get_class_type())) { ModelRoot *model_root = DCAST(ModelRoot, node.p()); model_root->set_fullpath(path); model_root->set_timestamp(timestamp); diff --git a/panda/src/pgraph/loaderFileTypeRegistry.cxx b/panda/src/pgraph/loaderFileTypeRegistry.cxx index 8ed3774368..6f5f6fed44 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.cxx +++ b/panda/src/pgraph/loaderFileTypeRegistry.cxx @@ -124,7 +124,7 @@ get_num_types() const { */ LoaderFileType *LoaderFileTypeRegistry:: get_type(int n) const { - nassertr(n >= 0 && n < (int)_types.size(), NULL); + nassertr(n >= 0 && n < (int)_types.size(), nullptr); return _types[n]; } @@ -154,11 +154,11 @@ get_type_from_extension(const string &extension) { loader_cat->info() << "loading file type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { loader_cat->warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; - return NULL; + return nullptr; } else if (loader_cat.is_debug()) { loader_cat.debug() << "done loading file type module: " << name << endl; @@ -172,7 +172,7 @@ get_type_from_extension(const string &extension) { if (ei == _extensions.end()) { // Nothing matches that extension, even after we've checked for a deferred // type description. - return NULL; + return nullptr; } return (*ei).second; @@ -231,7 +231,7 @@ write(ostream &out, int indent_level) const { */ LoaderFileTypeRegistry *LoaderFileTypeRegistry:: get_global_ptr() { - if (_global_ptr == (LoaderFileTypeRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new LoaderFileTypeRegistry; } return _global_ptr; diff --git a/panda/src/pgraph/materialCollection.cxx b/panda/src/pgraph/materialCollection.cxx index 665a924cbc..386758f1c5 100644 --- a/panda/src/pgraph/materialCollection.cxx +++ b/panda/src/pgraph/materialCollection.cxx @@ -181,7 +181,7 @@ find_material(const string &name) const { return material; } } - return NULL; + return nullptr; } /** @@ -197,7 +197,7 @@ get_num_materials() const { */ Material *MaterialCollection:: get_material(int index) const { - nassertr(index >= 0 && index < (int)_materials.size(), NULL); + nassertr(index >= 0 && index < (int)_materials.size(), nullptr); return _materials[index]; } @@ -208,7 +208,7 @@ get_material(int index) const { */ Material *MaterialCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_materials.size(), NULL); + nassertr(index >= 0 && index < (int)_materials.size(), nullptr); return _materials[index]; } diff --git a/panda/src/pgraph/modelPool.I b/panda/src/pgraph/modelPool.I index 26efd0a8c8..f52be7de00 100644 --- a/panda/src/pgraph/modelPool.I +++ b/panda/src/pgraph/modelPool.I @@ -33,7 +33,7 @@ has_model(const Filename &filename) { */ INLINE bool ModelPool:: verify_model(const Filename &filename) { - return load_model(filename) != (ModelRoot *)NULL; + return load_model(filename) != nullptr; } /** diff --git a/panda/src/pgraph/modelPool.cxx b/panda/src/pgraph/modelPool.cxx index 70d7b318c9..b5722f2271 100644 --- a/panda/src/pgraph/modelPool.cxx +++ b/panda/src/pgraph/modelPool.cxx @@ -18,7 +18,7 @@ #include "virtualFileSystem.h" -ModelPool *ModelPool::_global_ptr = (ModelPool *)NULL; +ModelPool *ModelPool::_global_ptr = nullptr; /** * Lists the contents of the model pool to the indicated output stream. Helps @@ -37,7 +37,7 @@ ns_has_model(const Filename &filename) { LightMutexHolder holder(_lock); Models::const_iterator ti; ti = _models.find(filename); - if (ti != _models.end() && (*ti).second != (ModelRoot *)NULL) { + if (ti != _models.end() && (*ti).second != nullptr) { // This model was previously loaded. return true; } @@ -71,7 +71,7 @@ ns_get_model(const Filename &filename, bool verify) { << "ModelPool found " << cached_model << " for " << filename << "\n"; } - if (cached_model == NULL) { + if (cached_model == nullptr) { // This filename was previously attempted, but it did not exist (or the // model could not be loaded for some reason). if (cache_check_timestamps) { @@ -89,7 +89,7 @@ ns_get_model(const Filename &filename, bool verify) { // Compare the timestamp to the file on-disk. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(cached_model->get_fullpath()); - if (vfile == NULL) { + if (vfile == nullptr) { // The file has disappeared! Look further along the model-path. got_cached_model = false; @@ -109,7 +109,7 @@ ns_get_model(const Filename &filename, bool verify) { } return cached_model; } else { - return NULL; + return nullptr; } } @@ -121,7 +121,7 @@ ns_load_model(const Filename &filename, const LoaderOptions &options) { // First check if it has already been loaded and is still current. PT(ModelRoot) cached_model = ns_get_model(filename, true); - if (cached_model != (ModelRoot *)NULL) { + if (cached_model != nullptr) { return cached_model; } @@ -239,7 +239,7 @@ ns_garbage_collect() { Models::iterator ti; for (ti = _models.begin(); ti != _models.end(); ++ti) { ModelRoot *node = (*ti).second; - if (node == (ModelRoot *)NULL || + if (node == nullptr || node->get_model_ref_count() == 1) { if (loader_cat.is_debug()) { loader_cat.debug() @@ -267,7 +267,7 @@ ns_list_contents(ostream &out) const { Models::const_iterator ti; int num_models = 0; for (ti = _models.begin(); ti != _models.end(); ++ti) { - if ((*ti).second != NULL) { + if ((*ti).second != nullptr) { ++num_models; out << (*ti).first << "\n" << " (count = " << (*ti).second->get_model_ref_count() @@ -285,7 +285,7 @@ ns_list_contents(ostream &out) const { */ ModelPool *ModelPool:: get_ptr() { - if (_global_ptr == (ModelPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ModelPool; } return _global_ptr; diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index 8860fff331..641ab1c2b7 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -16,9 +16,9 @@ */ INLINE NodePath:: NodePath() : - _error_type(ET_ok) + _error_type(ET_ok), + _backup_key(0) { - _backup_key = 0; } /** @@ -46,7 +46,7 @@ INLINE NodePath:: NodePath(PandaNode *node, Thread *current_thread) : _error_type(ET_ok) { - if (node != (PandaNode *)NULL) { + if (node != nullptr) { int pipeline_stage = current_thread->get_pipeline_stage(); _head = node->get_generic_component(false, pipeline_stage, current_thread); } @@ -61,7 +61,7 @@ NodePath(PandaNode *node, Thread *current_thread) : INLINE NodePath NodePath:: any_path(PandaNode *node, Thread *current_thread) { NodePath result; - if (node != (PandaNode *)NULL) { + if (node != nullptr) { int pipeline_stage = current_thread->get_pipeline_stage(); result._head = node->get_generic_component(true, pipeline_stage, current_thread); @@ -186,7 +186,7 @@ get_max_search_depth() { */ INLINE bool NodePath:: is_empty() const { - return (_head == (NodePathComponent *)NULL); + return (_head == nullptr); } /** @@ -195,7 +195,7 @@ is_empty() const { INLINE bool NodePath:: is_singleton(Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); - return (_head != (NodePathComponent *)NULL && _head->is_top_node(pipeline_stage, current_thread)); + return (_head != nullptr && _head->is_top_node(pipeline_stage, current_thread)); } /** @@ -214,7 +214,7 @@ get_error_type() const { INLINE PandaNode *NodePath:: get_top_node(Thread *current_thread) const { if (is_empty()) { - return (PandaNode *)NULL; + return nullptr; } return get_top(current_thread).node(); @@ -225,7 +225,7 @@ get_top_node(Thread *current_thread) const { */ INLINE PandaNode *NodePath:: node() const { - nassertr_always(!is_empty(), (PandaNode *)NULL); + nassertr_always(!is_empty(), nullptr); return _head->get_node(); } @@ -283,7 +283,7 @@ is_same_graph(const NodePath &other, Thread *current_thread) const { // different instance of render that appears to have the same top node. But // this is a very rare thing to do. int a_count, b_count; - return (find_common_ancestor(*this, other, a_count, b_count, current_thread) != (NodePathComponent *)NULL); + return (find_common_ancestor(*this, other, a_count, b_count, current_thread) != nullptr); } /** @@ -293,7 +293,7 @@ is_same_graph(const NodePath &other, Thread *current_thread) const { INLINE bool NodePath:: is_ancestor_of(const NodePath &other, Thread *current_thread) const { int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { // Not related. return false; } @@ -312,7 +312,7 @@ INLINE NodePath NodePath:: get_common_ancestor(const NodePath &other, Thread *current_thread) const { int a_count, b_count; NodePathComponent *common = find_common_ancestor(*this, other, a_count, b_count, current_thread); - if (common == (NodePathComponent *)NULL) { + if (common == nullptr) { return NodePath::not_found(); } @@ -457,7 +457,7 @@ set_attrib(const RenderAttrib *attrib, int priority) { */ INLINE const RenderAttrib *NodePath:: get_attrib(TypeHandle type) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); return node()->get_attrib(type); } @@ -498,7 +498,7 @@ set_effect(const RenderEffect *effect) { */ INLINE const RenderEffect *NodePath:: get_effect(TypeHandle type) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); return node()->get_effect(type); } diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index f8d7d6c4b0..065bef7424 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -90,7 +90,7 @@ NodePath(const NodePath &parent, PandaNode *child_node, Thread *current_thread) : _error_type(ET_fail) { - nassertv(child_node != (PandaNode *)NULL); + nassertv(child_node != nullptr); int pipeline_stage = current_thread->get_pipeline_stage(); if (parent.is_empty()) { @@ -102,9 +102,9 @@ NodePath(const NodePath &parent, PandaNode *child_node, _head = PandaNode::get_component(parent._head, child_node, pipeline_stage, current_thread); } - nassertv(_head != (NodePathComponent *)NULL); + nassertv(_head != nullptr); - if (_head != (NodePathComponent *)NULL) { + if (_head != nullptr) { _error_type = ET_ok; } _backup_key = 0; @@ -145,7 +145,7 @@ get_num_nodes(Thread *current_thread) const { */ PandaNode *NodePath:: get_node(int index, Thread *current_thread) const { - nassertr(index >= 0 && index < get_num_nodes(), NULL); + nassertr(index >= 0 && index < get_num_nodes(), nullptr); int pipeline_stage = current_thread->get_pipeline_stage(); @@ -153,14 +153,14 @@ get_node(int index, Thread *current_thread) const { while (index > 0) { // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NULL); + nassertr(comp != nullptr, nullptr); comp = comp->get_next(pipeline_stage, current_thread); index--; } // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NULL); + nassertr(comp != nullptr, nullptr); return comp->get_node(); } @@ -181,14 +181,14 @@ get_ancestor(int index, Thread *current_thread) const { while (index > 0) { // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(comp != nullptr, NodePath::fail()); comp = comp->get_next(pipeline_stage, current_thread); index--; } // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(comp != nullptr, NodePath::fail()); NodePath result; result._head = comp; @@ -210,7 +210,7 @@ get_top(Thread *current_thread) const { NodePathComponent *comp = _head; while (!comp->is_top_node(pipeline_stage, current_thread)) { comp = comp->get_next(pipeline_stage, current_thread); - nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(comp != nullptr, NodePath::fail()); } NodePath top; @@ -284,7 +284,7 @@ get_sort(Thread *current_thread) const { PandaNode *parent = _head->get_next(pipeline_stage, current_thread)->get_node(); PandaNode *child = node(); - nassertr(parent != (PandaNode *)NULL && child != (PandaNode *)NULL, 0); + nassertr(parent != nullptr && child != nullptr, 0); int child_index = parent->find_child(child); if (child_index != -1) { return parent->get_child_sort(child_index); @@ -325,7 +325,7 @@ find(const string &path) const { NodePath NodePath:: find_path_to(PandaNode *node) const { nassertr_always(!is_empty(), fail()); - nassertr(node != (PandaNode *)NULL, fail()); + nassertr(node != nullptr, fail()); NodePathCollection col; FindApproxPath approx_path; @@ -362,7 +362,7 @@ find_all_paths_to(PandaNode *node) const { NodePathCollection col; nassertr_always(!is_empty(), col); nassertr(verify_complete(), col); - nassertr(node != (PandaNode *)NULL, col); + nassertr(node != nullptr, col); FindApproxPath approx_path; approx_path.add_match_many(0); approx_path.add_match_pointer(node, 0); @@ -472,7 +472,7 @@ instance_to(const NodePath &other, int sort, Thread *current_thread) const { // First, we'll attach to NULL, to guarantee we get a brand new instance. int pipeline_stage = current_thread->get_pipeline_stage(); - new_instance._head = PandaNode::attach(NULL, node(), sort, pipeline_stage, + new_instance._head = PandaNode::attach(nullptr, node(), sort, pipeline_stage, current_thread); // Now, we'll reparent the new instance to the target node. @@ -534,7 +534,7 @@ copy_to(const NodePath &other, int sort, Thread *current_thread) const { PandaNode *source_node = node(); PT(PandaNode) copy_node = source_node->copy_subgraph(current_thread); - nassertr(copy_node != (PandaNode *)NULL, fail()); + nassertr(copy_node != nullptr, fail()); copy_node->reset_prev_transform(current_thread); @@ -557,7 +557,7 @@ NodePath NodePath:: attach_new_node(PandaNode *node, int sort, Thread *current_thread) const { nassertr(verify_complete(current_thread), NodePath::fail()); nassertr(_error_type == ET_ok, NodePath::fail()); - nassertr(node != (PandaNode *)NULL, NodePath::fail()); + nassertr(node != nullptr, NodePath::fail()); NodePath new_path(*this); int pipeline_stage = current_thread->get_pipeline_stage(); @@ -666,7 +666,7 @@ output(ostream &out) const { break; } - if (_head == (NodePathComponent *)NULL) { + if (_head == nullptr) { out << "(empty)"; } else { _head->output(out); @@ -705,7 +705,7 @@ get_state(const NodePath &other, Thread *current_thread) const { #endif int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { if (allow_unrelated_wrt) { pgraph_cat.debug() << *this << " is not related to " << other << "\n"; @@ -777,7 +777,7 @@ get_transform(const NodePath &other, Thread *current_thread) const { #endif int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { if (allow_unrelated_wrt) { if (pgraph_cat.is_debug()) { pgraph_cat.debug() @@ -793,10 +793,10 @@ get_transform(const NodePath &other, Thread *current_thread) const { CPT(TransformState) a_transform, b_transform; a_transform = r_get_partial_transform(_head, a_count, current_thread); - if (a_transform != (TransformState *)NULL) { + if (a_transform != nullptr) { b_transform = r_get_partial_transform(other._head, b_count, current_thread); } - if (b_transform == (TransformState *)NULL) { + if (b_transform == nullptr) { // If either path involved a node with a net_transform RenderEffect // applied, we have to go all the way up to the root to get the right // answer. @@ -864,7 +864,7 @@ get_prev_transform(const NodePath &other, Thread *current_thread) const { #endif int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { if (allow_unrelated_wrt) { pgraph_cat.debug() << *this << " is not related to " << other << "\n"; @@ -1998,7 +1998,7 @@ get_color() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(ColorAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attrib); if (ca->get_color_type() == ColorAttrib::T_flat) { return ca->get_color(); @@ -2043,7 +2043,7 @@ compose_color_scale(const LVecBase4 &scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2073,7 +2073,7 @@ set_color_scale(const LVecBase4 &scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2115,7 +2115,7 @@ set_alpha_scale(PN_stdfloat scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2141,7 +2141,7 @@ set_all_color_scale(PN_stdfloat scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2167,7 +2167,7 @@ get_color_scale() const { nassertr_always(!is_empty(), ident_scale); const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); return csa->get_scale(); } @@ -2186,11 +2186,11 @@ set_light(const NodePath &light, int priority) { nassertv_always(!is_empty()); if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { // It's an actual Light object. const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(LightAttrib::get_class_slot())); const LightAttrib *la = DCAST(LightAttrib, attrib); @@ -2216,7 +2216,7 @@ set_light(const NodePath &light, int priority) { const RenderEffect *effect = node()->get_effect(PolylightEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const PolylightEffect *ple = DCAST(PolylightEffect, effect); // Modify the existing PolylightEffect to add the indicated light. @@ -2264,10 +2264,10 @@ set_light_off(const NodePath &light, int priority) { if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(LightAttrib::get_class_slot())); const LightAttrib *la = DCAST(LightAttrib, attrib); @@ -2310,10 +2310,10 @@ clear_light(const NodePath &light) { if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(LightAttrib) la = DCAST(LightAttrib, attrib); la = DCAST(LightAttrib, la->remove_on_light(light)); la = DCAST(LightAttrib, la->remove_off_light(light)); @@ -2331,7 +2331,7 @@ clear_light(const NodePath &light) { } else if (light.node()->is_of_type(PolylightNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(PolylightEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { CPT(PolylightEffect) ple = DCAST(PolylightEffect, effect); ple = DCAST(PolylightEffect, ple->remove_light(light)); node()->set_effect(ple); @@ -2353,10 +2353,10 @@ has_light(const NodePath &light) const { if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LightAttrib *la = DCAST(LightAttrib, attrib); return la->has_on_light(light); } @@ -2365,7 +2365,7 @@ has_light(const NodePath &light) const { } else if (light.node()->is_of_type(PolylightNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(PolylightEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const PolylightEffect *ple = DCAST(PolylightEffect, effect); return ple->has_light(light); } @@ -2387,7 +2387,7 @@ has_light_off() const { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LightAttrib *la = DCAST(LightAttrib, attrib); return la->has_all_off(); } @@ -2408,10 +2408,10 @@ has_light_off(const NodePath &light) const { nassertr_always(!is_empty(), false); if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LightAttrib *la = DCAST(LightAttrib, attrib); return la->has_off_light(light); } @@ -2434,7 +2434,7 @@ set_clip_plane(const NodePath &clip_plane, int priority) { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ClipPlaneAttrib::get_class_slot())); const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); @@ -2482,7 +2482,7 @@ set_clip_plane_off(const NodePath &clip_plane, int priority) { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ClipPlaneAttrib::get_class_slot())); const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); @@ -2523,7 +2523,7 @@ clear_clip_plane(const NodePath &clip_plane) { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(ClipPlaneAttrib) la = DCAST(ClipPlaneAttrib, attrib); la = DCAST(ClipPlaneAttrib, la->remove_on_plane(clip_plane)); la = DCAST(ClipPlaneAttrib, la->remove_off_plane(clip_plane)); @@ -2553,7 +2553,7 @@ has_clip_plane(const NodePath &clip_plane) const { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); return la->has_on_plane(clip_plane); } @@ -2574,7 +2574,7 @@ has_clip_plane_off() const { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); return la->has_all_off(); } @@ -2593,7 +2593,7 @@ has_clip_plane_off(const NodePath &clip_plane) const { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); return la->has_off_plane(clip_plane); } @@ -2615,7 +2615,7 @@ set_occluder(const NodePath &occluder) { if (!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(OccluderEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const OccluderEffect *la = DCAST(OccluderEffect, effect); // Modify the existing OccluderEffect to add the indicated occluder. @@ -2651,7 +2651,7 @@ clear_occluder(const NodePath &occluder) { if (!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(OccluderEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { CPT(OccluderEffect) la = DCAST(OccluderEffect, effect); la = DCAST(OccluderEffect, la->remove_on_occluder(occluder)); @@ -2679,7 +2679,7 @@ has_occluder(const NodePath &occluder) const { if (!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(OccluderEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const OccluderEffect *la = DCAST(OccluderEffect, effect); return la->has_on_occluder(occluder); } @@ -2824,7 +2824,7 @@ get_bin_name() const { nassertr_always(!is_empty(), string()); const RenderAttrib *attrib = node()->get_attrib(CullBinAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib); return ba->get_bin_name(); } @@ -2842,7 +2842,7 @@ get_bin_draw_order() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(CullBinAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib); return ba->get_draw_order(); } @@ -2878,7 +2878,7 @@ set_texture(TextureStage *stage, Texture *tex, int priority) { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); @@ -2928,7 +2928,7 @@ set_texture(TextureStage *stage, Texture *tex, const SamplerState &sampler, int const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); @@ -2966,7 +2966,7 @@ set_texture_off(TextureStage *stage, int priority) { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); @@ -3004,7 +3004,7 @@ clear_texture(TextureStage *stage) { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(TextureAttrib) tsa = DCAST(TextureAttrib, attrib); tsa = DCAST(TextureAttrib, tsa->remove_on_stage(stage)); tsa = DCAST(TextureAttrib, tsa->remove_off_stage(stage)); @@ -3027,7 +3027,7 @@ clear_texture(TextureStage *stage) { */ bool NodePath:: has_texture() const { - return get_texture() != (Texture *)NULL; + return get_texture() != nullptr; } /** @@ -3042,7 +3042,7 @@ has_texture(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->has_on_stage(stage); } @@ -3061,7 +3061,7 @@ has_texture_off() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->has_all_off(); } @@ -3081,7 +3081,7 @@ has_texture_off(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->has_off_stage(stage); } @@ -3099,15 +3099,15 @@ has_texture_off(TextureStage *stage) const { */ Texture *NodePath:: get_texture() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->get_texture(); } - return NULL; + return nullptr; } /** @@ -3116,15 +3116,15 @@ get_texture() const { */ Texture *NodePath:: get_texture(TextureStage *stage) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->get_on_texture(stage); } - return NULL; + return nullptr; } /** @@ -3153,7 +3153,7 @@ get_texture_sampler(TextureStage *stage) const { nassertr_always(!is_empty(), SamplerState::get_default()); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - nassertr_always(attrib != NULL, SamplerState::get_default()); + nassertr_always(attrib != nullptr, SamplerState::get_default()); const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->get_on_sampler(stage); @@ -3168,7 +3168,7 @@ set_shader(const Shader *sha, int priority) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ShaderAttrib::get_class_slot())); const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); @@ -3185,7 +3185,7 @@ set_shader(const Shader *sha, int priority) { */ void NodePath:: set_shader_off(int priority) { - set_shader(NULL, priority); + set_shader(nullptr, priority); } /** @@ -3197,7 +3197,7 @@ set_shader_auto(int priority) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ShaderAttrib::get_class_slot())); const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); @@ -3218,7 +3218,7 @@ set_shader_auto(BitMask32 shader_switch, int priority) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ShaderAttrib::get_class_slot())); const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); @@ -3238,7 +3238,7 @@ clear_shader() { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); node()->set_attrib(sa->clear_shader()); } @@ -3249,14 +3249,14 @@ clear_shader() { */ const Shader *NodePath:: get_shader() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); return sa->get_shader(); } - return NULL; + return nullptr; } /** @@ -3326,7 +3326,7 @@ get_instance_count() const { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); return sa->get_instance_count(); } @@ -3343,7 +3343,7 @@ clear_shader_input(CPT_InternalName id) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); node()->set_attrib(sa->clear_shader_input(id)); } @@ -3360,7 +3360,7 @@ set_instance_count(int instance_count) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); node()->set_attrib(sa->set_instance_count(instance_count)); } else { @@ -3380,7 +3380,7 @@ set_tex_transform(TextureStage *stage, const TransformState *transform) { const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); // Modify the existing TexMatrixAttrib to add the indicated stage. @@ -3410,7 +3410,7 @@ clear_tex_transform(TextureStage *stage) { const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(TexMatrixAttrib) tma = DCAST(TexMatrixAttrib, attrib); tma = DCAST(TexMatrixAttrib, tma->remove_stage(stage)); @@ -3433,7 +3433,7 @@ has_tex_transform(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); return tma->has_stage(stage); } @@ -3448,11 +3448,11 @@ has_tex_transform(TextureStage *stage) const { */ CPT(TransformState) NodePath:: get_tex_transform(TextureStage *stage) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); return tma->get_transform(stage); } @@ -3472,7 +3472,7 @@ set_tex_transform(const NodePath &other, TextureStage *stage, const TransformSta CPT(RenderState) state = get_state(other); const RenderAttrib *attrib = state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); // Modify the existing TexMatrixAttrib to add the indicated stage. @@ -3508,7 +3508,7 @@ get_tex_transform(const NodePath &other, TextureStage *stage) const { CPT(RenderState) state = get_state(other); const RenderAttrib *attrib = state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); return tma->get_transform(stage); } @@ -3529,7 +3529,7 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, int priority) { CPT(TexGenAttrib) tga; - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(TextureAttrib::get_class_slot())); tga = DCAST(TexGenAttrib, attrib); @@ -3556,7 +3556,7 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, CPT(TexGenAttrib) tga; - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(TextureAttrib::get_class_slot())); tga = DCAST(TexGenAttrib, attrib); @@ -3588,7 +3588,7 @@ clear_tex_gen(TextureStage *stage) { const RenderAttrib *attrib = node()->get_attrib(TexGenAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(TexGenAttrib) tga = DCAST(TexGenAttrib, attrib); tga = DCAST(TexGenAttrib, tga->remove_stage(stage)); @@ -3611,7 +3611,7 @@ has_tex_gen(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TexGenAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexGenAttrib *tga = DCAST(TexGenAttrib, attrib); return tga->has_stage(stage); } @@ -3629,7 +3629,7 @@ get_tex_gen(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TexGenAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexGenAttrib *tga = DCAST(TexGenAttrib, attrib); return tga->get_mode(stage); } @@ -3658,7 +3658,7 @@ set_tex_projector(TextureStage *stage, const NodePath &from, const NodePath &to, CPT(TexProjectorEffect) tpe; - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { tpe = DCAST(TexProjectorEffect, effect); } else { @@ -3677,7 +3677,7 @@ clear_tex_projector(TextureStage *stage) { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { CPT(TexProjectorEffect) tpe = DCAST(TexProjectorEffect, effect); tpe = DCAST(TexProjectorEffect, tpe->remove_stage(stage)); @@ -3709,7 +3709,7 @@ has_tex_projector(TextureStage *stage) const { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const TexProjectorEffect *tpe = DCAST(TexProjectorEffect, effect); return tpe->has_stage(stage); } @@ -3728,7 +3728,7 @@ get_tex_projector_from(TextureStage *stage) const { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const TexProjectorEffect *tpe = DCAST(TexProjectorEffect, effect); return tpe->get_from(stage); } @@ -3747,7 +3747,7 @@ get_tex_projector_to(TextureStage *stage) const { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const TexProjectorEffect *tpe = DCAST(TexProjectorEffect, effect); return tpe->get_to(stage); } @@ -3886,7 +3886,7 @@ find_all_texcoords(const string &name) const { */ Texture *NodePath:: find_texture(const string &name) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); GlobPattern glob(name); return r_find_texture(node(), get_net_state(), glob); } @@ -3898,7 +3898,7 @@ find_texture(const string &name) const { */ Texture *NodePath:: find_texture(TextureStage *stage) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); return r_find_texture(node(), stage); } @@ -3968,7 +3968,7 @@ find_all_textures(TextureStage *stage) const { */ TextureStage *NodePath:: find_texture_stage(const string &name) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); GlobPattern glob(name); return r_find_texture_stage(node(), get_net_state(), glob); } @@ -4035,7 +4035,7 @@ find_all_texture_stages(const string &name) const { */ Material *NodePath:: find_material(const string &name) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); GlobPattern glob(name); return r_find_material(node(), get_net_state(), glob); } @@ -4090,7 +4090,7 @@ find_all_materials(const string &name) const { void NodePath:: set_material(Material *mat, int priority) { nassertv_always(!is_empty()); - nassertv(mat != NULL); + nassertv(mat != nullptr); node()->set_attrib(MaterialAttrib::make(mat), priority); } @@ -4125,7 +4125,7 @@ has_material() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ma = DCAST(MaterialAttrib, attrib); return !ma->is_off(); } @@ -4143,15 +4143,15 @@ has_material() const { */ PT(Material) NodePath:: get_material() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ma = DCAST(MaterialAttrib, attrib); return ma->get_material(); } - return NULL; + return nullptr; } /** @@ -4198,7 +4198,7 @@ has_fog() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(FogAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const FogAttrib *fa = DCAST(FogAttrib, attrib); return !fa->is_off(); } @@ -4217,7 +4217,7 @@ has_fog_off() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(FogAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const FogAttrib *fa = DCAST(FogAttrib, attrib); return fa->is_off(); } @@ -4233,15 +4233,15 @@ has_fog_off() const { */ Fog *NodePath:: get_fog() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(FogAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const FogAttrib *fa = DCAST(FogAttrib, attrib); return fa->get_fog(); } - return NULL; + return nullptr; } /** @@ -4356,7 +4356,7 @@ get_render_mode() const { nassertr_always(!is_empty(), RenderModeAttrib::M_unchanged); const RenderAttrib *attrib = node()->get_attrib(RenderModeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib); return ta->get_mode(); } @@ -4373,7 +4373,7 @@ get_render_mode_thickness() const { nassertr_always(!is_empty(), 0.0f); const RenderAttrib *attrib = node()->get_attrib(RenderModeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib); return ta->get_thickness(); } @@ -4390,7 +4390,7 @@ get_render_mode_perspective() const { nassertr_always(!is_empty(), 0.0f); const RenderAttrib *attrib = node()->get_attrib(RenderModeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib); return ta->get_perspective(); } @@ -4451,7 +4451,7 @@ get_two_sided() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(CullFaceAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const CullFaceAttrib *cfa = DCAST(CullFaceAttrib, attrib); return (cfa->get_actual_mode() == CullFaceAttrib::M_cull_none); } @@ -4508,7 +4508,7 @@ get_depth_test() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(DepthTestAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const DepthTestAttrib *dta = DCAST(DepthTestAttrib, attrib); return (dta->get_mode() != DepthTestAttrib::M_none); } @@ -4565,7 +4565,7 @@ get_depth_write() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(DepthWriteAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const DepthWriteAttrib *dta = DCAST(DepthWriteAttrib, attrib); return (dta->get_mode() != DepthWriteAttrib::M_off); } @@ -4619,7 +4619,7 @@ get_depth_offset() const { nassertr_always(!is_empty(), 0); const RenderAttrib *attrib = node()->get_attrib(DepthOffsetAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const DepthOffsetAttrib *doa = DCAST(DepthOffsetAttrib, attrib); return doa->get_offset(); } @@ -4853,7 +4853,7 @@ get_transparency() const { nassertr_always(!is_empty(), TransparencyAttrib::M_none); const RenderAttrib *attrib = node()->get_attrib(TransparencyAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TransparencyAttrib *ta = DCAST(TransparencyAttrib, attrib); return ta->get_mode(); } @@ -4909,7 +4909,7 @@ get_logic_op() const { nassertr_always(!is_empty(), LogicOpAttrib::O_none); const RenderAttrib *attrib = node()->get_attrib(LogicOpAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LogicOpAttrib *ta = DCAST(LogicOpAttrib, attrib); return ta->get_operation(); } @@ -4958,7 +4958,7 @@ get_antialias() const { nassertr_always(!is_empty(), AntialiasAttrib::M_none); const RenderAttrib *attrib = node()->get_attrib(AntialiasAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const AntialiasAttrib *ta = DCAST(AntialiasAttrib, attrib); return ta->get_mode(); } @@ -4997,7 +4997,7 @@ set_audio_volume(PN_stdfloat volume, int priority) { const RenderAttrib *attrib = node()->get_attrib(AudioVolumeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(AudioVolumeAttrib::get_class_slot())); CPT(AudioVolumeAttrib) ava = DCAST(AudioVolumeAttrib, attrib); @@ -5035,7 +5035,7 @@ PN_stdfloat NodePath:: get_audio_volume() const { const RenderAttrib *attrib = node()->get_attrib(AudioVolumeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const AudioVolumeAttrib *ava = DCAST(AudioVolumeAttrib, attrib); return ava->get_volume(); } @@ -5051,9 +5051,9 @@ PN_stdfloat NodePath:: get_net_audio_volume() const { CPT(RenderState) net_state = get_net_state(); const RenderAttrib *attrib = net_state->get_attrib(AudioVolumeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const AudioVolumeAttrib *ava = DCAST(AudioVolumeAttrib, attrib); - if (ava != (const AudioVolumeAttrib *)NULL) { + if (ava != nullptr) { return ava->get_volume(); } } @@ -5072,7 +5072,7 @@ get_hidden_ancestor(DrawMask camera_mask, Thread *current_thread) const { NodePathComponent *comp; for (comp = _head; - comp != (NodePathComponent *)NULL; + comp != nullptr; comp = comp->get_next(pipeline_stage, current_thread)) { PandaNode *node = comp->get_node(); if (node->is_overall_hidden() || @@ -5143,11 +5143,11 @@ unstash_all(Thread *current_thread) { NodePath NodePath:: get_stashed_ancestor(Thread *current_thread) const { NodePathComponent *comp = _head; - if (comp != (NodePathComponent *)NULL) { + if (comp != nullptr) { int pipeline_stage = current_thread->get_pipeline_stage(); NodePathComponent *next = comp->get_next(pipeline_stage, current_thread); - while (next != (NodePathComponent *)NULL) { + while (next != nullptr) { PandaNode *node = comp->get_node(); PandaNode *parent_node = next->get_node(); @@ -5237,19 +5237,19 @@ verify_complete(Thread *current_thread) const { PStatTimer timer(_verify_complete_pcollector); const NodePathComponent *comp = _head; - nassertr(comp != (const NodePathComponent *)NULL, false); + nassertr(comp != nullptr, false); int pipeline_stage = current_thread->get_pipeline_stage(); PandaNode *node = comp->get_node(); - nassertr(node != (const PandaNode *)NULL, false); + nassertr(node != nullptr, false); int length = comp->get_length(pipeline_stage, current_thread); comp = comp->get_next(pipeline_stage, current_thread); length--; - while (comp != (const NodePathComponent *)NULL) { + while (comp != nullptr) { PandaNode *next_node = comp->get_node(); - nassertr(next_node != (const PandaNode *)NULL, false); + nassertr(next_node != nullptr, false); if (node->find_parent(next_node) < 0) { pgraph_cat.warning() @@ -5654,7 +5654,7 @@ encode_to_bam_stream(vector_uchar &data, BamWriter *writer) const { DatagramBuffer buffer; BamWriter local_writer; bool used_local_writer = false; - if (writer == NULL) { + if (writer == nullptr) { // Create our own writer. if (!buffer.write_header(_bam_header)) { @@ -5683,20 +5683,20 @@ encode_to_bam_stream(vector_uchar &data, BamWriter *writer) const { dg.add_int32(num_nodes); if (!buffer.put_datagram(dg)) { - writer->set_target(NULL); + writer->set_target(nullptr); return false; } // Now write the nodes, one at a time. for (int i = 0; i < num_nodes; ++i) { PandaNode *node = get_node(num_nodes - i - 1); - nassertr(node != NULL, false); + nassertr(node != nullptr, false); if (!writer->write_object(node)) { - writer->set_target(NULL); + writer->set_target(nullptr); return false; } } - writer->set_target(NULL); + writer->set_target(nullptr); buffer.swap_data(data); return true; @@ -5713,7 +5713,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { DatagramBuffer buffer(move(data)); BamReader local_reader; - if (reader == NULL) { + if (reader == nullptr) { // Create a local reader. string head; @@ -5748,14 +5748,14 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { for (int i = 0; i < num_nodes; ++i) { TypedWritable *object = reader->read_object(); - if (object == (TypedWritable *)NULL || + if (object == nullptr || !object->is_of_type(PandaNode::get_class_type())) { - reader->set_source(NULL); + reader->set_source(nullptr); return NodePath::fail(); } if (!reader->resolve()) { - reader->set_source(NULL); + reader->set_source(nullptr); return NodePath::fail(); } @@ -5764,7 +5764,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { } } - reader->set_source(NULL); + reader->set_source(nullptr); return result; } @@ -5780,7 +5780,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { NodePathComponent *NodePath:: find_common_ancestor(const NodePath &a, const NodePath &b, int &a_count, int &b_count, Thread *current_thread) { - nassertr(!a.is_empty() && !b.is_empty(), NULL); + nassertr(!a.is_empty() && !b.is_empty(), nullptr); NodePathComponent *ac = a._head; NodePathComponent *bc = b._head; a_count = 0; @@ -5790,12 +5790,12 @@ find_common_ancestor(const NodePath &a, const NodePath &b, // Shorten up the longer one until they are the same length. while (ac->get_length(pipeline_stage, current_thread) > bc->get_length(pipeline_stage, current_thread)) { - nassertr(ac != (NodePathComponent *)NULL, NULL); + nassertr(ac != nullptr, nullptr); ac = ac->get_next(pipeline_stage, current_thread); a_count++; } while (bc->get_length(pipeline_stage, current_thread) > ac->get_length(pipeline_stage, current_thread)) { - nassertr(bc != (NodePathComponent *)NULL, NULL); + nassertr(bc != nullptr, nullptr); bc = bc->get_next(pipeline_stage, current_thread); b_count++; } @@ -5803,8 +5803,8 @@ find_common_ancestor(const NodePath &a, const NodePath &b, // Now shorten them both up until we reach the same component. while (ac != bc) { // These shouldn't go to NULL unless they both go there together. - nassertr(ac != (NodePathComponent *)NULL, NULL); - nassertr(bc != (NodePathComponent *)NULL, NULL); + nassertr(ac != nullptr, nullptr); + nassertr(bc != nullptr, nullptr); ac = ac->get_next(pipeline_stage, current_thread); a_count++; bc = bc->get_next(pipeline_stage, current_thread); @@ -5820,7 +5820,7 @@ find_common_ancestor(const NodePath &a, const NodePath &b, */ CPT(RenderState) NodePath:: r_get_net_state(NodePathComponent *comp, Thread *current_thread) const { - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { return RenderState::make_empty(); } else { CPT(RenderState) state = comp->get_node()->get_state(current_thread); @@ -5837,7 +5837,7 @@ r_get_net_state(NodePathComponent *comp, Thread *current_thread) const { CPT(RenderState) NodePath:: r_get_partial_state(NodePathComponent *comp, int n, Thread *current_thread) const { - if (n == 0 || comp == (NodePathComponent *)NULL) { + if (n == 0 || comp == nullptr) { return RenderState::make_empty(); } else { CPT(RenderState) state = comp->get_node()->get_state(current_thread); @@ -5852,7 +5852,7 @@ r_get_partial_state(NodePathComponent *comp, int n, */ CPT(TransformState) NodePath:: r_get_net_transform(NodePathComponent *comp, Thread *current_thread) const { - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { return TransformState::make_identity(); } else { PandaNode *node = comp->get_node(); @@ -5885,18 +5885,18 @@ r_get_net_transform(NodePathComponent *comp, Thread *current_thread) const { CPT(TransformState) NodePath:: r_get_partial_transform(NodePathComponent *comp, int n, Thread *current_thread) const { - if (n == 0 || comp == (NodePathComponent *)NULL) { + if (n == 0 || comp == nullptr) { return TransformState::make_identity(); } else { PandaNode *node = comp->get_node(); PandaNode::CDReader node_cdata(node->_cycler, current_thread); if (node_cdata->_effects->has_adjust_transform()) { - return NULL; + return nullptr; } int pipeline_stage = current_thread->get_pipeline_stage(); CPT(TransformState) partial = r_get_partial_transform(comp->get_next(pipeline_stage, current_thread), n - 1, current_thread); - if (partial == (const TransformState *)NULL) { - return NULL; + if (partial == nullptr) { + return nullptr; } if (node_cdata->_transform->is_identity()) { return partial; @@ -5912,7 +5912,7 @@ r_get_partial_transform(NodePathComponent *comp, int n, */ CPT(TransformState) NodePath:: r_get_net_prev_transform(NodePathComponent *comp, Thread *current_thread) const { - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { return TransformState::make_identity(); } else { CPT(TransformState) transform = comp->get_node()->get_prev_transform(current_thread); @@ -5928,7 +5928,7 @@ r_get_net_prev_transform(NodePathComponent *comp, Thread *current_thread) const */ CPT(TransformState) NodePath:: r_get_partial_prev_transform(NodePathComponent *comp, int n, Thread *current_thread) const { - if (n == 0 || comp == (NodePathComponent *)NULL) { + if (n == 0 || comp == nullptr) { return TransformState::make_identity(); } else { CPT(TransformState) transform = comp->get_node()->get_prev_transform(current_thread); @@ -5989,9 +5989,9 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, int num_levels_remaining = _max_search_depth; - FindApproxLevelEntry *deleted_entries = NULL; + FindApproxLevelEntry *deleted_entries = nullptr; - while (num_levels_remaining > 0 && level != NULL) { + while (num_levels_remaining > 0 && level != nullptr) { if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "find_matches pass: " << result << ", " @@ -6001,27 +6001,27 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, num_levels_remaining--; - FindApproxLevelEntry *next_level = NULL; + FindApproxLevelEntry *next_level = nullptr; // For each node in the current level, build up the set of possible // matches in the next level. FindApproxLevelEntry *entry = level; - while (entry != (FindApproxLevelEntry *)NULL) { + while (entry != nullptr) { if (entry->consider_node(result, next_level, max_matches, 0)) { // If we found the requisite number of matches, we can stop. Delete // all remaining entries and return immediately. - while (entry != (FindApproxLevelEntry *)NULL) { + while (entry != nullptr) { FindApproxLevelEntry *next = entry->_next; delete entry; entry = next; } - while (next_level != (FindApproxLevelEntry *)NULL) { + while (next_level != nullptr) { FindApproxLevelEntry *next = next_level->_next; delete next_level; next_level = next; } - while (deleted_entries != (FindApproxLevelEntry *)NULL) { + while (deleted_entries != nullptr) { FindApproxLevelEntry *next = deleted_entries->_next; delete deleted_entries; deleted_entries = next; @@ -6042,7 +6042,7 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, // Make sure the remaining entries from this level are added to the delete // chain. - while (entry != (FindApproxLevelEntry *)NULL) { + while (entry != nullptr) { FindApproxLevelEntry *next = entry->_next; entry->_next = deleted_entries; deleted_entries = entry; @@ -6054,7 +6054,7 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, } // Now it's safe to delete all entries on the delete chain. - while (deleted_entries != (FindApproxLevelEntry *)NULL) { + while (deleted_entries != nullptr) { FindApproxLevelEntry *next = deleted_entries->_next; delete deleted_entries; deleted_entries = next; @@ -6231,7 +6231,7 @@ r_find_texture(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6241,11 +6241,11 @@ r_find_texture(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { Texture *texture = ta->get_on_texture(ta->get_on_stage(i)); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { if (glob.matches(texture->get_name())) { return texture; } @@ -6263,12 +6263,12 @@ r_find_texture(PandaNode *node, const RenderState *state, CPT(RenderState) next_state = state->compose(child->get_state()); Texture *result = r_find_texture(child, next_state, glob); - if (result != (Texture *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6289,11 +6289,11 @@ r_find_all_textures(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { Texture *texture = ta->get_on_texture(ta->get_on_stage(i)); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { textures.insert(texture); } } @@ -6319,7 +6319,7 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { // Look for a TextureAttrib on the node. const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { return ta->get_on_texture(stage); @@ -6328,7 +6328,7 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6337,7 +6337,7 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { return ta->get_on_texture(stage); @@ -6353,12 +6353,12 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { PandaNode *child = cr.get_child(i); Texture *result = r_find_texture(child, stage); - if (result != (Texture *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6370,7 +6370,7 @@ r_find_all_textures(PandaNode *node, TextureStage *stage, // Look for a TextureAttrib on the node. const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { textures.insert(ta->get_on_texture(stage)); @@ -6388,7 +6388,7 @@ r_find_all_textures(PandaNode *node, TextureStage *stage, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { textures.insert(ta->get_on_texture(stage)); @@ -6414,7 +6414,7 @@ r_find_texture_stage(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6424,11 +6424,11 @@ r_find_texture_stage(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { TextureStage *texture_stage = ta->get_on_stage(i); - if (texture_stage != (TextureStage *)NULL) { + if (texture_stage != nullptr) { if (glob.matches(texture_stage->get_name())) { return texture_stage; } @@ -6446,12 +6446,12 @@ r_find_texture_stage(PandaNode *node, const RenderState *state, CPT(RenderState) next_state = state->compose(child->get_state()); TextureStage *result = r_find_texture_stage(child, next_state, glob); - if (result != (TextureStage *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6472,11 +6472,11 @@ r_find_all_texture_stages(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { TextureStage *texture_stage = ta->get_on_stage(i); - if (texture_stage != (TextureStage *)NULL) { + if (texture_stage != nullptr) { texture_stages.insert(texture_stage); } } @@ -6502,7 +6502,7 @@ r_unify_texture_stages(PandaNode *node, TextureStage *stage) { // Look for a TextureAttrib on the state. const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); CPT(RenderAttrib) new_attrib = ta->unify_texture_stages(stage); if (new_attrib != ta) { @@ -6521,7 +6521,7 @@ r_unify_texture_stages(PandaNode *node, TextureStage *stage) { // Look for a TextureAttrib on the state. const RenderAttrib *attrib = state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); CPT(RenderAttrib) new_attrib = ta->unify_texture_stages(stage); if (new_attrib != ta) { @@ -6549,7 +6549,7 @@ r_find_material(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6559,11 +6559,11 @@ r_find_material(PandaNode *node, const RenderState *state, // Look for a MaterialAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ta = DCAST(MaterialAttrib, attrib); if (!ta->is_off()) { Material *material = ta->get_material(); - if (material != (Material *)NULL) { + if (material != nullptr) { if (glob.matches(material->get_name())) { return material; } @@ -6581,12 +6581,12 @@ r_find_material(PandaNode *node, const RenderState *state, CPT(RenderState) next_state = state->compose(child->get_state()); Material *result = r_find_material(child, next_state, glob); - if (result != (Material *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6607,11 +6607,11 @@ r_find_all_materials(PandaNode *node, const RenderState *state, // Look for a MaterialAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ta = DCAST(MaterialAttrib, attrib); if (!ta->is_off()) { Material *material = ta->get_material(); - if (material != (Material *)NULL) { + if (material != nullptr) { materials.insert(material); } } @@ -6638,9 +6638,9 @@ write_datagram(BamWriter *manager, Datagram &dg) const { PandaNode *root = DCAST(PandaNode, manager->get_root_node()); // We have no root node to measure from. - if (root == (PandaNode *)NULL || root == node()) { + if (root == nullptr || root == node()) { manager->write_pointer(dg, node()); - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); return; } @@ -6650,7 +6650,7 @@ write_datagram(BamWriter *manager, Datagram &dg) const { // Record the chain of nodes from the root to this node. pvector path; NodePathComponent *comp = _head; - while (comp != NULL) { + while (comp != nullptr) { PandaNode *node = comp->get_node(); path.push_back(node); @@ -6661,10 +6661,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { comp = comp->get_next(pipeline_stage, current_thread); } - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { // We did not encounter the root node. Not much we can do. manager->write_pointer(dg, node()); - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); return; } @@ -6672,7 +6672,7 @@ write_datagram(BamWriter *manager, Datagram &dg) const { for (int i = path.size() - 1; i >= 0; --i) { manager->write_pointer(dg, path[i]); } - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); } /** @@ -6685,7 +6685,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { PT(PandaNode) node = DCAST(PandaNode, p_list[pi++]); if (node.is_null()) { // An empty NodePath. - _head = (NodePathComponent *)NULL; + _head = nullptr; return pi; } @@ -6702,7 +6702,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } // Build up the chain of NodePathComponents leading up to this node. - while (p_list[pi] != NULL) { + while (p_list[pi] != nullptr) { PT(PandaNode) node = DCAST(PandaNode, p_list[pi++]); LightReMutexHolder holder(node->_paths_lock); diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index bdd9d3f2d7..f932b48efc 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -887,7 +887,7 @@ PUBLISHED: // Miscellaneous bool verify_complete(Thread *current_thread = Thread::get_current_thread()) const; - void premunge_scene(GraphicsStateGuardianBase *gsg = NULL); + void premunge_scene(GraphicsStateGuardianBase *gsg = nullptr); void prepare_scene(GraphicsStateGuardianBase *gsg); void show_bounds(); diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index 40efb80192..68977a8b4b 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -229,7 +229,7 @@ find_all_matches(const string &path) const { FindApproxPath approx_path; if (approx_path.add_string(path)) { if (!is_empty()) { - FindApproxLevelEntry *level = NULL; + FindApproxLevelEntry *level = nullptr; for (int i = 0; i < get_num_paths(); i++) { FindApproxLevelEntry *start = new FindApproxLevelEntry(get_path(i), approx_path); diff --git a/panda/src/pgraph/nodePathCollection_ext.cxx b/panda/src/pgraph/nodePathCollection_ext.cxx index 32f5ac0d13..1e2b13fe1e 100644 --- a/panda/src/pgraph/nodePathCollection_ext.cxx +++ b/panda/src/pgraph/nodePathCollection_ext.cxx @@ -32,7 +32,7 @@ extern struct Dtool_PyTypedObject Dtool_LPoint3f; void Extension:: __init__(PyObject *self, PyObject *sequence) { PyObject *fast = PySequence_Fast(sequence, "NodePathCollection constructor requires a sequence"); - if (fast == NULL) { + if (fast == nullptr) { return; } @@ -41,7 +41,7 @@ __init__(PyObject *self, PyObject *sequence) { for (int i = 0; i < size; ++i) { PyObject *item = PySequence_Fast_GET_ITEM(fast, i); - if (item == NULL) { + if (item == nullptr) { return; } @@ -76,13 +76,13 @@ __reduce__(PyObject *self) const { // necessary to reconstruct this object. PyObject *this_class = (PyObject *)self->ob_type; - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *self_iter = PyObject_GetIter(self); - if (self_iter == NULL) { - return NULL; + if (self_iter == nullptr) { + return nullptr; } // Since a NodePathCollection is itself an iterator, we can simply pass it diff --git a/panda/src/pgraph/nodePathComponent.I b/panda/src/pgraph/nodePathComponent.I index b54d4cfc7d..00b8d6d19d 100644 --- a/panda/src/pgraph/nodePathComponent.I +++ b/panda/src/pgraph/nodePathComponent.I @@ -34,7 +34,7 @@ CData(const NodePathComponent::CData ©) : */ INLINE NodePathComponent:: ~NodePathComponent() { - nassertv(_node != (PandaNode *)NULL); + nassertv(_node != nullptr); _node->delete_component(this); } @@ -43,7 +43,7 @@ INLINE NodePathComponent:: */ INLINE PandaNode *NodePathComponent:: get_node() const { - nassertr(_node != (PandaNode *)NULL, _node); + nassertr(_node != nullptr, _node); return _node; } diff --git a/panda/src/pgraph/nodePathComponent.cxx b/panda/src/pgraph/nodePathComponent.cxx index a9f8a38788..dd767cf172 100644 --- a/panda/src/pgraph/nodePathComponent.cxx +++ b/panda/src/pgraph/nodePathComponent.cxx @@ -50,7 +50,7 @@ NodePathComponent(PandaNode *node, NodePathComponent *next, CDStageWriter cdata(_cycler, pipeline_stage_i, current_thread); cdata->_next = next; - if (next != (NodePathComponent *)NULL) { + if (next != nullptr) { cdata->_length = next->get_length(pipeline_stage_i, current_thread) + 1; } } @@ -80,7 +80,7 @@ get_key() const { bool NodePathComponent:: is_top_node(int pipeline_stage, Thread *current_thread) const { CDStageReader cdata(_cycler, pipeline_stage, current_thread); - return (cdata->_next == (NodePathComponent *)NULL); + return (cdata->_next == nullptr); } /** @@ -102,7 +102,7 @@ fix_length(int pipeline_stage, Thread *current_thread) { CDLockedStageReader cdata(_cycler, pipeline_stage, current_thread); int length_should_be = 1; - if (cdata->_next != (NodePathComponent *)NULL) { + if (cdata->_next != nullptr) { length_should_be = cdata->_next->get_length(pipeline_stage, current_thread) + 1; } @@ -127,7 +127,7 @@ output(ostream &out) const { PandaNode *node = get_node(); NodePathComponent *next = get_next(pipeline_stage, current_thread); - if (next != (NodePathComponent *)NULL) { + if (next != nullptr) { // This is not the head of the list; keep going up. next->output(out); out << "/"; @@ -157,7 +157,7 @@ output(ostream &out) const { */ void NodePathComponent:: set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread) { - nassertv(next != (NodePathComponent *)NULL); + nassertv(next != nullptr); CDStageWriter cdata(_cycler, pipeline_stage, current_thread); cdata->_next = next; } @@ -169,5 +169,5 @@ set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread) { void NodePathComponent:: set_top_node(int pipeline_stage, Thread *current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); - cdata->_next = (NodePathComponent *)NULL; + cdata->_next = nullptr; } diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index 1c7576290a..f167d0c57a 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -57,7 +57,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { // Borrowed reference. PyObject *dupe = PyDict_GetItem(memo, self); - if (dupe != NULL) { + if (dupe != nullptr) { // Already in the memo dictionary. Py_INCREF(dupe); return dupe; @@ -74,7 +74,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { true, false); if (PyDict_SetItem(memo, self, dupe) != 0) { Py_DECREF(dupe); - return NULL; + return nullptr; } return dupe; @@ -89,7 +89,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { */ PyObject *Extension:: __reduce__(PyObject *self) const { - return __reduce_persist__(self, NULL); + return __reduce_persist__(self, nullptr); } /** @@ -107,10 +107,10 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. - BamWriter *writer = NULL; - if (pickler != NULL) { + BamWriter *writer = nullptr; + if (pickler != nullptr) { PyObject *py_writer = PyObject_GetAttrString(pickler, "bamWriter"); - if (py_writer == NULL) { + if (py_writer == nullptr) { // It's OK if there's no bamWriter. PyErr_Clear(); } else { @@ -127,33 +127,33 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { stream << "Could not bamify " << _this; string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; + return nullptr; } // Start by getting this class object. PyObject *this_class = (PyObject *)Py_TYPE(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *func; - if (writer != NULL) { + if (writer != nullptr) { // The modified pickle support: call the "persistent" version of this // function, which receives the unpickler itself as an additional // parameter. func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream_persist"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream_persist()"); - return NULL; + return nullptr; } } else { // The traditional pickle support: call the non-persistent version of this // function. func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream()"); - return NULL; + return nullptr; } } @@ -221,10 +221,10 @@ py_decode_NodePath_from_bam_stream(vector_uchar data) { */ NodePath py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, vector_uchar data) { - BamReader *reader = NULL; - if (unpickler != NULL) { + BamReader *reader = nullptr; + if (unpickler != nullptr) { PyObject *py_reader = PyObject_GetAttrString(unpickler, "bamReader"); - if (py_reader == NULL) { + if (py_reader == nullptr) { // It's OK if there's no bamReader. PyErr_Clear(); } else { diff --git a/panda/src/pgraph/occluderEffect.cxx b/panda/src/pgraph/occluderEffect.cxx index f27c486d88..9e81d4e52d 100644 --- a/panda/src/pgraph/occluderEffect.cxx +++ b/panda/src/pgraph/occluderEffect.cxx @@ -31,7 +31,7 @@ CPT(RenderEffect) OccluderEffect:: make() { // We make it a special case and store a pointer to the empty effect forever // once we find it the first time, as an optimization. - if (_empty_effect == (RenderEffect *)NULL) { + if (_empty_effect == nullptr) { _empty_effect = return_new(new OccluderEffect); } diff --git a/panda/src/pgraph/occluderNode.cxx b/panda/src/pgraph/occluderNode.cxx index c1a4c4d9da..3fc81bc944 100644 --- a/panda/src/pgraph/occluderNode.cxx +++ b/panda/src/pgraph/occluderNode.cxx @@ -146,7 +146,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { trav->get_cull_handler()->record_object(occluder_viz, trav); // Also get the frame. - nassertr(_frame_viz != (Geom *)NULL, false); + nassertr(_frame_viz != nullptr, false); CullableObject *frame_viz = new CullableObject(_frame_viz, get_frame_viz_state(trav, data), data.get_internal_transform(trav)); @@ -210,8 +210,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, */ PT(Geom) OccluderNode:: get_occluder_viz(CullTraverser *trav, CullTraverserData &data) { - if (_occluder_viz == (Geom *)NULL) { - nassertr(_vertices.size() == 4, NULL); + if (_occluder_viz == nullptr) { + nassertr(_vertices.size() == 4, nullptr); if (pgraph_cat.is_debug()) { pgraph_cat.debug() @@ -270,7 +270,7 @@ get_occluder_viz(CullTraverser *trav, CullTraverserData &data) { */ CPT(RenderState) OccluderNode:: get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { - if (_viz_tex == NULL) { + if (_viz_tex == nullptr) { // Create a default texture. We set it up as a 2x2 graytone checkerboard, // since that's real easy, and it doesn't look like a CollisionPolygon. _viz_tex = new Texture("occluder_viz"); @@ -283,7 +283,7 @@ get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { } static CPT(RenderState) viz_state; - if (viz_state == NULL) { + if (viz_state == nullptr) { viz_state = RenderState::make (ColorAttrib::make_flat(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha), @@ -308,7 +308,7 @@ get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { CPT(RenderState) OccluderNode:: get_frame_viz_state(CullTraverser *trav, CullTraverserData &data) { static CPT(RenderState) viz_state; - if (viz_state == NULL) { + if (viz_state == nullptr) { viz_state = RenderState::make (ColorAttrib::make_flat(LVecBase4(0.0f, 0.0f, 0.0f, 1.0f)), TextureAttrib::make_off()); diff --git a/panda/src/pgraph/pandaNode.I b/panda/src/pgraph/pandaNode.I index 93bf19cc2d..fcd02ae429 100644 --- a/panda/src/pgraph/pandaNode.I +++ b/panda/src/pgraph/pandaNode.I @@ -32,7 +32,7 @@ INLINE PandaNode *PandaNode:: get_parent(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); CPT(Up) up = cdata->get_up(); - nassertr(n >= 0 && n < (int)up->size(), NULL); + nassertr(n >= 0 && n < (int)up->size(), nullptr); return (*up)[n].get_parent(); } @@ -66,7 +66,7 @@ INLINE PandaNode *PandaNode:: get_child(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); CPT(Down) down = cdata->get_down(); - nassertr(n >= 0 && n < (int)down->size(), NULL); + nassertr(n >= 0 && n < (int)down->size(), nullptr); return (*down)[n].get_child(); } @@ -154,7 +154,7 @@ INLINE PandaNode *PandaNode:: get_stashed(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); CPT(Down) stashed = cdata->get_stashed(); - nassertr(n >= 0 && n < (int)stashed->size(), NULL); + nassertr(n >= 0 && n < (int)stashed->size(), nullptr); return (*stashed)[n].get_child(); } @@ -247,7 +247,7 @@ get_effect(TypeHandle type) const { if (index >= 0) { return cdata->_effects->get_effect(index); } - return NULL; + return nullptr; } /** @@ -496,7 +496,7 @@ get_into_collide_mask() const { */ INLINE void PandaNode:: clear_bounds() { - set_bounds((BoundingVolume *)NULL); + set_bounds(nullptr); } /** @@ -806,7 +806,7 @@ get_parent() const { */ INLINE PandaNode::BoundsData:: BoundsData() : - _internal_bounds(NULL), + _internal_bounds(nullptr), _internal_vertices(0) { ++_internal_bounds_mark; @@ -951,7 +951,7 @@ operator = (PandaNode::Children &&from) noexcept { */ INLINE size_t PandaNode::Children:: get_num_children() const { - nassertr(_down != (Down *)NULL, 0); + nassertr(_down != nullptr, 0); return _down->size(); } @@ -960,8 +960,8 @@ get_num_children() const { */ INLINE PandaNode *PandaNode::Children:: get_child(size_t n) const { - nassertr(_down != (Down *)NULL, NULL); - nassertr(n < (size_t)_down->size(), NULL); + nassertr(_down != nullptr, nullptr); + nassertr(n < (size_t)_down->size(), nullptr); return (*_down)[n].get_child(); } @@ -971,7 +971,7 @@ get_child(size_t n) const { */ INLINE int PandaNode::Children:: get_child_sort(size_t n) const { - nassertr(_down != (Down *)NULL, -1); + nassertr(_down != nullptr, -1); nassertr(n < _down->size(), -1); return (*_down)[n].get_sort(); } @@ -1031,7 +1031,7 @@ operator = (PandaNode::Stashed &&from) noexcept { */ INLINE size_t PandaNode::Stashed:: get_num_stashed() const { - nassertr(_stashed != (Down *)NULL, 0); + nassertr(_stashed != nullptr, 0); return _stashed->size(); } @@ -1040,8 +1040,8 @@ get_num_stashed() const { */ INLINE PandaNode *PandaNode::Stashed:: get_stashed(size_t n) const { - nassertr(_stashed != (Down *)NULL, NULL); - nassertr(n < _stashed->size(), NULL); + nassertr(_stashed != nullptr, nullptr); + nassertr(n < _stashed->size(), nullptr); return (*_stashed)[n].get_child(); } @@ -1051,7 +1051,7 @@ get_stashed(size_t n) const { */ INLINE int PandaNode::Stashed:: get_stashed_sort(size_t n) const { - nassertr(_stashed != (Down *)NULL, -1); + nassertr(_stashed != nullptr, -1); nassertr(n < _stashed->size(), -1); return (*_stashed)[n].get_sort(); } @@ -1111,7 +1111,7 @@ operator = (PandaNode::Parents &&from) noexcept { */ INLINE size_t PandaNode::Parents:: get_num_parents() const { - nassertr(_up != (Up *)NULL, 0); + nassertr(_up != nullptr, 0); return _up->size(); } @@ -1120,8 +1120,8 @@ get_num_parents() const { */ INLINE PandaNode *PandaNode::Parents:: get_parent(size_t n) const { - nassertr(_up != (Up *)NULL, NULL); - nassertr(n < _up->size(), NULL); + nassertr(_up != nullptr, nullptr); + nassertr(n < _up->size(), nullptr); return (*_up)[n].get_parent(); } @@ -1213,8 +1213,8 @@ INLINE PandaNodePipelineReader:: #endif // DO_PIPELINING #ifdef _DEBUG - _node = NULL; - _cdata = NULL; + _node = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -1254,7 +1254,7 @@ release() { */ INLINE void PandaNodePipelineReader:: compose_draw_mask(DrawMask &running_draw_mask) const { - nassertv(_cdata != (PandaNode::CData *)NULL); + nassertv(_cdata != nullptr); running_draw_mask = (running_draw_mask & ~_cdata->_draw_control_mask) | (_cdata->_draw_show_mask & _cdata->_draw_control_mask); } @@ -1267,7 +1267,7 @@ compose_draw_mask(DrawMask &running_draw_mask) const { */ INLINE bool PandaNodePipelineReader:: compare_draw_mask(DrawMask running_draw_mask, DrawMask camera_mask) const { - nassertr(_cdata != (PandaNode::CData *)NULL, false); + nassertr(_cdata != nullptr, false); nassertr(_cdata->_last_update == _cdata->_next_update, false); // As a special case, if net_draw_show_mask is all 0, it means either that @@ -1316,7 +1316,7 @@ get_num_parents() const { INLINE PandaNode *PandaNodePipelineReader:: get_parent(int n) const { CPT(PandaNode::Up) up = _cdata->get_up(); - nassertr(n >= 0 && n < (int)up->size(), NULL); + nassertr(n >= 0 && n < (int)up->size(), nullptr); return (*up)[n].get_parent(); } @@ -1347,7 +1347,7 @@ get_num_children() const { INLINE PandaNode *PandaNodePipelineReader:: get_child(int n) const { CPT(PandaNode::Down) down = _cdata->get_down(); - nassertr(n >= 0 && n < (int)down->size(), NULL); + nassertr(n >= 0 && n < (int)down->size(), nullptr); return (*down)[n].get_child(); } @@ -1389,7 +1389,7 @@ get_num_stashed() const { INLINE PandaNode *PandaNodePipelineReader:: get_stashed(int n) const { CPT(PandaNode::Down) stashed = _cdata->get_stashed(); - nassertr(n >= 0 && n < (int)stashed->size(), NULL); + nassertr(n >= 0 && n < (int)stashed->size(), nullptr); return (*stashed)[n].get_child(); } diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 91afd2f768..c6cc323d2a 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -166,7 +166,7 @@ PandaNode(const PandaNode ©) : cdata->_into_collide_mask = copy_cdata->_into_collide_mask; cdata->_bounds_type = copy_cdata->_bounds_type; cdata->_user_bounds = copy_cdata->_user_bounds; - cdata->_internal_bounds = NULL; + cdata->_internal_bounds = nullptr; cdata->_internal_bounds_computed = UpdateSeq::initial(); cdata->_internal_bounds_mark = UpdateSeq::initial(); ++cdata->_internal_bounds_mark; @@ -333,7 +333,7 @@ combine_with(PandaNode *other) { } // We're something other than an ordinary PandaNode. Don't combine. - return (PandaNode *)NULL; + return nullptr; } /** @@ -523,7 +523,7 @@ count_num_descendants() const { */ void PandaNode:: add_child(PandaNode *child_node, int sort, Thread *current_thread) { - nassertv(child_node != (PandaNode *)NULL); + nassertv(child_node != nullptr); if (!verify_child_no_cycles(child_node)) { // Whoops, adding this child node would introduce a cycle in the scene @@ -596,7 +596,7 @@ remove_child(int child_index, Thread *current_thread) { */ bool PandaNode:: remove_child(PandaNode *child_node, Thread *current_thread) { - nassertr(child_node != (PandaNode *)NULL, false); + nassertr(child_node != nullptr, false); // Make sure the child node is not destructed during the execution of this // method. @@ -633,8 +633,8 @@ remove_child(PandaNode *child_node, Thread *current_thread) { bool PandaNode:: replace_child(PandaNode *orig_child, PandaNode *new_child, Thread *current_thread) { - nassertr(orig_child != (PandaNode *)NULL, false); - nassertr(new_child != (PandaNode *)NULL, false); + nassertr(orig_child != nullptr, false); + nassertr(new_child != nullptr, false); if (orig_child == new_child) { // Trivial no-op. @@ -1182,8 +1182,8 @@ reset_all_prev_transform(Thread *current_thread) { list_node = panda_node->_next; #ifndef NDEBUG - panda_node->_prev = NULL; - panda_node->_next = NULL; + panda_node->_prev = nullptr; + panda_node->_next = nullptr; #endif // NDEBUG panda_node->mark_bam_modified(); } @@ -1768,7 +1768,7 @@ is_scene_root() const { // This function pointer has to be filled in when the global GraphicsEngine // is created, because we can't link with the GraphicsEngine functions // directly. - if (_scene_root_func != (SceneRootFunc *)NULL) { + if (_scene_root_func != nullptr) { return (*_scene_root_func)(this); } return false; @@ -1906,8 +1906,8 @@ set_bounds(const BoundingVolume *volume) { Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); - if (volume == NULL) { - cdata->_user_bounds = NULL; + if (volume == nullptr) { + cdata->_user_bounds = nullptr; } else { cdata->_user_bounds = volume->make_copy(); } @@ -2091,7 +2091,7 @@ is_collision_node() const { */ Light *PandaNode:: as_light() { - return NULL; + return nullptr; } /** @@ -2135,7 +2135,7 @@ get_internal_bounds(int pipeline_stage, Thread *current_thread) const { UpdateSeq mark; { CDStageReader cdata(_cycler, pipeline_stage, current_thread); - if (cdata->_user_bounds != (BoundingVolume *)NULL) { + if (cdata->_user_bounds != nullptr) { return cdata->_user_bounds; } @@ -2152,7 +2152,7 @@ get_internal_bounds(int pipeline_stage, Thread *current_thread) const { int internal_vertices; compute_internal_bounds(internal_bounds, internal_vertices, pipeline_stage, current_thread); - nassertr(!internal_bounds.is_null(), NULL); + nassertr(!internal_bounds.is_null(), nullptr); // Now, acquire the lock, and apply the above-computed bounds. CDStageWriter cdataw(((PandaNode *)this)->_cycler, pipeline_stage); @@ -2373,13 +2373,13 @@ draw_mask_changed() { PT(PandaNode) PandaNode:: r_copy_subgraph(PandaNode::InstanceMap &inst_map, Thread *current_thread) const { PT(PandaNode) copy = make_copy(); - nassertr(copy != (PandaNode *)NULL, NULL); + nassertr(copy != nullptr, nullptr); if (copy->get_type() != get_type()) { pgraph_cat.warning() << "Don't know how to copy nodes of type " << get_type() << "\n"; if (no_unsupported_copy) { - nassertr(false, NULL); + nassertr(false, nullptr); } } @@ -2666,11 +2666,11 @@ find_node_above(PandaNode *node) { PT(NodePathComponent) PandaNode:: attach(NodePathComponent *parent, PandaNode *child_node, int sort, int pipeline_stage, Thread *current_thread) { - if (parent == (NodePathComponent *)NULL) { + if (parent == nullptr) { // Attaching to NULL means to create a new "instance" with no attachments, // and no questions asked. PT(NodePathComponent) child = - new NodePathComponent(child_node, (NodePathComponent *)NULL, + new NodePathComponent(child_node, nullptr, pipeline_stage, current_thread); LightReMutexHolder holder(child_node->_paths_lock); child_node->_paths.insert(child); @@ -2681,7 +2681,7 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort, // use that same NodePathComponent. PT(NodePathComponent) child = get_component(parent, child_node, pipeline_stage, current_thread); - if (child == (NodePathComponent *)NULL) { + if (child == nullptr) { // The child was not already attached to the parent, so get a new // component. child = get_top_component(child_node, true, pipeline_stage, current_thread); @@ -2700,7 +2700,7 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort, */ void PandaNode:: detach(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { - nassertv(child != (NodePathComponent *)NULL); + nassertv(child != nullptr); for (int pipeline_stage_i = pipeline_stage; pipeline_stage_i >= 0; @@ -2720,7 +2720,7 @@ detach(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { void PandaNode:: detach_one_stage(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { - nassertv(child != (NodePathComponent *)NULL); + nassertv(child != nullptr); if (child->is_top_node(pipeline_stage, current_thread)) { return; } @@ -2786,7 +2786,7 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, bool as_stashed, int pipeline_stage, Thread *current_thread) { bool any_ok = false; - if (new_parent != (NodePathComponent *)NULL && + if (new_parent != nullptr && !new_parent->get_node()->verify_child_no_cycles(child->get_node())) { // Whoops, adding this child node would introduce a cycle in the scene // graph. @@ -2802,7 +2802,7 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, } } - if (new_parent != (NodePathComponent *)NULL) { + if (new_parent != nullptr) { new_parent->get_node()->children_changed(); new_parent->get_node()->mark_bam_modified(); } @@ -2825,7 +2825,7 @@ bool PandaNode:: reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, int sort, bool as_stashed, int pipeline_stage, Thread *current_thread) { - nassertr(child != (NodePathComponent *)NULL, false); + nassertr(child != nullptr, false); // Keep a reference count to the new parent, since detaching the child might // lose the count. @@ -2835,7 +2835,7 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, detach(child, pipeline_stage, current_thread); } - if (new_parent != (NodePathComponent *)NULL) { + if (new_parent != nullptr) { PandaNode *child_node = child->get_node(); PandaNode *parent_node = new_parent->get_node(); @@ -2887,7 +2887,7 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, PT(NodePathComponent) PandaNode:: get_component(NodePathComponent *parent, PandaNode *child_node, int pipeline_stage, Thread *current_thread) { - nassertr(parent != (NodePathComponent *)NULL, (NodePathComponent *)NULL); + nassertr(parent != nullptr, nullptr); PandaNode *parent_node = parent->get_node(); LightReMutexHolder holder(child_node->_paths_lock); @@ -2916,7 +2916,7 @@ get_component(NodePathComponent *parent, PandaNode *child_node, return child; } else { // They aren't related. Return NULL. - return NULL; + return nullptr; } } @@ -2948,13 +2948,13 @@ get_top_component(PandaNode *child_node, bool force, int pipeline_stage, if (!force) { // If we don't care to force the point, return NULL to indicate there's // not already a top component. - return NULL; + return nullptr; } // We don't already have such a NodePathComponent; create and return a new // one. PT(NodePathComponent) child = - new NodePathComponent(child_node, (NodePathComponent *)NULL, + new NodePathComponent(child_node, nullptr, pipeline_stage, current_thread); child_node->_paths.insert(child); @@ -3169,7 +3169,7 @@ r_list_descendants(ostream &out, int indent_level) const { */ int PandaNode:: do_find_child(PandaNode *node, const PandaNode::Down *down) const { - nassertr(node != (PandaNode *)NULL, -1); + nassertr(node != nullptr, -1); // We have to search for the child by brute force, since we don't know what // sort index it was added as. @@ -3232,7 +3232,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe << "\n"; } CPT(RenderAttrib) off_clip_planes = cdata->_state->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (off_clip_planes == (RenderAttrib *)NULL) { + if (off_clip_planes == nullptr) { off_clip_planes = ClipPlaneAttrib::make(); } @@ -3261,7 +3261,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe int child_volumes_i = 0; bool all_box = true; - CPT(BoundingVolume) internal_bounds = NULL; + CPT(BoundingVolume) internal_bounds = nullptr; if (update_bounds) { child_volumes = (const BoundingVolume **)alloca(sizeof(BoundingVolume *) * (num_children + 1)); @@ -3273,7 +3273,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe #endif nassertr(child_volumes_i < num_children + 1, CDStageWriter(_cycler, pipeline_stage, cdata)); child_volumes[child_volumes_i++] = internal_bounds; - if (internal_bounds->as_bounding_box() == NULL) { + if (internal_bounds->as_bounding_box() == nullptr) { all_box = false; } } @@ -3371,7 +3371,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe #endif nassertr(child_volumes_i < num_children + 1, CDStageWriter(_cycler, pipeline_stage, cdata)); child_volumes[child_volumes_i++] = child_cdataw->_external_bounds; - if (child_cdataw->_external_bounds->as_bounding_box() == NULL) { + if (child_cdataw->_external_bounds->as_bounding_box() == nullptr) { all_box = false; } } @@ -3426,7 +3426,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe #endif nassertr(child_volumes_i < num_children + 1, CDStageWriter(_cycler, pipeline_stage, cdata)); child_volumes[child_volumes_i++] = child_cdata->_external_bounds; - if (child_cdata->_external_bounds->as_bounding_box() == NULL) { + if (child_cdata->_external_bounds->as_bounding_box() == nullptr) { all_box = false; } } @@ -3668,7 +3668,7 @@ CData() : _draw_show_mask(DrawMask::all_on()), _into_collide_mask(CollideMask::all_off()), _bounds_type(BoundingVolume::BT_default), - _user_bounds(NULL), + _user_bounds(nullptr), _final_bounds(false), _fancy_bits(0), @@ -4075,7 +4075,7 @@ fillin_down_list(PandaNode::Down &down_list, const string &tag, for (int i = 0; i < num_children; i++) { manager->read_pointer(scan); int sort = scan.get_int32(); - DownConnection connection(NULL, sort); + DownConnection connection(nullptr, sort); new_down_list.push_back(connection); } @@ -4104,7 +4104,7 @@ check_cached(bool update_bounds) const { #ifdef DO_PIPELINING node_unref_delete((CycleData *)_cdata); #endif // DO_PIPELINING - ((PandaNodePipelineReader *)this)->_cdata = NULL; + ((PandaNodePipelineReader *)this)->_cdata = nullptr; int pipeline_stage = _current_thread->get_pipeline_stage(); PandaNode::CDLockedStageReader fresh_cdata(_node->_cycler, pipeline_stage, _current_thread); if (fresh_cdata->_last_update == fresh_cdata->_next_update && diff --git a/panda/src/pgraph/pandaNodeChain.I b/panda/src/pgraph/pandaNodeChain.I index 8a401d3a80..c53beec7e7 100644 --- a/panda/src/pgraph/pandaNodeChain.I +++ b/panda/src/pgraph/pandaNodeChain.I @@ -26,6 +26,6 @@ PandaNodeChain(const char *lock_name) : */ INLINE PandaNodeChain:: ~PandaNodeChain() { - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; } diff --git a/panda/src/pgraph/pandaNode_ext.cxx b/panda/src/pgraph/pandaNode_ext.cxx index 4f0a1b4e8d..bc6427b1d0 100644 --- a/panda/src/pgraph/pandaNode_ext.cxx +++ b/panda/src/pgraph/pandaNode_ext.cxx @@ -48,7 +48,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { // Borrowed reference. PyObject *dupe = PyDict_GetItem(memo, self); - if (dupe != NULL) { + if (dupe != nullptr) { // Already in the memo dictionary. Py_INCREF(dupe); return dupe; @@ -64,7 +64,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { if (PyDict_SetItem(memo, self, dupe) != 0) { Py_DECREF(dupe); - return NULL; + return nullptr; } return dupe; @@ -120,14 +120,14 @@ set_python_tag(PyObject *key, PyObject *value) { */ PyObject *Extension:: get_python_tag(PyObject *key) const { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { Py_INCREF(Py_None); return Py_None; } PyObject *dict = ((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict; PyObject *value = PyDict_GetItem(dict, key); - if (value == NULL) { + if (value == nullptr) { value = Py_None; } // PyDict_GetItem returns a borrowed reference. @@ -142,12 +142,12 @@ get_python_tag(PyObject *key) const { */ bool Extension:: has_python_tag(PyObject *key) const { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { return false; } PyObject *dict = ((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict; - return (PyDict_GetItem(dict, key) != NULL); + return (PyDict_GetItem(dict, key) != nullptr); } /** @@ -157,12 +157,12 @@ has_python_tag(PyObject *key) const { */ void Extension:: clear_python_tag(PyObject *key) { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { return; } PyObject *dict = do_get_python_tags(); - if (PyDict_GetItem(dict, key) != NULL) { + if (PyDict_GetItem(dict, key) != nullptr) { PyDict_DelItem(dict, key); } } @@ -172,7 +172,7 @@ clear_python_tag(PyObject *key) { */ PyObject *Extension:: get_python_tag_keys() const { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { return PyTuple_New(0); } @@ -190,7 +190,7 @@ __traverse__(visitproc visit, void *arg) { // quite expensive, so I'd rather not do it unless we had some optimization // that would allow us to quickly find out whether there are children with // Python tags. - if (_this->_python_tag_data != NULL) { + if (_this->_python_tag_data != nullptr) { Py_VISIT(((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict); } return 0; @@ -201,7 +201,7 @@ __traverse__(visitproc visit, void *arg) { */ PyObject *Extension:: do_get_python_tags() { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { _this->_python_tag_data = new PythonTagDataImpl; } else if (_this->_python_tag_data->get_ref_count() > 1) { diff --git a/panda/src/pgraph/paramNodePath.cxx b/panda/src/pgraph/paramNodePath.cxx index a620144a14..32d5aeb585 100644 --- a/panda/src/pgraph/paramNodePath.cxx +++ b/panda/src/pgraph/paramNodePath.cxx @@ -45,7 +45,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // Before bam 6.40, we did not support writing NodePaths. Instaed, we // write the PandaNode pointer and pray there is an unambiguous path. if (_node_path.is_empty()) { - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); } else { manager->write_pointer(dg, _node_path.node()); } diff --git a/panda/src/pgraph/paramNodePath.h b/panda/src/pgraph/paramNodePath.h index 86f027eb99..dae621443f 100644 --- a/panda/src/pgraph/paramNodePath.h +++ b/panda/src/pgraph/paramNodePath.h @@ -21,7 +21,7 @@ /** * A class object for storing a NodePath as a parameter. */ -class EXPCL_PANDA_GOBJ ParamNodePath : public ParamValueBase { +class EXPCL_PANDA_PGRAPH ParamNodePath : public ParamValueBase { protected: INLINE ParamNodePath() {}; diff --git a/panda/src/pgraph/planeNode.I b/panda/src/pgraph/planeNode.I index e3983c1305..fd4e8d4634 100644 --- a/panda/src/pgraph/planeNode.I +++ b/panda/src/pgraph/planeNode.I @@ -42,8 +42,8 @@ set_plane(const LPlane &plane) { CDWriter cdata(_cycler); if (cdata->_plane != plane) { cdata->_plane = plane; - cdata->_front_viz = NULL; - cdata->_back_viz = NULL; + cdata->_front_viz = nullptr; + cdata->_back_viz = nullptr; } } @@ -65,8 +65,8 @@ set_viz_scale(PN_stdfloat viz_scale) { CDWriter cdata(_cycler); if (cdata->_viz_scale != viz_scale) { cdata->_viz_scale = viz_scale; - cdata->_front_viz = NULL; - cdata->_back_viz = NULL; + cdata->_front_viz = nullptr; + cdata->_back_viz = nullptr; } } diff --git a/panda/src/pgraph/planeNode.cxx b/panda/src/pgraph/planeNode.cxx index c096eaeb49..2af7609809 100644 --- a/panda/src/pgraph/planeNode.cxx +++ b/panda/src/pgraph/planeNode.cxx @@ -112,8 +112,8 @@ xform(const LMatrix4 &mat) { PandaNode::xform(mat); CDWriter cdata(_cycler); cdata->_plane = cdata->_plane * mat; - cdata->_front_viz = NULL; - cdata->_back_viz = NULL; + cdata->_front_viz = nullptr; + cdata->_back_viz = nullptr; } /** @@ -186,7 +186,7 @@ get_viz(CullTraverser *trav, CullTraverserData &data) { LPlane eye_plane = cdata->_plane * data.get_modelview_transform(trav)->get_mat(); bool front = (eye_plane.dist_to_plane(lens->get_nodal_point()) >= 0.0f); - if (cdata->_front_viz != (Geom *)NULL) { + if (cdata->_front_viz != nullptr) { return front ? cdata->_front_viz : cdata->_back_viz; } diff --git a/panda/src/pgraph/polylightNode.I b/panda/src/pgraph/polylightNode.I index 7a4fcb5899..26eafa9898 100644 --- a/panda/src/pgraph/polylightNode.I +++ b/panda/src/pgraph/polylightNode.I @@ -322,7 +322,7 @@ get_color_scenegraph() const { const RenderAttrib *attrib = PandaNode::get_attrib(ColorAttrib::get_class_type()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attrib); if (ca->get_color_type() == ColorAttrib::T_flat) { return ca->get_color(); diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index f6d45aab8f..c0fe73f73f 100644 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -39,7 +39,7 @@ PortalClipper:: PortalClipper(GeometricBoundingVolume *frustum, SceneSetup *scene_setup): _reduced_viewport_min(-1,-1), _reduced_viewport_max(1,1), -_clip_state(NULL) +_clip_state(nullptr) { _previous = new GeomNode("my_frustum"); @@ -140,7 +140,7 @@ draw_current_portal() void PortalClipper:: draw_lines() { if (!_list.empty()) { - _created_data = NULL; + _created_data = nullptr; PT(GeomVertexData) vdata = new GeomVertexData ("portal", GeomVertexFormat::get_v3cp(), Geom::UH_static); @@ -200,7 +200,7 @@ prepare_portal(const NodePath &node_path) { // Get the Portal Node from this node_path PandaNode *node = node_path.node(); - _portal_node = NULL; + _portal_node = nullptr; if (node->is_of_type(PortalNode::get_class_type())) { _portal_node = DCAST(PortalNode, node); } diff --git a/panda/src/pgraph/portalNode.cxx b/panda/src/pgraph/portalNode.cxx index dccfef23c4..8ddb409f09 100644 --- a/panda/src/pgraph/portalNode.cxx +++ b/panda/src/pgraph/portalNode.cxx @@ -180,7 +180,7 @@ combine_with(PandaNode *other) { } // Two PortalNodes with different names can't combine. - return (PandaNode *)NULL; + return nullptr; } return PandaNode::combine_with(other); @@ -273,7 +273,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // undo parent clip state and compose our new clip state ito the new // state - if (old_clip_state != NULL) { + if (old_clip_state != nullptr) { next_state = old_clip_state->invert_compose(next_state); portal_cat.spam() << "next state after removing parent state " << *next_state << endl; } @@ -376,8 +376,8 @@ CPT(RenderState) PortalNode:: get_last_pos_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha)); diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 45f8ea2fb9..66c507c1c8 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -18,8 +18,8 @@ #include "lightReMutexHolder.h" #include "pStatTimer.h" -LightReMutex *RenderAttrib::_attribs_lock = NULL; -RenderAttrib::Attribs *RenderAttrib::_attribs = NULL; +LightReMutex *RenderAttrib::_attribs_lock = nullptr; +RenderAttrib::Attribs *RenderAttrib::_attribs = nullptr; TypeHandle RenderAttrib::_type_handle; size_t RenderAttrib::_garbage_index = 0; @@ -31,7 +31,7 @@ PStatCollector RenderAttrib::_garbage_collect_pcollector("*:State Cache:Garbage */ RenderAttrib:: RenderAttrib() { - if (_attribs == (Attribs *)NULL) { + if (_attribs == nullptr) { init_attribs(); } _saved_entry = -1; @@ -155,7 +155,7 @@ int RenderAttrib:: get_num_attribs() { LightReMutexHolder holder(*_attribs_lock); - if (_attribs == (Attribs *)NULL) { + if (_attribs == nullptr) { return 0; } return _attribs->get_num_entries(); @@ -184,7 +184,7 @@ list_attribs(ostream &out) { */ int RenderAttrib:: garbage_collect() { - if (_attribs == (Attribs *)NULL || !garbage_collect_states) { + if (_attribs == nullptr || !garbage_collect_states) { return 0; } LightReMutexHolder holder(*_attribs_lock); @@ -313,7 +313,7 @@ validate_attribs() { */ CPT(RenderAttrib) RenderAttrib:: return_new(RenderAttrib *attrib) { - nassertr(attrib != (RenderAttrib *)NULL, attrib); + nassertr(attrib != nullptr, attrib); if (!uniquify_attribs) { attrib->calc_hash(); return attrib; @@ -334,7 +334,7 @@ return_new(RenderAttrib *attrib) { */ CPT(RenderAttrib) RenderAttrib:: return_unique(RenderAttrib *attrib) { - nassertr(attrib != (RenderAttrib *)NULL, attrib); + nassertr(attrib != nullptr, attrib); attrib->calc_hash(); diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index b506d64841..514a90b7d4 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -185,7 +185,7 @@ public: private: // This mutex protects _attribs. static LightReMutex *_attribs_lock; - typedef SimpleHashMap > Attribs; + typedef SimpleHashMap > Attribs; static Attribs *_attribs; int _saved_entry; diff --git a/panda/src/pgraph/renderAttribRegistry.I b/panda/src/pgraph/renderAttribRegistry.I index 5ad950dd4d..e90c306821 100644 --- a/panda/src/pgraph/renderAttribRegistry.I +++ b/panda/src/pgraph/renderAttribRegistry.I @@ -86,7 +86,7 @@ get_sorted_slot(int n) const { */ INLINE RenderAttribRegistry *RenderAttribRegistry:: get_global_ptr() { - if (_global_ptr == (RenderAttribRegistry *)NULL) { + if (_global_ptr == nullptr) { init_global_ptr(); } return _global_ptr; diff --git a/panda/src/pgraph/renderAttribRegistry.cxx b/panda/src/pgraph/renderAttribRegistry.cxx index 4c27e4c0a7..939f9753f7 100644 --- a/panda/src/pgraph/renderAttribRegistry.cxx +++ b/panda/src/pgraph/renderAttribRegistry.cxx @@ -28,7 +28,7 @@ RenderAttribRegistry() { // Reserve slot 0 for TypeHandle::none(), and for types that exceed // max_slots. - _registry.push_back(RegistryNode(TypeHandle::none(), 0, NULL)); + _registry.push_back(RegistryNode(TypeHandle::none(), 0, nullptr)); } /** @@ -86,7 +86,7 @@ register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { // it even if the state cache is disabled, because we can't read the // state_cache config variable yet at this time. It probably doesn't hurt // to have these 32 entries around in the attrib cache. - if (default_attrib != (RenderAttrib *)NULL) { + if (default_attrib != nullptr) { default_attrib->calc_hash(); if (default_attrib->_saved_entry == -1) { @@ -105,7 +105,7 @@ register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { _registry.push_back(RegistryNode(type_handle, sort, default_attrib)); _sorted_slots.push_back(slot); - ::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); + std::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); return slot; } @@ -123,7 +123,7 @@ set_slot_sort(int slot, int sort) { for (int i = 1; i < (int)_registry.size(); ++i) { _sorted_slots.push_back(i); } - ::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); + std::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); } /** diff --git a/panda/src/pgraph/renderEffect.cxx b/panda/src/pgraph/renderEffect.cxx index 585db7db26..583c04d812 100644 --- a/panda/src/pgraph/renderEffect.cxx +++ b/panda/src/pgraph/renderEffect.cxx @@ -16,7 +16,7 @@ #include "indent.h" #include "config_pgraph.h" -RenderEffect::Effects *RenderEffect::_effects = NULL; +RenderEffect::Effects *RenderEffect::_effects = nullptr; TypeHandle RenderEffect::_type_handle; /** @@ -24,7 +24,7 @@ TypeHandle RenderEffect::_type_handle; */ RenderEffect:: RenderEffect() { - if (_effects == (Effects *)NULL) { + if (_effects == nullptr) { // Make sure the global _effects map is allocated. This only has to be // done once. We could make this map static, but then we run into // problems if anyone creates a RenderState object at static init time; it @@ -169,7 +169,7 @@ write(ostream &out, int indent_level) const { */ int RenderEffect:: get_num_effects() { - if (_effects == (Effects *)NULL) { + if (_effects == nullptr) { return 0; } return _effects->size(); @@ -231,7 +231,7 @@ validate_effects() { */ CPT(RenderEffect) RenderEffect:: return_new(RenderEffect *effect) { - nassertr(effect != (RenderEffect *)NULL, effect); + nassertr(effect != nullptr, effect); // This should be a newly allocated pointer, not one that was used for // anything else. diff --git a/panda/src/pgraph/renderEffects.I b/panda/src/pgraph/renderEffects.I index 23c00f9a3b..a0ae6af279 100644 --- a/panda/src/pgraph/renderEffects.I +++ b/panda/src/pgraph/renderEffects.I @@ -37,7 +37,7 @@ Effect() { INLINE RenderEffects::Effect:: Effect(TypeHandle type) : _type(type), - _effect(NULL) + _effect(nullptr) { } diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index aaa81773ce..4ef038625d 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -29,8 +29,8 @@ #include -LightReMutex *RenderEffects::_states_lock = NULL; -RenderEffects::States *RenderEffects::_states = NULL; +LightReMutex *RenderEffects::_states_lock = nullptr; +RenderEffects::States *RenderEffects::_states = nullptr; CPT(RenderEffects) RenderEffects::_empty_state; TypeHandle RenderEffects::_type_handle; @@ -41,7 +41,7 @@ TypeHandle RenderEffects::_type_handle; */ RenderEffects:: RenderEffects() : _lock("RenderEffects") { - if (_states == (States *)NULL) { + if (_states == nullptr) { init_states(); } _saved_entry = _states->end(); @@ -123,8 +123,8 @@ xform(const LMatrix4 &mat) const { } RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = - back_inserter(new_state->_effects); + std::back_insert_iterator result = + std::back_inserter(new_state->_effects); Effects::const_iterator ai; for (ai = _effects.begin(); ai != _effects.end(); ++ai) { @@ -176,7 +176,7 @@ CPT(RenderEffects) RenderEffects:: make_empty() { // The empty state is asked for so often, we make it a special case and // store a pointer forever once we find it the first time. - if (_empty_state == (RenderEffects *)NULL) { + if (_empty_state == nullptr) { RenderEffects *state = new RenderEffects; _empty_state = return_new(state); } @@ -251,8 +251,8 @@ make(const RenderEffect *effect1, CPT(RenderEffects) RenderEffects:: add_effect(const RenderEffect *effect) const { RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = - back_inserter(new_state->_effects); + std::back_insert_iterator result = + std::back_inserter(new_state->_effects); Effect new_effect(effect); Effects::const_iterator ai = _effects.begin(); @@ -288,8 +288,8 @@ add_effect(const RenderEffect *effect) const { CPT(RenderEffects) RenderEffects:: remove_effect(TypeHandle type) const { RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = - back_inserter(new_state->_effects); + std::back_insert_iterator result = + std::back_inserter(new_state->_effects); Effects::const_iterator ai = _effects.begin(); @@ -315,7 +315,7 @@ get_effect(TypeHandle type) const { if (ai != _effects.end()) { return (*ai)._effect; } - return NULL; + return nullptr; } /** @@ -387,7 +387,7 @@ write(ostream &out, int indent_level) const { */ int RenderEffects:: get_num_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -514,7 +514,7 @@ init_states() { */ CPT(RenderEffects) RenderEffects:: return_new(RenderEffects *state) { - nassertr(state != (RenderEffects *)NULL, state); + nassertr(state != nullptr, state); #ifndef NDEBUG if (!state_cache) { @@ -580,7 +580,7 @@ determine_decal() { } const RenderEffect *effect = get_effect(DecalEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { _flags |= F_has_decal; } _flags |= F_checked_decal; @@ -598,7 +598,7 @@ determine_show_bounds() { } const RenderEffect *effect = get_effect(ShowBoundsEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { _flags |= F_has_show_bounds; const ShowBoundsEffect *sba = DCAST(ShowBoundsEffect, effect); if (sba->get_tight()) { @@ -694,7 +694,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { Effect &effect = _effects[i]; effect._effect = DCAST(RenderEffect, p_list[pi++]); - if (effect._effect == (RenderEffect *)NULL) { + if (effect._effect == nullptr) { // Remove this bogus RenderEffect pointer (it must have been from an // unwritable class). _effects.erase(_effects.begin() + i); diff --git a/panda/src/pgraph/renderState.I b/panda/src/pgraph/renderState.I index 185b18b24d..faf68f2fe2 100644 --- a/panda/src/pgraph/renderState.I +++ b/panda/src/pgraph/renderState.I @@ -67,7 +67,7 @@ remove_attrib(TypeHandle type) const { */ INLINE bool RenderState:: has_attrib(TypeHandle type) const { - return get_attrib(type) != (RenderAttrib *)NULL; + return get_attrib(type) != nullptr; } /** @@ -76,7 +76,7 @@ has_attrib(TypeHandle type) const { */ INLINE bool RenderState:: has_attrib(int slot) const { - return get_attrib(slot) != (RenderAttrib *)NULL; + return get_attrib(slot) != nullptr; } /** @@ -105,7 +105,7 @@ get_attrib(int slot) const { */ INLINE const RenderAttrib *RenderState:: get_attrib_def(int slot) const { - if (_attributes[slot]._attrib != (RenderAttrib *)NULL) { + if (_attributes[slot]._attrib != nullptr) { return _attributes[slot]._attrib; } RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); @@ -448,9 +448,9 @@ operator = (const Attribute ©) { INLINE int RenderState::Attribute:: compare_to(const Attribute &other) const { if (_attrib != other._attrib) { - if (_attrib == NULL) { + if (_attrib == nullptr) { return -1; - } else if (other._attrib == NULL) { + } else if (other._attrib == nullptr) { return 1; } @@ -490,7 +490,7 @@ template INLINE bool RenderState:: get_attrib(const AttribType *&attrib) const { attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot()); - return (attrib != (const AttribType *)NULL); + return (attrib != nullptr); } /** diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index a4d2952e50..1a8a3f0a56 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -36,9 +36,9 @@ #include "thread.h" #include "renderAttribRegistry.h" -LightReMutex *RenderState::_states_lock = NULL; -RenderState::States *RenderState::_states = NULL; -const RenderState *RenderState::_empty_state = NULL; +LightReMutex *RenderState::_states_lock = nullptr; +RenderState::States *RenderState::_states = nullptr; +const RenderState *RenderState::_empty_state = nullptr; UpdateSeq RenderState::_last_cycle_detect; size_t RenderState::_garbage_index = 0; @@ -66,14 +66,14 @@ RenderState() : _flags(0), _lock("RenderState") { - if (_states == (States *)NULL) { + if (_states == nullptr) { init_states(); } _saved_entry = -1; _last_mi = -1; _cache_stats.add_num_states(1); - _read_overrides = NULL; - _generated_shader = NULL; + _read_overrides = nullptr; + _generated_shader = nullptr; #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); @@ -97,8 +97,8 @@ RenderState(const RenderState ©) : _saved_entry = -1; _last_mi = -1; _cache_stats.add_num_states(1); - _read_overrides = NULL; - _generated_shader = NULL; + _read_overrides = nullptr; + _generated_shader = nullptr; #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); @@ -169,7 +169,7 @@ compare_sort(const RenderState &other) const { int num_sorted_slots = reg->get_num_sorted_slots(); for (int n = 0; n < num_sorted_slots; ++n) { int slot = reg->get_sorted_slot(n); - nassertr((_attributes[slot]._attrib != NULL) == _filled_slots.get_bit(slot), 0); + nassertr((_attributes[slot]._attrib != nullptr) == _filled_slots.get_bit(slot), 0); const RenderAttrib *a = _attributes[slot]._attrib; const RenderAttrib *b = other._attributes[slot]._attrib; @@ -214,7 +214,7 @@ cull_callback(CullTraverser *trav, const CullTraverserData &data) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertr(attrib._attrib != NULL, false); + nassertr(attrib._attrib != nullptr, false); if (!attrib._attrib->cull_callback(trav, data)) { return false; } @@ -362,7 +362,7 @@ compose(const RenderState *other) const { int index = _composition_cache.find(other); if (index != -1) { Composition &comp = ((RenderState *)this)->_composition_cache.modify_data(index); - if (comp._result == (const RenderState *)NULL) { + if (comp._result == nullptr) { // Well, it wasn't cached already, but we already had an entry (probably // created for the reverse direction), so use the same entry to store // the new result. @@ -397,7 +397,7 @@ compose(const RenderState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_composition_cache.is_empty()); - ((RenderState *)other)->_composition_cache[this]._result = NULL; + ((RenderState *)other)->_composition_cache[this]._result = nullptr; } if (result != (const RenderState *)this) { @@ -451,7 +451,7 @@ invert_compose(const RenderState *other) const { int index = _invert_composition_cache.find(other); if (index != -1) { Composition &comp = ((RenderState *)this)->_invert_composition_cache.modify_data(index); - if (comp._result == (const RenderState *)NULL) { + if (comp._result == nullptr) { // Well, it wasn't cached already, but we already had an entry (probably // created for the reverse direction), so use the same entry to store // the new result. @@ -485,7 +485,7 @@ invert_compose(const RenderState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_invert_composition_cache.is_empty()); - ((RenderState *)other)->_invert_composition_cache[this]._result = NULL; + ((RenderState *)other)->_invert_composition_cache[this]._result = nullptr; } if (result != (const RenderState *)this) { @@ -559,7 +559,7 @@ set_attrib(const RenderAttrib *attrib, int override) const { */ CPT(RenderState) RenderState:: remove_attrib(int slot) const { - if (_attributes[slot]._attrib == NULL) { + if (_attributes[slot]._attrib == nullptr) { // Already removed. return this; } @@ -570,7 +570,7 @@ remove_attrib(int slot) const { } RenderState *new_state = new RenderState(*this); - new_state->_attributes[slot].set(NULL, 0); + new_state->_attributes[slot].set(nullptr, 0); new_state->_filled_slots.clear_bit(slot); return return_new(new_state); } @@ -589,7 +589,7 @@ adjust_all_priorities(int adjustment) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { Attribute &attrib = new_state->_attributes[slot]; - nassertr(attrib._attrib != (RenderAttrib *)NULL, this); + nassertr(attrib._attrib != nullptr, this); attrib._override = max(attrib._override + adjustment, 0); mask.clear_bit(slot); @@ -664,7 +664,7 @@ output(ostream &out) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); out << sep << attrib._attrib->get_type(); sep = " "; @@ -689,7 +689,7 @@ write(ostream &out, int indent_level) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); attrib._attrib->write(out, indent_level); mask.clear_bit(slot); @@ -714,7 +714,7 @@ get_max_priority() { */ int RenderState:: get_num_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -736,7 +736,7 @@ get_num_states() { */ int RenderState:: get_num_unused_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -754,7 +754,7 @@ get_num_unused_states() { size_t cache_size = state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { // Here's a RenderState that's recorded in the cache. Count it. pair ir = state_count.insert(StateCount::value_type(result, 1)); @@ -768,7 +768,7 @@ get_num_unused_states() { cache_size = state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { @@ -819,7 +819,7 @@ get_num_unused_states() { */ int RenderState:: clear_cache() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -852,7 +852,7 @@ clear_cache() { size_t cache_size = (int)state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -863,7 +863,7 @@ clear_cache() { cache_size = (int)state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -893,7 +893,7 @@ int RenderState:: garbage_collect() { int num_attribs = RenderAttrib::garbage_collect(); - if (_states == (States *)NULL || !garbage_collect_states) { + if (_states == nullptr || !garbage_collect_states) { return num_attribs; } @@ -999,7 +999,7 @@ clear_munger_cache() { */ void RenderState:: list_cycles(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { return; } LightReMutexHolder holder(*_states_lock); @@ -1076,7 +1076,7 @@ list_cycles(ostream &out) { */ void RenderState:: list_states(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { out << "0 states:\n"; return; } @@ -1098,7 +1098,7 @@ list_states(ostream &out) { */ bool RenderState:: validate_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return true; } @@ -1194,7 +1194,7 @@ validate_filled_slots() const { int max_slots = reg->get_max_slots(); for (int slot = 1; slot < max_slots; ++slot) { const Attribute &attribute = _attributes[slot]; - if (attribute._attrib != (RenderAttrib *)NULL) { + if (attribute._attrib != nullptr) { mask.set_bit(slot); } } @@ -1213,7 +1213,7 @@ do_calc_hash() { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); _hash = pointer_hash::add_hash(_hash, attrib._attrib); _hash = int_hash::add_hash(_hash, attrib._override); @@ -1233,12 +1233,12 @@ do_calc_hash() { */ CPT(RenderState) RenderState:: return_new(RenderState *state) { - nassertr(state != (RenderState *)NULL, state); + nassertr(state != nullptr, state); // Make sure we don't have anything in the 0 slot. If we did, that would // indicate an uninitialized slot number. #ifndef NDEBUG - if (state->_attributes[0]._attrib != (RenderAttrib *)NULL) { + if (state->_attributes[0]._attrib != nullptr) { const RenderAttrib *attrib = state->_attributes[0]._attrib; if (attrib->get_type() == TypeHandle::none()) { ((RenderAttrib *)attrib)->force_init_type(); @@ -1255,7 +1255,7 @@ return_new(RenderState *state) { } } #endif - state->_attributes[0]._attrib = NULL; + state->_attributes[0]._attrib = nullptr; state->_filled_slots.clear_bit(0); #ifndef NDEBUG @@ -1279,7 +1279,7 @@ return_new(RenderState *state) { */ CPT(RenderState) RenderState:: return_unique(RenderState *state) { - nassertr(state != (RenderState *)NULL, NULL); + nassertr(state != nullptr, nullptr); if (!state_cache) { return state; @@ -1306,7 +1306,7 @@ return_unique(RenderState *state) { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { Attribute &attrib = state->_attributes[slot]; - nassertd(attrib._attrib != (RenderAttrib *)NULL) continue; + nassertd(attrib._attrib != nullptr) continue; attrib._attrib = attrib._attrib->get_unique(); mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); @@ -1357,12 +1357,12 @@ do_compose(const RenderState *other) const { const Attribute &b = other->_attributes[slot]; Attribute &result = new_state->_attributes[slot]; - if (a._attrib == NULL) { - nassertr(b._attrib != NULL, this); + if (a._attrib == nullptr) { + nassertr(b._attrib != nullptr, this); // B wins. result = b; - } else if (b._attrib == NULL) { + } else if (b._attrib == nullptr) { // A wins. result = a; @@ -1411,12 +1411,12 @@ do_invert_compose(const RenderState *other) const { const Attribute &b = other->_attributes[slot]; Attribute &result = new_state->_attributes[slot]; - if (a._attrib == NULL) { - nassertr(b._attrib != NULL, this); + if (a._attrib == nullptr) { + nassertr(b._attrib != nullptr, this); // B wins. result = b; - } else if (b._attrib == NULL) { + } else if (b._attrib == nullptr) { // A wins. Invert it. RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); result.set(a._attrib->invert_compose(reg->get_slot_default(slot)), 0); @@ -1441,7 +1441,7 @@ detect_and_break_cycles() { PStatTimer timer(_state_break_cycles_pcollector); ++_last_cycle_detect; - if (r_detect_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_cycles(this, this, 1, _last_cycle_detect, nullptr)) { // Ok, we have a cycle. This will be a leak unless we break the cycle by // freeing the cache on this object. if (pgraph_cat.is_debug()) { @@ -1452,7 +1452,7 @@ detect_and_break_cycles() { ((RenderState *)this)->remove_cache_pointers(); } else { ++_last_cycle_detect; - if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, nullptr)) { if (pgraph_cat.is_debug()) { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; @@ -1489,11 +1489,11 @@ r_detect_cycles(const RenderState *start_state, size_t cache_size = current_state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = current_state->_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1506,11 +1506,11 @@ r_detect_cycles(const RenderState *start_state, cache_size = current_state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = current_state->_invert_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, true); cycle_desc->push_back(entry); @@ -1553,11 +1553,11 @@ r_detect_reverse_cycles(const RenderState *start_state, nassertr(oi != -1, false); const RenderState *result = other->_composition_cache.get_data(oi)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1576,11 +1576,11 @@ r_detect_reverse_cycles(const RenderState *start_state, nassertr(oi != -1, false); const RenderState *result = other->_invert_composition_cache.get_data(oi)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1682,7 +1682,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. This may have // cascading effects as other RenderState objects are destructed, but // there will be no harm done if they destruct now. - if (ocomp._result != (const RenderState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } @@ -1690,7 +1690,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. (See comment // above.) - if (comp._result != (const RenderState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -1711,12 +1711,12 @@ remove_cache_pointers() { other->_invert_composition_cache.remove_element(oi); _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); - if (ocomp._result != (const RenderState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } } - if (comp._result != (const RenderState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -1788,7 +1788,7 @@ determine_cull_callback() { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); if (attrib._attrib->has_cull_callback()) { _flags |= F_has_cull_callback; break; @@ -1888,7 +1888,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); manager->write_pointer(dg, attrib._attrib); dg.add_int32(attrib._override); @@ -1912,7 +1912,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { int override = (*_read_overrides)[i]; RenderAttrib *attrib = DCAST(RenderAttrib, p_list[pi++]); - if (attrib != (RenderAttrib *)NULL) { + if (attrib != nullptr) { int slot = attrib->get_slot(); if (slot > 0 && slot < reg->get_max_slots()) { _attributes[slot].set(attrib, override); @@ -1923,7 +1923,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } delete _read_overrides; - _read_overrides = NULL; + _read_overrides = nullptr; return pi; } diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 433582fd2c..053f8cc365 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -227,7 +227,7 @@ private: // cache, which is encoded in _composition_cache and // _invert_composition_cache. static LightReMutex *_states_lock; - typedef SimpleHashMap > States; + typedef SimpleHashMap > States; static States *_states; static const RenderState *_empty_state; diff --git a/panda/src/pgraph/renderState_ext.cxx b/panda/src/pgraph/renderState_ext.cxx index 0dc0d8acc5..2b7e3a4791 100644 --- a/panda/src/pgraph/renderState_ext.cxx +++ b/panda/src/pgraph/renderState_ext.cxx @@ -37,7 +37,7 @@ get_composition_cache() const { PyObject *tuple = PyTuple_New(2); PyObject *a, *b; const RenderState *source = _this->_composition_cache.get_key(i); - if (source == (RenderState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -46,7 +46,7 @@ get_composition_cache() const { true, true, source->get_type_index()); } const RenderState *result = _this->_composition_cache.get_data(i)._result; - if (result == (RenderState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -85,7 +85,7 @@ get_invert_composition_cache() const { PyObject *tuple = PyTuple_New(2); PyObject *a, *b; const RenderState *source = _this->_invert_composition_cache.get_key(i); - if (source == (RenderState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -94,7 +94,7 @@ get_invert_composition_cache() const { true, true, source->get_type_index()); } const RenderState *result = _this->_invert_composition_cache.get_data(i)._result; - if (result == (RenderState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -118,7 +118,7 @@ get_invert_composition_cache() const { PyObject *Extension:: get_states() { extern struct Dtool_PyTypedObject Dtool_RenderState; - if (RenderState::_states == (RenderState::States *)NULL) { + if (RenderState::_states == nullptr) { return PyList_New(0); } LightReMutexHolder holder(*RenderState::_states_lock); diff --git a/panda/src/pgraph/sceneGraphReducer.I b/panda/src/pgraph/sceneGraphReducer.I index 4319b118df..2db336c546 100644 --- a/panda/src/pgraph/sceneGraphReducer.I +++ b/panda/src/pgraph/sceneGraphReducer.I @@ -77,7 +77,7 @@ get_combine_radius() const { INLINE void SceneGraphReducer:: apply_attribs(PandaNode *node, int attrib_types) { nassertv(check_live_flatten(node)); - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); PStatTimer timer(_apply_collector); AccumulatedAttribs attribs; r_apply_attribs(node, attribs, attrib_types, _transformer); @@ -93,7 +93,7 @@ apply_attribs(PandaNode *node, int attrib_types) { INLINE void SceneGraphReducer:: apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); r_apply_attribs(node, attribs, attrib_types, transformer); } @@ -115,7 +115,7 @@ apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, */ INLINE int SceneGraphReducer:: make_compatible_format(PandaNode *root, int collect_bits) { - nassertr(root != (PandaNode *)NULL, 0); + nassertr(root != nullptr, 0); nassertr(check_live_flatten(root), 0); PStatTimer timer(_collect_collector); int count = 0; @@ -137,7 +137,7 @@ make_compatible_format(PandaNode *root, int collect_bits) { */ INLINE int SceneGraphReducer:: collect_vertex_data(PandaNode *root, int collect_bits) { - nassertr(root != (PandaNode *)NULL, 0); + nassertr(root != nullptr, 0); nassertr(check_live_flatten(root), 0); PStatTimer timer(_collect_collector); int count = 0; @@ -155,7 +155,7 @@ collect_vertex_data(PandaNode *root, int collect_bits) { */ INLINE int SceneGraphReducer:: make_nonindexed(PandaNode *root, int nonindexed_bits) { - nassertr(root != (PandaNode *)NULL, 0); + nassertr(root != nullptr, 0); nassertr(check_live_flatten(root), 0); PStatTimer timer(_make_nonindexed_collector); return r_make_nonindexed(root, nonindexed_bits); @@ -171,9 +171,9 @@ make_nonindexed(PandaNode *root, int nonindexed_bits) { */ INLINE void SceneGraphReducer:: premunge(PandaNode *root, const RenderState *initial_state) { - nassertv(root != (PandaNode *)NULL); + nassertv(root != nullptr); nassertv(check_live_flatten(root)); - if (_gsg != (GraphicsStateGuardianBase *)NULL) { + if (_gsg != nullptr) { PStatTimer timer(_premunge_collector); r_premunge(root, initial_state); } diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index d0dc3e4411..3b1e075a90 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -42,7 +42,7 @@ PStatCollector SceneGraphReducer::_premunge_collector("*:Premunge"); */ void SceneGraphReducer:: set_gsg(GraphicsStateGuardianBase *gsg) { - if (gsg != (GraphicsStateGuardianBase *)NULL) { + if (gsg != nullptr) { _gsg = gsg; } else { _gsg = GraphicsStateGuardianBase::get_default_gsg(); @@ -50,7 +50,7 @@ set_gsg(GraphicsStateGuardianBase *gsg) { int max_vertices = max_collect_vertices; - if (_gsg != (GraphicsStateGuardianBase *)NULL) { + if (_gsg != nullptr) { max_vertices = min(max_vertices, _gsg->get_max_vertices_per_array()); } @@ -64,7 +64,7 @@ set_gsg(GraphicsStateGuardianBase *gsg) { */ void SceneGraphReducer:: clear_gsg() { - _gsg = NULL; + _gsg = nullptr; _transformer.set_max_collect_vertices(max_collect_vertices); } @@ -180,7 +180,7 @@ unify(PandaNode *root, bool preserve_order) { PStatTimer timer(_unify_collector); int max_indices = max_collect_indices; - if (_gsg != (GraphicsStateGuardianBase *)NULL) { + if (_gsg != nullptr) { max_indices = min(max_indices, _gsg->get_max_vertices_per_primitive()); } r_unify(root, max_indices, preserve_order); @@ -578,7 +578,7 @@ flatten_siblings(PandaNode *parent_node, int combine_siblings_bits) { if (consider_siblings(parent_node, child1, child2)) { PT(PandaNode) new_node = do_flatten_siblings(parent_node, child1, child2); - if (new_node != (PandaNode *)NULL) { + if (new_node != nullptr) { // We successfully collapsed a node. (*ai1_hold) = new_node; nodes.erase(ai2_hold); @@ -655,7 +655,7 @@ do_flatten_child(PandaNode *grandparent_node, PandaNode *parent_node, } PT(PandaNode) new_parent = collapse_nodes(parent_node, child_node, false); - if (new_parent == (PandaNode *)NULL) { + if (new_parent == nullptr) { if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "Decided not to collapse " << *parent_node @@ -689,12 +689,12 @@ do_flatten_siblings(PandaNode *parent_node, PandaNode *child1, } PT(PandaNode) new_child = collapse_nodes(child2, child1, true); - if (new_child == (PandaNode *)NULL) { + if (new_child == nullptr) { if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "Decided not to collapse " << *child1 << " and " << *child2 << "\n"; } - return NULL; + return nullptr; } choose_name(new_child, child2, child1); @@ -717,7 +717,7 @@ do_flatten_siblings(PandaNode *parent_node, PandaNode *child1, PT(PandaNode) SceneGraphReducer:: collapse_nodes(PandaNode *node1, PandaNode *node2, bool siblings) { PT(PandaNode) result = node2->combine_with(node1); - if (result == NULL) { + if (result == nullptr) { result = node1->combine_with(node2); } return result; diff --git a/panda/src/pgraph/sceneGraphReducer.h b/panda/src/pgraph/sceneGraphReducer.h index 5d9550856a..ec898d5820 100644 --- a/panda/src/pgraph/sceneGraphReducer.h +++ b/panda/src/pgraph/sceneGraphReducer.h @@ -38,7 +38,7 @@ class PandaNode; */ class EXPCL_PANDA_PGRAPH SceneGraphReducer { PUBLISHED: - INLINE explicit SceneGraphReducer(GraphicsStateGuardianBase *gsg = NULL); + INLINE explicit SceneGraphReducer(GraphicsStateGuardianBase *gsg = nullptr); INLINE ~SceneGraphReducer(); enum AttribTypes { diff --git a/panda/src/pgraph/sceneSetup.I b/panda/src/pgraph/sceneSetup.I index 425c538d85..cf420ee132 100644 --- a/panda/src/pgraph/sceneSetup.I +++ b/panda/src/pgraph/sceneSetup.I @@ -16,7 +16,7 @@ */ INLINE SceneSetup:: SceneSetup() { - _display_region = NULL; + _display_region = nullptr; _viewport_width = 0; _viewport_height = 0; _inverted = false; @@ -175,7 +175,7 @@ get_cull_center() const { INLINE PT(BoundingVolume) SceneSetup:: get_cull_bounds() const { PT(BoundingVolume) bounds = _camera_node->get_cull_bounds(); - if (bounds != (BoundingVolume *)NULL) { + if (bounds != nullptr) { return bounds; } diff --git a/panda/src/pgraph/scissorAttrib.cxx b/panda/src/pgraph/scissorAttrib.cxx index e1c3c29e01..f6281cd083 100644 --- a/panda/src/pgraph/scissorAttrib.cxx +++ b/panda/src/pgraph/scissorAttrib.cxx @@ -44,7 +44,7 @@ ScissorAttrib(const LVecBase4 &frame) : */ CPT(RenderAttrib) ScissorAttrib:: make_off() { - if (_off_attrib != NULL) { + if (_off_attrib != nullptr) { return _off_attrib; } ScissorAttrib *attrib = new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f)); diff --git a/panda/src/pgraph/scissorEffect.cxx b/panda/src/pgraph/scissorEffect.cxx index 9794250346..8e0d47ca9e 100644 --- a/panda/src/pgraph/scissorEffect.cxx +++ b/panda/src/pgraph/scissorEffect.cxx @@ -58,7 +58,7 @@ ScissorEffect(const ScissorEffect ©) : */ CPT(RenderEffect) ScissorEffect:: make_screen(const LVecBase4 &frame, bool clip) { - ScissorEffect *effect = new ScissorEffect(true, frame, NULL, 0, clip); + ScissorEffect *effect = new ScissorEffect(true, frame, nullptr, 0, clip); return return_new(effect); } @@ -69,7 +69,7 @@ make_screen(const LVecBase4 &frame, bool clip) { */ CPT(RenderEffect) ScissorEffect:: make_node(bool clip) { - ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), NULL, 0, clip); + ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), nullptr, 0, clip); return return_new(effect); } @@ -273,7 +273,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, // Set up the culling. We do this by extruding the four corners of the // frame into the eight corners of the bounding frustum. PT(GeometricBoundingVolume) frustum = make_frustum(lens, frame); - if (frustum != (GeometricBoundingVolume *)NULL) { + if (frustum != nullptr) { frustum->xform(modelview_transform->get_inverse()->get_mat()); data._view_frustum = frustum; } @@ -362,7 +362,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { */ TypedWritable *ScissorEffect:: make_from_bam(const FactoryParams ¶ms) { - ScissorEffect *effect = new ScissorEffect(true, LVecBase4::zero(), NULL, 0, false); + ScissorEffect *effect = new ScissorEffect(true, LVecBase4::zero(), nullptr, 0, false); DatagramIterator scan; BamReader *manager; @@ -415,28 +415,28 @@ make_frustum(const Lens *lens, const LVecBase4 &frame) const{ // Upper left. if (!lens->extrude(corner, nul, ful)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } corner[0] = f2[1]; corner[1] = f2[3]; // Upper right. if (!lens->extrude(corner, nur, fur)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } corner[0] = f2[1]; corner[1] = f2[2]; // Lower right. if (!lens->extrude(corner, nlr, flr)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } corner[0] = f2[0]; corner[1] = f2[2]; // Lower left. if (!lens->extrude(corner, nll, fll)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } return new BoundingHexahedron(fll, flr, fur, ful, nll, nlr, nur, nul); diff --git a/panda/src/pgraph/shaderAttrib.I b/panda/src/pgraph/shaderAttrib.I index 6513604ae9..baea58607f 100644 --- a/panda/src/pgraph/shaderAttrib.I +++ b/panda/src/pgraph/shaderAttrib.I @@ -18,7 +18,7 @@ */ INLINE ShaderAttrib:: ShaderAttrib() : - _shader(NULL), + _shader(nullptr), _shader_priority(0), _auto_shader(false), _has_shader(false), diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 130d85c1b8..982497497e 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -39,7 +39,7 @@ int ShaderAttrib::_attrib_slot; CPT(RenderAttrib) ShaderAttrib:: make_off() { static CPT(RenderAttrib) _off_attrib; - if (_off_attrib == 0) { + if (_off_attrib == nullptr) { ShaderAttrib *attrib = new ShaderAttrib; attrib->_has_shader = true; _off_attrib = return_new(attrib); @@ -53,12 +53,12 @@ make_off() { CPT(RenderAttrib) ShaderAttrib:: make(const Shader *shader, int priority) { static CPT(RenderAttrib) _null_attrib; - if (_null_attrib == 0) { + if (_null_attrib == nullptr) { ShaderAttrib *attrib = new ShaderAttrib; _null_attrib = return_new(attrib); } - if (shader == NULL) { + if (shader == nullptr) { return _null_attrib; } else { return DCAST(ShaderAttrib, _null_attrib)->set_shader(shader, priority); @@ -93,7 +93,7 @@ set_shader(const Shader *s, int priority) const { CPT(RenderAttrib) ShaderAttrib:: set_shader_off(int priority) const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = priority; result->_auto_shader = false; result->_auto_normal_on = false; @@ -112,7 +112,7 @@ set_shader_off(int priority) const { CPT(RenderAttrib) ShaderAttrib:: set_shader_auto(int priority) const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = priority; result->_auto_shader = true; result->_has_shader = true; @@ -132,7 +132,7 @@ CPT(RenderAttrib) ShaderAttrib:: set_shader_auto(BitMask32 shader_switch, int priority) const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = priority; result->_auto_shader = true; result->_has_shader = true; @@ -151,7 +151,7 @@ set_shader_auto(BitMask32 shader_switch, int priority) const { CPT(RenderAttrib) ShaderAttrib:: clear_shader() const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = 0; result->_auto_shader = false; result->_has_shader = false; @@ -355,7 +355,7 @@ get_shader_input_vector(InternalName *id) const { } else if (p.get_value_type() == ShaderInput::M_param) { // Temporary solution until the new param system TypedWritableReferenceCount *param = p.get_value(); - if (param != NULL && param->is_of_type(ParamVecBase4::get_class_type())) { + if (param != nullptr && param->is_of_type(ParamVecBase4::get_class_type())) { return ((const ParamVecBase4 *)param)->get_value(); } } @@ -385,14 +385,14 @@ get_shader_input_ptr(const InternalName *id) const { ostringstream strm; strm << "Shader input " << id->get_name() << " is not a PTA(float/double) type.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } return &(p.get_ptr()); } else { ostringstream strm; strm << "Shader input " << id->get_name() << " is not present.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } @@ -431,14 +431,14 @@ get_shader_input_texture(const InternalName *id, SamplerState *sampler) const { ostringstream strm; strm << "Shader input " << id->get_name() << " is not a texture.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } else { ostringstream strm; strm << "Shader input " << id->get_name() << " is not present.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } @@ -506,20 +506,20 @@ get_shader_input_buffer(const InternalName *id) const { ostringstream strm; strm << "Shader input " << id->get_name() << " is not present.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } else { const ShaderInput &p = (*i).second; if (p.get_value_type() == ShaderInput::M_buffer) { ShaderBuffer *value; - DCAST_INTO_R(value, p._value, NULL); + DCAST_INTO_R(value, p._value, nullptr); return value; } ostringstream strm; strm << "Shader input " << id->get_name() << " is not a ShaderBuffer.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h index 02a3189233..33af01fc99 100644 --- a/panda/src/pgraph/shaderAttrib.h +++ b/panda/src/pgraph/shaderAttrib.h @@ -42,7 +42,7 @@ private: INLINE ShaderAttrib(const ShaderAttrib ©); PUBLISHED: - static CPT(RenderAttrib) make(const Shader *shader = NULL, int priority = 0); + static CPT(RenderAttrib) make(const Shader *shader = nullptr, int priority = 0); static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make_default(); @@ -115,7 +115,7 @@ PUBLISHED: const NodePath &get_shader_input_nodepath(const InternalName *id) const; LVecBase4 get_shader_input_vector(InternalName *id) const; - Texture *get_shader_input_texture(const InternalName *id, SamplerState *sampler=NULL) const; + Texture *get_shader_input_texture(const InternalName *id, SamplerState *sampler=nullptr) const; const Shader::ShaderPtrData *get_shader_input_ptr(const InternalName *id) const; const LMatrix4 &get_shader_input_matrix(const InternalName *id, LMatrix4 &matrix) const; ShaderBuffer *get_shader_input_buffer(const InternalName *id) const; diff --git a/panda/src/pgraph/shaderInput.cxx b/panda/src/pgraph/shaderInput.cxx index 86a3912ec4..a1d698cce7 100644 --- a/panda/src/pgraph/shaderInput.cxx +++ b/panda/src/pgraph/shaderInput.cxx @@ -110,7 +110,7 @@ get_texture() const { return DCAST(Texture, _value); default: - return NULL; + return nullptr; } } diff --git a/panda/src/pgraph/shaderPool.I b/panda/src/pgraph/shaderPool.I index 3139ff2daf..074a24e147 100644 --- a/panda/src/pgraph/shaderPool.I +++ b/panda/src/pgraph/shaderPool.I @@ -27,7 +27,7 @@ has_shader(const Filename &filename) { */ INLINE bool ShaderPool:: verify_shader(const Filename &filename) { - return load_shader(filename) != (Shader *)NULL; + return load_shader(filename) != nullptr; } /** diff --git a/panda/src/pgraph/shaderPool.cxx b/panda/src/pgraph/shaderPool.cxx index ba9f99e8c2..87823b9e50 100644 --- a/panda/src/pgraph/shaderPool.cxx +++ b/panda/src/pgraph/shaderPool.cxx @@ -19,7 +19,7 @@ #include "shader.h" #include "string_utils.h" -ShaderPool *ShaderPool::_global_ptr = (ShaderPool *)NULL; +ShaderPool *ShaderPool::_global_ptr = nullptr; /** * Lists the contents of the shader pool to the indicated output stream. @@ -89,9 +89,9 @@ ns_load_shader(const Filename &orig_filename) { } PT(Shader) shader = Shader::load(filename, lang); - if (shader == (Shader *)NULL) { + if (shader == nullptr) { // This shader was not found or could not be read. - return NULL; + return nullptr; } { @@ -211,7 +211,7 @@ resolve_filename(Filename &new_filename, const Filename &orig_filename) { */ ShaderPool *ShaderPool:: get_ptr() { - if (_global_ptr == (ShaderPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ShaderPool; } return _global_ptr; diff --git a/panda/src/pgraph/texGenAttrib.cxx b/panda/src/pgraph/texGenAttrib.cxx index 451eacab83..9842d1158f 100644 --- a/panda/src/pgraph/texGenAttrib.cxx +++ b/panda/src/pgraph/texGenAttrib.cxx @@ -38,7 +38,7 @@ CPT(RenderAttrib) TexGenAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new TexGenAttrib); } diff --git a/panda/src/pgraph/texMatrixAttrib.cxx b/panda/src/pgraph/texMatrixAttrib.cxx index 4e2e1adba8..a228b79072 100644 --- a/panda/src/pgraph/texMatrixAttrib.cxx +++ b/panda/src/pgraph/texMatrixAttrib.cxx @@ -38,7 +38,7 @@ CPT(RenderAttrib) TexMatrixAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new TexMatrixAttrib); } @@ -148,7 +148,7 @@ get_num_stages() const { */ TextureStage *TexMatrixAttrib:: get_stage(int n) const { - nassertr(n >= 0 && n < (int)_stages.size(), NULL); + nassertr(n >= 0 && n < (int)_stages.size(), nullptr); return _stages[n]._stage; } @@ -504,7 +504,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { override = scan.get_int32(); } - StageNode sn(NULL); + StageNode sn(nullptr); sn._override = override; _stages.push_back(sn); } diff --git a/panda/src/pgraph/texProjectorEffect.I b/panda/src/pgraph/texProjectorEffect.I index 35e699476e..067d023574 100644 --- a/panda/src/pgraph/texProjectorEffect.I +++ b/panda/src/pgraph/texProjectorEffect.I @@ -34,7 +34,7 @@ TexProjectorEffect(const TexProjectorEffect ©) : */ INLINE TexProjectorEffect::StageDef:: StageDef() : - _to_lens_node(NULL) + _to_lens_node(nullptr) { } diff --git a/panda/src/pgraph/texProjectorEffect.cxx b/panda/src/pgraph/texProjectorEffect.cxx index a8f0078dea..5d850ab0f5 100644 --- a/panda/src/pgraph/texProjectorEffect.cxx +++ b/panda/src/pgraph/texProjectorEffect.cxx @@ -39,7 +39,7 @@ CPT(RenderEffect) TexProjectorEffect:: make() { // We make it a special case and store a pointer to the empty effect forever // once we find it the first time, as an optimization. - if (_empty_effect == (RenderEffect *)NULL) { + if (_empty_effect == nullptr) { _empty_effect = return_new(new TexProjectorEffect); } @@ -189,18 +189,18 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) transform = def._from.get_transform(def._to); - if (def._to_lens_node != (LensNode *)NULL && - def._to_lens_node->get_lens() != (Lens *)NULL) { + if (def._to_lens_node != nullptr && + def._to_lens_node->get_lens() != nullptr) { // Get the lens's projection matrix, as a TransformState. Lens *lens = def._to_lens_node->get_lens(def._lens_index); - if (lens != NULL) { + if (lens != nullptr) { CPT(TransformState) projmat = TransformState::make_mat(lens->get_projection_mat()); // We need a special transform to convert the -0.5, 0.5 centering of // the lens's projection matrix to UV's in the range of (0, 1). static CPT(TransformState) fixmat; - if (fixmat == (TransformState *)NULL) { + if (fixmat == nullptr) { fixmat = TransformState::make_pos_hpr_scale (LVecBase3(0.5f, 0.5f, 0.0f), LVecBase3(0.0f, 0.0f, 0.0f), @@ -357,6 +357,6 @@ set_to(const NodePath &to) { if (!_to.is_empty() && _to.node()->is_of_type(LensNode::get_class_type())) { DCAST_INTO_V(_to_lens_node, _to.node()); } else { - _to_lens_node = (LensNode *)NULL; + _to_lens_node = nullptr; } } diff --git a/panda/src/pgraph/textureAttrib.I b/panda/src/pgraph/textureAttrib.I index da1feca0be..9ee2f69f62 100644 --- a/panda/src/pgraph/textureAttrib.I +++ b/panda/src/pgraph/textureAttrib.I @@ -60,7 +60,7 @@ is_off() const { INLINE Texture *TextureAttrib:: get_texture() const { if (_on_stages.empty()) { - return NULL; + return nullptr; } check_sorted(); return get_on_texture(filter_to_max(1)->get_on_stage(0)); @@ -80,7 +80,7 @@ get_num_on_stages() const { */ INLINE TextureStage *TextureAttrib:: get_on_stage(int n) const { - nassertr(n >= 0 && n < (int)_render_stages.size(), (TextureStage *)NULL); + nassertr(n >= 0 && n < (int)_render_stages.size(), nullptr); return _render_stages[n]->_stage; } @@ -101,7 +101,7 @@ get_num_on_ff_stages() const { */ INLINE TextureStage *TextureAttrib:: get_on_ff_stage(int n) const { - nassertr(n >= 0 && n < (int)_render_ff_stages.size(), (TextureStage *)NULL); + nassertr(n >= 0 && n < (int)_render_ff_stages.size(), nullptr); return _render_ff_stages[n]->_stage; } @@ -137,7 +137,7 @@ get_on_texture(TextureStage *stage) const { if (si != _on_stages.end()) { return (*si)._texture; } - return NULL; + return nullptr; } /** @@ -183,7 +183,7 @@ get_num_off_stages() const { */ INLINE TextureStage *TextureAttrib:: get_off_stage(int n) const { - nassertr(n >= 0 && n < (int)_off_stages.size(), (TextureStage *)NULL); + nassertr(n >= 0 && n < (int)_off_stages.size(), nullptr); return _off_stages[n]._stage; } diff --git a/panda/src/pgraph/textureAttrib.cxx b/panda/src/pgraph/textureAttrib.cxx index ee3c5a8165..49bf20f5b9 100644 --- a/panda/src/pgraph/textureAttrib.cxx +++ b/panda/src/pgraph/textureAttrib.cxx @@ -52,7 +52,7 @@ CPT(RenderAttrib) TextureAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new TextureAttrib); } @@ -67,7 +67,7 @@ CPT(RenderAttrib) TextureAttrib:: make_all_off() { // We make it a special case and store a pointer to the off attrib forever // once we find it the first time, as an optimization. - if (_all_off_attrib == (RenderAttrib *)NULL) { + if (_all_off_attrib == nullptr) { TextureAttrib *attrib = new TextureAttrib; attrib->_off_all_stages = true; _all_off_attrib = return_new(attrib); @@ -768,7 +768,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { for (si = _on_stages.begin(); si != _on_stages.end(); ++si) { TextureStage *stage = (*si)._stage; Texture *tex = (*si)._texture; - nassertv(tex != (Texture *)NULL); + nassertv(tex != nullptr); manager->write_pointer(dg, stage); manager->write_pointer(dg, tex); @@ -811,7 +811,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { // have to do anything special here. Texture *tex = DCAST(Texture, p_list[pi++]); - if (tex != (Texture *)NULL) { + if (tex != nullptr) { StageNode &sn = _on_stages[sni]; sn._stage = ts; sn._texture = tex; @@ -867,7 +867,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _off_stages.reserve(num_off_stages); for (i = 0; i < num_off_stages; i++) { manager->read_pointer(scan); - _off_stages.push_back(StageNode(NULL)); + _off_stages.push_back(StageNode(nullptr)); } // Read the _on_stages data. @@ -893,7 +893,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _next_implicit_sort = max(_next_implicit_sort, implicit_sort + 1); Stages::iterator si = - _on_stages.insert_nonunique(StageNode(NULL, _next_implicit_sort, override)); + _on_stages.insert_nonunique(StageNode(nullptr, _next_implicit_sort, override)); ++_next_implicit_sort; if (manager->get_file_minor_ver() >= 36) { @@ -923,8 +923,8 @@ sort_on_stages() { StageNode &sn = (*si); TextureStage *stage = sn._stage; Texture *texture = sn._texture; - nassertv(stage != NULL); - nassertv(texture != NULL); + nassertv(stage != nullptr); + nassertv(texture != nullptr); if (stage->is_fixed_function() && texture->get_texture_type() != Texture::TT_2d_texture_array) { const InternalName *name = stage->get_texcoord_name(); diff --git a/panda/src/pgraph/textureStageCollection.cxx b/panda/src/pgraph/textureStageCollection.cxx index 4f707efe63..33e3ce00a6 100644 --- a/panda/src/pgraph/textureStageCollection.cxx +++ b/panda/src/pgraph/textureStageCollection.cxx @@ -184,7 +184,7 @@ find_texture_stage(const string &name) const { return texture_stage; } } - return NULL; + return nullptr; } /** @@ -200,7 +200,7 @@ get_num_texture_stages() const { */ TextureStage *TextureStageCollection:: get_texture_stage(int index) const { - nassertr(index >= 0 && index < (int)_texture_stages.size(), NULL); + nassertr(index >= 0 && index < (int)_texture_stages.size(), nullptr); return _texture_stages[index]; } @@ -211,7 +211,7 @@ get_texture_stage(int index) const { */ TextureStage *TextureStageCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_texture_stages.size(), NULL); + nassertr(index >= 0 && index < (int)_texture_stages.size(), nullptr); return _texture_stages[index]; } @@ -231,8 +231,8 @@ size() const { */ void TextureStageCollection:: sort() { - ::sort(_texture_stages.begin(), _texture_stages.end(), - CompareTextureStageSort()); + std::sort(_texture_stages.begin(), _texture_stages.end(), + CompareTextureStageSort()); } /** diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index c66bd3a281..a58bd78510 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -24,8 +24,8 @@ #include "lightMutexHolder.h" #include "thread.h" -LightReMutex *TransformState::_states_lock = NULL; -TransformState::States *TransformState::_states = NULL; +LightReMutex *TransformState::_states_lock = nullptr; +TransformState::States *TransformState::_states = nullptr; CPT(TransformState) TransformState::_identity_state; CPT(TransformState) TransformState::_invalid_state; UpdateSeq TransformState::_last_cycle_detect; @@ -55,12 +55,12 @@ TypeHandle TransformState::_type_handle; */ TransformState:: TransformState() : _lock("TransformState") { - if (_states == (States *)NULL) { + if (_states == nullptr) { init_states(); } _saved_entry = -1; _flags = F_is_identity | F_singular_known | F_is_2d; - _inv_mat = (LMatrix4 *)NULL; + _inv_mat = nullptr; _cache_stats.add_num_states(1); #ifdef DO_MEMORY_USAGE @@ -79,9 +79,9 @@ TransformState:: set_destructing(); // Free the inverse matrix computation, if it has been stored. - if (_inv_mat != (LMatrix4 *)NULL) { + if (_inv_mat != nullptr) { delete _inv_mat; - _inv_mat = (LMatrix4 *)NULL; + _inv_mat = nullptr; } LightReMutexHolder holder(*_states_lock); @@ -235,7 +235,7 @@ CPT(TransformState) TransformState:: make_identity() { // The identity state is asked for so often, we make it a special case and // store a pointer forever once we find it the first time. - if (_identity_state == (TransformState *)NULL) { + if (_identity_state == nullptr) { TransformState *state = new TransformState; _identity_state = return_unique(state); } @@ -249,7 +249,7 @@ make_identity() { */ CPT(TransformState) TransformState:: make_invalid() { - if (_invalid_state == (TransformState *)NULL) { + if (_invalid_state == nullptr) { TransformState *state = new TransformState; state->_flags = F_is_invalid | F_singular_known | F_is_singular | F_components_known | F_mat_known; _invalid_state = return_unique(state); @@ -647,7 +647,7 @@ compose(const TransformState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_composition_cache.is_empty()); - other->_composition_cache[this]._result = NULL; + other->_composition_cache[this]._result = nullptr; } if (result != (TransformState *)this) { @@ -753,7 +753,7 @@ invert_compose(const TransformState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_invert_composition_cache.is_empty()); - other->_invert_composition_cache[this]._result = NULL; + other->_invert_composition_cache[this]._result = nullptr; } if (result != (TransformState *)this) { @@ -829,7 +829,7 @@ validate_composition_cache() const { size_t size = _composition_cache.get_num_entries(); for (size_t i = 0; i < size; ++i) { const TransformState *source = _composition_cache.get_key(i); - if (source != (TransformState *)NULL) { + if (source != nullptr) { // Check that the source also has a pointer back to this one. We always // add entries to the composition cache in pairs. int ri = source->_composition_cache.find(this); @@ -849,7 +849,7 @@ validate_composition_cache() const { size = _invert_composition_cache.get_num_entries(); for (size_t i = 0; i < size; ++i) { const TransformState *source = _invert_composition_cache.get_key(i); - if (source != (TransformState *)NULL) { + if (source != nullptr) { // Check that the source also has a pointer back to this one. We always // add entries to the composition cache in pairs. int ri = source->_invert_composition_cache.find(this); @@ -982,7 +982,7 @@ write_composition_cache(ostream &out, int indent_level) const { */ int TransformState:: get_num_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -1004,7 +1004,7 @@ get_num_states() { */ int TransformState:: get_num_unused_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -1023,7 +1023,7 @@ get_num_unused_states() { size_t cache_size = state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { // Here's a TransformState that's recorded in the cache. Count it. pair ir = state_count.insert(StateCount::value_type(result, 1)); @@ -1037,7 +1037,7 @@ get_num_unused_states() { cache_size = state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { @@ -1089,7 +1089,7 @@ get_num_unused_states() { */ int TransformState:: clear_cache() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -1122,7 +1122,7 @@ clear_cache() { size_t cache_size = state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -1133,7 +1133,7 @@ clear_cache() { cache_size = state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -1159,7 +1159,7 @@ clear_cache() { */ int TransformState:: garbage_collect() { - if (_states == (States *)NULL || !garbage_collect_states) { + if (_states == nullptr || !garbage_collect_states) { return 0; } @@ -1248,7 +1248,7 @@ garbage_collect() { */ void TransformState:: list_cycles(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { return; } LightReMutexHolder holder(*_states_lock); @@ -1325,7 +1325,7 @@ list_cycles(ostream &out) { */ void TransformState:: list_states(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { out << "0 states:\n"; return; } @@ -1347,7 +1347,7 @@ list_states(ostream &out) { */ bool TransformState:: validate_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return true; } @@ -1438,7 +1438,7 @@ init_states() { */ CPT(TransformState) TransformState:: return_new(TransformState *state) { - nassertr(state != (TransformState *)NULL, state); + nassertr(state != nullptr, state); if (!uniquify_transforms && !state->is_identity()) { return state; } @@ -1457,7 +1457,7 @@ return_new(TransformState *state) { */ CPT(TransformState) TransformState:: return_unique(TransformState *state) { - nassertr(state != (TransformState *)NULL, state); + nassertr(state != nullptr, state); if (!transform_cache) { return state; @@ -1663,7 +1663,7 @@ do_invert_compose(const TransformState *other) const { pgraph_cat.warning() << "Unexpected singular matrix found for " << *this << "\n"; } else { - nassertr(_inv_mat != (LMatrix4 *)NULL, make_invalid()); + nassertr(_inv_mat != nullptr, make_invalid()); LMatrix4 new_mat; new_mat.multiply(other->get_mat(), *_inv_mat); if (!new_mat.almost_equal(result->get_mat(), 0.1)) { @@ -1687,7 +1687,7 @@ do_invert_compose(const TransformState *other) const { // Now that is_singular() has returned false, we can assume that _inv_mat // has been allocated and filled in. - nassertr(_inv_mat != (LMatrix4 *)NULL, make_invalid()); + nassertr(_inv_mat != nullptr, make_invalid()); if (is_2d() && other->is_2d()) { const LMatrix4 &i = *_inv_mat; @@ -1717,7 +1717,7 @@ detect_and_break_cycles() { PStatTimer timer(_transform_break_cycles_pcollector); ++_last_cycle_detect; - if (r_detect_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_cycles(this, this, 1, _last_cycle_detect, nullptr)) { // Ok, we have a cycle. This will be a leak unless we break the cycle by // freeing the cache on this object. if (pgraph_cat.is_debug()) { @@ -1728,7 +1728,7 @@ detect_and_break_cycles() { remove_cache_pointers(); } else { ++_last_cycle_detect; - if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, nullptr)) { if (pgraph_cat.is_debug()) { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; @@ -1765,11 +1765,11 @@ r_detect_cycles(const TransformState *start_state, size_t cache_size = current_state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = current_state->_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1782,11 +1782,11 @@ r_detect_cycles(const TransformState *start_state, cache_size = current_state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = current_state->_invert_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, true); cycle_desc->push_back(entry); @@ -1829,11 +1829,11 @@ r_detect_reverse_cycles(const TransformState *start_state, nassertr(oi != -1, false); const TransformState *result = other->_composition_cache.get_data(oi)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1852,11 +1852,11 @@ r_detect_reverse_cycles(const TransformState *start_state, nassertr(oi != -1, false); const TransformState *result = other->_invert_composition_cache.get_data(oi)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1961,7 +1961,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. This may have // cascading effects as other TransformState objects are destructed, // but there will be no harm done if they destruct now. - if (ocomp._result != (const TransformState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } @@ -1969,7 +1969,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. (See comment // above.) - if (comp._result != (const TransformState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -1990,12 +1990,12 @@ remove_cache_pointers() { other->_invert_composition_cache.remove_element(oi); _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); - if (ocomp._result != (const TransformState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } } - if (comp._result != (const TransformState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -2077,7 +2077,7 @@ calc_singular() { // is asking whether we're singular). // This should be NULL if no one has called calc_singular() yet. - nassertv(_inv_mat == (LMatrix4 *)NULL); + nassertv(_inv_mat == nullptr); _inv_mat = new LMatrix4; if ((_flags & F_mat_known) == 0) { @@ -2088,7 +2088,7 @@ calc_singular() { if (!inverted) { _flags |= F_is_singular; delete _inv_mat; - _inv_mat = (LMatrix4 *)NULL; + _inv_mat = nullptr; } _flags |= F_singular_known; } diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 5edd8985d6..e204402489 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -252,7 +252,7 @@ private: // cache, which is encoded in _composition_cache and // _invert_composition_cache. static LightReMutex *_states_lock; - typedef SimpleHashMap > States; + typedef SimpleHashMap > States; static States *_states; static CPT(TransformState) _identity_state; static CPT(TransformState) _invalid_state; diff --git a/panda/src/pgraph/transformState_ext.cxx b/panda/src/pgraph/transformState_ext.cxx index 44ddfd71f8..08a47b92cd 100644 --- a/panda/src/pgraph/transformState_ext.cxx +++ b/panda/src/pgraph/transformState_ext.cxx @@ -41,7 +41,7 @@ get_composition_cache() const { PyObject *a, *b; const TransformState *source = _this->_composition_cache.get_key(si); - if (source == (TransformState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -50,7 +50,7 @@ get_composition_cache() const { true, true, source->get_type_index()); } const TransformState *result = _this->_composition_cache.get_data(si)._result; - if (result == (TransformState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -96,7 +96,7 @@ get_invert_composition_cache() const { PyObject *a, *b; const TransformState *source = _this->_invert_composition_cache.get_key(si); - if (source == (TransformState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -105,7 +105,7 @@ get_invert_composition_cache() const { true, true, source->get_type_index()); } const TransformState *result = _this->_invert_composition_cache.get_data(si)._result; - if (result == (TransformState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -132,7 +132,7 @@ get_invert_composition_cache() const { PyObject *Extension:: get_states() { extern struct Dtool_PyTypedObject Dtool_TransformState; - if (TransformState::_states == (TransformState::States *)NULL) { + if (TransformState::_states == nullptr) { return PyList_New(0); } LightReMutexHolder holder(*TransformState::_states_lock); @@ -163,7 +163,7 @@ get_states() { PyObject *Extension:: get_unused_states() { extern struct Dtool_PyTypedObject Dtool_TransformState; - if (TransformState::_states == (TransformState::States *)NULL) { + if (TransformState::_states == nullptr) { return PyList_New(0); } LightReMutexHolder holder(*TransformState::_states_lock); diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index 613afe0800..8191821b12 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -79,7 +79,7 @@ operator bool () const { */ INLINE bool WeakNodePath:: is_empty() const { - return _head == (NodePathComponent *)NULL || _head.was_deleted(); + return _head == nullptr || _head.was_deleted(); } /** @@ -88,7 +88,7 @@ is_empty() const { */ INLINE bool WeakNodePath:: was_deleted() const { - return _head != (NodePathComponent *)NULL && _head.was_deleted(); + return _head != nullptr && _head.was_deleted(); } /** diff --git a/panda/src/pgraph/workingNodePath.I b/panda/src/pgraph/workingNodePath.I index b74921827b..ad5c80ba18 100644 --- a/panda/src/pgraph/workingNodePath.I +++ b/panda/src/pgraph/workingNodePath.I @@ -19,7 +19,7 @@ INLINE WorkingNodePath:: WorkingNodePath(const NodePath &start) { nassertv(!start.is_empty()); - _next = (WorkingNodePath *)NULL; + _next = nullptr; _start = start._head; _node = start.node(); } @@ -33,8 +33,8 @@ WorkingNodePath(const WorkingNodePath ©) : _start(copy._start), _node(copy._node) { - nassertv(_next != (WorkingNodePath *)NULL || - _start != (NodePathComponent *)NULL); + nassertv(_next != nullptr || + _start != nullptr); } /** @@ -66,8 +66,8 @@ operator = (const WorkingNodePath ©) { _start = copy._start; _node = copy._node; - nassertv(_next != (WorkingNodePath *)NULL || - _start != (NodePathComponent *)NULL); + nassertv(_next != nullptr || + _start != nullptr); } /** @@ -78,7 +78,7 @@ INLINE NodePath WorkingNodePath:: get_node_path() const { NodePath result; result._head = r_get_node_path(); - nassertr(result._head != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(result._head != nullptr, NodePath::fail()); return result; } diff --git a/panda/src/pgraph/workingNodePath.cxx b/panda/src/pgraph/workingNodePath.cxx index 42e8bd7141..af9a1fb8e8 100644 --- a/panda/src/pgraph/workingNodePath.cxx +++ b/panda/src/pgraph/workingNodePath.cxx @@ -20,11 +20,11 @@ */ bool WorkingNodePath:: is_valid() const { - if (_node == (PandaNode *)NULL) { + if (_node == nullptr) { return false; } - if (_next == (WorkingNodePath *)NULL) { - return (_start != (NodePathComponent *)NULL); + if (_next == nullptr) { + return (_start != nullptr); } nassertr(_node != _next->_node, false); @@ -39,7 +39,7 @@ is_valid() const { */ int WorkingNodePath:: get_num_nodes() const { - if (_next == (WorkingNodePath *)NULL) { + if (_next == nullptr) { Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); return _start->get_length(pipeline_stage, current_thread); @@ -55,12 +55,12 @@ get_num_nodes() const { */ PandaNode *WorkingNodePath:: get_node(int index) const { - nassertr(index >= 0, NULL); + nassertr(index >= 0, nullptr); if (index == 0) { return _node; } - if (_next == (WorkingNodePath *)NULL) { + if (_next == nullptr) { return get_node_path().get_node(index - 1); } @@ -83,22 +83,22 @@ output(ostream &out) const { */ PT(NodePathComponent) WorkingNodePath:: r_get_node_path() const { - if (_next == (WorkingNodePath *)NULL) { - nassertr(_start != (NodePathComponent *)NULL, NULL); + if (_next == nullptr) { + nassertr(_start != nullptr, nullptr); return _start; } - nassertr(_start == (NodePathComponent *)NULL, NULL); - nassertr(_node != (PandaNode *)NULL, NULL); + nassertr(_start == nullptr, nullptr); + nassertr(_node != nullptr, nullptr); PT(NodePathComponent) comp = _next->r_get_node_path(); - nassertr(comp != (NodePathComponent *)NULL, NULL); + nassertr(comp != nullptr, nullptr); Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); PT(NodePathComponent) result = PandaNode::get_component(comp, _node, pipeline_stage, current_thread); - if (result == (NodePathComponent *)NULL) { + if (result == nullptr) { // This means we found a disconnected chain in the WorkingNodePath's // ancestry: the node above this node isn't connected. In this case, // don't attempt to go higher; just truncate the NodePath at the bottom of diff --git a/panda/src/pgraphnodes/callbackNode.I b/panda/src/pgraphnodes/callbackNode.I index 4db6cb59de..6314f124e3 100644 --- a/panda/src/pgraphnodes/callbackNode.I +++ b/panda/src/pgraphnodes/callbackNode.I @@ -44,7 +44,7 @@ set_cull_callback(CallbackObject *object) { */ INLINE void CallbackNode:: clear_cull_callback() { - set_cull_callback(NULL); + set_cull_callback(nullptr); } /** @@ -86,7 +86,7 @@ set_draw_callback(CallbackObject *object) { */ INLINE void CallbackNode:: clear_draw_callback() { - set_draw_callback(NULL); + set_draw_callback(nullptr); } /** diff --git a/panda/src/pgraphnodes/callbackNode.cxx b/panda/src/pgraphnodes/callbackNode.cxx index 17424d5a0a..12018de8da 100644 --- a/panda/src/pgraphnodes/callbackNode.cxx +++ b/panda/src/pgraphnodes/callbackNode.cxx @@ -90,7 +90,7 @@ safe_to_combine() const { bool CallbackNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { CallbackObject *cbobj = get_cull_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { NodeCullCallbackData cbdata(trav, data); cbobj->do_callback(&cbdata); @@ -130,9 +130,9 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // CullableObject for the draw_callback, if any. We don't need to pass any // Geoms, however. CallbackObject *cbobj = get_draw_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { CullableObject *object = - new CullableObject(NULL, data._state, + new CullableObject(nullptr, data._state, data.get_internal_transform(trav)); object->set_draw_callback(cbobj); trav->get_cull_handler()->record_object(object, trav); diff --git a/panda/src/pgraphnodes/computeNode.cxx b/panda/src/pgraphnodes/computeNode.cxx index 7962378afa..0a55d988ef 100644 --- a/panda/src/pgraphnodes/computeNode.cxx +++ b/panda/src/pgraphnodes/computeNode.cxx @@ -93,7 +93,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // CullableObject for the Dispatcher. We don't need to pass any Geoms, // however. CullableObject *object = - new CullableObject(NULL, data._state, + new CullableObject(nullptr, data._state, data.get_internal_transform(trav)); object->set_draw_callback(_dispatcher); trav->get_cull_handler()->record_object(object, trav); diff --git a/panda/src/pgraphnodes/fadeLodNode.cxx b/panda/src/pgraphnodes/fadeLodNode.cxx index de952457e8..92141d7f2d 100644 --- a/panda/src/pgraphnodes/fadeLodNode.cxx +++ b/panda/src/pgraphnodes/fadeLodNode.cxx @@ -99,7 +99,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { double now = ClockObject::get_global_clock()->get_frame_time(); - if (ldata == (AuxSceneData *)NULL || now > ldata->get_expiration_time()) { + if (ldata == nullptr || now > ldata->get_expiration_time()) { // This is the first time we have rendered this instance of this LOD node // in a while. ldata = new FadeLODNodeData; @@ -169,7 +169,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // drawing the old LOD opaque with z writing on if (out_child >= 0 && out_child < get_num_children()) { PandaNode *child = get_child(out_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_out(data, child); next_data_out._state = next_data_out._state->compose(get_fade_1_old_state()); @@ -179,7 +179,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (in_child >= 0 && in_child < get_num_children()) { PandaNode *child = get_child(in_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_in(data, child); PN_stdfloat in_alpha = elapsed / half_fade_time; @@ -194,7 +194,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // draw the opaque new LOD with z write on if (in_child >= 0 && in_child < get_num_children()) { PandaNode *child = get_child(in_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_in(data, child); next_data_in._state = next_data_in._state->compose(get_fade_2_new_state()); @@ -204,7 +204,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (out_child >= 0 && out_child < get_num_children()) { PandaNode *child = get_child(out_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_out(data, child); PN_stdfloat out_alpha = 1.0f - (elapsed - half_fade_time) / half_fade_time; @@ -224,7 +224,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { int index = ldata->_fade_in; if (index >= 0 && index < get_num_children()) { PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data(data, child); trav->traverse(next_data); } @@ -278,7 +278,7 @@ set_fade_state_override(int override) { */ CPT(RenderState) FadeLODNode:: get_fade_1_old_state() { - if (_fade_1_old_state == (const RenderState *)NULL) { + if (_fade_1_old_state == nullptr) { _fade_1_old_state = RenderState::make_empty(); } @@ -291,7 +291,7 @@ get_fade_1_old_state() { */ CPT(RenderState) FadeLODNode:: get_fade_1_new_state(PN_stdfloat in_alpha) { - if (_fade_1_new_state == (const RenderState *)NULL) { + if (_fade_1_new_state == nullptr) { _fade_1_new_state = RenderState::make (TransparencyAttrib::make(TransparencyAttrib::M_alpha), CullBinAttrib::make(_fade_bin_name, _fade_bin_draw_order), @@ -310,7 +310,7 @@ get_fade_1_new_state(PN_stdfloat in_alpha) { */ CPT(RenderState) FadeLODNode:: get_fade_2_old_state(PN_stdfloat out_alpha) { - if (_fade_2_old_state == (const RenderState *)NULL) { + if (_fade_2_old_state == nullptr) { _fade_2_old_state = RenderState::make (TransparencyAttrib::make(TransparencyAttrib::M_alpha), DepthWriteAttrib::make(DepthWriteAttrib::M_off), @@ -329,7 +329,7 @@ get_fade_2_old_state(PN_stdfloat out_alpha) { */ CPT(RenderState) FadeLODNode:: get_fade_2_new_state() { - if (_fade_2_new_state == (const RenderState *)NULL) { + if (_fade_2_new_state == nullptr) { _fade_2_new_state = RenderState::make (DepthOffsetAttrib::make(), _fade_state_override); diff --git a/panda/src/pgraphnodes/lightLensNode.I b/panda/src/pgraphnodes/lightLensNode.I index 1df14eb971..9c59b6c998 100644 --- a/panda/src/pgraphnodes/lightLensNode.I +++ b/panda/src/pgraphnodes/lightLensNode.I @@ -110,7 +110,7 @@ INLINE GraphicsOutputBase *LightLensNode:: get_shadow_buffer(GraphicsStateGuardianBase *gsg) { ShadowBuffers::iterator it = _sbuffers.find(gsg); if (it == _sbuffers.end()) { - return NULL; + return nullptr; } else { return (*it).second; } diff --git a/panda/src/pgraphnodes/lodNode.cxx b/panda/src/pgraphnodes/lodNode.cxx index 4c2ca87528..e39f0d0c97 100644 --- a/panda/src/pgraphnodes/lodNode.cxx +++ b/panda/src/pgraphnodes/lodNode.cxx @@ -160,7 +160,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (in_range) { // This switch level is in range. Draw its children. PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data(data, child); trav->traverse(next_data); } @@ -384,7 +384,7 @@ show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { // wireframe mode. if (index < get_num_children()) { PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data3(data, child); next_data3._state = next_data3._state->compose(sw.get_viz_model_state()); trav->traverse(next_data3); @@ -524,7 +524,7 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, if (index < get_num_children()) { const Switch &sw = cdata->_switch_vector[index]; PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { UpdateSeq seq; CPT(BoundingVolume) bv = child->get_bounds(seq); diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.cxx b/panda/src/pgraphnodes/nodeCullCallbackData.cxx index b0cbd9d980..e4ee2acdb1 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.cxx +++ b/panda/src/pgraphnodes/nodeCullCallbackData.cxx @@ -47,9 +47,9 @@ upcall() { // CullableObject for the draw_callback, if any. We don't need to pass // any Geoms, however. CallbackObject *cbobj = cbnode->get_draw_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { CullableObject *object = - new CullableObject(NULL, _data._state, + new CullableObject(nullptr, _data._state, _data.get_internal_transform(_trav)); object->set_draw_callback(cbobj); _trav->get_cull_handler()->record_object(object, _trav); diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx index b24678b333..7e374721f6 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx @@ -284,7 +284,7 @@ collect_statistics(PandaNode *node, bool under_instance) { _num_nodes_with_attribs++; const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { collect_statistics(ta->get_on_texture(ta->get_on_stage(i))); @@ -336,7 +336,7 @@ collect_statistics(PandaNode *node, bool under_instance) { */ void SceneGraphAnalyzer:: collect_statistics(GeomNode *geom_node) { - nassertv(geom_node != (GeomNode *)NULL); + nassertv(geom_node != nullptr); ++_num_geom_nodes; @@ -351,7 +351,7 @@ collect_statistics(GeomNode *geom_node) { const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { collect_statistics(ta->get_on_texture(ta->get_on_stage(i))); @@ -477,7 +477,7 @@ collect_statistics(const Geom *geom) { */ void SceneGraphAnalyzer:: collect_statistics(Texture *texture) { - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); Textures::iterator ti = _textures.find(texture); if (ti == _textures.end()) { @@ -506,7 +506,7 @@ collect_statistics(Texture *texture) { */ void SceneGraphAnalyzer:: collect_statistics(const GeomVertexArrayData *vadata) { - nassertv(vadata != NULL); + nassertv(vadata != nullptr); bool inserted = _vadatas.insert(vadata).second; if (inserted) { // This is the first time we've encountered this vertex array. @@ -523,7 +523,7 @@ collect_statistics(const GeomVertexArrayData *vadata) { */ void SceneGraphAnalyzer:: collect_prim_statistics(const GeomVertexArrayData *vadata) { - nassertv(vadata != NULL); + nassertv(vadata != nullptr); bool inserted = _prim_vadatas.insert(vadata).second; if (inserted) { // This is the first time we've encountered this vertex array. diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 372bd89e1d..af4410aea2 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -288,8 +288,6 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { } } - bool normal_mapping = key._lighting && shader_attrib->auto_normal_on(); - // See if there is a normal map, height map, gloss map, or glow map. Also // check if anything has TexGen. @@ -355,7 +353,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { if (parallax_mapping_samples == 0) { info._mode = TextureStage::M_normal; } else if (!shader_attrib->auto_normal_on() || - (!key._lighting && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { + (key._lights.empty() && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { info._mode = TextureStage::M_height; info._flags = ShaderKey::TF_has_alpha; } else { @@ -364,7 +362,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { break; case TextureStage::M_normal_gloss: - if (!shader_attrib->auto_gloss_on() || !key._lighting) { + if (!shader_attrib->auto_gloss_on() || key._lights.empty()) { info._mode = TextureStage::M_normal; } else if (!shader_attrib->auto_normal_on()) { info._mode = TextureStage::M_gloss; @@ -413,7 +411,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { switch (info._mode) { case TextureStage::M_normal: if (!shader_attrib->auto_normal_on() || - (!key._lighting && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { + (key._lights.empty() && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { skip = true; } else { info._flags = ShaderKey::TF_map_normal; @@ -427,7 +425,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { } break; case TextureStage::M_gloss: - if (key._lighting && shader_attrib->auto_gloss_on()) { + if (!key._lights.empty() && shader_attrib->auto_gloss_on()) { info._flags = ShaderKey::TF_map_gloss; } else { skip = true; @@ -663,23 +661,23 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { // These variables will hold the results of register allocation. - const char *tangent_freg = 0; - const char *binormal_freg = 0; + const char *tangent_freg = nullptr; + const char *binormal_freg = nullptr; string tangent_input; string binormal_input; pmap texcoord_fregs; pvector lightcoord_fregs; - const char *world_position_freg = 0; - const char *world_normal_freg = 0; - const char *eye_position_freg = 0; - const char *eye_normal_freg = 0; - const char *hpos_freg = 0; + const char *world_position_freg = nullptr; + const char *world_normal_freg = nullptr; + const char *eye_position_freg = nullptr; + const char *eye_normal_freg = nullptr; + const char *hpos_freg = nullptr; const char *position_vreg; - const char *transform_weight_vreg = 0; + const char *transform_weight_vreg = nullptr; const char *normal_vreg; - const char *color_vreg = 0; - const char *transform_index_vreg = 0; + const char *color_vreg = nullptr; + const char *transform_index_vreg = nullptr; if (_use_generic_attr) { position_vreg = "ATTR0"; diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index 99432a904b..5935485ceb 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -123,7 +123,7 @@ write(ostream &out, int indent_level) const { } Lens *lens = get_lens(); - if (lens != (Lens *)NULL) { + if (lens != nullptr) { lens->write(out, indent_level + 2); } } @@ -214,12 +214,12 @@ bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id) { void Spotlight:: fill_viz_geom(GeomNode *viz_geom) { Lens *lens = get_lens(); - if (lens == (Lens *)NULL) { + if (lens == nullptr) { return; } PT(Geom) geom = lens->make_geometry(); - if (geom == (Geom *)NULL) { + if (geom == nullptr) { return; } diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index dec418c9fd..2e15320b8f 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -23,7 +23,7 @@ INLINE bool PGEntry:: set_text(const string &text) { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != (TextNode *)NULL, false); + nassertr(text_node != nullptr, false); return set_wtext(text_node->decode_text(text)); } @@ -38,7 +38,7 @@ INLINE string PGEntry:: get_plain_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != (TextNode *)NULL, string()); + nassertr(text_node != nullptr, string()); return text_node->encode_wtext(get_plain_wtext()); } @@ -51,7 +51,7 @@ INLINE string PGEntry:: get_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != (TextNode *)NULL, string()); + nassertr(text_node != nullptr, string()); return text_node->encode_wtext(get_wtext()); } diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index c9f84fae4f..bc8fb204c7 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -49,7 +49,7 @@ PGEntry(const string &name) : _max_width = 0.0f; _num_lines = 1; _accept_enabled = true; - _last_text_def = (TextNode *)NULL; + _last_text_def = nullptr; _text_geom_stale = true; _text_geom_flattened = true; _blink_start = 0.0f; @@ -117,7 +117,7 @@ PGEntry(const PGEntry ©) : _overflow_mode(copy._overflow_mode) { _cursor_stale = true; - _last_text_def = (TextNode *)NULL; + _last_text_def = nullptr; _text_geom_stale = true; _text_geom_flattened = true; @@ -642,7 +642,7 @@ void PGEntry:: set_text_def(int state, TextNode *node) { LightReMutexHolder holder(_lock); nassertv(state >= 0 && state < 1000); // Sanity check. - if (node == (TextNode *)NULL && state >= (int)_text_defs.size()) { + if (node == nullptr && state >= (int)_text_defs.size()) { // If we're setting it to NULL, we don't need to slot a new one. return; } @@ -662,7 +662,7 @@ get_text_def(int state) const { // If we don't have a definition, use the global one. return get_text_node(); } - if (_text_defs[state] == (TextNode *)NULL) { + if (_text_defs[state] == nullptr) { return get_text_node(); } return _text_defs[state]; @@ -715,7 +715,7 @@ is_wtext() const { void PGEntry:: slot_text_def(int state) { while (state >= (int)_text_defs.size()) { - _text_defs.push_back((TextNode *)NULL); + _text_defs.push_back(nullptr); } } @@ -725,7 +725,7 @@ slot_text_def(int state) { void PGEntry:: update_text() { TextNode *node = get_text_def(get_state()); - nassertv(node != (TextNode *)NULL); + nassertv(node != nullptr); if (_text_geom_stale || node != _last_text_def) { TextProperties props = *node; @@ -846,7 +846,7 @@ update_text() { void PGEntry:: update_cursor() { TextNode *node = get_text_def(get_state()); - nassertv(node != (TextNode *)NULL); + nassertv(node != nullptr); _cursor_scale.set_mat(node->get_transform()); _cursor_scale.set_color(node->get_text_color()); diff --git a/panda/src/pgui/pgFrameStyle.cxx b/panda/src/pgui/pgFrameStyle.cxx index c2106e3ef2..0f0458265c 100644 --- a/panda/src/pgui/pgFrameStyle.cxx +++ b/panda/src/pgui/pgFrameStyle.cxx @@ -191,7 +191,7 @@ generate_into(const NodePath &parent, const LVecBase4 &frame, break; } - if (new_node != (PandaNode *)NULL && _color[3] != 1.0f) { + if (new_node != nullptr && _color[3] != 1.0f) { // We've got some alpha on the color; we need transparency. new_node->set_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha)); } diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index 7d00a0e595..ce2c9f0532 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -42,11 +42,11 @@ get_region() const { INLINE void PGItem:: set_notify(PGItemNotify *notify) { LightReMutexHolder holder(_lock); - if (_notify != (PGItemNotify *)NULL) { + if (_notify != nullptr) { _notify->remove_item(this); } _notify = notify; - if (_notify != (PGItemNotify *)NULL) { + if (_notify != nullptr) { _notify->add_item(this); } } @@ -58,7 +58,7 @@ set_notify(PGItemNotify *notify) { INLINE bool PGItem:: has_notify() const { LightReMutexHolder holder(_lock); - return (_notify != (PGItemNotify *)NULL); + return (_notify != nullptr); } /** diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index 53966e26d7..da3dfe86ba 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -37,7 +37,7 @@ TypeHandle PGItem::_type_handle; PT(TextNode) PGItem::_text_node; -PGItem *PGItem::_focus_item = (PGItem *)NULL; +PGItem *PGItem::_focus_item = nullptr; PGItem::BackgroundFocus PGItem::_background_focus; @@ -59,7 +59,7 @@ PGItem(const string &name) : { set_cull_callback(); - _notify = NULL; + _notify = nullptr; _has_frame = false; _frame.set(0, 0, 0, 0); _region = new PGMouseWatcherRegion(this); @@ -72,17 +72,17 @@ PGItem(const string &name) : */ PGItem:: ~PGItem() { - if (_notify != (PGItemNotify *)NULL) { + if (_notify != nullptr) { _notify->remove_item(this); - _notify = NULL; + _notify = nullptr; } nassertv(_region->_item == this); - _region->_item = (PGItem *)NULL; + _region->_item = nullptr; set_background_focus(false); if (_focus_item == this) { - _focus_item = (PGItem *)NULL; + _focus_item = nullptr; } } @@ -100,7 +100,7 @@ PGItem(const PGItem ©) : , _sounds(copy._sounds) #endif { - _notify = NULL; + _notify = nullptr; _region = new PGMouseWatcherRegion(this); // We give our region the same name as the region for the PGItem we're @@ -415,7 +415,7 @@ activate_region(const LMatrix4 &transform, int sort, } LVecBase4 frame; - if (cpa != (ClipPlaneAttrib *)NULL && cpa->get_num_on_planes() != 0) { + if (cpa != nullptr && cpa->get_num_on_planes() != 0) { // Apply the clip plane(s) andor scissor region now that we are here in // world space. @@ -462,7 +462,7 @@ activate_region(const LMatrix4 &transform, int sort, max(max(ll[up_axis], lr[up_axis]), max(ul[up_axis], ur[up_axis]))); } - if (sa != (ScissorAttrib *)NULL) { + if (sa != nullptr) { // Also restrict it to within the scissor region. const LVecBase4 &sf = sa->get_frame(); // Expand sf from 0..1 to -1..1. @@ -835,7 +835,7 @@ set_focus(bool focus) { // Set the keyboard focus to this item. if (_focus_item != this) { - if (_focus_item != (PGItem *)NULL) { + if (_focus_item != nullptr) { // Clear the focus from whatever item currently has it. _focus_item->set_focus(false); } @@ -849,7 +849,7 @@ set_focus(bool focus) { } else { if (_focus_item == this) { // Remove this item from the focus. - _focus_item = (PGItem *)NULL; + _focus_item = nullptr; } if (get_focus()) { @@ -1033,7 +1033,7 @@ get_sound(const string &event) const { if (si != _sounds.end()) { return (*si).second; } - return (AudioSound *)NULL; + return nullptr; } /** @@ -1054,7 +1054,7 @@ has_sound(const string &event) const { */ TextNode *PGItem:: get_text_node() { - if (_text_node == (TextNode *)NULL) { + if (_text_node == nullptr) { _text_node = new TextNode("pguiText"); _text_node->set_text_color(0.0f, 0.0f, 0.0f, 1.0f); @@ -1093,7 +1093,7 @@ play_sound(const string &event) { */ void PGItem:: reduce_region(LVecBase4 &frame, PGItem *obscurer) const { - if (obscurer != (PGItem *)NULL && !obscurer->is_overall_hidden()) { + if (obscurer != nullptr && !obscurer->is_overall_hidden()) { LVecBase4 oframe = get_relative_frame(obscurer); // Determine the four rectangular regions on the four sides of the diff --git a/panda/src/pgui/pgItemNotify.cxx b/panda/src/pgui/pgItemNotify.cxx index 52f01dc63b..da232d6a95 100644 --- a/panda/src/pgui/pgItemNotify.cxx +++ b/panda/src/pgui/pgItemNotify.cxx @@ -23,7 +23,7 @@ PGItemNotify:: // Disconnect all of the items that are connected to this object. PGItem *item = (*_items.begin()); nassertv(item->get_notify() == this); - (*_items.begin())->set_notify(NULL); + (*_items.begin())->set_notify(nullptr); } } diff --git a/panda/src/pgui/pgMouseWatcherGroup.I b/panda/src/pgui/pgMouseWatcherGroup.I index db3ce6b80a..f0ae87c891 100644 --- a/panda/src/pgui/pgMouseWatcherGroup.I +++ b/panda/src/pgui/pgMouseWatcherGroup.I @@ -25,5 +25,5 @@ PGMouseWatcherGroup(PGTop *top) : _top(top) { INLINE void PGMouseWatcherGroup:: clear_top(PGTop *top) { nassertv(_top == top); - _top = (PGTop *)NULL; + _top = nullptr; } diff --git a/panda/src/pgui/pgMouseWatcherGroup.cxx b/panda/src/pgui/pgMouseWatcherGroup.cxx index ccc3e91f31..d5f14976ce 100644 --- a/panda/src/pgui/pgMouseWatcherGroup.cxx +++ b/panda/src/pgui/pgMouseWatcherGroup.cxx @@ -23,8 +23,8 @@ PGMouseWatcherGroup:: ~PGMouseWatcherGroup() { // When the MouseWatcherGroup destructs for whatever reason, the PGTop // object should lose its MouseWatcher. - if (_top != (PGTop *)NULL) { - _top->_watcher_group = (PGMouseWatcherGroup *)NULL; - _top->set_mouse_watcher((MouseWatcher *)NULL); + if (_top != nullptr) { + _top->_watcher_group = nullptr; + _top->set_mouse_watcher(nullptr); } } diff --git a/panda/src/pgui/pgMouseWatcherRegion.cxx b/panda/src/pgui/pgMouseWatcherRegion.cxx index 6e0a18daad..2f0155722f 100644 --- a/panda/src/pgui/pgMouseWatcherRegion.cxx +++ b/panda/src/pgui/pgMouseWatcherRegion.cxx @@ -47,7 +47,7 @@ PGMouseWatcherRegion:: */ void PGMouseWatcherRegion:: enter_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->enter_region(param); } } @@ -60,7 +60,7 @@ enter_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: exit_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->exit_region(param); } } @@ -73,7 +73,7 @@ exit_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: within_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->within_region(param); } } @@ -84,7 +84,7 @@ within_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: without_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->without_region(param); } } @@ -95,7 +95,7 @@ without_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: press(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->press(param, false); } } @@ -106,7 +106,7 @@ press(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: release(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->release(param, false); } } @@ -116,7 +116,7 @@ release(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: keystroke(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->keystroke(param, false); } } @@ -127,7 +127,7 @@ keystroke(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: candidate(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->candidate(param, false); } } @@ -138,7 +138,7 @@ candidate(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: move(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->move(param); } } diff --git a/panda/src/pgui/pgScrollFrame.I b/panda/src/pgui/pgScrollFrame.I index ede2f4201e..69353db31b 100644 --- a/panda/src/pgui/pgScrollFrame.I +++ b/panda/src/pgui/pgScrollFrame.I @@ -127,11 +127,11 @@ get_auto_hide() const { INLINE void PGScrollFrame:: set_horizontal_slider(PGSliderBar *horizontal_slider) { LightReMutexHolder holder(_lock); - if (_horizontal_slider != (PGSliderBar *)NULL) { - _horizontal_slider->set_notify(NULL); + if (_horizontal_slider != nullptr) { + _horizontal_slider->set_notify(nullptr); } _horizontal_slider = horizontal_slider; - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { _horizontal_slider->set_notify(this); } _needs_recompute_clip = true; @@ -143,7 +143,7 @@ set_horizontal_slider(PGSliderBar *horizontal_slider) { */ INLINE void PGScrollFrame:: clear_horizontal_slider() { - set_horizontal_slider(NULL); + set_horizontal_slider(nullptr); } /** @@ -164,11 +164,11 @@ get_horizontal_slider() const { INLINE void PGScrollFrame:: set_vertical_slider(PGSliderBar *vertical_slider) { LightReMutexHolder holder(_lock); - if (_vertical_slider != (PGSliderBar *)NULL) { - _vertical_slider->set_notify(NULL); + if (_vertical_slider != nullptr) { + _vertical_slider->set_notify(nullptr); } _vertical_slider = vertical_slider; - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { _vertical_slider->set_notify(this); } _needs_recompute_clip = true; @@ -180,7 +180,7 @@ set_vertical_slider(PGSliderBar *vertical_slider) { */ INLINE void PGScrollFrame:: clear_vertical_slider() { - set_vertical_slider(NULL); + set_vertical_slider(nullptr); } /** diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index e930ba3b15..c35ea7b395 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -30,8 +30,8 @@ PGScrollFrame(const string &name) : PGVirtualFrame(name) _virtual_frame.set(0.0f, 0.0f, 0.0f, 0.0f); _manage_pieces = false; _auto_hide = false; - _horizontal_slider = NULL; - _vertical_slider = NULL; + _horizontal_slider = nullptr; + _vertical_slider = nullptr; } /** @@ -39,8 +39,8 @@ PGScrollFrame(const string &name) : PGVirtualFrame(name) */ PGScrollFrame:: ~PGScrollFrame() { - set_horizontal_slider(NULL); - set_vertical_slider(NULL); + set_horizontal_slider(nullptr); + set_vertical_slider(nullptr); } /** @@ -143,13 +143,13 @@ setup(PN_stdfloat width, PN_stdfloat height, set_virtual_frame(left, right, bottom, top); // Remove the slider nodes created by a previous call to setup(), if any. - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { remove_child(_horizontal_slider); - set_horizontal_slider(NULL); + set_horizontal_slider(nullptr); } - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { remove_child(_vertical_slider); - set_vertical_slider(NULL); + set_vertical_slider(nullptr); } // Create new slider bars. @@ -185,7 +185,7 @@ remanage() { bool got_horizontal = false; PN_stdfloat horizontal_width = 0.0f; - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { got_horizontal = true; const LVecBase4 &slider_frame = _horizontal_slider->get_frame(); horizontal_width = slider_frame[3] - slider_frame[2]; @@ -193,7 +193,7 @@ remanage() { bool got_vertical = false; PN_stdfloat vertical_width = 0.0f; - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { got_vertical = true; const LVecBase4 &slider_frame = _vertical_slider->get_frame(); vertical_width = slider_frame[1] - slider_frame[0]; @@ -235,7 +235,7 @@ remanage() { } // Now show or hide the sliders appropriately. - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { if (got_horizontal) { _horizontal_slider->set_overall_hidden(false); } else { @@ -244,7 +244,7 @@ remanage() { horizontal_width = 0.0f; } } - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { if (got_vertical) { _vertical_slider->set_overall_hidden(false); } else { @@ -350,10 +350,10 @@ recompute_clip() { set_clip_frame(clip); - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { _horizontal_slider->set_page_size((clip[1] - clip[0]) / (_virtual_frame[1] - _virtual_frame[0])); } - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { _vertical_slider->set_page_size((clip[3] - clip[2]) / (_virtual_frame[3] - _virtual_frame[2])); } } @@ -390,7 +390,7 @@ interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, PGSliderBar *slider_bar) { LightReMutexHolder holder(_lock); PN_stdfloat t = 0.0f; - if (slider_bar != (PGSliderBar *)NULL) { + if (slider_bar != nullptr) { t = slider_bar->get_ratio(); } diff --git a/panda/src/pgui/pgScrollFrame.h b/panda/src/pgui/pgScrollFrame.h index 7dfae33d1b..c60a161a78 100644 --- a/panda/src/pgui/pgScrollFrame.h +++ b/panda/src/pgui/pgScrollFrame.h @@ -94,8 +94,6 @@ private: bool _needs_recompute_clip; bool _needs_recompute_canvas; - LVecBase4 _orig_clip_frame; - bool _has_virtual_frame; LVecBase4 _virtual_frame; diff --git a/panda/src/pgui/pgSliderBar.I b/panda/src/pgui/pgSliderBar.I index 927424706f..866dd1dec3 100644 --- a/panda/src/pgui/pgSliderBar.I +++ b/panda/src/pgui/pgSliderBar.I @@ -185,7 +185,7 @@ INLINE bool PGSliderBar:: is_button_down() const { LightReMutexHolder holder(_lock); return _dragging || _mouse_button_page || - (_scroll_button_held != (PGItem *)NULL); + (_scroll_button_held != nullptr); } /** @@ -243,11 +243,11 @@ get_manage_pieces() const { INLINE void PGSliderBar:: set_thumb_button(PGButton *thumb_button) { LightReMutexHolder holder(_lock); - if (_thumb_button != (PGButton *)NULL) { - _thumb_button->set_notify(NULL); + if (_thumb_button != nullptr) { + _thumb_button->set_notify(nullptr); } _thumb_button = thumb_button; - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->set_notify(this); } _needs_remanage = true; @@ -260,7 +260,7 @@ set_thumb_button(PGButton *thumb_button) { */ INLINE void PGSliderBar:: clear_thumb_button() { - set_thumb_button(NULL); + set_thumb_button(nullptr); } /** @@ -284,11 +284,11 @@ get_thumb_button() const { INLINE void PGSliderBar:: set_left_button(PGButton *left_button) { LightReMutexHolder holder(_lock); - if (_left_button != (PGButton *)NULL) { - _left_button->set_notify(NULL); + if (_left_button != nullptr) { + _left_button->set_notify(nullptr); } _left_button = left_button; - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { _left_button->set_notify(this); } _needs_remanage = true; @@ -301,7 +301,7 @@ set_left_button(PGButton *left_button) { */ INLINE void PGSliderBar:: clear_left_button() { - set_left_button(NULL); + set_left_button(nullptr); } /** @@ -325,11 +325,11 @@ get_left_button() const { INLINE void PGSliderBar:: set_right_button(PGButton *right_button) { LightReMutexHolder holder(_lock); - if (_right_button != (PGButton *)NULL) { - _right_button->set_notify(NULL); + if (_right_button != nullptr) { + _right_button->set_notify(nullptr); } _right_button = right_button; - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { _right_button->set_notify(this); } _needs_remanage = true; @@ -342,7 +342,7 @@ set_right_button(PGButton *right_button) { */ INLINE void PGSliderBar:: clear_right_button() { - set_right_button(NULL); + set_right_button(nullptr); } /** diff --git a/panda/src/pgui/pgSliderBar.cxx b/panda/src/pgui/pgSliderBar.cxx index da09bf73f3..ae7720140a 100644 --- a/panda/src/pgui/pgSliderBar.cxx +++ b/panda/src/pgui/pgSliderBar.cxx @@ -42,7 +42,7 @@ PGSliderBar(const string &name) _needs_remanage = false; _needs_recompute = true; _needs_reposition = false; - _scroll_button_held = NULL; + _scroll_button_held = nullptr; _mouse_button_page = false; _dragging = false; _thumb_width = 0.1f; @@ -76,7 +76,7 @@ PGSliderBar(const PGSliderBar ©) : { _needs_remanage = false; _needs_recompute = true; - _scroll_button_held = NULL; + _scroll_button_held = nullptr; _mouse_button_page = false; _dragging = false; } @@ -109,7 +109,7 @@ press(const MouseWatcherParameter ¶m, bool background) { if (_range_x != 0.0f) { _mouse_button_page = true; - _scroll_button_held = NULL; + _scroll_button_held = nullptr; advance_page(); _next_advance_time = ClockObject::get_global_clock()->get_frame_time() + scroll_initial_delay; @@ -180,7 +180,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { recompute(); } - if (_scroll_button_held != (PGItem *)NULL && + if (_scroll_button_held != nullptr && _next_advance_time <= ClockObject::get_global_clock()->get_frame_time()) { advance_scroll(); } @@ -209,7 +209,7 @@ xform(const LMatrix4 &mat) { // Make sure we set the thumb to identity position first, so it won't be // accidentally flattened. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->clear_transform(); } @@ -267,17 +267,17 @@ setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdflo style.set_width(bevel, bevel); // Remove the button nodes created by a previous call to setup(), if any. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { remove_child(_thumb_button); - set_thumb_button(NULL); + set_thumb_button(nullptr); } - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { remove_child(_left_button); - set_left_button(NULL); + set_left_button(nullptr); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { remove_child(_right_button); - set_right_button(NULL); + set_right_button(nullptr); } PT(PGButton) thumb = new PGButton("thumb"); @@ -336,17 +336,17 @@ setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat b set_frame_style(0, style); // Remove the button nodes created by a previous call to setup(), if any. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { remove_child(_thumb_button); - set_thumb_button(NULL); + set_thumb_button(nullptr); } - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { remove_child(_left_button); - set_left_button(NULL); + set_left_button(nullptr); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { remove_child(_right_button); - set_right_button(NULL); + set_right_button(nullptr); } PT(PGButton) thumb = new PGButton("thumb"); @@ -372,13 +372,13 @@ set_active(bool active) { PGItem::set_active(active); // This also implicitly sets the managed pieces. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->set_active(active); } - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { _left_button->set_active(active); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { _right_button->set_active(active); } } @@ -410,19 +410,19 @@ remanage() { 0.0f, (frame[2] + frame[3]) / 2.0f); - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { _left_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _left_button->set_transform(TransformState::make_pos(center + ((width - length) / 2.0f) * _axis)); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { _right_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _right_button->set_transform(TransformState::make_pos(center + ((length - width) / 2.0f) * _axis)); } - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _thumb_button->set_transform(TransformState::make_pos(center)); @@ -469,7 +469,7 @@ recompute() { PN_stdfloat trough_width = _max_x - _min_x; - if (_thumb_button == (PGButton *)NULL) { + if (_thumb_button == nullptr) { _thumb_width = 0.0f; _range_x = 0.0f; _thumb_start.set(0.0f, 0.0f, 0.0f); @@ -510,7 +510,7 @@ recompute() { PN_stdfloat trough_width = _max_x - _min_x; - if (_thumb_button == (PGButton *)NULL) { + if (_thumb_button == nullptr) { _thumb_width = 0.0f; _range_x = 0.0f; _thumb_start.set(0.0f, 0.0f, 0.0f); @@ -603,7 +603,7 @@ item_press(PGItem *item, const MouseWatcherParameter ¶m) { ClockObject::get_global_clock()->get_frame_time() + scroll_initial_delay; } else if (item == _thumb_button) { - _scroll_button_held = NULL; + _scroll_button_held = nullptr; begin_drag(); } } @@ -616,10 +616,10 @@ void PGSliderBar:: item_release(PGItem *item, const MouseWatcherParameter &) { LightReMutexHolder holder(_lock); if (item == _scroll_button_held) { - _scroll_button_held = NULL; + _scroll_button_held = nullptr; } else if (item == _thumb_button) { - _scroll_button_held = NULL; + _scroll_button_held = nullptr; if (_dragging) { end_drag(); } @@ -651,7 +651,7 @@ reposition() { PN_stdfloat t = get_ratio(); - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { LPoint3 pos = (t * _range_x) * _axis + _thumb_start; CPT(TransformState) transform = TransformState::make_pos(pos); CPT(TransformState) orig_transform = _thumb_button->get_transform(); diff --git a/panda/src/pgui/pgTop.I b/panda/src/pgui/pgTop.I index 76bee2d409..775e8cf827 100644 --- a/panda/src/pgui/pgTop.I +++ b/panda/src/pgui/pgTop.I @@ -74,6 +74,6 @@ get_start_sort() const { */ INLINE void PGTop:: add_region(MouseWatcherRegion *region) { - nassertv(_watcher_group != (PGMouseWatcherGroup *)NULL); + nassertv(_watcher_group != nullptr); _watcher_group->add_region(region); } diff --git a/panda/src/pgui/pgTop.cxx b/panda/src/pgui/pgTop.cxx index b65aaa81ac..172f62123c 100644 --- a/panda/src/pgui/pgTop.cxx +++ b/panda/src/pgui/pgTop.cxx @@ -47,7 +47,7 @@ PGTop(const string &name) : */ PGTop:: ~PGTop() { - set_mouse_watcher((MouseWatcher *)NULL); + set_mouse_watcher(nullptr); } /** @@ -83,7 +83,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // We create a new MouseWatcherGroup for the purposes of collecting a new // set of regions visible onscreen. PT(PGMouseWatcherGroup) old_watcher_group; - if (_watcher_group != (PGMouseWatcherGroup *)NULL) { + if (_watcher_group != nullptr) { _watcher_group->clear_top(this); old_watcher_group = _watcher_group; _watcher_group = new PGMouseWatcherGroup(this); @@ -102,8 +102,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // shouldn't do this until the frame that we're about to render has been // presented; otherwise, we may make regions active before they are actually // visible. But no one has complained about this so far. - if (_watcher_group != (PGMouseWatcherGroup *)NULL) { - nassertr(_watcher != (MouseWatcher *)NULL, false); + if (_watcher_group != nullptr) { + nassertr(_watcher != nullptr, false); _watcher->replace_group(old_watcher_group, _watcher_group); } @@ -130,17 +130,17 @@ is_renderable() const { */ void PGTop:: set_mouse_watcher(MouseWatcher *watcher) { - if (_watcher_group != (PGMouseWatcherGroup *)NULL) { + if (_watcher_group != nullptr) { _watcher_group->clear_top(this); } - if (_watcher != (MouseWatcher *)NULL) { + if (_watcher != nullptr) { _watcher->remove_group(_watcher_group); } _watcher = watcher; - _watcher_group = (PGMouseWatcherGroup *)NULL; + _watcher_group = nullptr; - if (_watcher != (MouseWatcher *)NULL) { + if (_watcher != nullptr) { _watcher_group = new PGMouseWatcherGroup(this); _watcher->add_group(_watcher_group); } diff --git a/panda/src/pgui/test_pgentry.cxx b/panda/src/pgui/test_pgentry.cxx index fb7440c6b4..f00369a603 100644 --- a/panda/src/pgui/test_pgentry.cxx +++ b/panda/src/pgui/test_pgentry.cxx @@ -22,7 +22,7 @@ main(int argc, char *argv[]) { framework.set_window_title("Panda Viewer"); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { window->enable_keyboard(); NodePath aspect2d = window->get_aspect_2d(); diff --git a/panda/src/physics/actorNode.cxx b/panda/src/physics/actorNode.cxx index e77e8e5ca5..b216036009 100644 --- a/panda/src/physics/actorNode.cxx +++ b/panda/src/physics/actorNode.cxx @@ -120,7 +120,7 @@ transform_changed() { * Write a string representation of this instance to . */ void ActorNode:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ActorNode:\n"; out.width(indent+2); out<<""; out<<"_ok_to_callback "<<_ok_to_callback<<"\n"; diff --git a/panda/src/physics/actorNode.h b/panda/src/physics/actorNode.h index aacdec669e..bfa4ffff66 100644 --- a/panda/src/physics/actorNode.h +++ b/panda/src/physics/actorNode.h @@ -39,7 +39,7 @@ PUBLISHED: void update_transform(); void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: PhysicsObject *_mass_center; diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 9900223d4c..1ca581eaf6 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -51,7 +51,7 @@ child_integrate(Physical *physical, PhysicsObject *current_object = *current_object_iter; // bail out if this object doesn't exist or doesn't want to be processed. - if (current_object == (PhysicsObject *) NULL) { + if (current_object == nullptr) { continue; } @@ -152,7 +152,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularEulerIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularEulerIntegrator:\n"; AngularIntegrator::write(out, indent+2); diff --git a/panda/src/physics/angularEulerIntegrator.h b/panda/src/physics/angularEulerIntegrator.h index 5e342b10f9..3e0790950c 100644 --- a/panda/src/physics/angularEulerIntegrator.h +++ b/panda/src/physics/angularEulerIntegrator.h @@ -26,7 +26,7 @@ PUBLISHED: virtual ~AngularEulerIntegrator(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual void child_integrate(Physical *physical, diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index 722a4611ab..06c71289ae 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -69,7 +69,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularForce (id "<. */ void AngularIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_angular_dt "<<_max_angular_dt<<" (class const)\n"; diff --git a/panda/src/physics/angularIntegrator.h b/panda/src/physics/angularIntegrator.h index 4ee8d41009..5ca3fd729a 100644 --- a/panda/src/physics/angularIntegrator.h +++ b/panda/src/physics/angularIntegrator.h @@ -32,7 +32,7 @@ public: PUBLISHED: virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: AngularIntegrator(); diff --git a/panda/src/physics/angularVectorForce.cxx b/panda/src/physics/angularVectorForce.cxx index d9ab88b054..736deec04f 100644 --- a/panda/src/physics/angularVectorForce.cxx +++ b/panda/src/physics/angularVectorForce.cxx @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularVectorForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/angularVectorForce.h b/panda/src/physics/angularVectorForce.h index aab32eaaae..f42c2f0c81 100644 --- a/panda/src/physics/angularVectorForce.h +++ b/panda/src/physics/angularVectorForce.h @@ -32,7 +32,7 @@ PUBLISHED: INLINE LRotation get_local_quat() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: LRotation _fvec; diff --git a/panda/src/physics/baseForce.cxx b/panda/src/physics/baseForce.cxx index 7a7ba6d71b..c06ba12180 100644 --- a/panda/src/physics/baseForce.cxx +++ b/panda/src/physics/baseForce.cxx @@ -21,7 +21,7 @@ TypeHandle BaseForce::_type_handle; */ BaseForce:: BaseForce(bool active) : - _force_node(NULL), + _force_node(nullptr), _active(active) { } @@ -34,7 +34,7 @@ BaseForce(const BaseForce ©) : TypedReferenceCount(copy) { _active = copy._active; - _force_node = (ForceNode *) NULL; + _force_node = nullptr; } /** diff --git a/panda/src/physics/baseIntegrator.cxx b/panda/src/physics/baseIntegrator.cxx index b21fd38612..ca5ec4faad 100644 --- a/panda/src/physics/baseIntegrator.cxx +++ b/panda/src/physics/baseIntegrator.cxx @@ -40,16 +40,13 @@ precompute_linear_matrices(Physical *physical, const LinearForceVector &forces) { nassertv(physical); // make sure the physical's in the scene graph, somewhere. - PhysicalNode *physical_node = physical->get_physical_node(); - nassertv(physical_node); + nassertv(physical->get_physical_node() != nullptr); // by global forces, we mean forces not contained in the physical - int global_force_vec_size = forces.size(); + size_t global_force_vec_size = forces.size(); // by local forces, we mean members of the physical's force set. - int local_force_vec_size = physical->get_linear_forces().size(); - - ForceNode *force_node; + size_t local_force_vec_size = physical->get_linear_forces().size(); // prepare the vector _precomputed_linear_matrices.clear(); @@ -63,8 +60,7 @@ precompute_linear_matrices(Physical *physical, LinearForceVector::const_iterator fi; for (fi = forces.begin(); fi != forces.end(); ++fi) { // LinearForce *cur_force = *fi; - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_linear_matrices.push_back( @@ -74,8 +70,7 @@ precompute_linear_matrices(Physical *physical, // tally the local xforms const LinearForceVector &force_vector = physical->get_linear_forces(); for (fi = force_vector.begin(); fi != force_vector.end(); ++fi) { - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_linear_matrices.push_back( @@ -93,16 +88,13 @@ precompute_angular_matrices(Physical *physical, const AngularForceVector &forces) { nassertv(physical); // make sure the physical's in the scene graph, somewhere. - PhysicalNode *physical_node = physical->get_physical_node(); - nassertv(physical_node != NULL); + nassertv(physical->get_physical_node() != nullptr); // by global forces, we mean forces not contained in the physical - int global_force_vec_size = forces.size(); + size_t global_force_vec_size = forces.size(); // by local forces, we mean members of the physical's force set. - int local_force_vec_size = physical->get_angular_forces().size(); - - ForceNode *force_node; + size_t local_force_vec_size = physical->get_angular_forces().size(); // prepare the vector _precomputed_angular_matrices.clear(); @@ -115,8 +107,7 @@ precompute_angular_matrices(Physical *physical, // tally the global xforms AngularForceVector::const_iterator fi; for (fi = forces.begin(); fi != forces.end(); ++fi) { - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_angular_matrices.push_back( @@ -126,8 +117,7 @@ precompute_angular_matrices(Physical *physical, // tally the local xforms const AngularForceVector &force_vector = physical->get_angular_forces(); for (fi = force_vector.begin(); fi != force_vector.end(); ++fi) { - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_angular_matrices.push_back( @@ -149,7 +139,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseIntegrator:: -write_precomputed_linear_matrices(ostream &out, unsigned int indent) const { +write_precomputed_linear_matrices(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_precomputed_linear_matrices\n"; @@ -165,7 +155,7 @@ write_precomputed_linear_matrices(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void BaseIntegrator:: -write_precomputed_angular_matrices(ostream &out, unsigned int indent) const { +write_precomputed_angular_matrices(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_precomputed_angular_matrices\n"; @@ -181,7 +171,7 @@ write_precomputed_angular_matrices(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void BaseIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseIntegrator:\n"; write_precomputed_linear_matrices(out, indent+2); diff --git a/panda/src/physics/baseIntegrator.h b/panda/src/physics/baseIntegrator.h index aaedce91cd..9d134fa2ee 100644 --- a/panda/src/physics/baseIntegrator.h +++ b/panda/src/physics/baseIntegrator.h @@ -42,10 +42,10 @@ public: PUBLISHED: virtual void output(ostream &out) const; virtual void write_precomputed_linear_matrices(ostream &out, - unsigned int indent=0) const; + int indent=0) const; virtual void write_precomputed_angular_matrices(ostream &out, - unsigned int indent=0) const; - virtual void write(ostream &out, unsigned int indent=0) const; + int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: BaseIntegrator(); diff --git a/panda/src/physics/forceNode.I b/panda/src/physics/forceNode.I index 8fd6845727..f1c4db3d60 100644 --- a/panda/src/physics/forceNode.I +++ b/panda/src/physics/forceNode.I @@ -24,7 +24,7 @@ clear() { */ INLINE BaseForce *ForceNode:: get_force(size_t index) const { - nassertr(index < _forces.size(), (BaseForce *) NULL); + nassertr(index < _forces.size(), nullptr); return _forces[index]; } diff --git a/panda/src/physics/forceNode.cxx b/panda/src/physics/forceNode.cxx index 0e186a98b3..326962b7c1 100644 --- a/panda/src/physics/forceNode.cxx +++ b/panda/src/physics/forceNode.cxx @@ -114,7 +114,7 @@ remove_force(size_t index) { pvector< PT(BaseForce) >::iterator remove; remove = _forces.begin() + index; - (*remove)->_force_node = (ForceNode *) NULL; + (*remove)->_force_node = nullptr; (*remove)->_force_node_path = NodePath(); _forces.erase(remove); @@ -133,7 +133,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ForceNode:: -write_forces(ostream &out, unsigned int indent) const { +write_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_forces ("<<_forces.size()<<" forces)"<<"\n"; for (ForceVector::const_iterator i=_forces.begin(); @@ -149,7 +149,7 @@ write_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void ForceNode:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ForceNode (id "<. */ void LinearControlForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearControlForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/linearControlForce.h b/panda/src/physics/linearControlForce.h index d39a9c2581..b1a28a5405 100644 --- a/panda/src/physics/linearControlForce.h +++ b/panda/src/physics/linearControlForce.h @@ -39,7 +39,7 @@ PUBLISHED: INLINE LVector3 get_local_vector() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: CPT(PhysicsObject) _physics_object; diff --git a/panda/src/physics/linearCylinderVortexForce.cxx b/panda/src/physics/linearCylinderVortexForce.cxx index 9976d6b1eb..ab91296af0 100644 --- a/panda/src/physics/linearCylinderVortexForce.cxx +++ b/panda/src/physics/linearCylinderVortexForce.cxx @@ -127,7 +127,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearCylinderVortexForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearCylinderVortexForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearCylinderVortexForce.h b/panda/src/physics/linearCylinderVortexForce.h index 5698aa9d8d..e04328580f 100644 --- a/panda/src/physics/linearCylinderVortexForce.h +++ b/panda/src/physics/linearCylinderVortexForce.h @@ -43,7 +43,7 @@ PUBLISHED: INLINE PN_stdfloat get_length() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: PN_stdfloat _radius; diff --git a/panda/src/physics/linearDistanceForce.cxx b/panda/src/physics/linearDistanceForce.cxx index 65922d0a2a..b48907feeb 100644 --- a/panda/src/physics/linearDistanceForce.cxx +++ b/panda/src/physics/linearDistanceForce.cxx @@ -57,7 +57,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearDistanceForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearDistanceForce:\n"; out.width(indent+2); out<<""; out<<"_force_center "<<_force_center<<"\n"; diff --git a/panda/src/physics/linearDistanceForce.h b/panda/src/physics/linearDistanceForce.h index 4afa6f2d11..208fc38bfd 100644 --- a/panda/src/physics/linearDistanceForce.h +++ b/panda/src/physics/linearDistanceForce.h @@ -40,7 +40,7 @@ PUBLISHED: INLINE PN_stdfloat get_scalar_term() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: LPoint3 _force_center; diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index f208eda299..5095937a48 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -72,7 +72,7 @@ child_integrate(Physical *physical, PhysicsObject *current_object = *current_object_iter; // bail out if this object doesn't exist or doesn't want to be processed. - if (current_object == (PhysicsObject *) NULL) { + if (current_object == nullptr) { continue; } @@ -199,7 +199,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearEulerIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearEulerIntegrator:\n"; diff --git a/panda/src/physics/linearEulerIntegrator.h b/panda/src/physics/linearEulerIntegrator.h index c7b6d3ff47..566c16d1d2 100644 --- a/panda/src/physics/linearEulerIntegrator.h +++ b/panda/src/physics/linearEulerIntegrator.h @@ -26,7 +26,7 @@ PUBLISHED: virtual ~LinearEulerIntegrator(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual void child_integrate(Physical *physical, diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index dde98eba84..e7481a2703 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -92,7 +92,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearForce (id "<. */ void LinearFrictionForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearFrictionForce:\n"; out.width(indent+2); out<<""; out<<"_coef "<<_coef<<":\n"; diff --git a/panda/src/physics/linearFrictionForce.h b/panda/src/physics/linearFrictionForce.h index 8ba4d19534..6e58b6d332 100644 --- a/panda/src/physics/linearFrictionForce.h +++ b/panda/src/physics/linearFrictionForce.h @@ -29,7 +29,7 @@ PUBLISHED: INLINE PN_stdfloat get_coef() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: PN_stdfloat _coef; diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index c58f9a4904..9efd0a3c1b 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -53,7 +53,7 @@ integrate(Physical *physical, LinearForceVector &forces, PhysicsObject *current_object = *current_object_iter; // bail out if this object doesn't exist or doesn't want to be processed. - if (current_object == (PhysicsObject *) NULL) { + if (current_object == nullptr) { continue; } @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_linear_dt "<<_max_linear_dt<<" (class static)\n"; diff --git a/panda/src/physics/linearIntegrator.h b/panda/src/physics/linearIntegrator.h index d5e6a1375d..85d717677b 100644 --- a/panda/src/physics/linearIntegrator.h +++ b/panda/src/physics/linearIntegrator.h @@ -33,7 +33,7 @@ public: PUBLISHED: virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: LinearIntegrator(); diff --git a/panda/src/physics/linearJitterForce.cxx b/panda/src/physics/linearJitterForce.cxx index d74a14fac6..80809a0f28 100644 --- a/panda/src/physics/linearJitterForce.cxx +++ b/panda/src/physics/linearJitterForce.cxx @@ -68,7 +68,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearJitterForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearJitterForce:\n"; LinearRandomForce::write(out, indent+2); diff --git a/panda/src/physics/linearJitterForce.h b/panda/src/physics/linearJitterForce.h index 076d7d12ca..eba7b0c9ff 100644 --- a/panda/src/physics/linearJitterForce.h +++ b/panda/src/physics/linearJitterForce.h @@ -27,7 +27,7 @@ PUBLISHED: virtual ~LinearJitterForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearNoiseForce.cxx b/panda/src/physics/linearNoiseForce.cxx index b7d9109f8f..b86754b8fe 100644 --- a/panda/src/physics/linearNoiseForce.cxx +++ b/panda/src/physics/linearNoiseForce.cxx @@ -146,7 +146,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearNoiseForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearNoiseForce:"; diff --git a/panda/src/physics/linearNoiseForce.h b/panda/src/physics/linearNoiseForce.h index b87fec2256..74b1ccd2d7 100644 --- a/panda/src/physics/linearNoiseForce.h +++ b/panda/src/physics/linearNoiseForce.h @@ -28,7 +28,7 @@ PUBLISHED: virtual ~LinearNoiseForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; public: static ConfigVariableInt _random_seed; diff --git a/panda/src/physics/linearRandomForce.cxx b/panda/src/physics/linearRandomForce.cxx index 252397c5bc..f961fdba4e 100644 --- a/panda/src/physics/linearRandomForce.cxx +++ b/panda/src/physics/linearRandomForce.cxx @@ -60,7 +60,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearRandomForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearRandomForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearRandomForce.h b/panda/src/physics/linearRandomForce.h index 2c05fd9763..ad440c034f 100644 --- a/panda/src/physics/linearRandomForce.h +++ b/panda/src/physics/linearRandomForce.h @@ -27,7 +27,7 @@ PUBLISHED: virtual ~LinearRandomForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: static PN_stdfloat bounded_rand(); diff --git a/panda/src/physics/linearSinkForce.cxx b/panda/src/physics/linearSinkForce.cxx index bee27f2d48..066fc64bef 100644 --- a/panda/src/physics/linearSinkForce.cxx +++ b/panda/src/physics/linearSinkForce.cxx @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSinkForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSinkForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearSinkForce.h b/panda/src/physics/linearSinkForce.h index 42f158d184..d8127049f1 100644 --- a/panda/src/physics/linearSinkForce.h +++ b/panda/src/physics/linearSinkForce.h @@ -28,7 +28,7 @@ PUBLISHED: virtual ~LinearSinkForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearSourceForce.cxx b/panda/src/physics/linearSourceForce.cxx index 88db962127..87e8d4e6ef 100644 --- a/panda/src/physics/linearSourceForce.cxx +++ b/panda/src/physics/linearSourceForce.cxx @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSourceForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSourceForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearSourceForce.h b/panda/src/physics/linearSourceForce.h index f6b2358c22..7d757a032f 100644 --- a/panda/src/physics/linearSourceForce.h +++ b/panda/src/physics/linearSourceForce.h @@ -28,7 +28,7 @@ PUBLISHED: virtual ~LinearSourceForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearUserDefinedForce.cxx b/panda/src/physics/linearUserDefinedForce.cxx index 4f6c4f4063..8e009aa6d9 100644 --- a/panda/src/physics/linearUserDefinedForce.cxx +++ b/panda/src/physics/linearUserDefinedForce.cxx @@ -72,7 +72,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearUserDefinedForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 3f05b1ea77..93051290c2 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -21,7 +21,7 @@ */ class EXPCL_PANDAPHYSICS LinearUserDefinedForce : public LinearForce { PUBLISHED: - explicit LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *) = NULL, + explicit LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *) = nullptr, PN_stdfloat a = 1.0f, bool md = false); LinearUserDefinedForce(const LinearUserDefinedForce ©); virtual ~LinearUserDefinedForce(); @@ -29,7 +29,7 @@ PUBLISHED: INLINE void set_proc(LVector3 (*proc)(const PhysicsObject *)); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: LVector3 (*_proc)(const PhysicsObject *po); diff --git a/panda/src/physics/linearVectorForce.cxx b/panda/src/physics/linearVectorForce.cxx index 47848073ec..ed2012dccf 100644 --- a/panda/src/physics/linearVectorForce.cxx +++ b/panda/src/physics/linearVectorForce.cxx @@ -84,7 +84,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearVectorForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/linearVectorForce.h b/panda/src/physics/linearVectorForce.h index ca12ab6bc5..c0a5cd2ea6 100644 --- a/panda/src/physics/linearVectorForce.h +++ b/panda/src/physics/linearVectorForce.h @@ -34,7 +34,7 @@ PUBLISHED: INLINE LVector3 get_local_vector() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; public: INLINE LinearVectorForce& operator += (const LinearVectorForce &other); diff --git a/panda/src/physics/physical.I b/panda/src/physics/physical.I index 3b44d50917..7232c1ebdf 100644 --- a/panda/src/physics/physical.I +++ b/panda/src/physics/physical.I @@ -167,7 +167,7 @@ get_num_linear_forces() const { */ INLINE PT(LinearForce) Physical:: get_linear_force(int index) const { - nassertr(index >= 0 && index < (int)_linear_forces.size(), NULL); + nassertr(index >= 0 && index < (int)_linear_forces.size(), nullptr); return _linear_forces[index]; } @@ -184,7 +184,7 @@ get_num_angular_forces() const { */ INLINE PT(AngularForce) Physical:: get_angular_force(int index) const { - nassertr(index >= 0 && index < (int)_angular_forces.size(), NULL); + nassertr(index >= 0 && index < (int)_angular_forces.size(), nullptr); return _angular_forces[index]; } diff --git a/panda/src/physics/physical.cxx b/panda/src/physics/physical.cxx index f7e64e0507..1cad199507 100644 --- a/panda/src/physics/physical.cxx +++ b/panda/src/physics/physical.cxx @@ -39,7 +39,7 @@ Physical(int total_objects, bool pre_alloc) : _phys_body = new PhysicsObject; add_physics_object(_phys_body); } else { - _phys_body = (PhysicsObject *) NULL; + _phys_body = nullptr; // allocate each object. if (pre_alloc == true) { for (int i = 0; i < total_objects; ++i) { @@ -87,7 +87,7 @@ Physical(const Physical& copy) : if (_physics_objects.size() == 1) _phys_body = _physics_objects[0]; else - _phys_body = (PhysicsObject *) NULL; + _phys_body = nullptr; } /** @@ -99,7 +99,7 @@ Physical:: // because the physics manager doesn't keep PT's to physicals, simply *'s, // and also means that we don't have to tell the physics manager ourselves // when one of our physicals is dead. - if (_physics_manager != (PhysicsManager *) NULL) { + if (_physics_manager != nullptr) { _physics_manager->remove_physical(this); } } @@ -134,7 +134,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void Physical:: -write_physics_objects(ostream &out, unsigned int indent) const { +write_physics_objects(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_physics_objects ("<<_physics_objects.size()<<" objects)\n"; @@ -150,7 +150,7 @@ write_physics_objects(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void Physical:: -write_linear_forces(ostream &out, unsigned int indent) const { +write_linear_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_linear_forces ("<<_linear_forces.size()<<" forces)\n"; @@ -166,7 +166,7 @@ write_linear_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void Physical:: -write_angular_forces(ostream &out, unsigned int indent) const { +write_angular_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_angular_forces ("<<_angular_forces.size()<<" forces)\n"; @@ -182,7 +182,7 @@ write_angular_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void Physical:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"Physical\n"; write_physics_objects(out, indent+2); diff --git a/panda/src/physics/physical.h b/panda/src/physics/physical.h index 64550823af..8a51e43e51 100644 --- a/panda/src/physics/physical.h +++ b/panda/src/physics/physical.h @@ -75,12 +75,12 @@ PUBLISHED: virtual void output(ostream &out = cout) const; virtual void write_physics_objects( - ostream &out = cout, unsigned int indent=0) const; + ostream &out = cout, int indent=0) const; virtual void write_linear_forces( - ostream &out = cout, unsigned int indent=0) const; + ostream &out = cout, int indent=0) const; virtual void write_angular_forces( - ostream &out = cout, unsigned int indent=0) const; - virtual void write(ostream &out = cout, unsigned int indent=0) const; + ostream &out = cout, int indent=0) const; + virtual void write(ostream &out = cout, int indent=0) const; public: INLINE const PhysicsObject::Vector &get_object_vector() const; diff --git a/panda/src/physics/physicalNode.I b/panda/src/physics/physicalNode.I index 700511b1e6..407cf52f5a 100644 --- a/panda/src/physics/physicalNode.I +++ b/panda/src/physics/physicalNode.I @@ -29,7 +29,7 @@ clear() { */ INLINE Physical *PhysicalNode:: get_physical(size_t index) const { - nassertr(index < _physicals.size(), (Physical *) NULL); + nassertr(index < _physicals.size(), nullptr); return _physicals[index]; } diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index daa454aff1..0166b81ade 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -124,7 +124,7 @@ remove_physical(size_t index) { pvector< PT(Physical) >::iterator remove; remove = _physicals.begin() + index; - (*remove)->_physical_node = (PhysicalNode *) NULL; + (*remove)->_physical_node = nullptr; _physicals.erase(remove); } @@ -133,7 +133,7 @@ remove_physical(size_t index) { * Write a string representation of this instance to . */ void PhysicalNode:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PhysicalNode:\n"; // PandaNode::write(out, indent+2); diff --git a/panda/src/physics/physicalNode.h b/panda/src/physics/physicalNode.h index 24bd272fdc..42f6822dde 100644 --- a/panda/src/physics/physicalNode.h +++ b/panda/src/physics/physicalNode.h @@ -43,7 +43,7 @@ PUBLISHED: MAKE_SEQ_PROPERTY(physicals, get_num_physicals, get_physical, set_physical, remove_physical, insert_physical); - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; public: virtual ~PhysicalNode(); diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index e9c128c641..3e4704a3ba 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -16,7 +16,7 @@ */ INLINE void PhysicsManager:: attach_physical(Physical *p) { - nassertv(p && p->_physics_manager == NULL); + nassertv(p && p->_physics_manager == nullptr); p->_physics_manager = this; PhysicalsVector::iterator found; found = find(_physicals.begin(), _physicals.end(), p); @@ -57,7 +57,7 @@ attach_physicalnode(PhysicalNode *p) { INLINE void PhysicsManager:: attach_physical_node(PhysicalNode *p) { nassertv(p); - for (int i = 0; i < p->get_num_physicals(); ++i) { + for (size_t i = 0; i < p->get_num_physicals(); ++i) { attach_physical(p->get_physical(i)); } } diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index b108176dd6..510d61abce 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -38,7 +38,7 @@ PhysicsManager:: PhysicalsVector::iterator pi; for (pi = _physicals.begin(); pi != _physicals.end(); ++pi) { nassertv((*pi)->_physics_manager == this); - (*pi)->_physics_manager = NULL; + (*pi)->_physics_manager = nullptr; } } @@ -100,7 +100,7 @@ remove_physical(Physical *p) { return; } nassertv(p->_physics_manager == this); - p->_physics_manager = (PhysicsManager *) NULL; + p->_physics_manager = nullptr; _physicals.erase(found); } @@ -110,7 +110,7 @@ remove_physical(Physical *p) { void PhysicsManager:: remove_physical_node(PhysicalNode *p) { nassertv(p); - for (int i = 0; i < p->get_num_physicals(); ++i) { + for (size_t i = 0; i < p->get_num_physicals(); ++i) { remove_physical(p->get_physical(i)); } } @@ -186,7 +186,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write_physicals(ostream &out, unsigned int indent) const { +write_physicals(ostream &out, int indent) const { #ifndef NDEBUG //[ if (indent>10) { return; @@ -206,7 +206,7 @@ write_physicals(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write_linear_forces(ostream &out, unsigned int indent) const { +write_linear_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_linear_forces ("<<_linear_forces.size()<<" forces)\n"; @@ -222,7 +222,7 @@ write_linear_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write_angular_forces(ostream &out, unsigned int indent) const { +write_angular_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_angular_forces ("<<_angular_forces.size()<<" forces)\n"; @@ -238,7 +238,7 @@ write_angular_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsManager:\n"; if (indent>20) { @@ -268,7 +268,7 @@ write(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -debug_output(ostream &out, unsigned int indent) const { +debug_output(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsManager li"<<(_linear_integrator?1:0)<<" ai"<<(_angular_integrator?1:0)<<"\n"; out<<" _physicals "<<_physicals.size()<<"\n"; diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index 80319ef2f0..c79c180dab 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -72,12 +72,12 @@ PUBLISHED: void init_random_seed(); virtual void output(ostream &out) const; - virtual void write_physicals(ostream &out, unsigned int indent=0) const; - virtual void write_linear_forces(ostream &out, unsigned int indent=0) const; - virtual void write_angular_forces(ostream &out, unsigned int indent=0) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write_physicals(ostream &out, int indent=0) const; + virtual void write_linear_forces(ostream &out, int indent=0) const; + virtual void write_angular_forces(ostream &out, int indent=0) const; + virtual void write(ostream &out, int indent=0) const; - virtual void debug_output(ostream &out, unsigned int indent=0) const; + virtual void debug_output(ostream &out, int indent=0) const; public: friend class Physical; diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index dc9b663771..96651949d5 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -160,7 +160,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PhysicsObject:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsObject "<<_name<<"\n"; diff --git a/panda/src/physics/physicsObject.h b/panda/src/physics/physicsObject.h index 5cb266ae7f..7f30b373f7 100644 --- a/panda/src/physics/physicsObject.h +++ b/panda/src/physics/physicsObject.h @@ -97,7 +97,7 @@ PUBLISHED: #endif virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: // physical diff --git a/panda/src/physx/physxActor.cxx b/panda/src/physx/physxActor.cxx index fdbce36aff..2b3075e45a 100644 --- a/panda/src/physx/physxActor.cxx +++ b/panda/src/physx/physxActor.cxx @@ -61,7 +61,7 @@ unlink() { } // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -78,7 +78,7 @@ release() { unlink(); _ptr->getScene().releaseActor(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -358,7 +358,7 @@ get_node_path() const { PhysxScene *PhysxActor:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxScene *scenePtr = &(_ptr->getScene()); PhysxScene *scene = (PhysxScene *)(scenePtr->userData); @@ -387,14 +387,14 @@ get_num_shapes() const { PhysxShape *PhysxActor:: create_shape(PhysxShapeDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(),NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(),nullptr); PhysxShape *shape = PhysxShape::factory(desc.ptr()->getType()); - nassertr(shape, NULL); + nassertr(shape, nullptr); NxShape *shapePtr = _ptr->createShape(*desc.ptr()); - nassertr(shapePtr, NULL); + nassertr(shapePtr, nullptr); shape->link(shapePtr); @@ -408,8 +408,8 @@ create_shape(PhysxShapeDesc &desc) { PhysxShape *PhysxActor:: get_shape(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbShapes(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbShapes(), nullptr); NxShape * const *shapes = _ptr->getShapes(); NxShape *shapePtr = shapes[idx]; @@ -426,10 +426,10 @@ get_shape(unsigned int idx) const { PhysxShape *PhysxActor:: get_shape_by_name(const char *name) const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxShape * const *shapes = _ptr->getShapes(); - NxShape *shapePtr = NULL; + NxShape *shapePtr = nullptr; NxU32 nShapes = _ptr->getNbShapes(); for (NxU32 i=0; i < nShapes; i++) { @@ -440,7 +440,7 @@ get_shape_by_name(const char *name) const { } } - return NULL; + return nullptr; } /** diff --git a/panda/src/physx/physxBoxForceFieldShape.cxx b/panda/src/physx/physxBoxForceFieldShape.cxx index 2aff7e32a7..af874e3b4b 100644 --- a/panda/src/physx/physxBoxForceFieldShape.cxx +++ b/panda/src/physx/physxBoxForceFieldShape.cxx @@ -39,7 +39,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxBoxForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxBoxShape.cxx b/panda/src/physx/physxBoxShape.cxx index 695ed1fd71..0ec704bc02 100644 --- a/panda/src/physx/physxBoxShape.cxx +++ b/panda/src/physx/physxBoxShape.cxx @@ -39,7 +39,7 @@ link(NxShape *shapePtr) { void PhysxBoxShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxCapsuleForceFieldShape.cxx b/panda/src/physx/physxCapsuleForceFieldShape.cxx index 0aacd1e61b..be0ce986e6 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.cxx +++ b/panda/src/physx/physxCapsuleForceFieldShape.cxx @@ -38,7 +38,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxCapsuleForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxCapsuleShape.cxx b/panda/src/physx/physxCapsuleShape.cxx index ed4dc24d75..29269dd4dd 100644 --- a/panda/src/physx/physxCapsuleShape.cxx +++ b/panda/src/physx/physxCapsuleShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxCapsuleShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxCcdSkeleton.cxx b/panda/src/physx/physxCcdSkeleton.cxx index 22dc3f4173..e18ff74023 100644 --- a/panda/src/physx/physxCcdSkeleton.cxx +++ b/panda/src/physx/physxCcdSkeleton.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseCCDSkeleton(*_ptr); - _ptr = NULL; + _ptr = nullptr; // TODO PhysxMeshPool::release_ccd_skeleton(this); } diff --git a/panda/src/physx/physxCcdSkeletonDesc.I b/panda/src/physx/physxCcdSkeletonDesc.I index 227a6f9684..271e1c94e9 100644 --- a/panda/src/physx/physxCcdSkeletonDesc.I +++ b/panda/src/physx/physxCcdSkeletonDesc.I @@ -20,11 +20,11 @@ PhysxCcdSkeletonDesc() { _desc.flags = 0; _desc.pointStrideBytes = sizeof(NxVec3); _desc.triangleStrideBytes = 3*sizeof(NxU32); - _desc.points = NULL; - _desc.triangles = NULL; + _desc.points = nullptr; + _desc.triangles = nullptr; - _vertices = NULL; - _triangles = NULL; + _vertices = nullptr; + _triangles = nullptr; } /** diff --git a/panda/src/physx/physxCloth.cxx b/panda/src/physx/physxCloth.cxx index 9f2583f7df..05e77b54b6 100644 --- a/panda/src/physx/physxCloth.cxx +++ b/panda/src/physx/physxCloth.cxx @@ -46,13 +46,13 @@ void PhysxCloth:: unlink() { // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_cloths.remove(this); - _node = NULL; + _node = nullptr; } /** @@ -65,7 +65,7 @@ release() { unlink(); _ptr->getScene().releaseCloth(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -95,7 +95,7 @@ update() { PhysxScene *PhysxCloth:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)_ptr->getScene().userData; } @@ -105,7 +105,7 @@ get_scene() const { PhysxClothNode *PhysxCloth:: get_cloth_node() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _node; } @@ -115,7 +115,7 @@ get_cloth_node() const { PhysxClothNode *PhysxCloth:: create_cloth_node(const char *name) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); _node = new PhysxClothNode(name); _node->allocate(this); @@ -455,11 +455,11 @@ get_vertex_attachment_status(unsigned int vertexId) const { PhysxShape *PhysxCloth:: get_vertex_attachment_shape(unsigned int vertexId) const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), NULL); NxShape *shapePtr = _ptr->getVertexAttachmentShape(vertexId); - PhysxShape *shape = shapePtr ? (PhysxShape *)(shapePtr->userData) : NULL; + PhysxShape *shape = shapePtr ? (PhysxShape *)(shapePtr->userData) : nullptr; return shape; } diff --git a/panda/src/physx/physxClothMesh.cxx b/panda/src/physx/physxClothMesh.cxx index 7a11a450e3..493b781a0a 100644 --- a/panda/src/physx/physxClothMesh.cxx +++ b/panda/src/physx/physxClothMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseClothMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_cloth_mesh(this); } diff --git a/panda/src/physx/physxClothMeshDesc.I b/panda/src/physx/physxClothMeshDesc.I index 973883686b..2cf02c8152 100644 --- a/panda/src/physx/physxClothMeshDesc.I +++ b/panda/src/physx/physxClothMeshDesc.I @@ -20,12 +20,12 @@ PhysxClothMeshDesc() { _desc.flags = 0; _desc.pointStrideBytes = sizeof(NxVec3); _desc.triangleStrideBytes = 3*sizeof(NxU32); - _desc.points = NULL; - _desc.triangles = NULL; + _desc.points = nullptr; + _desc.triangles = nullptr; - _points = NULL; - _triangles = NULL; - _texcoords = NULL; + _points = nullptr; + _triangles = nullptr; + _texcoords = nullptr; } /** diff --git a/panda/src/physx/physxClothNode.I b/panda/src/physx/physxClothNode.I index 3597004f03..a06bfcc3c3 100644 --- a/panda/src/physx/physxClothNode.I +++ b/panda/src/physx/physxClothNode.I @@ -30,7 +30,7 @@ PhysxClothNode(const char *name) : GeomNode(name) { this->add_geom(_geom); _numTexcoords = 0; - _texcoords = NULL; + _texcoords = nullptr; } /** diff --git a/panda/src/physx/physxContactPair.cxx b/panda/src/physx/physxContactPair.cxx index 1ecd1fab6d..3e8d69e34f 100644 --- a/panda/src/physx/physxContactPair.cxx +++ b/panda/src/physx/physxContactPair.cxx @@ -26,11 +26,11 @@ get_actor_a() const { if (_pair.isDeletedActor[0]) { physx_cat.warning() << "actor A has been deleted" << endl; - return NULL; + return nullptr; } NxActor *actorPtr = _pair.actors[0]; - return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData; + return (actorPtr == nullptr) ? nullptr : (PhysxActor *)actorPtr->userData; } /** @@ -41,11 +41,11 @@ get_actor_b() const { if (_pair.isDeletedActor[1]) { physx_cat.warning() << "actor B has been deleted" << endl; - return NULL; + return nullptr; } NxActor *actorPtr = _pair.actors[1]; - return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData; + return (actorPtr == nullptr) ? nullptr : (PhysxActor *)actorPtr->userData; } /** diff --git a/panda/src/physx/physxController.cxx b/panda/src/physx/physxController.cxx index 4e83a282a4..7787c4019e 100644 --- a/panda/src/physx/physxController.cxx +++ b/panda/src/physx/physxController.cxx @@ -55,7 +55,7 @@ factory(NxControllerType controllerType) { } physx_cat.error() << "Unknown controller type.\n"; - return NULL; + return nullptr; } @@ -65,7 +65,7 @@ factory(NxControllerType controllerType) { PhysxActor *PhysxController:: get_actor() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxActor *)(ptr()->getActor()->userData); } diff --git a/panda/src/physx/physxControllerReport.cxx b/panda/src/physx/physxControllerReport.cxx index dd6cfb225c..a9b570fcda 100644 --- a/panda/src/physx/physxControllerReport.cxx +++ b/panda/src/physx/physxControllerReport.cxx @@ -23,8 +23,8 @@ enable() { _enabled = true; - _shape_hit_cbobj = NULL; - _controller_hit_cbobj = NULL; + _shape_hit_cbobj = nullptr; + _controller_hit_cbobj = nullptr; } /** diff --git a/panda/src/physx/physxControllerShapeHit.I b/panda/src/physx/physxControllerShapeHit.I index a894ae013d..b6500ca736 100644 --- a/panda/src/physx/physxControllerShapeHit.I +++ b/panda/src/physx/physxControllerShapeHit.I @@ -30,7 +30,7 @@ get_controller() const { return (PhysxController *)(_hit.controller->getUserData()); } else { - return NULL; + return nullptr; } } @@ -44,7 +44,7 @@ get_shape() const { return (PhysxShape *)(_hit.shape->userData); } else { - return NULL; + return nullptr; } } diff --git a/panda/src/physx/physxControllersHit.I b/panda/src/physx/physxControllersHit.I index 74816e9159..e3d9aea411 100644 --- a/panda/src/physx/physxControllersHit.I +++ b/panda/src/physx/physxControllersHit.I @@ -27,7 +27,7 @@ INLINE PhysxController *PhysxControllersHit:: get_controller() const { NxController *controllerPtr = _hit.controller; - PhysxController *controller = controllerPtr ? (PhysxController *)controllerPtr : NULL; + PhysxController *controller = controllerPtr ? (PhysxController *)controllerPtr : nullptr; return controller; } @@ -39,7 +39,7 @@ INLINE PhysxController *PhysxControllersHit:: get_other() const { NxController *otherPtr = _hit.other; - PhysxController *other = otherPtr ? (PhysxController *)otherPtr : NULL; + PhysxController *other = otherPtr ? (PhysxController *)otherPtr : nullptr; return other; } diff --git a/panda/src/physx/physxConvexForceFieldShape.cxx b/panda/src/physx/physxConvexForceFieldShape.cxx index 406fabd878..bf89f9c485 100644 --- a/panda/src/physx/physxConvexForceFieldShape.cxx +++ b/panda/src/physx/physxConvexForceFieldShape.cxx @@ -38,7 +38,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxConvexForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxConvexMesh.cxx b/panda/src/physx/physxConvexMesh.cxx index 85bc518d9e..f703533856 100644 --- a/panda/src/physx/physxConvexMesh.cxx +++ b/panda/src/physx/physxConvexMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseConvexMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_convex_mesh(this); } diff --git a/panda/src/physx/physxConvexMeshDesc.I b/panda/src/physx/physxConvexMeshDesc.I index fae24d3130..1611726ecb 100644 --- a/panda/src/physx/physxConvexMeshDesc.I +++ b/panda/src/physx/physxConvexMeshDesc.I @@ -19,9 +19,9 @@ PhysxConvexMeshDesc() { _desc.flags = NX_CF_COMPUTE_CONVEX; _desc.pointStrideBytes = sizeof(NxVec3); - _desc.points = NULL; + _desc.points = nullptr; - _vertices = NULL; + _vertices = nullptr; } /** diff --git a/panda/src/physx/physxConvexShape.cxx b/panda/src/physx/physxConvexShape.cxx index 58d4a6c510..73acc06b87 100644 --- a/panda/src/physx/physxConvexShape.cxx +++ b/panda/src/physx/physxConvexShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxConvexShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxCylindricalJoint.cxx b/panda/src/physx/physxCylindricalJoint.cxx index 2a2fbb22d3..037668db54 100644 --- a/panda/src/physx/physxCylindricalJoint.cxx +++ b/panda/src/physx/physxCylindricalJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxCylindricalJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxD6Joint.cxx b/panda/src/physx/physxD6Joint.cxx index d52f1cdae1..a95abddcf5 100644 --- a/panda/src/physx/physxD6Joint.cxx +++ b/panda/src/physx/physxD6Joint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxD6Joint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxDistanceJoint.cxx b/panda/src/physx/physxDistanceJoint.cxx index 648821ce66..f24baa7c87 100644 --- a/panda/src/physx/physxDistanceJoint.cxx +++ b/panda/src/physx/physxDistanceJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxDistanceJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxFileStream.cxx b/panda/src/physx/physxFileStream.cxx index 1f308ab410..a93444148b 100644 --- a/panda/src/physx/physxFileStream.cxx +++ b/panda/src/physx/physxFileStream.cxx @@ -20,7 +20,7 @@ /** * */ -PhysxFileStream::PhysxFileStream(const Filename &fn, bool load) : _fp(NULL), _vf(NULL), _in(NULL) +PhysxFileStream::PhysxFileStream(const Filename &fn, bool load) : _fp(nullptr), _vf(nullptr), _in(nullptr) { if (load) { _vf = VirtualFileSystem::get_global_ptr()->get_file(fn); diff --git a/panda/src/physx/physxFixedJoint.cxx b/panda/src/physx/physxFixedJoint.cxx index 49b5265923..e3257eb22c 100644 --- a/panda/src/physx/physxFixedJoint.cxx +++ b/panda/src/physx/physxFixedJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxFixedJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxForceField.cxx b/panda/src/physx/physxForceField.cxx index eada698729..26149e72e0 100644 --- a/panda/src/physx/physxForceField.cxx +++ b/panda/src/physx/physxForceField.cxx @@ -50,7 +50,7 @@ unlink() { group->unlink(); // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -67,7 +67,7 @@ release() { unlink(); _ptr->getScene().releaseForceField(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -98,7 +98,7 @@ get_name() const { PhysxScene *PhysxForceField:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(_ptr->getScene().userData); } @@ -108,7 +108,7 @@ get_scene() const { PhysxForceFieldShapeGroup *PhysxForceField:: get_include_shape_group() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxForceFieldShapeGroup *)(_ptr->getIncludeShapeGroup().userData); } @@ -128,8 +128,8 @@ get_num_shape_groups() const { PhysxForceFieldShapeGroup *PhysxForceField:: get_shape_group(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbShapeGroups(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbShapeGroups(), nullptr); NxForceFieldShapeGroup *groupPtr; NxU32 nGroups = _ptr->getNbShapeGroups(); diff --git a/panda/src/physx/physxForceFieldShape.cxx b/panda/src/physx/physxForceFieldShape.cxx index a0a2d1b931..fe5cdfb316 100644 --- a/panda/src/physx/physxForceFieldShape.cxx +++ b/panda/src/physx/physxForceFieldShape.cxx @@ -56,7 +56,7 @@ factory(NxShapeType shapeType) { } physx_cat.error() << "Unknown shape type.\n"; - return NULL; + return nullptr; } /** @@ -66,11 +66,11 @@ factory(NxShapeType shapeType) { PhysxForceField *PhysxForceFieldShape:: get_force_field() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxForceField *fieldPtr = ptr()->getForceField(); - if (fieldPtr == NULL) { - return NULL; + if (fieldPtr == nullptr) { + return nullptr; } return (PhysxForceField *)(fieldPtr->userData); } @@ -81,7 +81,7 @@ get_force_field() const { PhysxForceFieldShapeGroup *PhysxForceFieldShape:: get_shape_group() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxForceFieldShapeGroup *)(ptr()->getShapeGroup().userData); } diff --git a/panda/src/physx/physxForceFieldShapeGroup.cxx b/panda/src/physx/physxForceFieldShapeGroup.cxx index c0bb56b93d..8819fbfd19 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.cxx +++ b/panda/src/physx/physxForceFieldShapeGroup.cxx @@ -60,7 +60,7 @@ unlink() { } // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -77,7 +77,7 @@ release() { unlink(); _ptr->getScene().releaseForceFieldShapeGroup(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -86,7 +86,7 @@ release() { PhysxScene *PhysxForceFieldShapeGroup:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(_ptr->getScene().userData); } @@ -97,10 +97,10 @@ get_scene() const { PhysxForceField *PhysxForceFieldShapeGroup:: get_force_field() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); - if (_ptr->getForceField() == NULL) { - return NULL; + if (_ptr->getForceField() == nullptr) { + return nullptr; } else { return (PhysxForceField *)(_ptr->getForceField()->userData); @@ -157,14 +157,14 @@ get_num_shapes() const { PhysxForceFieldShape *PhysxForceFieldShapeGroup:: create_shape(PhysxForceFieldShapeDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(),NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(),nullptr); PhysxForceFieldShape *shape = PhysxForceFieldShape::factory(desc.ptr()->getType()); - nassertr(shape, NULL); + nassertr(shape, nullptr); NxForceFieldShape *shapePtr = _ptr->createShape(*desc.ptr()); - nassertr(shapePtr, NULL); + nassertr(shapePtr, nullptr); shape->link(shapePtr); @@ -177,8 +177,8 @@ create_shape(PhysxForceFieldShapeDesc &desc) { PhysxForceFieldShape *PhysxForceFieldShapeGroup:: get_shape(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbShapes(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbShapes(), nullptr); NxForceFieldShape *shapePtr; NxU32 nShapes = _ptr->getNbShapes(); diff --git a/panda/src/physx/physxHeightField.cxx b/panda/src/physx/physxHeightField.cxx index b4885a1b26..4234eaf9e6 100644 --- a/panda/src/physx/physxHeightField.cxx +++ b/panda/src/physx/physxHeightField.cxx @@ -46,7 +46,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseHeightField(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** diff --git a/panda/src/physx/physxHeightFieldDesc.I b/panda/src/physx/physxHeightFieldDesc.I index e6870dd4cb..daf9ebc58c 100644 --- a/panda/src/physx/physxHeightFieldDesc.I +++ b/panda/src/physx/physxHeightFieldDesc.I @@ -17,7 +17,7 @@ INLINE PhysxHeightFieldDesc:: PhysxHeightFieldDesc() { - _samples = NULL; + _samples = nullptr; _desc.setToDefault(); } @@ -76,7 +76,7 @@ unset_size() { if (_samples) { _desc.nbRows = (NxU32) 0; _desc.nbColumns = (NxU32) 0; - _desc.samples = NULL; + _desc.samples = nullptr; delete[] _samples; } } diff --git a/panda/src/physx/physxHeightFieldShape.cxx b/panda/src/physx/physxHeightFieldShape.cxx index 21d0f6f81f..87b8ef7581 100644 --- a/panda/src/physx/physxHeightFieldShape.cxx +++ b/panda/src/physx/physxHeightFieldShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxHeightFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxJoint.cxx b/panda/src/physx/physxJoint.cxx index 0217d43849..0af47ee6e0 100644 --- a/panda/src/physx/physxJoint.cxx +++ b/panda/src/physx/physxJoint.cxx @@ -80,7 +80,7 @@ factory(NxJointType shapeType) { } physx_cat.error() << "Unknown joint type.\n"; - return NULL; + return nullptr; } /** @@ -112,8 +112,8 @@ get_name() const { PhysxActor *PhysxJoint:: get_actor(unsigned int idx) const { - nassertr_always(idx < 2, NULL); - nassertr(_error_type == ET_ok, NULL); + nassertr_always(idx < 2, nullptr); + nassertr(_error_type == ET_ok, nullptr); NxActor *actorPtr[2]; ptr()->getActors(&actorPtr[0], &actorPtr[1]); @@ -126,7 +126,7 @@ get_actor(unsigned int idx) const { PhysxScene *PhysxJoint:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(ptr()->getScene().userData); } diff --git a/panda/src/physx/physxJointDesc.cxx b/panda/src/physx/physxJointDesc.cxx index fec3e3f791..dc0eeb1196 100644 --- a/panda/src/physx/physxJointDesc.cxx +++ b/panda/src/physx/physxJointDesc.cxx @@ -208,11 +208,11 @@ get_joint_flag(const PhysxJointFlag flag) const { PhysxActor *PhysxJointDesc:: get_actor(unsigned int idx) const { - nassertr_always(idx < 2, NULL); + nassertr_always(idx < 2, nullptr); NxActor *actorPtr = ptr()->actor[idx]; - if (actorPtr == NULL) { - return NULL; + if (actorPtr == nullptr) { + return nullptr; } else { return (PhysxActor *)(actorPtr->userData); diff --git a/panda/src/physx/physxKitchen.cxx b/panda/src/physx/physxKitchen.cxx index 144e6b2cbe..8dda747eaa 100644 --- a/panda/src/physx/physxKitchen.cxx +++ b/panda/src/physx/physxKitchen.cxx @@ -151,20 +151,20 @@ cook_texcoords(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { PhysxConvexMesh *PhysxKitchen:: cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer buffer; bool status = _cooking->NxCookConvexMesh(meshDesc.get_desc(), buffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxConvexMesh *mesh = new PhysxConvexMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); NxConvexMesh *meshPtr = sdk->createConvexMesh(PhysxMemoryReadBuffer(buffer.data)); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); @@ -177,20 +177,20 @@ cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc) { PhysxTriangleMesh *PhysxKitchen:: cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer buffer; bool status = _cooking->NxCookTriangleMesh(meshDesc.get_desc(), buffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxTriangleMesh *mesh = new PhysxTriangleMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); NxTriangleMesh *meshPtr = sdk->createTriangleMesh(PhysxMemoryReadBuffer(buffer.data)); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); @@ -203,21 +203,21 @@ cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc) { PhysxClothMesh *PhysxKitchen:: cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer wbuffer; bool status = _cooking->NxCookClothMesh(meshDesc.get_desc(), wbuffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxClothMesh *mesh = new PhysxClothMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); PhysxMemoryReadBuffer rbuffer(wbuffer.data); NxClothMesh *meshPtr = sdk->createClothMesh(rbuffer); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); @@ -230,21 +230,21 @@ cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc) { PhysxSoftBodyMesh *PhysxKitchen:: cook_soft_body_mesh(const PhysxSoftBodyMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer wbuffer; bool status = _cooking->NxCookSoftBodyMesh(meshDesc.get_desc(), wbuffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxSoftBodyMesh *mesh = new PhysxSoftBodyMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); PhysxMemoryReadBuffer rbuffer(wbuffer.data); NxSoftBodyMesh *meshPtr = sdk->createSoftBodyMesh(rbuffer); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); diff --git a/panda/src/physx/physxManager.cxx b/panda/src/physx/physxManager.cxx index 297bbbaed4..56f63149c8 100644 --- a/panda/src/physx/physxManager.cxx +++ b/panda/src/physx/physxManager.cxx @@ -28,7 +28,7 @@ PhysxManager() { NxSDKCreateError error; NxPhysicsSDKDesc desc = NxPhysicsSDKDesc(); - _sdk = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL, &_outputStream, desc, &error); + _sdk = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, nullptr, &_outputStream, desc, &error); if (error == NXCE_NO_ERROR) { physx_cat.info() << "PhysX subsystem initialized. Number of PPUs=" @@ -37,7 +37,7 @@ PhysxManager() { else { physx_cat.error() << "Error when setting up the PhysX subsystem: " << get_sdk_error_string(error) << endl; - _sdk = NULL; + _sdk = nullptr; } nassertv_always(error == NXCE_NO_ERROR); @@ -95,12 +95,12 @@ PhysxManager:: PhysxManager *PhysxManager:: get_global_ptr() { - if (_global_ptr == (PhysxManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PhysxManager; } - if (_global_ptr->_sdk == NULL) { - return NULL; + if (_global_ptr->_sdk == nullptr) { + return nullptr; } else { return _global_ptr; @@ -122,7 +122,7 @@ get_num_scenes() const { PhysxScene *PhysxManager:: create_scene(PhysxSceneDesc &sceneDesc) { - nassertr(sceneDesc.is_valid(),NULL); + nassertr(sceneDesc.is_valid(),nullptr); // _desc.timeStepMethod = NX_TIMESTEP_FIXED; _desc.maxTimestep = 1.0f // 240.0f; _desc.maxIter = 8; @@ -139,10 +139,10 @@ create_scene(PhysxSceneDesc &sceneDesc) { } PhysxScene *scene = new PhysxScene(); - nassertr(scene, NULL); + nassertr(scene, nullptr); NxScene *scenePtr = _sdk->createScene(sceneDesc._desc); - nassertr(scenePtr, NULL); + nassertr(scenePtr, nullptr); scene->link(scenePtr); @@ -155,7 +155,7 @@ create_scene(PhysxSceneDesc &sceneDesc) { PhysxScene *PhysxManager:: get_scene(unsigned int idx) const { - nassertr_always(idx < _sdk->getNbScenes(), NULL); + nassertr_always(idx < _sdk->getNbScenes(), nullptr); NxScene *scenePtr = _sdk->getScene(idx); PhysxScene *scene = (PhysxScene *)(scenePtr->userData); @@ -178,13 +178,13 @@ get_num_height_fields() { PhysxHeightField *PhysxManager:: create_height_field(PhysxHeightFieldDesc &desc) { - nassertr(desc.is_valid(),NULL); + nassertr(desc.is_valid(),nullptr); PhysxHeightField *hf = new PhysxHeightField(); - nassertr(hf, NULL); + nassertr(hf, nullptr); NxHeightField *hfPtr = _sdk->createHeightField(desc._desc); - nassertr(hfPtr, NULL); + nassertr(hfPtr, nullptr); hf->link(hfPtr); @@ -197,7 +197,7 @@ create_height_field(PhysxHeightFieldDesc &desc) { PhysxHeightField *PhysxManager:: get_height_field(unsigned int idx) { - nassertr_always(idx < _sdk->getNbHeightFields(), NULL); + nassertr_always(idx < _sdk->getNbHeightFields(), nullptr); return (PhysxHeightField *)_heightfields[idx]; } @@ -217,7 +217,7 @@ get_num_convex_meshes() { PhysxConvexMesh *PhysxManager:: get_convex_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbConvexMeshes(), NULL); + nassertr_always(idx < _sdk->getNbConvexMeshes(), nullptr); return (PhysxConvexMesh *)_convex_meshes[idx]; } @@ -237,7 +237,7 @@ get_num_triangle_meshes() { PhysxTriangleMesh *PhysxManager:: get_triangle_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbTriangleMeshes(), NULL); + nassertr_always(idx < _sdk->getNbTriangleMeshes(), nullptr); return (PhysxTriangleMesh *)_triangle_meshes[idx]; } @@ -257,7 +257,7 @@ get_num_cloth_meshes() { PhysxClothMesh *PhysxManager:: get_cloth_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbClothMeshes(), NULL); + nassertr_always(idx < _sdk->getNbClothMeshes(), nullptr); return (PhysxClothMesh *)_cloth_meshes[idx]; } @@ -277,7 +277,7 @@ get_num_soft_body_meshes() { PhysxSoftBodyMesh *PhysxManager:: get_soft_body_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbSoftBodyMeshes(), NULL); + nassertr_always(idx < _sdk->getNbSoftBodyMeshes(), nullptr); return (PhysxSoftBodyMesh *)_softbody_meshes[idx]; } @@ -297,14 +297,14 @@ get_num_ccd_skeletons() { PhysxCcdSkeleton *PhysxManager:: create_ccd_skeleton(PhysxCcdSkeletonDesc &desc) { - nassertr(desc.is_valid(), NULL); - nassertr(desc.get_desc().numVertices < 64, NULL); + nassertr(desc.is_valid(), nullptr); + nassertr(desc.get_desc().numVertices < 64, nullptr); PhysxCcdSkeleton *skel = new PhysxCcdSkeleton(); - nassertr(skel, NULL); + nassertr(skel, nullptr); NxCCDSkeleton *skelPtr = _sdk->createCCDSkeleton(desc.get_desc()); - nassertr(skelPtr, NULL); + nassertr(skelPtr, nullptr); skel->link(skelPtr); @@ -317,7 +317,7 @@ create_ccd_skeleton(PhysxCcdSkeletonDesc &desc) { PhysxCcdSkeleton *PhysxManager:: get_ccd_skeleton(unsigned int idx) { - nassertr_always(idx < _sdk->getNbCCDSkeletons(), NULL); + nassertr_always(idx < _sdk->getNbCCDSkeletons(), nullptr); return (PhysxCcdSkeleton *)_ccd_skeletons[idx]; } diff --git a/panda/src/physx/physxMaterial.cxx b/panda/src/physx/physxMaterial.cxx index b583bcd000..11dedcacd4 100644 --- a/panda/src/physx/physxMaterial.cxx +++ b/panda/src/physx/physxMaterial.cxx @@ -39,7 +39,7 @@ void PhysxMaterial:: unlink() { // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -56,7 +56,7 @@ release() { unlink(); _ptr->getScene().releaseMaterial(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -65,7 +65,7 @@ release() { PhysxScene *PhysxMaterial:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(_ptr->getScene().userData); } diff --git a/panda/src/physx/physxMemoryWriteBuffer.cxx b/panda/src/physx/physxMemoryWriteBuffer.cxx index f690b1e327..0bede7e426 100644 --- a/panda/src/physx/physxMemoryWriteBuffer.cxx +++ b/panda/src/physx/physxMemoryWriteBuffer.cxx @@ -16,7 +16,7 @@ /** * */ -PhysxMemoryWriteBuffer::PhysxMemoryWriteBuffer() : currentSize(0), maxSize(0), data(NULL) +PhysxMemoryWriteBuffer::PhysxMemoryWriteBuffer() : currentSize(0), maxSize(0), data(nullptr) { } diff --git a/panda/src/physx/physxMeshPool.cxx b/panda/src/physx/physxMeshPool.cxx index 71fb20f495..4bf65576e2 100644 --- a/panda/src/physx/physxMeshPool.cxx +++ b/panda/src/physx/physxMeshPool.cxx @@ -50,7 +50,7 @@ check_filename(const Filename &fn) { PhysxConvexMesh *PhysxMeshPool:: load_convex_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxConvexMesh *mesh; @@ -61,13 +61,13 @@ load_convex_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxConvexMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createConvexMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); @@ -87,7 +87,7 @@ load_convex_mesh(const Filename &fn) { PhysxTriangleMesh *PhysxMeshPool:: load_triangle_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxTriangleMesh *mesh; @@ -98,13 +98,13 @@ load_triangle_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxTriangleMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createTriangleMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); @@ -124,7 +124,7 @@ load_triangle_mesh(const Filename &fn) { PhysxClothMesh *PhysxMeshPool:: load_cloth_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxClothMesh *mesh; @@ -135,13 +135,13 @@ load_cloth_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxClothMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createClothMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); @@ -161,7 +161,7 @@ load_cloth_mesh(const Filename &fn) { PhysxSoftBodyMesh *PhysxMeshPool:: load_soft_body_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxSoftBodyMesh *mesh; @@ -172,13 +172,13 @@ load_soft_body_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxSoftBodyMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createSoftBodyMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); diff --git a/panda/src/physx/physxObjectCollection.I b/panda/src/physx/physxObjectCollection.I index 128d031bfc..62270910f7 100644 --- a/panda/src/physx/physxObjectCollection.I +++ b/panda/src/physx/physxObjectCollection.I @@ -58,7 +58,7 @@ template INLINE T *PhysxObjectCollection:: get(unsigned int index) const { - nassertr(index < _objects.size(), NULL); + nassertr(index < _objects.size(), nullptr); return _objects[index]; } @@ -70,7 +70,7 @@ template INLINE T *PhysxObjectCollection:: operator [] (unsigned int index) const { - nassertr(index < _objects.size(), NULL); + nassertr(index < _objects.size(), nullptr); return _objects[index]; } diff --git a/panda/src/physx/physxOverlapReport.cxx b/panda/src/physx/physxOverlapReport.cxx index dc5fafb431..4589740dc4 100644 --- a/panda/src/physx/physxOverlapReport.cxx +++ b/panda/src/physx/physxOverlapReport.cxx @@ -58,7 +58,7 @@ get_next_overlap() { } // No more items. Return empty overlap. - return NULL; + return nullptr; } /** @@ -67,6 +67,6 @@ get_next_overlap() { PhysxShape *PhysxOverlapReport:: get_overlap(unsigned int idx) { - nassertr(idx < get_num_overlaps(), NULL); + nassertr(idx < get_num_overlaps(), nullptr); return _overlaps[idx]; } diff --git a/panda/src/physx/physxPlaneShape.cxx b/panda/src/physx/physxPlaneShape.cxx index 49ce975f38..05a22a60f7 100644 --- a/panda/src/physx/physxPlaneShape.cxx +++ b/panda/src/physx/physxPlaneShape.cxx @@ -39,7 +39,7 @@ link(NxShape *shapePtr) { void PhysxPlaneShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxPointInPlaneJoint.cxx b/panda/src/physx/physxPointInPlaneJoint.cxx index 34c4b0df42..fc05d6f8ca 100644 --- a/panda/src/physx/physxPointInPlaneJoint.cxx +++ b/panda/src/physx/physxPointInPlaneJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxPointInPlaneJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxPointOnLineJoint.cxx b/panda/src/physx/physxPointOnLineJoint.cxx index 1cdf84981f..5e5d4e8665 100644 --- a/panda/src/physx/physxPointOnLineJoint.cxx +++ b/panda/src/physx/physxPointOnLineJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxPointOnLineJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxPrismaticJoint.cxx b/panda/src/physx/physxPrismaticJoint.cxx index 9fd765c94f..94b9fd0949 100644 --- a/panda/src/physx/physxPrismaticJoint.cxx +++ b/panda/src/physx/physxPrismaticJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxPrismaticJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxPulleyJoint.cxx b/panda/src/physx/physxPulleyJoint.cxx index 3b98de1cef..0986774ae8 100644 --- a/panda/src/physx/physxPulleyJoint.cxx +++ b/panda/src/physx/physxPulleyJoint.cxx @@ -39,7 +39,7 @@ link(NxJoint *jointPtr) { void PhysxPulleyJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxRaycastHit.cxx b/panda/src/physx/physxRaycastHit.cxx index 30d983f0ea..5d2bce1737 100644 --- a/panda/src/physx/physxRaycastHit.cxx +++ b/panda/src/physx/physxRaycastHit.cxx @@ -21,7 +21,7 @@ bool PhysxRaycastHit:: is_empty() const { - return (_hit.shape == NULL); + return (_hit.shape == nullptr); } /** @@ -30,7 +30,7 @@ is_empty() const { PhysxShape *PhysxRaycastHit:: get_shape() const { - nassertr_always(_hit.shape, NULL); + nassertr_always(_hit.shape, nullptr); return (PhysxShape *)_hit.shape->userData; } diff --git a/panda/src/physx/physxRaycastReport.cxx b/panda/src/physx/physxRaycastReport.cxx index cb00d85b10..368c5a5c54 100644 --- a/panda/src/physx/physxRaycastReport.cxx +++ b/panda/src/physx/physxRaycastReport.cxx @@ -55,7 +55,7 @@ get_next_hit() { // No more items. Return an empty hit. NxRaycastHit hit; - hit.shape = NULL; + hit.shape = nullptr; return PhysxRaycastHit(hit); } @@ -69,7 +69,7 @@ get_hit(unsigned int idx) { { // Index out of bounds. Return an empty hit. NxRaycastHit hit; - hit.shape = NULL; + hit.shape = nullptr; return PhysxRaycastHit(hit); } diff --git a/panda/src/physx/physxRevoluteJoint.cxx b/panda/src/physx/physxRevoluteJoint.cxx index 5b3f9c5cde..43314ba157 100644 --- a/panda/src/physx/physxRevoluteJoint.cxx +++ b/panda/src/physx/physxRevoluteJoint.cxx @@ -41,7 +41,7 @@ link(NxJoint *jointPtr) { void PhysxRevoluteJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -242,7 +242,7 @@ set_limits(const PhysxJointLimitDesc &low, const PhysxJointLimitDesc &high) { PhysxMotorDesc PhysxRevoluteJoint:: get_motor() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, PhysxMotorDesc(0)); PhysxMotorDesc value; _ptr->getMotor(value._desc); @@ -255,7 +255,7 @@ get_motor() const { PhysxSpringDesc PhysxRevoluteJoint:: get_spring() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, PhysxSpringDesc(0)); PhysxSpringDesc value; _ptr->getSpring(value._desc); diff --git a/panda/src/physx/physxScene.I b/panda/src/physx/physxScene.I index d611cbe3db..9f9e2c5aa8 100644 --- a/panda/src/physx/physxScene.I +++ b/panda/src/physx/physxScene.I @@ -26,7 +26,7 @@ PhysxScene() : PhysxObject() { INLINE PhysxScene:: ~PhysxScene() { - _debugNode = NULL; + _debugNode = nullptr; } /** diff --git a/panda/src/physx/physxScene.cxx b/panda/src/physx/physxScene.cxx index e2623ef47a..b07a373729 100644 --- a/panda/src/physx/physxScene.cxx +++ b/panda/src/physx/physxScene.cxx @@ -157,7 +157,7 @@ unlink() { _cm->purgeControllers(); NxReleaseControllerManager(_cm); - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxManager::get_global_ptr()->_scenes.remove(this); @@ -174,7 +174,7 @@ release() { unlink(); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); sdk->releaseScene(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -226,7 +226,7 @@ void PhysxScene:: fetch_results() { nassertv(_error_type == ET_ok); - nassertv(_ptr != NULL); + nassertv(_ptr != nullptr); _pcollector_fetch_results.start(); _ptr->fetchResults(NX_RIGID_BODY_FINISHED, true); @@ -354,14 +354,14 @@ get_num_actors() const { PhysxActor *PhysxScene:: create_actor(PhysxActorDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxActor *actor = new PhysxActor(); - nassertr(actor, NULL); + nassertr(actor, nullptr); NxActor *actorPtr = _ptr->createActor(desc._desc); - nassertr(actorPtr, NULL); + nassertr(actorPtr, nullptr); actor->link(actorPtr); @@ -374,8 +374,8 @@ create_actor(PhysxActorDesc &desc) { PhysxActor *PhysxScene:: get_actor(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbActors(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbActors(), nullptr); NxActor *actorPtr = _ptr->getActors()[idx]; PhysxActor *actor = (PhysxActor *)(actorPtr->userData); @@ -395,7 +395,7 @@ get_actor(unsigned int idx) const { PhysxDebugGeomNode *PhysxScene:: get_debug_geom_node() { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _debugNode; } @@ -412,7 +412,7 @@ enable_contact_reporting(bool enabled) { _contact_report.enable(); } else { - _ptr->setUserContactReport(NULL); + _ptr->setUserContactReport(nullptr); _contact_report.disable(); } } @@ -441,7 +441,7 @@ enable_trigger_reporting(bool enabled) { _trigger_report.enable(); } else { - _ptr->setUserTriggerReport(NULL); + _ptr->setUserTriggerReport(nullptr); _trigger_report.disable(); } } @@ -510,14 +510,14 @@ get_num_materials() const { PhysxMaterial *PhysxScene:: create_material(PhysxMaterialDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxMaterial *material = new PhysxMaterial(); - nassertr(material, NULL); + nassertr(material, nullptr); NxMaterial *materialPtr = _ptr->createMaterial(desc._desc); - nassertr(materialPtr, NULL); + nassertr(materialPtr, nullptr); material->link(materialPtr); @@ -531,15 +531,15 @@ create_material(PhysxMaterialDesc &desc) { PhysxMaterial *PhysxScene:: create_material() { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxMaterial *material = new PhysxMaterial(); - nassertr(material, NULL); + nassertr(material, nullptr); NxMaterialDesc desc; desc.setToDefault(); NxMaterial *materialPtr = _ptr->createMaterial(desc); - nassertr(materialPtr, NULL); + nassertr(materialPtr, nullptr); material->link(materialPtr); @@ -570,7 +570,7 @@ get_hightest_material_index() const { PhysxMaterial *PhysxScene:: get_material_from_index(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxMaterial *materialPtr = _ptr->getMaterialFromIndex(idx); @@ -584,8 +584,8 @@ get_material_from_index(unsigned int idx) const { PhysxMaterial *PhysxScene:: get_material(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbMaterials(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbMaterials(), nullptr); NxU32 n = _ptr->getNbMaterials(); NxMaterial **materials = new NxMaterial *[n]; @@ -593,7 +593,7 @@ get_material(unsigned int idx) const { NxU32 iterator = 0; materialCount = _ptr->getMaterialArray(materials, n, iterator); - nassertr((materialCount == n), NULL); + nassertr((materialCount == n), nullptr); NxMaterial *materialPtr = materials[idx]; delete[] materials; @@ -618,17 +618,17 @@ get_num_controllers() const { PhysxController *PhysxScene:: create_controller(PhysxControllerDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxController *controller = PhysxController::factory(desc.ptr()->getType()); - nassertr(controller, NULL); + nassertr(controller, nullptr); desc.ptr()->callback = &_controller_report; desc.ptr()->userData = controller; NxController *controllerPtr = _cm->createController(_ptr,*desc.ptr()); - nassertr(controllerPtr, NULL); + nassertr(controllerPtr, nullptr); controller->link(controllerPtr); controller->get_actor()->set_name(""); @@ -642,8 +642,8 @@ create_controller(PhysxControllerDesc &desc) { PhysxController *PhysxScene:: get_controller(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _cm->getNbControllers(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _cm->getNbControllers(), nullptr); NxController *controllerPtr = _cm->getController(idx); PhysxController *controller = (PhysxController *)(controllerPtr->getUserData()); @@ -668,14 +668,14 @@ get_num_joints() const { PhysxJoint *PhysxScene:: create_joint(PhysxJointDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxJoint *joint = PhysxJoint::factory(desc.ptr()->getType()); - nassertr(joint, NULL); + nassertr(joint, nullptr); NxJoint *jointPtr = _ptr->createJoint(*desc.ptr()); - nassertr(jointPtr, NULL); + nassertr(jointPtr, nullptr); joint->link(jointPtr); @@ -688,8 +688,8 @@ create_joint(PhysxJointDesc &desc) { PhysxJoint *PhysxScene:: get_joint(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbJoints(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbJoints(), nullptr); NxJoint *jointPtr; NxU32 nJoints = _ptr->getNbJoints(); @@ -718,18 +718,18 @@ get_num_force_fields() const { PhysxForceField *PhysxScene:: create_force_field(PhysxForceFieldDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); // Create the kernel desc.create_kernel(_ptr); - nassertr(desc.is_valid(), NULL); + nassertr(desc.is_valid(), nullptr); // Create the force field PhysxForceField *field = new PhysxForceField(); - nassertr(field, NULL); + nassertr(field, nullptr); NxForceField *fieldPtr = _ptr->createForceField(desc._desc); - nassertr(fieldPtr, NULL); + nassertr(fieldPtr, nullptr); field->link(fieldPtr); @@ -743,8 +743,8 @@ create_force_field(PhysxForceFieldDesc &desc) { PhysxForceField *PhysxScene:: get_force_field(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbForceFields(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbForceFields(), nullptr); NxForceField **fields = _ptr->getForceFields(); NxForceField *fieldPtr = fields[idx]; @@ -768,13 +768,13 @@ get_num_force_field_shape_groups() const { PhysxForceFieldShapeGroup *PhysxScene:: create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxForceFieldShapeGroup *group = new PhysxForceFieldShapeGroup(); - nassertr(group, NULL); + nassertr(group, nullptr); NxForceFieldShapeGroup *groupPtr = _ptr->createForceFieldShapeGroup(desc._desc); - nassertr(groupPtr, NULL); + nassertr(groupPtr, nullptr); group->link(groupPtr); @@ -787,17 +787,17 @@ create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { PhysxForceFieldShapeGroup *PhysxScene:: get_force_field_shape_group(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbForceFieldShapeGroups(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbForceFieldShapeGroups(), nullptr); _ptr->resetForceFieldShapeGroupsIterator(); - NxForceFieldShapeGroup *groupPtr = NULL; + NxForceFieldShapeGroup *groupPtr = nullptr; idx++; while (idx-- > 0) { groupPtr = _ptr->getNextForceFieldShapeGroup(); } - return groupPtr ? (PhysxForceFieldShapeGroup *)groupPtr->userData : NULL; + return groupPtr ? (PhysxForceFieldShapeGroup *)groupPtr->userData : nullptr; } /** @@ -816,13 +816,13 @@ get_num_cloths() const { PhysxCloth *PhysxScene:: create_cloth(PhysxClothDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxCloth *cloth = new PhysxCloth(); - nassertr(cloth, NULL); + nassertr(cloth, nullptr); NxCloth *clothPtr = _ptr->createCloth(desc._desc); - nassertr(clothPtr, NULL); + nassertr(clothPtr, nullptr); cloth->link(clothPtr); @@ -835,8 +835,8 @@ create_cloth(PhysxClothDesc &desc) { PhysxCloth *PhysxScene:: get_cloth(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbCloths(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbCloths(), nullptr); NxCloth **cloths = _ptr->getCloths(); NxCloth *clothPtr = cloths[idx]; @@ -860,13 +860,13 @@ get_num_soft_bodies() const { PhysxSoftBody *PhysxScene:: create_soft_body(PhysxSoftBodyDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxSoftBody *softbody = new PhysxSoftBody(); - nassertr(softbody, NULL); + nassertr(softbody, nullptr); NxSoftBody *softbodyPtr = _ptr->createSoftBody(desc._desc); - nassertr(softbodyPtr, NULL); + nassertr(softbodyPtr, nullptr); softbody->link(softbodyPtr); @@ -880,8 +880,8 @@ create_soft_body(PhysxSoftBodyDesc &desc) { PhysxSoftBody *PhysxScene:: get_soft_body(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbSoftBodies(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbSoftBodies(), nullptr); NxSoftBody **softbodies = _ptr->getSoftBodies(); NxSoftBody *softbodyPtr = softbodies[idx]; @@ -905,11 +905,11 @@ get_num_vehicles() const { PhysxVehicle *PhysxScene:: create_vehicle(PhysxVehicleDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxVehicle *vehicle = new PhysxVehicle(); - nassertr(vehicle, NULL); + nassertr(vehicle, nullptr); vehicle->create(this, desc); @@ -922,8 +922,8 @@ create_vehicle(PhysxVehicleDesc &desc) { PhysxVehicle *PhysxScene:: get_vehicle(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _vehicles.size(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _vehicles.size(), nullptr); return _vehicles[idx]; } @@ -934,7 +934,7 @@ get_vehicle(unsigned int idx) const { PhysxSceneStats2 PhysxScene:: get_stats2() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return PhysxSceneStats2(_ptr->getStats2()); } @@ -949,7 +949,7 @@ raycast_any_shape(const PhysxRay &ray, nassertr(_error_type == ET_ok, false); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; return _ptr->raycastAnyShape(ray._ray, (NxShapesType)shapesType, mask.get_mask(), ray._length, groupsPtr); @@ -969,7 +969,7 @@ raycast_closest_shape(const PhysxRay &ray, nassertr(_error_type == ET_ok, hit); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1000,7 +1000,7 @@ raycast_all_shapes(const PhysxRay &ray, nassertr(_error_type == ET_ok, report); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1028,7 +1028,7 @@ raycast_any_bounds(const PhysxRay &ray, nassertr(_error_type == ET_ok, false); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; return _ptr->raycastAnyBounds(ray._ray, (NxShapesType)shapesType, mask.get_mask(), ray._length, groupsPtr); @@ -1046,7 +1046,7 @@ raycast_closest_bounds(const PhysxRay &ray, PhysxShapesType shapesType, PhysxMas nassertr(_error_type == ET_ok, hit); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1078,7 +1078,7 @@ raycast_all_bounds(const PhysxRay &ray, nassertr(_error_type == ET_ok, report); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1109,8 +1109,8 @@ overlap_sphere_shapes(const LPoint3f ¢er, float radius, NxSphere worldSphere(PhysxManager::point3_to_nxVec3(center), radius); - _ptr->overlapSphereShapes(worldSphere, (NxShapesType)shapesType, 0, NULL, &report, - mask.get_mask(), NULL, accurateCollision); + _ptr->overlapSphereShapes(worldSphere, (NxShapesType)shapesType, 0, nullptr, &report, + mask.get_mask(), nullptr, accurateCollision); return report; } @@ -1132,8 +1132,8 @@ overlap_capsule_shapes(const LPoint3f &p0, const LPoint3f &p1, float radius, PhysxManager::point3_to_nxVec3(p1)); NxCapsule worldCapsule(segment, radius); - _ptr->overlapCapsuleShapes(worldCapsule, (NxShapesType)shapesType, 0, NULL, &report, - mask.get_mask(), NULL, accurateCollision); + _ptr->overlapCapsuleShapes(worldCapsule, (NxShapesType)shapesType, 0, nullptr, &report, + mask.get_mask(), nullptr, accurateCollision); return report; } @@ -1541,9 +1541,9 @@ get_dominance_group_pair(unsigned int g1, unsigned int g2) { PhysxMaterial *PhysxScene:: get_wheel_shape_material() { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); - if (_wheelShapeMaterial == NULL) { + if (_wheelShapeMaterial == nullptr) { PhysxMaterialDesc materialDesc; materialDesc.set_flag(PhysxMaterialDesc::MF_disable_friction, true); _wheelShapeMaterial = create_material(materialDesc); diff --git a/panda/src/physx/physxScene.h b/panda/src/physx/physxScene.h index b26105c644..ed3b39ff4e 100644 --- a/panda/src/physx/physxScene.h +++ b/panda/src/physx/physxScene.h @@ -157,32 +157,32 @@ PUBLISHED: bool raycast_any_shape(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL) const; + PhysxGroupsMask *groups=nullptr) const; PhysxRaycastHit raycast_closest_shape(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; PhysxRaycastReport raycast_all_shapes(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; bool raycast_any_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL) const; + PhysxGroupsMask *groups=nullptr) const; PhysxRaycastHit raycast_closest_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; PhysxRaycastReport raycast_all_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; // Overlap queries PhysxOverlapReport overlap_sphere_shapes(const LPoint3f ¢er, float radius, diff --git a/panda/src/physx/physxShape.cxx b/panda/src/physx/physxShape.cxx index 926001f1be..0518f81d12 100644 --- a/panda/src/physx/physxShape.cxx +++ b/panda/src/physx/physxShape.cxx @@ -79,7 +79,7 @@ factory(NxShapeType shapeType) { } physx_cat.error() << "Unknown shape type.\n"; - return NULL; + return nullptr; } /** @@ -88,7 +88,7 @@ factory(NxShapeType shapeType) { PhysxActor *PhysxShape:: get_actor() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxActor *)(ptr()->getActor().userData); } @@ -406,7 +406,7 @@ set_ccd_skeleton(PhysxCcdSkeleton *skel) { PhysxCcdSkeleton *PhysxShape:: get_ccd_skeleton() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _skel; } diff --git a/panda/src/physx/physxSoftBody.cxx b/panda/src/physx/physxSoftBody.cxx index 268a229502..1e5ed73685 100644 --- a/panda/src/physx/physxSoftBody.cxx +++ b/panda/src/physx/physxSoftBody.cxx @@ -45,13 +45,13 @@ void PhysxSoftBody:: unlink() { // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_softbodies.remove(this); - _node = NULL; + _node = nullptr; } /** @@ -64,7 +64,7 @@ release() { unlink(); _ptr->getScene().releaseSoftBody(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -94,7 +94,7 @@ update() { PhysxScene *PhysxSoftBody:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)_ptr->getScene().userData; } @@ -104,7 +104,7 @@ get_scene() const { PhysxSoftBodyNode *PhysxSoftBody:: get_soft_body_node() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _node; } @@ -114,7 +114,7 @@ get_soft_body_node() const { PhysxSoftBodyNode *PhysxSoftBody:: create_soft_body_node(const char *name) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); _node = new PhysxSoftBodyNode(name); _node->allocate(this); diff --git a/panda/src/physx/physxSoftBodyMesh.cxx b/panda/src/physx/physxSoftBodyMesh.cxx index 4cb0c9cc26..2f69f3d173 100644 --- a/panda/src/physx/physxSoftBodyMesh.cxx +++ b/panda/src/physx/physxSoftBodyMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseSoftBodyMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_soft_body_mesh(this); } diff --git a/panda/src/physx/physxSoftBodyMeshDesc.I b/panda/src/physx/physxSoftBodyMeshDesc.I index 0cf5663cd7..0125b456ec 100644 --- a/panda/src/physx/physxSoftBodyMeshDesc.I +++ b/panda/src/physx/physxSoftBodyMeshDesc.I @@ -20,11 +20,11 @@ PhysxSoftBodyMeshDesc() { _desc.flags = 0; _desc.vertexStrideBytes = sizeof(NxVec3); _desc.tetrahedronStrideBytes = 4*sizeof(NxU32); - _desc.vertices = NULL; - _desc.tetrahedra = NULL; + _desc.vertices = nullptr; + _desc.tetrahedra = nullptr; - _vertices = NULL; - _tetrahedra = NULL; + _vertices = nullptr; + _tetrahedra = nullptr; } /** diff --git a/panda/src/physx/physxSphereForceFieldShape.cxx b/panda/src/physx/physxSphereForceFieldShape.cxx index 4f140de456..bb04de907a 100644 --- a/panda/src/physx/physxSphereForceFieldShape.cxx +++ b/panda/src/physx/physxSphereForceFieldShape.cxx @@ -38,7 +38,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxSphereForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxSphereShape.cxx b/panda/src/physx/physxSphereShape.cxx index 60d7f15425..a67a3b2062 100644 --- a/panda/src/physx/physxSphereShape.cxx +++ b/panda/src/physx/physxSphereShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxSphereShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxSphericalJoint.cxx b/panda/src/physx/physxSphericalJoint.cxx index f1e8606ffa..3dabd9bfe4 100644 --- a/panda/src/physx/physxSphericalJoint.cxx +++ b/panda/src/physx/physxSphericalJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxSphericalJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxTriangleMesh.cxx b/panda/src/physx/physxTriangleMesh.cxx index 80971a3f2e..2b3d81280c 100644 --- a/panda/src/physx/physxTriangleMesh.cxx +++ b/panda/src/physx/physxTriangleMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseTriangleMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_triangle_mesh(this); } diff --git a/panda/src/physx/physxTriangleMeshDesc.I b/panda/src/physx/physxTriangleMeshDesc.I index 4acd6b09f9..e337b35d18 100644 --- a/panda/src/physx/physxTriangleMeshDesc.I +++ b/panda/src/physx/physxTriangleMeshDesc.I @@ -21,13 +21,13 @@ PhysxTriangleMeshDesc() { _desc.pointStrideBytes = sizeof(NxVec3); _desc.triangleStrideBytes = 3*sizeof(NxU32); _desc.materialIndexStride = sizeof(NxMaterialIndex); - _desc.points = NULL; - _desc.triangles = NULL; - _desc.materialIndices = NULL; + _desc.points = nullptr; + _desc.triangles = nullptr; + _desc.materialIndices = nullptr; - _vertices = NULL; - _triangles = NULL; - _materials = NULL; + _vertices = nullptr; + _triangles = nullptr; + _materials = nullptr; } /** diff --git a/panda/src/physx/physxTriangleMeshShape.cxx b/panda/src/physx/physxTriangleMeshShape.cxx index 954d0cf321..eaa57db4fc 100644 --- a/panda/src/physx/physxTriangleMeshShape.cxx +++ b/panda/src/physx/physxTriangleMeshShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxTriangleMeshShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxUtilLib.I b/panda/src/physx/physxUtilLib.I index ff04f2a2c2..dcdcb328ae 100644 --- a/panda/src/physx/physxUtilLib.I +++ b/panda/src/physx/physxUtilLib.I @@ -26,5 +26,5 @@ PhysxUtilLib() { INLINE PhysxUtilLib:: ~PhysxUtilLib() { - _ptr = NULL; + _ptr = nullptr; } diff --git a/panda/src/physx/physxWheelShape.cxx b/panda/src/physx/physxWheelShape.cxx index de34bf760c..69a3e5d02a 100644 --- a/panda/src/physx/physxWheelShape.cxx +++ b/panda/src/physx/physxWheelShape.cxx @@ -39,7 +39,7 @@ link(NxShape *shapePtr) { void PhysxWheelShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/pipeline/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx index 0cc738542f..fb67e7d3c9 100644 --- a/panda/src/pipeline/conditionVarDebug.cxx +++ b/panda/src/pipeline/conditionVarDebug.cxx @@ -75,8 +75,8 @@ wait() { << *current_thread << " waiting on " << *this << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar = this; @@ -86,7 +86,7 @@ wait() { nassertd(current_thread->_waiting_on_cvar == this) { } - current_thread->_waiting_on_cvar = NULL; + current_thread->_waiting_on_cvar = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() @@ -125,8 +125,8 @@ wait(double timeout) { << ", with timeout " << timeout << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar = this; @@ -136,7 +136,7 @@ wait(double timeout) { nassertd(current_thread->_waiting_on_cvar == this) { } - current_thread->_waiting_on_cvar = NULL; + current_thread->_waiting_on_cvar = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() diff --git a/panda/src/pipeline/conditionVarFullDebug.cxx b/panda/src/pipeline/conditionVarFullDebug.cxx index 8f59702a3f..24f9d1cdc3 100644 --- a/panda/src/pipeline/conditionVarFullDebug.cxx +++ b/panda/src/pipeline/conditionVarFullDebug.cxx @@ -75,8 +75,8 @@ wait() { << *current_thread << " waiting on " << *this << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar_full = this; @@ -86,7 +86,7 @@ wait() { nassertd(current_thread->_waiting_on_cvar_full == this) { } - current_thread->_waiting_on_cvar_full = NULL; + current_thread->_waiting_on_cvar_full = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() @@ -125,8 +125,8 @@ wait(double timeout) { << ", with timeout " << timeout << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar_full = this; @@ -136,7 +136,7 @@ wait(double timeout) { nassertd(current_thread->_waiting_on_cvar_full == this) { } - current_thread->_waiting_on_cvar_full = NULL; + current_thread->_waiting_on_cvar_full = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() diff --git a/panda/src/pipeline/conditionVarFullWin32Impl.I b/panda/src/pipeline/conditionVarFullWin32Impl.I index 361e81ac93..386a9d5784 100644 --- a/panda/src/pipeline/conditionVarFullWin32Impl.I +++ b/panda/src/pipeline/conditionVarFullWin32Impl.I @@ -19,8 +19,8 @@ ConditionVarFullWin32Impl(MutexWin32Impl &mutex) { _external_mutex = &mutex._lock; // Create an auto-reset event and a manual-reset event. - _event_signal = CreateEvent(NULL, false, false, NULL); - _event_broadcast = CreateEvent(NULL, true, false, NULL); + _event_signal = CreateEvent(nullptr, false, false, nullptr); + _event_broadcast = CreateEvent(nullptr, true, false, nullptr); _waiters_count = 0; } diff --git a/panda/src/pipeline/conditionVarPosixImpl.I b/panda/src/pipeline/conditionVarPosixImpl.I index e51c0e8447..0b3e533717 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.I +++ b/panda/src/pipeline/conditionVarPosixImpl.I @@ -19,7 +19,7 @@ ConditionVarPosixImpl(MutexPosixImpl &mutex) : _mutex(mutex) { TAU_PROFILE("ConditionVarPosixImpl::ConditionVarPosixImpl()", " ", TAU_USER); - int result = pthread_cond_init(&_cvar, NULL); + int result = pthread_cond_init(&_cvar, nullptr); nassertv(result == 0); } diff --git a/panda/src/pipeline/conditionVarPosixImpl.cxx b/panda/src/pipeline/conditionVarPosixImpl.cxx index 6613dd53b4..e2e527c369 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.cxx +++ b/panda/src/pipeline/conditionVarPosixImpl.cxx @@ -26,7 +26,7 @@ wait(double timeout) { // TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER); struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); // Convert from timeval to timespec struct timespec ts; diff --git a/panda/src/pipeline/conditionVarWin32Impl.I b/panda/src/pipeline/conditionVarWin32Impl.I index 263a7d37a4..5994c638d5 100644 --- a/panda/src/pipeline/conditionVarWin32Impl.I +++ b/panda/src/pipeline/conditionVarWin32Impl.I @@ -19,7 +19,7 @@ ConditionVarWin32Impl(MutexWin32Impl &mutex) { _external_mutex = &mutex._lock; // Create an auto-reset event. - _event_signal = CreateEvent(NULL, false, false, NULL); + _event_signal = CreateEvent(nullptr, false, false, nullptr); } /** diff --git a/panda/src/pipeline/cycleDataLockedReader.I b/panda/src/pipeline/cycleDataLockedReader.I index 311314e1dd..a622b9a2c0 100644 --- a/panda/src/pipeline/cycleDataLockedReader.I +++ b/panda/src/pipeline/cycleDataLockedReader.I @@ -28,7 +28,7 @@ CycleDataLockedReader(const PipelineCycler &cycler, _current_thread(current_thread) { _pointer = _cycler->read(_current_thread); - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -41,7 +41,7 @@ CycleDataLockedReader(const CycleDataLockedReader ©) : _current_thread(copy._current_thread), _pointer(copy._pointer) { - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -51,13 +51,13 @@ CycleDataLockedReader(const CycleDataLockedReader ©) : template INLINE void CycleDataLockedReader:: operator = (const CycleDataLockedReader ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -71,7 +71,7 @@ CycleDataLockedReader(CycleDataLockedReader &&from) noexcept : _current_thread(from._current_thread), _pointer(from._pointer) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -80,13 +80,13 @@ CycleDataLockedReader(CycleDataLockedReader &&from) noexcept : template INLINE void CycleDataLockedReader:: operator = (CycleDataLockedReader &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -95,7 +95,7 @@ operator = (CycleDataLockedReader &&from) noexcept { template INLINE CycleDataLockedReader:: ~CycleDataLockedReader() { - if (_pointer != NULL) { + if (_pointer != nullptr) { _cycler->release_read(_pointer); } } @@ -106,7 +106,7 @@ INLINE CycleDataLockedReader:: template INLINE const CycleDataType *CycleDataLockedReader:: operator -> () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -117,7 +117,7 @@ operator -> () const { template INLINE CycleDataLockedReader:: operator const CycleDataType * () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -131,8 +131,8 @@ template INLINE const CycleDataType *CycleDataLockedReader:: take_pointer() { const CycleDataType *pointer = _pointer; - _pointer = (CycleDataType *)NULL; - nassertr(pointer != (const CycleDataType *)NULL, _cycler->cheat()); + _pointer = nullptr; + nassertr(pointer != nullptr, _cycler->cheat()); return pointer; } diff --git a/panda/src/pipeline/cycleDataLockedStageReader.I b/panda/src/pipeline/cycleDataLockedStageReader.I index d65d9da889..22b8785c82 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.I +++ b/panda/src/pipeline/cycleDataLockedStageReader.I @@ -29,7 +29,7 @@ CycleDataLockedStageReader(const PipelineCycler &cycler, _stage(stage) { _pointer = _cycler->read_stage(_stage, _current_thread); - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -43,7 +43,7 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © _pointer(copy._pointer), _stage(copy._stage) { - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -53,14 +53,14 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © template INLINE void CycleDataLockedStageReader:: operator = (const CycleDataLockedStageReader ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; _stage = copy._stage; - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -75,7 +75,7 @@ CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noe _pointer(from._pointer), _stage(from._stage) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -84,14 +84,14 @@ CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noe template INLINE void CycleDataLockedStageReader:: operator = (CycleDataLockedStageReader &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; _stage = from._stage; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -100,7 +100,7 @@ operator = (CycleDataLockedStageReader &&from) noexcept { template INLINE CycleDataLockedStageReader:: ~CycleDataLockedStageReader() { - if (_pointer != NULL) { + if (_pointer != nullptr) { _cycler->release_read_stage(_stage, _pointer); } } @@ -111,7 +111,7 @@ INLINE CycleDataLockedStageReader:: template INLINE const CycleDataType *CycleDataLockedStageReader:: operator -> () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -122,7 +122,7 @@ operator -> () const { template INLINE CycleDataLockedStageReader:: operator const CycleDataType * () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -136,8 +136,8 @@ template INLINE const CycleDataType *CycleDataLockedStageReader:: take_pointer() { const CycleDataType *pointer = _pointer; - _pointer = (CycleDataType *)NULL; - nassertr(pointer != (const CycleDataType *)NULL, _cycler->cheat()); + _pointer = nullptr; + nassertr(pointer != nullptr, _cycler->cheat()); return pointer; } diff --git a/panda/src/pipeline/cycleDataStageWriter.I b/panda/src/pipeline/cycleDataStageWriter.I index a4ccc54c60..a4c1851dde 100644 --- a/panda/src/pipeline/cycleDataStageWriter.I +++ b/panda/src/pipeline/cycleDataStageWriter.I @@ -29,7 +29,7 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, _stage(stage) { _pointer = _cycler->write_stage(_stage, _current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -44,7 +44,7 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, _stage(stage) { _pointer = _cycler->write_stage_upstream(_stage, force_to_0, _current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -58,7 +58,7 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : _pointer(copy._pointer), _stage(copy._stage) { - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -68,14 +68,14 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : template INLINE void CycleDataStageWriter:: operator = (const CycleDataStageWriter ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; _stage = copy._stage; - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -125,7 +125,7 @@ CycleDataStageWriter(CycleDataStageWriter &&from) noexcept : _pointer(from._pointer), _stage(from._stage) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -134,14 +134,14 @@ CycleDataStageWriter(CycleDataStageWriter &&from) noexcept : template INLINE void CycleDataStageWriter:: operator = (CycleDataStageWriter &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; _stage = from._stage; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -150,7 +150,7 @@ operator = (CycleDataStageWriter &&from) noexcept { template INLINE CycleDataStageWriter:: ~CycleDataStageWriter() { - if (_pointer != (CycleDataType *)NULL) { + if (_pointer != nullptr) { _cycler->release_write_stage(_stage, _pointer); } } @@ -161,7 +161,7 @@ INLINE CycleDataStageWriter:: template INLINE CycleDataType *CycleDataStageWriter:: operator -> () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -171,7 +171,7 @@ operator -> () { template INLINE const CycleDataType *CycleDataStageWriter:: operator -> () const { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -182,7 +182,7 @@ operator -> () const { template INLINE CycleDataStageWriter:: operator CycleDataType * () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } diff --git a/panda/src/pipeline/cycleDataWriter.I b/panda/src/pipeline/cycleDataWriter.I index e142c38b3a..584c3ea129 100644 --- a/panda/src/pipeline/cycleDataWriter.I +++ b/panda/src/pipeline/cycleDataWriter.I @@ -27,7 +27,7 @@ CycleDataWriter(PipelineCycler &cycler, Thread *current_thread) : _current_thread(current_thread) { _pointer = _cycler->write(_current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -45,7 +45,7 @@ CycleDataWriter(PipelineCycler &cycler, bool force_to_0, _current_thread(current_thread) { _pointer = _cycler->write_upstream(force_to_0, _current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -64,7 +64,7 @@ CycleDataWriter(PipelineCycler &cycler, CycleDataType *locked_cda _current_thread(current_thread) { _pointer = locked_cdata; - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -77,7 +77,7 @@ CycleDataWriter(const CycleDataWriter ©) : _current_thread(copy._current_thread), _pointer(copy._pointer) { - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -87,13 +87,13 @@ CycleDataWriter(const CycleDataWriter ©) : template INLINE void CycleDataWriter:: operator = (const CycleDataWriter ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -140,7 +140,7 @@ CycleDataWriter(CycleDataWriter &&from) noexcept : _current_thread(from._current_thread), _pointer(from._pointer) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -149,13 +149,13 @@ CycleDataWriter(CycleDataWriter &&from) noexcept : template INLINE void CycleDataWriter:: operator = (CycleDataWriter &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -164,7 +164,7 @@ operator = (CycleDataWriter &&from) noexcept { template INLINE CycleDataWriter:: ~CycleDataWriter() { - if (_pointer != (CycleDataType *)NULL) { + if (_pointer != nullptr) { _cycler->release_write(_pointer); } } @@ -175,7 +175,7 @@ INLINE CycleDataWriter:: template INLINE CycleDataType *CycleDataWriter:: operator -> () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -185,7 +185,7 @@ operator -> () { template INLINE const CycleDataType *CycleDataWriter:: operator -> () const { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -196,7 +196,7 @@ operator -> () const { template INLINE CycleDataWriter:: operator CycleDataType * () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } diff --git a/panda/src/pipeline/genericThread.cxx b/panda/src/pipeline/genericThread.cxx index eb1941a5e3..b91819f61f 100644 --- a/panda/src/pipeline/genericThread.cxx +++ b/panda/src/pipeline/genericThread.cxx @@ -23,8 +23,8 @@ GenericThread:: GenericThread(const string &name, const string &sync_name) : Thread(name, sync_name) { - _function = NULL; - _user_data = NULL; + _function = nullptr; + _user_data = nullptr; } /** @@ -43,6 +43,6 @@ GenericThread(const string &name, const string &sync_name, GenericThread::Thread */ void GenericThread:: thread_main() { - nassertv(_function != NULL); + nassertv(_function != nullptr); (*_function)(_user_data); } diff --git a/panda/src/pipeline/lightMutexHolder.I b/panda/src/pipeline/lightMutexHolder.I index fb8a8951e4..6793c533ca 100644 --- a/panda/src/pipeline/lightMutexHolder.I +++ b/panda/src/pipeline/lightMutexHolder.I @@ -33,7 +33,7 @@ LightMutexHolder(const LightMutex &mutex) { INLINE LightMutexHolder:: LightMutexHolder(LightMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (LightMutex *)NULL) { + if (mutex == nullptr) { mutex = new LightMutex; } _mutex = mutex; diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index 388387517c..bdfe87059b 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -21,7 +21,7 @@ LightReMutexDirect() #endif { #ifndef HAVE_REMUTEXIMPL - _locking_thread = NULL; + _locking_thread = nullptr; _lock_count = 0; #endif } diff --git a/panda/src/pipeline/lightReMutexHolder.I b/panda/src/pipeline/lightReMutexHolder.I index 4158d92c26..8c0f82d98a 100644 --- a/panda/src/pipeline/lightReMutexHolder.I +++ b/panda/src/pipeline/lightReMutexHolder.I @@ -45,7 +45,7 @@ LightReMutexHolder(const LightReMutex &mutex, Thread *current_thread) { INLINE LightReMutexHolder:: LightReMutexHolder(LightReMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (LightReMutex *)NULL) { + if (mutex == nullptr) { mutex = new LightReMutex; } _mutex = mutex; diff --git a/panda/src/pipeline/mutexDebug.I b/panda/src/pipeline/mutexDebug.I index 9262f3e6d3..ae3ce74967 100644 --- a/panda/src/pipeline/mutexDebug.I +++ b/panda/src/pipeline/mutexDebug.I @@ -142,7 +142,7 @@ debug_is_locked() const { */ INLINE MutexTrueImpl *MutexDebug:: get_global_lock() { - if (_global_lock == (MutexTrueImpl *)NULL) { + if (_global_lock == nullptr) { _global_lock = new MutexTrueImpl; } return _global_lock; diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index ea75142fc6..a73e1257bc 100644 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -28,9 +28,9 @@ MutexDebug(const string &name, bool allow_recursion, bool lightweight) : Namable(name), _allow_recursion(allow_recursion), _lightweight(lightweight), - _locking_thread(NULL), + _locking_thread(nullptr), _lock_count(0), - _deleted_name(NULL), + _deleted_name(nullptr), _cvar_impl(*get_global_lock()) { #ifndef SIMPLE_THREADS @@ -45,7 +45,7 @@ MutexDebug(const string &name, bool allow_recursion, bool lightweight) : */ MutexDebug:: ~MutexDebug() { - nassertv(_locking_thread == NULL && _lock_count == 0); + nassertv(_locking_thread == nullptr && _lock_count == 0); // If the config variable says to, allocate (and leak) a string name for the // mutex, so we can report which mutex it is that has destructed after the @@ -86,7 +86,7 @@ void MutexDebug:: output_with_holder(ostream &out) const { _global_lock->lock(); output(out); - if (_locking_thread != (Thread *)NULL) { + if (_locking_thread != nullptr) { out << " (held by " << *_locking_thread << ")\n"; } _global_lock->unlock(); @@ -125,7 +125,7 @@ do_lock(Thread *current_thread) { nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; - if (name_deleted_mutexes && _deleted_name != NULL) { + if (name_deleted_mutexes && _deleted_name != nullptr) { pipeline_cat.error() << _deleted_name << "\n"; } else { @@ -135,7 +135,7 @@ do_lock(Thread *current_thread) { return; } - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -178,7 +178,7 @@ do_lock(Thread *current_thread) { // Check for deadlock. MutexDebug *next_mutex = this; - while (next_mutex != NULL) { + while (next_mutex != nullptr) { if (next_mutex->_locking_thread == current_thread) { // Whoops, the thread is blocked on me! Deadlock! report_deadlock(current_thread); @@ -186,7 +186,7 @@ do_lock(Thread *current_thread) { return; } Thread *next_thread = next_mutex->_locking_thread; - if (next_thread == NULL) { + if (next_thread == nullptr) { // Looks like this mutex isn't actually locked, which means the last // thread isn't really blocked--it just hasn't woken up yet to // discover that. In any case, no deadlock. @@ -209,7 +209,7 @@ do_lock(Thread *current_thread) { << *_locking_thread << ")\n"; } - while (_locking_thread != (Thread *)NULL) { + while (_locking_thread != nullptr) { thread_cat.debug() << *current_thread << " still blocking on " << *this << " (held by " << *_locking_thread << ")\n"; @@ -221,7 +221,7 @@ do_lock(Thread *current_thread) { << *current_thread << " acquired " << *this << "\n"; } - current_thread->_blocked_on_mutex = NULL; + current_thread->_blocked_on_mutex = nullptr; _locking_thread = current_thread; ++_lock_count; @@ -241,7 +241,7 @@ do_try_lock(Thread *current_thread) { nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; - if (name_deleted_mutexes && _deleted_name != NULL) { + if (name_deleted_mutexes && _deleted_name != nullptr) { pipeline_cat.error() << _deleted_name << "\n"; } else { @@ -252,7 +252,7 @@ do_try_lock(Thread *current_thread) { } bool acquired = true; - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -307,7 +307,7 @@ do_unlock() { nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; - if (name_deleted_mutexes && _deleted_name != NULL) { + if (name_deleted_mutexes && _deleted_name != nullptr) { pipeline_cat.error() << _deleted_name << "\n"; } else { @@ -350,7 +350,7 @@ do_unlock() { --_lock_count; if (_lock_count == 0) { // That was the last lock held by this thread. Release the lock. - _locking_thread = (Thread *)NULL; + _locking_thread = nullptr; if (_lightweight) { if (!_missed_threads.empty()) { @@ -415,7 +415,7 @@ report_deadlock(Thread *current_thread) { MutexDebug *next_mutex = this; Thread *next_thread = next_mutex->_locking_thread; next_mutex = next_thread->_blocked_on_mutex; - while (next_mutex != NULL) { + while (next_mutex != nullptr) { thread_cat.error() << *next_thread << " is blocked waiting on " << *next_mutex << " which is held by " diff --git a/panda/src/pipeline/mutexHolder.I b/panda/src/pipeline/mutexHolder.I index c2b6204e5a..f70220f338 100644 --- a/panda/src/pipeline/mutexHolder.I +++ b/panda/src/pipeline/mutexHolder.I @@ -47,7 +47,7 @@ MutexHolder(const Mutex &mutex, Thread *current_thread) { INLINE MutexHolder:: MutexHolder(Mutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (Mutex *)NULL) { + if (mutex == nullptr) { mutex = new Mutex; } _mutex = mutex; diff --git a/panda/src/pipeline/pipeline.I b/panda/src/pipeline/pipeline.I index 9d3512ae6c..163612e5f2 100644 --- a/panda/src/pipeline/pipeline.I +++ b/panda/src/pipeline/pipeline.I @@ -16,7 +16,7 @@ */ INLINE Pipeline *Pipeline:: get_render_pipeline() { - if (_render_pipeline == (Pipeline *)NULL) { + if (_render_pipeline == nullptr) { make_render_pipeline(); } return _render_pipeline; diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 94e1ff3c2a..c12e72114b 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -16,7 +16,7 @@ #include "configVariableInt.h" #include "config_pipeline.h" -Pipeline *Pipeline::_render_pipeline = (Pipeline *)NULL; +Pipeline *Pipeline::_render_pipeline = nullptr; /** * @@ -500,7 +500,7 @@ make_render_pipeline() { "pipeline stages than your application requires will incur " "additional runtime overhead.")); - nassertv(_render_pipeline == (Pipeline *)NULL); + nassertv(_render_pipeline == nullptr); _render_pipeline = new Pipeline("render", pipeline_stages); } diff --git a/panda/src/pipeline/pipelineCyclerDummyImpl.I b/panda/src/pipeline/pipelineCyclerDummyImpl.I index 997bdc9a09..2d0a9a8f04 100644 --- a/panda/src/pipeline/pipelineCyclerDummyImpl.I +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.I @@ -22,7 +22,7 @@ PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline) : _write_count(0), _locked(false) { - if (_pipeline == (Pipeline *)NULL) { + if (_pipeline == nullptr) { _pipeline = Pipeline::get_render_pipeline(); } } @@ -259,7 +259,7 @@ get_num_stages() { INLINE const CycleData *PipelineCyclerDummyImpl:: read_stage_unlocked(int pipeline_stage) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read_stage_unlocked(int)", " ", TAU_USER); - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); return _data; } @@ -276,7 +276,7 @@ read_stage(int pipeline_stage, Thread *) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read_stage(int, Thread *)", " ", TAU_USER); // This function isn't truly const, but it doesn't change the data in any // meaningful way, so we pretend it is. - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); ((PipelineCyclerDummyImpl *)this)->_read_count++; // It's not an error to grab a read pointer while someone else holds a read @@ -307,7 +307,7 @@ release_read_stage(int pipeline_stage, const CycleData *pointer) const { INLINE CycleData *PipelineCyclerDummyImpl:: write_stage(int pipeline_stage, Thread *) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write_stage(int)", " ", TAU_USER); - nassertr(pipeline_stage == 0, (CycleData *)NULL); + nassertr(pipeline_stage == 0, nullptr); _write_count++; return _data; } @@ -321,7 +321,7 @@ write_stage(int pipeline_stage, Thread *) { INLINE CycleData *PipelineCyclerDummyImpl:: write_stage_upstream(int pipeline_stage, bool, Thread *) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write_stage_upstream(int)", " ", TAU_USER); - nassertr(pipeline_stage == 0, (CycleData *)NULL); + nassertr(pipeline_stage == 0, nullptr); _write_count++; return _data; } @@ -334,7 +334,7 @@ write_stage_upstream(int pipeline_stage, bool, Thread *) { INLINE CycleData *PipelineCyclerDummyImpl:: elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read_stage(int, CycleData *)", " ", TAU_USER); - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); release_read(pointer); return write(current_thread); } @@ -348,7 +348,7 @@ INLINE CycleData *PipelineCyclerDummyImpl:: elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read_stage(int, CycleData *)", " ", TAU_USER); - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); release_read(pointer); return write(current_thread); } diff --git a/panda/src/pipeline/pipelineCyclerDummyImpl.h b/panda/src/pipeline/pipelineCyclerDummyImpl.h index 00e0df9387..588bb09d0c 100644 --- a/panda/src/pipeline/pipelineCyclerDummyImpl.h +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.h @@ -38,12 +38,12 @@ */ struct EXPCL_PANDA_PIPELINE PipelineCyclerDummyImpl { public: - INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = NULL); + INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = nullptr); INLINE PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl ©); INLINE void operator = (const PipelineCyclerDummyImpl ©); INLINE ~PipelineCyclerDummyImpl(); - INLINE void acquire(Thread *current_thread = NULL); + INLINE void acquire(Thread *current_thread = nullptr); INLINE void release(); INLINE const CycleData *read_unlocked(Thread *current_thread) const; diff --git a/panda/src/pipeline/pipelineCyclerLinks.I b/panda/src/pipeline/pipelineCyclerLinks.I index 7b52a935a5..bc002e8cd6 100644 --- a/panda/src/pipeline/pipelineCyclerLinks.I +++ b/panda/src/pipeline/pipelineCyclerLinks.I @@ -18,8 +18,8 @@ INLINE PipelineCyclerLinks:: PipelineCyclerLinks() { #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } #endif // THREADED_PIPELINE @@ -30,7 +30,7 @@ PipelineCyclerLinks() { */ INLINE PipelineCyclerLinks:: ~PipelineCyclerLinks() { - nassertv(_next == NULL && _prev == NULL); + nassertv(_next == nullptr && _prev == nullptr); } #endif // THREADED_PIPELINE @@ -40,7 +40,7 @@ INLINE PipelineCyclerLinks:: */ INLINE void PipelineCyclerLinks:: make_head() { - nassertv(_next == NULL && _prev == NULL); + nassertv(_next == nullptr && _prev == nullptr); _next = this; _prev = this; } @@ -55,8 +55,8 @@ INLINE void PipelineCyclerLinks:: clear_head() { nassertv(_next == this && _prev == this); #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } #endif // THREADED_PIPELINE @@ -71,8 +71,8 @@ remove_from_list() { _prev->_next = _next; _next->_prev = _prev; #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } #endif // THREADED_PIPELINE @@ -85,8 +85,8 @@ remove_from_list() { INLINE void PipelineCyclerLinks:: insert_before(PipelineCyclerLinks *node) { nassertv(node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (PipelineCyclerLinks *)NULL && - _next == (PipelineCyclerLinks *)NULL); + nassertv(_prev == nullptr && + _next == nullptr); _prev = node->_prev; _next = node; _prev->_next = this; diff --git a/panda/src/pipeline/pipelineCyclerTrivialImpl.h b/panda/src/pipeline/pipelineCyclerTrivialImpl.h index 9bcc9f12c9..75b2b6fffb 100644 --- a/panda/src/pipeline/pipelineCyclerTrivialImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.h @@ -40,13 +40,13 @@ class Pipeline; */ struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl { public: - INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = NULL); + INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = nullptr); PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl ©) = delete; ~PipelineCyclerTrivialImpl() = default; PipelineCyclerTrivialImpl &operator = (const PipelineCyclerTrivialImpl ©) = delete; - INLINE void acquire(Thread *current_thread = NULL); + INLINE void acquire(Thread *current_thread = nullptr); INLINE void release(); INLINE const CycleData *read_unlocked(Thread *current_thread) const; diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.I b/panda/src/pipeline/pipelineCyclerTrueImpl.I index fa6a97499b..4d6591b9b7 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.I +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.I @@ -54,7 +54,7 @@ read_unlocked(Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_unlocked(Thread *)", " ", TAU_USER); int pipeline_stage = current_thread->get_pipeline_stage(); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #endif return _data[pipeline_stage]._cdata; } @@ -72,7 +72,7 @@ read(Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read(Thread *)", " ", TAU_USER); int pipeline_stage = current_thread->get_pipeline_stage(); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #endif _lock.acquire(current_thread); return _data[pipeline_stage]._cdata; @@ -161,8 +161,8 @@ elevate_read(const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read(const CycleData *)", " ", TAU_USER); #ifdef _DEBUG int pipeline_stage = current_thread->get_pipeline_stage(); - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #endif CycleData *new_pointer = write(current_thread); _lock.release(); @@ -179,8 +179,8 @@ elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_upstream(const CycleData *, bool)", " ", TAU_USER); #ifdef _DEBUG int pipeline_stage = current_thread->get_pipeline_stage(); - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #endif CycleData *new_pointer = write_upstream(force_to_0, current_thread); _lock.release(); @@ -230,7 +230,7 @@ INLINE const CycleData *PipelineCyclerTrueImpl:: read_stage_unlocked(int pipeline_stage) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_stage_unlocked(int)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -249,7 +249,7 @@ INLINE const CycleData *PipelineCyclerTrueImpl:: read_stage(int pipeline_stage, Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_stage(int, Thread *)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -280,8 +280,8 @@ elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_stage(int, const CycleData *)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -300,8 +300,8 @@ elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool force_to_0, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_stage(int, const CycleData *)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -347,7 +347,7 @@ INLINE CycleData *PipelineCyclerTrueImpl:: cheat() const { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::cheat()", " ", TAU_USER); int pipeline_stage = Thread::get_current_pipeline_stage(); - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); return _data[pipeline_stage]._cdata; } diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx index f943a030f8..fb31088501 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx @@ -27,7 +27,7 @@ PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline) : _dirty(0), _lock(this) { - if (_pipeline == (Pipeline *)NULL) { + if (_pipeline == nullptr) { _pipeline = Pipeline::get_render_pipeline(); } @@ -64,7 +64,7 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©) : for (int i = 0; i < _num_stages; ++i) { PT(CycleData) &new_pt = pointers[copy._data[i]._cdata]; - if (new_pt == NULL) { + if (new_pt == nullptr) { new_pt = copy._data[i]._cdata->make_copy(); } _data[i]._cdata = new_pt.p(); @@ -90,7 +90,7 @@ operator = (const PipelineCyclerTrueImpl ©) { for (int i = 0; i < _num_stages; ++i) { PT(CycleData) &new_pt = pointers[copy._data[i]._cdata]; - if (new_pt == NULL) { + if (new_pt == nullptr) { new_pt = copy._data[i]._cdata->make_copy(); } _data[i]._cdata = new_pt.p(); @@ -111,7 +111,7 @@ PipelineCyclerTrueImpl:: _pipeline->remove_cycler(this); delete[] _data; - _data = NULL; + _data = nullptr; _num_stages = 0; } @@ -128,7 +128,7 @@ write_stage(int pipeline_stage, Thread *current_thread) { #ifndef NDEBUG nassertd(pipeline_stage >= 0 && pipeline_stage < _num_stages) { _lock.release(); - return NULL; + return nullptr; } #endif // NDEBUG @@ -176,7 +176,7 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread #ifndef NDEBUG nassertd(pipeline_stage >= 0 && pipeline_stage < _num_stages) { _lock.release(); - return NULL; + return nullptr; } #endif // NDEBUG @@ -209,7 +209,7 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread k = pipeline_stage - 1; while (k >= 0 && (_data[k]._cdata == old_data || force_to_0)) { - nassertr(_data[k]._writes_outstanding == 0, NULL); + nassertr(_data[k]._writes_outstanding == 0, nullptr); _data[k]._cdata = new_data.p(); --k; } @@ -228,7 +228,7 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread // There are no external pointers, so no need to copy-on-write, but the // current pointer doesn't go all the way back. Make it do so. while (k >= 0) { - nassertr(_data[k]._writes_outstanding == 0, NULL); + nassertr(_data[k]._writes_outstanding == 0, nullptr); _data[k]._cdata = old_data; --k; } diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.h b/panda/src/pipeline/pipelineCyclerTrueImpl.h index 59896c8b18..809fda99f4 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.h @@ -44,7 +44,7 @@ struct EXPCL_PANDA_PIPELINE PipelineCyclerTrueImpl : public PipelineCyclerLinks private: PipelineCyclerTrueImpl(); public: - PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline = NULL); + PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline = nullptr); PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©); void operator = (const PipelineCyclerTrueImpl ©); ~PipelineCyclerTrueImpl(); diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index 28bef610b5..ae64aba2a4 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -29,8 +29,8 @@ PythonThread(PyObject *function, PyObject *args, { _function = function; Py_INCREF(_function); - _args = NULL; - _result = NULL; + _args = nullptr; + _result = nullptr; if (!PyCallable_Check(_function)) { nassert_raise("Invalid function passed to PythonThread constructor"); @@ -78,7 +78,7 @@ PyObject *PythonThread:: join() { Thread::join(); - if (_result == NULL) { + if (_result == nullptr) { // No result; return None. Py_INCREF(Py_None); return Py_None; @@ -107,11 +107,11 @@ set_args(PyObject *args) { // None means no arguments; create an empty tuple. _args = PyTuple_New(0); } else { - _args = NULL; + _args = nullptr; if (PySequence_Check(args)) { _args = PySequence_Tuple(args); } - if (_args == NULL) { + if (_args == nullptr) { Dtool_Raise_TypeError("PythonThread args must be a tuple"); } } @@ -130,13 +130,13 @@ call_python_func(PyObject *function, PyObject *args) { // Create a new Python thread state data structure, so Python can properly // lock itself. - PyObject *result = NULL; + PyObject *result = nullptr; if (current_thread == get_main_thread()) { // In the main thread, just call the function. - result = PyObject_Call(function, args, NULL); + result = PyObject_Call(function, args, nullptr); - if (result == (PyObject *)NULL) { + if (result == nullptr) { if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_SystemExit)) { // If we caught SystemExit, let it pass by without bothering to print // a callback. @@ -161,7 +161,7 @@ call_python_func(PyObject *function, PyObject *args) { #ifndef HAVE_THREADS // Shouldn't be possible to come here without having some kind of // threading support enabled. - nassertr(false, NULL); + nassertr(false, nullptr); #else #ifdef SIMPLE_THREADS @@ -193,8 +193,8 @@ call_python_func(PyObject *function, PyObject *args) { PyThreadState_Swap(new_thread_state); // Call the user's function. - result = PyObject_Call(function, args, NULL); - if (result == (PyObject *)NULL && PyErr_Occurred()) { + result = PyObject_Call(function, args, nullptr); + if (result == nullptr && PyErr_Occurred()) { // We got an exception. Move the exception from the current thread into // the main thread, so it can be handled there. PyObject *exc, *val, *tb; @@ -237,8 +237,8 @@ call_python_func(PyObject *function, PyObject *args) { gstate = PyGILState_Ensure(); // Call the user's function. - result = PyObject_Call(function, args, NULL); - if (result == (PyObject *)NULL && PyErr_Occurred()) { + result = PyObject_Call(function, args, nullptr); + if (result == nullptr && PyErr_Occurred()) { // We got an exception. Move the exception from the current thread into // the main thread, so it can be handled there. PyObject *exc, *val, *tb; diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index cdcc7fd45e..51b380ac57 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -21,7 +21,7 @@ ReMutexDirect() #endif { #ifndef HAVE_REMUTEXTRUEIMPL - _locking_thread = NULL; + _locking_thread = nullptr; _lock_count = 0; #endif } diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index b82ed0f364..b83a2f30a6 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -36,7 +36,7 @@ void ReMutexDirect:: do_lock(Thread *current_thread) { _lock_impl.lock(); - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -52,7 +52,7 @@ do_lock(Thread *current_thread) { } else { // The mutex is locked by some other thread. Go to sleep on the condition // variable until it's unlocked. - while (_locking_thread != (Thread *)NULL) { + while (_locking_thread != nullptr) { _cvar_impl.wait(); } @@ -77,7 +77,7 @@ do_try_lock(Thread *current_thread) { bool acquired = true; _lock_impl.lock(); - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -117,7 +117,7 @@ do_elevate_lock() { return; } #elif !defined(NDEBUG) - nassertd(_locking_thread != (Thread *)NULL) { + nassertd(_locking_thread != nullptr) { _lock_impl.unlock(); return; } @@ -161,7 +161,7 @@ do_unlock() { --_lock_count; if (_lock_count == 0) { // That was the last lock held by this thread. Release the lock. - _locking_thread = (Thread *)NULL; + _locking_thread = nullptr; _cvar_impl.notify(); } _lock_impl.unlock(); diff --git a/panda/src/pipeline/reMutexHolder.I b/panda/src/pipeline/reMutexHolder.I index 00cd980e01..1c05196c7e 100644 --- a/panda/src/pipeline/reMutexHolder.I +++ b/panda/src/pipeline/reMutexHolder.I @@ -44,7 +44,7 @@ ReMutexHolder(const ReMutex &mutex, Thread *current_thread) { INLINE ReMutexHolder:: ReMutexHolder(ReMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (ReMutex *)NULL) { + if (mutex == nullptr) { mutex = new ReMutex; } _mutex = mutex; diff --git a/panda/src/pipeline/test_diners.cxx b/panda/src/pipeline/test_diners.cxx index 0a8f01e484..27976e3ea5 100644 --- a/panda/src/pipeline/test_diners.cxx +++ b/panda/src/pipeline/test_diners.cxx @@ -42,7 +42,7 @@ static double random_f(double max) return max * (double)i / (double)RAND_MAX; } -#define PRINTMSG(x) { MutexHolder l(Mutex::_notify_mutex); x << flush; } +#define PRINTMSG(x) { MutexHolder l(Mutex::_notify_mutex); x << std::flush; } // n philosophers sharing n chopsticks. Philosophers are poor folk and can't // afford luxuries like 2 chopsticks per person. diff --git a/panda/src/pipeline/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx index ebf6698216..2e347823c9 100644 --- a/panda/src/pipeline/test_threaddata.cxx +++ b/panda/src/pipeline/test_threaddata.cxx @@ -17,7 +17,7 @@ #include "mutexHolder.h" #include "pointerTo.h" -Mutex *cout_mutex = (Mutex *)NULL; +Mutex *cout_mutex = nullptr; // Test forking a thread with some private data. class ThreadWithData : public Thread { @@ -48,7 +48,7 @@ thread_main() { MutexHolder holder(cout_mutex); cout << "Running thread " << get_name() << " with parameter " << _parameter - << ", i = " << i << "\n" << flush; + << ", i = " << i << "\n" << std::flush; Thread *thread = get_current_thread(); nassertv(thread == this); } diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index d108f025dd..d8c8503742 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -84,7 +84,7 @@ set_min_pipeline_stage(int min_pipeline_stage) { */ INLINE Thread *Thread:: get_main_thread() { - if (_main_thread == (Thread *)NULL) { + if (_main_thread == nullptr) { init_main_thread(); } return _main_thread; @@ -98,7 +98,7 @@ get_main_thread() { */ INLINE Thread *Thread:: get_external_thread() { - if (_external_thread == (Thread *)NULL) { + if (_external_thread == nullptr) { init_external_thread(); } return _external_thread; @@ -121,7 +121,7 @@ get_current_thread() { return get_main_thread(); #else // HAVE_THREADS Thread *thread = ThreadImpl::get_current_thread(); - if (thread == (Thread *)NULL) { + if (thread == nullptr) { return Thread::get_external_thread(); } return thread; diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index 6a0f0278fc..3dc5994282 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -44,15 +44,15 @@ Thread(const string &name, const string &sync_name) : _started = false; _pstats_index = -1; _python_index = -1; - _pstats_callback = NULL; + _pstats_callback = nullptr; _pipeline_stage = 0; _joinable = false; - _current_task = NULL; + _current_task = nullptr; #ifdef DEBUG_THREADS - _blocked_on_mutex = NULL; - _waiting_on_cvar = NULL; - _waiting_on_cvar_full = NULL; + _blocked_on_mutex = nullptr; + _waiting_on_cvar = nullptr; + _waiting_on_cvar_full = nullptr; #endif } @@ -62,9 +62,9 @@ Thread(const string &name, const string &sync_name) : Thread:: ~Thread() { #ifdef DEBUG_THREADS - nassertv(_blocked_on_mutex == NULL && - _waiting_on_cvar == NULL && - _waiting_on_cvar_full == NULL); + nassertv(_blocked_on_mutex == nullptr && + _waiting_on_cvar == nullptr && + _waiting_on_cvar_full == nullptr); #endif } @@ -141,11 +141,11 @@ output(ostream &out) const { void Thread:: output_blocker(ostream &out) const { #ifdef DEBUG_THREADS - if (_blocked_on_mutex != (MutexDebug *)NULL) { + if (_blocked_on_mutex != nullptr) { _blocked_on_mutex->output_with_holder(out); - } else if (_waiting_on_cvar != (ConditionVarDebug *)NULL) { + } else if (_waiting_on_cvar != nullptr) { out << *_waiting_on_cvar; - } else if (_waiting_on_cvar_full != (ConditionVarFullDebug *)NULL) { + } else if (_waiting_on_cvar_full != nullptr) { out << *_waiting_on_cvar_full; } #endif // DEBUG_THREADS @@ -210,7 +210,7 @@ init_main_thread() { // here attempts to protect against that. static int count = 0; ++count; - if (count == 1 && _main_thread == (Thread *)NULL) { + if (count == 1 && _main_thread == nullptr) { _main_thread = new MainThread; _main_thread->ref(); } @@ -221,7 +221,7 @@ init_main_thread() { */ void Thread:: init_external_thread() { - if (_external_thread == (Thread *)NULL) { + if (_external_thread == nullptr) { _external_thread = new ExternalThread; _external_thread->ref(); } diff --git a/panda/src/pipeline/threadDummyImpl.I b/panda/src/pipeline/threadDummyImpl.I index 930f53fe4b..0bd2f7747a 100644 --- a/panda/src/pipeline/threadDummyImpl.I +++ b/panda/src/pipeline/threadDummyImpl.I @@ -107,7 +107,7 @@ sleep(double seconds) { struct timespec rqtp; rqtp.tv_sec = time_t(seconds); rqtp.tv_nsec = long((seconds - (double)rqtp.tv_sec) * 1000000000.0); - nanosleep(&rqtp, NULL); + nanosleep(&rqtp, nullptr); #endif // WIN32 } diff --git a/panda/src/pipeline/threadPosixImpl.I b/panda/src/pipeline/threadPosixImpl.I index 62b6026061..22a8c90118 100644 --- a/panda/src/pipeline/threadPosixImpl.I +++ b/panda/src/pipeline/threadPosixImpl.I @@ -101,7 +101,7 @@ sleep(double seconds) { struct timespec rqtp; rqtp.tv_sec = time_t(seconds); rqtp.tv_nsec = long((seconds - (double)rqtp.tv_sec) * 1000000000.0); - nanosleep(&rqtp, NULL); + nanosleep(&rqtp, nullptr); } /** diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index 9983ad24ea..dcae44e721 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -243,13 +243,13 @@ root_func(void *data) { ThreadPosixImpl *self = (ThreadPosixImpl *)data; int result = pthread_setspecific(_pt_ptr_index, self->_parent_obj); - nassertr(result == 0, NULL); + nassertr(result == 0, nullptr); { self->_mutex.lock(); nassertd(self->_status == S_start_called) { self->_mutex.unlock(); - return NULL; + return nullptr; } self->_status = S_running; @@ -273,7 +273,7 @@ root_func(void *data) { self->_mutex.lock(); nassertd(self->_status == S_running) { self->_mutex.unlock(); - return NULL; + return nullptr; } self->_status = S_finished; self->_mutex.unlock(); @@ -293,7 +293,7 @@ root_func(void *data) { unref_delete(self->_parent_obj); } - return NULL; + return nullptr; } /** @@ -304,7 +304,7 @@ void ThreadPosixImpl:: init_pt_ptr_index() { nassertv(!_got_pt_ptr_index); - int result = pthread_key_create(&_pt_ptr_index, NULL); + int result = pthread_key_create(&_pt_ptr_index, nullptr); if (result != 0) { thread_cat->error() << "Unable to associate Thread pointers with threads.\n"; diff --git a/panda/src/pipeline/threadSimpleImpl.cxx b/panda/src/pipeline/threadSimpleImpl.cxx index b4c90cd54e..1bde4c7ca0 100644 --- a/panda/src/pipeline/threadSimpleImpl.cxx +++ b/panda/src/pipeline/threadSimpleImpl.cxx @@ -43,7 +43,7 @@ ThreadSimpleImpl(Thread *parent_obj) : _wake_time = 0.0; _context = alloc_thread_context(); - _stack = NULL; + _stack = nullptr; _stack_size = 0; // Save this pointer for convenience. @@ -70,7 +70,7 @@ ThreadSimpleImpl:: free_thread_context(_context); - if (_stack != (void *)NULL) { + if (_stack != nullptr) { memory_hook->mmap_free(_stack, _stack_size); } _manager->remove_thread(this); @@ -107,7 +107,7 @@ start(ThreadPriority priority, bool joinable) { nassertr(_status == TS_new, false); - nassertr(_stack == NULL, false); + nassertr(_stack == nullptr, false); _stack_size = memory_hook->round_up_to_page_size((size_t)thread_stack_size); if (needs_stack_prealloc) { _stack = (unsigned char *)memory_hook->mmap_alloc(_stack_size, true); @@ -141,7 +141,7 @@ start(ThreadPriority priority, bool joinable) { #ifdef HAVE_PYTHON // Query the current Python thread state. - _python_state = PyThreadState_Swap(NULL); + _python_state = PyThreadState_Swap(nullptr); PyThreadState_Swap(_python_state); #endif // HAVE_PYTHON diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index 4c7640b885..8b58579642 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -71,9 +71,9 @@ ThreadSimpleManager() : { _tick_scale = 1000000.0; _total_ticks = 0; - _current_thread = NULL; + _current_thread = nullptr; _clock = TrueClock::get_global_ptr(); - _waiting_for_exit = NULL; + _waiting_for_exit = nullptr; // Install these global pointers so very low-level code (code defined before // the pipeline directory) can yield when necessary. @@ -235,12 +235,12 @@ next_context() { #ifdef HAVE_PYTHON // Save the current Python thread state. - _current_thread->_python_state = PyThreadState_Swap(NULL); + _current_thread->_python_state = PyThreadState_Swap(nullptr); #endif // HAVE_PYTHON #ifdef DO_PSTATS Thread::PStatsCallback *pstats_callback = _current_thread->_parent_obj->get_pstats_callback(); - if (pstats_callback != NULL) { + if (pstats_callback != nullptr) { pstats_callback->deactivate_hook(_current_thread->_parent_obj); } #endif // DO_PSTATS @@ -250,7 +250,7 @@ next_context() { // current thread. #ifdef DO_PSTATS - if (pstats_callback != NULL) { + if (pstats_callback != nullptr) { pstats_callback->activate_hook(_current_thread->_parent_obj); } #endif // DO_PSTATS @@ -281,7 +281,7 @@ prepare_for_exit() { << "prepare_for_exit\n"; } - nassertv(_waiting_for_exit == NULL); + nassertv(_waiting_for_exit == nullptr); _waiting_for_exit = _current_thread; // At this point, any non-joinable threads on any of the queues are @@ -321,7 +321,7 @@ prepare_for_exit() { */ void ThreadSimpleManager:: set_current_thread(ThreadSimpleImpl *current_thread) { - nassertv(_current_thread == (ThreadSimpleImpl *)NULL); + nassertv(_current_thread == nullptr); _current_thread = current_thread; } @@ -369,7 +369,7 @@ system_sleep(double seconds) { struct timeval tv; tv.tv_sec = time_t(seconds); tv.tv_usec = long((seconds - (double)tv.tv_sec) * 1000000.0 + 0.5); - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); #endif // WIN32 } @@ -498,7 +498,7 @@ choose_next_context(struct ThreadContext *from_context) { double now = get_current_time(); do_timeslice_accounting(_current_thread, now); - _current_thread = NULL; + _current_thread = nullptr; if (!_sleeping.empty() || !_volunteers.empty()) { if (_ready.empty() && _next_ready.empty()) { @@ -578,12 +578,12 @@ choose_next_context(struct ThreadContext *from_context) { } else { // No threads are ready! - if (_waiting_for_exit != NULL) { + if (_waiting_for_exit != nullptr) { // This is a shutdown situation. In this case, we quietly abandoned // the remaining blocked threads, if any, and switch back to the // main thread to finish shutting down. _ready.push_back(_waiting_for_exit); - _waiting_for_exit = NULL; + _waiting_for_exit = nullptr; break; } diff --git a/panda/src/pipeline/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx index 8508f23ac6..998dc44b8c 100644 --- a/panda/src/pipeline/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -70,7 +70,7 @@ start(ThreadPriority priority, bool joinable) { // eventually decrement it when it terminates. _parent_obj->ref(); _thread = - CreateThread(NULL, 0, &root_func, (void *)this, 0, &_thread_id); + CreateThread(nullptr, 0, &root_func, (void *)this, 0, &_thread_id); if (_thread_id == 0) { // Oops, we couldn't start the thread. Be sure to decrement the reference diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index d0424fcafe..97a151f324 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -118,7 +118,7 @@ read(const Filename &fullpath) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. pnmimage_cat.error() << "Could not find " << fullpath << "\n"; @@ -147,7 +147,7 @@ read(const Filename &fullpath) { bool PfmFile:: read(istream &in, const Filename &fullpath) { PNMReader *reader = make_reader(&in, false, fullpath); - if (reader == (PNMReader *)NULL) { + if (reader == nullptr) { clear(); return false; } @@ -163,7 +163,7 @@ bool PfmFile:: read(PNMReader *reader) { clear(); - if (reader == NULL) { + if (reader == nullptr) { return false; } @@ -230,7 +230,7 @@ write(ostream &out, const Filename &fullpath) { } PNMWriter *writer = make_writer(&out, false, fullpath); - if (writer == (PNMWriter *)NULL) { + if (writer == nullptr) { return false; } @@ -244,7 +244,7 @@ write(ostream &out, const Filename &fullpath) { */ bool PfmFile:: write(PNMWriter *writer) { - if (writer == NULL) { + if (writer == nullptr) { return false; } @@ -1816,7 +1816,7 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 break; default: - nassertr(false, NULL); + nassertr(false, nullptr); } // Rotate the bounding volume back into the original space of the screen. diff --git a/panda/src/pnmimage/pfmFile_ext.cxx b/panda/src/pnmimage/pfmFile_ext.cxx index 4e041e986f..fb31f7ead5 100644 --- a/panda/src/pnmimage/pfmFile_ext.cxx +++ b/panda/src/pnmimage/pfmFile_ext.cxx @@ -93,7 +93,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { int channels = _this->get_num_channels(); int num_pixels = _this->get_x_size() * _this->get_y_size(); - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -101,20 +101,20 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->len = 4 * table.size(); view->readonly = 1; view->itemsize = 4; - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char *) "f"; } view->ndim = 2; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // If you're leaking and you know it, clap your hands! view->shape = new Py_ssize_t[2]; view->shape[0] = num_pixels; view->shape[1] = channels; } - view->strides = NULL; - view->suboffsets = NULL; + view->strides = nullptr; + view->suboffsets = nullptr; return 0; #else diff --git a/panda/src/pnmimage/pnmFileType.cxx b/panda/src/pnmimage/pnmFileType.cxx index 762d86fee4..80fae2784a 100644 --- a/panda/src/pnmimage/pnmFileType.cxx +++ b/panda/src/pnmimage/pnmFileType.cxx @@ -92,7 +92,7 @@ matches_magic_number(const string &) const { */ PNMReader *PNMFileType:: make_reader(istream *, bool, const string &) { - return NULL; + return nullptr; } /** @@ -102,7 +102,7 @@ make_reader(istream *, bool, const string &) { */ PNMWriter *PNMFileType:: make_writer(ostream *, bool) { - return NULL; + return nullptr; } /** diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.cxx b/panda/src/pnmimage/pnmFileTypeRegistry.cxx index 96e24ef1bb..c1dd16f211 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.cxx +++ b/panda/src/pnmimage/pnmFileTypeRegistry.cxx @@ -132,7 +132,7 @@ get_num_types() const { */ PNMFileType *PNMFileTypeRegistry:: get_type(int n) const { - nassertr(n >= 0 && n < (int)_types.size(), NULL); + nassertr(n >= 0 && n < (int)_types.size(), nullptr); return _types[n]; } @@ -190,7 +190,7 @@ get_type_from_extension(const string &filename) const { if (ei == _extensions.end() || (*ei).second.empty()) { // Nothing matches that string. - return NULL; + return nullptr; } } @@ -219,7 +219,7 @@ get_type_from_magic_number(const string &magic_number) const { } } - return NULL; + return nullptr; } /** @@ -235,7 +235,7 @@ get_type_by_handle(TypeHandle handle) const { return (*hi).second; } - return (PNMFileType *)NULL; + return nullptr; } /** @@ -273,7 +273,7 @@ write(ostream &out, int indent_level) const { */ PNMFileTypeRegistry *PNMFileTypeRegistry:: get_global_ptr() { - if (_global_ptr == (PNMFileTypeRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PNMFileTypeRegistry; } return _global_ptr; diff --git a/panda/src/pnmimage/pnmImage.I b/panda/src/pnmimage/pnmImage.I index d4a7026483..21c6619ea8 100644 --- a/panda/src/pnmimage/pnmImage.I +++ b/panda/src/pnmimage/pnmImage.I @@ -16,8 +16,8 @@ */ INLINE PNMImage:: PNMImage() { - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; clear(); } @@ -28,8 +28,8 @@ PNMImage() { INLINE PNMImage:: PNMImage(int x_size, int y_size, int num_channels, xelval maxval, PNMFileType *type, ColorSpace color_space) { - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; clear(x_size, y_size, num_channels, maxval, type, color_space); } @@ -41,8 +41,8 @@ INLINE PNMImage:: PNMImage(const PNMImage ©) { // We don't need to invoke PNMImageHeader's copy constructor, because we'll // just call copy_from(). - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; copy_from(copy); } @@ -251,7 +251,7 @@ get_color_space() const { */ INLINE bool PNMImage:: is_valid() const { - return (_array != NULL); + return (_array != nullptr); } /** @@ -403,7 +403,7 @@ get_gray_val(int x, int y) const { */ INLINE xelval PNMImage:: get_alpha_val(int x, int y) const { - nassertr(_alpha != NULL && x >= 0 && x < _x_size && y >= 0 && y < _y_size, 0); + nassertr(_alpha != nullptr && x >= 0 && x < _x_size && y >= 0 && y < _y_size, 0); return alpha_row(y)[x]; } @@ -468,7 +468,7 @@ set_gray_val(int x, int y, xelval gray) { */ INLINE void PNMImage:: set_alpha_val(int x, int y, xelval a) { - nassertv(_alpha != NULL && x >= 0 && x < _x_size && y >= 0 && y < _y_size); + nassertv(_alpha != nullptr && x >= 0 && x < _x_size && y >= 0 && y < _y_size); alpha_row(y)[x] = a; } @@ -1120,7 +1120,7 @@ get_alpha_array() const { INLINE xel *PNMImage:: take_array() { xel *array = _array; - _array = NULL; + _array = nullptr; return array; } @@ -1133,7 +1133,7 @@ take_array() { INLINE xelval *PNMImage:: take_alpha_array() { xelval *alpha = _alpha; - _alpha = NULL; + _alpha = nullptr; return alpha; } @@ -1159,7 +1159,7 @@ allocate_alpha() { */ INLINE xel *PNMImage:: row(int y) const { - nassertr(y >= 0 && y < _y_size, NULL); + nassertr(y >= 0 && y < _y_size, nullptr); return _array + y * _x_size; } @@ -1169,7 +1169,7 @@ row(int y) const { */ INLINE xelval *PNMImage:: alpha_row(int y) const { - nassertr(_alpha != NULL && y >= 0 && y < _y_size, NULL); + nassertr(_alpha != nullptr && y >= 0 && y < _y_size, nullptr); return _alpha + y * _x_size; } diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 3e3829ac52..ce9871d6f0 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -26,8 +26,8 @@ */ PNMImage:: PNMImage(const Filename &filename, PNMFileType *type) { - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; _has_read_size = false; bool result = read(filename, type); @@ -43,13 +43,13 @@ PNMImage(const Filename &filename, PNMFileType *type) { */ void PNMImage:: clear() { - if (_array != (xel *)NULL) { + if (_array != nullptr) { PANDA_FREE_ARRAY(_array); - _array = (xel *)NULL; + _array = nullptr; } - if (_alpha != (xelval *)NULL) { + if (_alpha != nullptr) { PANDA_FREE_ARRAY(_alpha); - _alpha = (xelval *)NULL; + _alpha = nullptr; } _x_size = 0; _y_size = 0; @@ -58,7 +58,7 @@ clear() { _inv_maxval = 1.0 / 255.0; _color_space = CS_linear; _comment.clear(); - _type = (PNMFileType *)NULL; + _type = nullptr; _has_read_size = false; _xel_encoding = XE_generic; } @@ -226,10 +226,10 @@ take_from(PNMImage &orig) { if (has_alpha()) { _alpha = orig._alpha; - orig._alpha = NULL; + orig._alpha = nullptr; } _array = orig._array; - orig._array = NULL; + orig._array = nullptr; orig.clear(); } @@ -274,7 +274,7 @@ alpha_fill_val(xelval alpha) { bool PNMImage:: read(const Filename &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = make_reader(filename, type, report_unknown_type); - if (reader == (PNMReader *)NULL) { + if (reader == nullptr) { clear(); return false; } @@ -299,7 +299,7 @@ read(istream &data, const string &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = PNMImageHeader::make_reader (&data, false, filename, string(), type, report_unknown_type); - if (reader == (PNMReader *)NULL) { + if (reader == nullptr) { clear(); return false; } @@ -322,7 +322,7 @@ read(PNMReader *reader) { clear(); - if (reader == NULL) { + if (reader == nullptr) { return false; } @@ -385,7 +385,7 @@ write(const Filename &filename, PNMFileType *type) const { } PNMWriter *writer = PNMImageHeader::make_writer(filename, type); - if (writer == (PNMWriter *)NULL) { + if (writer == nullptr) { return false; } @@ -409,7 +409,7 @@ write(ostream &data, const string &filename, PNMFileType *type) const { PNMWriter *writer = PNMImageHeader::make_writer (&data, false, filename, type); - if (writer == (PNMWriter *)NULL) { + if (writer == nullptr) { return false; } @@ -425,7 +425,7 @@ write(ostream &data, const string &filename, PNMFileType *type) const { */ bool PNMImage:: write(PNMWriter *writer) const { - if (writer == NULL) { + if (writer == nullptr) { return false; } @@ -497,9 +497,9 @@ set_color_type(PNMImage::ColorType color_type) { if (has_alpha() && !has_alpha(color_type)) { // Discard the alpha channel - if (_alpha != NULL) { + if (_alpha != nullptr) { PANDA_FREE_ARRAY(_alpha); - _alpha = NULL; + _alpha = nullptr; } } else if (!has_alpha() && has_alpha(color_type)) { @@ -535,7 +535,7 @@ set_color_space(ColorSpace color_space) { return; } - if (_array != NULL) { + if (_array != nullptr) { size_t array_size = _x_size * _y_size; // Note: only convert RGB, since alpha channel is always linear. @@ -680,7 +680,7 @@ unpremultiply_alpha() { */ void PNMImage:: reverse_rows() { - if (_array != NULL) { + if (_array != nullptr) { xel *new_array = (xel *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xel)); for (int y = 0; y < _y_size; y++) { int new_y = _y_size - 1 - y; @@ -690,7 +690,7 @@ reverse_rows() { _array = new_array; } - if (_alpha != NULL) { + if (_alpha != nullptr) { xelval *new_alpha = (xelval *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xelval)); for (int y = 0; y < _y_size; y++) { int new_y = _y_size - 1 - y; @@ -712,7 +712,7 @@ void PNMImage:: flip(bool flip_x, bool flip_y, bool transpose) { if (transpose) { // Transposed case. X becomes Y, Y becomes X. - if (_array != NULL) { + if (_array != nullptr) { xel *new_array = (xel *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xel)); for (int xi = 0; xi < _x_size; ++xi) { xel *row = new_array + xi * _y_size; @@ -727,7 +727,7 @@ flip(bool flip_x, bool flip_y, bool transpose) { _array = new_array; } - if (_alpha != NULL) { + if (_alpha != nullptr) { xelval *new_alpha = (xelval *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xelval)); for (int xi = 0; xi < _x_size; ++xi) { xelval *row = new_alpha + xi * _y_size; @@ -749,7 +749,7 @@ flip(bool flip_x, bool flip_y, bool transpose) { } else { // Non-transposed. X is X, Y is Y. - if (_array != NULL) { + if (_array != nullptr) { xel *new_array = (xel *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xel)); for (int yi = 0; yi < _y_size; ++yi) { xel *row = new_array + yi * _x_size; @@ -765,7 +765,7 @@ flip(bool flip_x, bool flip_y, bool transpose) { _array = new_array; } - if (_alpha != NULL) { + if (_alpha != nullptr) { xelval *new_alpha = (xelval *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xelval)); for (int yi = 0; yi < _y_size; ++yi) { xelval *row = new_alpha + yi * _x_size; @@ -984,7 +984,7 @@ set_pixel(int x, int y, const PixelSpec &pixel) { xel p; PPM_ASSIGN(p, pixel._red, pixel._green, pixel._blue); set_xel_val(x, y, p); - if (_alpha != NULL) { + if (_alpha != nullptr) { set_alpha_val(x, y, pixel._alpha); } } @@ -1016,9 +1016,9 @@ blend(int x, int y, float r, float g, float b, float alpha) { } else { // Blend the color with the previous color. LRGBColorf prev_rgb = get_xel(x, y); - r = r + (1.0f - alpha) * (get_red(x, y) - r); - g = g + (1.0f - alpha) * (get_green(x, y) - g); - b = b + (1.0f - alpha) * (get_blue(x, y) - b); + r = r + (1.0f - alpha) * (prev_rgb[0] - r); + g = g + (1.0f - alpha) * (prev_rgb[1] - g); + b = b + (1.0f - alpha) * (prev_rgb[2] - b); alpha = prev_alpha + alpha * (1.0f - prev_alpha); if (has_alpha()) { @@ -1039,7 +1039,7 @@ blend(int x, int y, float r, float g, float b, float alpha) { */ void PNMImage:: set_array(xel *array) { - if (_array != (xel *)NULL) { + if (_array != nullptr) { PANDA_FREE_ARRAY(_array); } _array = array; @@ -1055,7 +1055,7 @@ set_array(xel *array) { */ void PNMImage:: set_alpha_array(xelval *alpha) { - if (_alpha != (xelval *)NULL) { + if (_alpha != nullptr) { PANDA_FREE_ARRAY(_alpha); } _alpha = alpha; @@ -1596,7 +1596,7 @@ threshold(const PNMImage &select_image, int channel, float threshold, void PNMImage:: fill_distance_inside(const PNMImage &mask, float threshold, int radius, bool shrink_from_border) { nassertv(radius <= PNM_MAXMAXVAL); - PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, NULL, CS_linear); + PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, nullptr, CS_linear); dist.fill_val(radius); xelval threshold_val = mask.to_val(threshold); @@ -1640,7 +1640,7 @@ fill_distance_inside(const PNMImage &mask, float threshold, int radius, bool shr void PNMImage:: fill_distance_outside(const PNMImage &mask, float threshold, int radius) { nassertv(radius <= PNM_MAXMAXVAL); - PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, NULL, CS_linear); + PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, nullptr, CS_linear); dist.fill_val(radius); xelval threshold_val = mask.to_val(threshold); @@ -1918,7 +1918,7 @@ make_histogram(PNMImage::Histogram &histogram) { pixels.push_back(PixelSpecCount((*hi).first, (*hi).second)); } } - ::sort(pixels.begin(), pixels.end()); + std::sort(pixels.begin(), pixels.end()); histogram.swap(pixels, hist_map); } @@ -2252,20 +2252,20 @@ operator ~ () const { PNMImage target (*this); size_t array_size = _x_size * _y_size; - if (_array != NULL && _alpha != NULL) { + if (_array != nullptr && _alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { target._array[i].r = _maxval - _array[i].r; target._array[i].g = _maxval - _array[i].g; target._array[i].b = _maxval - _array[i].b; target._alpha[i] = _maxval - _alpha[i]; } - } else if (_array != NULL) { + } else if (_array != nullptr) { for (size_t i = 0; i < array_size; ++i) { target._array[i].r = _maxval - _array[i].r; target._array[i].g = _maxval - _array[i].g; target._array[i].b = _maxval - _array[i].b; } - } else if (_alpha != NULL) { + } else if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { target._alpha[i] = _maxval - _alpha[i]; } @@ -2288,7 +2288,7 @@ operator += (const PNMImage &other) { size_t array_size = _x_size * _y_size; // Simple case: add vals directly. - if (_alpha != NULL && other._alpha != NULL) { + if (_alpha != nullptr && other._alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)_array[i].r + (int)other._array[i].r); _array[i].g = clamp_val((int)_array[i].g + (int)other._array[i].g); @@ -2329,7 +2329,7 @@ operator += (const LColorf &other) { int add_b = (int)(other.get_z() * get_maxval() + 0.5); int add_a = (int)(other.get_w() * get_maxval() + 0.5); - if (_alpha != NULL) { + if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)_array[i].r + add_r); _array[i].g = clamp_val((int)_array[i].g + add_g); @@ -2370,7 +2370,7 @@ operator -= (const PNMImage &other) { size_t array_size = _x_size * _y_size; // Simple case: subtract vals directly. - if (_alpha != NULL && other._alpha != NULL) { + if (_alpha != nullptr && other._alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)_array[i].r - (int)other._array[i].r); _array[i].g = clamp_val((int)_array[i].g - (int)other._array[i].g); @@ -2433,7 +2433,7 @@ operator *= (float multiplier) { if (get_color_space() == CS_linear) { size_t array_size = _x_size * _y_size; - if (_alpha != NULL) { + if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)(_array[i].r * multiplier + 0.5f)); _array[i].g = clamp_val((int)(_array[i].g * multiplier + 0.5f)); @@ -2470,7 +2470,7 @@ operator *= (const LColorf &other) { if (get_color_space() == CS_linear) { size_t array_size = _x_size * _y_size; - if (_alpha != NULL) { + if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)(_array[i].r * other[0] + 0.5f)); _array[i].g = clamp_val((int)(_array[i].g * other[1] + 0.5f)); diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index 2f7b653185..583d5edef2 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -58,9 +58,9 @@ class PNMFileType; class EXPCL_PANDA_PNMIMAGE PNMImage : public PNMImageHeader { PUBLISHED: INLINE PNMImage(); - explicit PNMImage(const Filename &filename, PNMFileType *type = NULL); + explicit PNMImage(const Filename &filename, PNMFileType *type = nullptr); INLINE explicit PNMImage(int x_size, int y_size, int num_channels = 3, - xelval maxval = 255, PNMFileType *type = NULL, + xelval maxval = 255, PNMFileType *type = nullptr, ColorSpace color_space = CS_linear); INLINE PNMImage(const PNMImage ©); INLINE void operator = (const PNMImage ©); @@ -75,7 +75,7 @@ PUBLISHED: void clear(); void clear(int x_size, int y_size, int num_channels = 3, - xelval maxval = 255, PNMFileType *type = NULL, + xelval maxval = 255, PNMFileType *type = nullptr, ColorSpace color_space = CS_linear); void copy_from(const PNMImage ©); @@ -100,16 +100,16 @@ PUBLISHED: INLINE int get_read_y_size() const; INLINE ColorSpace get_color_space() const; - BLOCKING bool read(const Filename &filename, PNMFileType *type = NULL, + BLOCKING bool read(const Filename &filename, PNMFileType *type = nullptr, bool report_unknown_type = true); BLOCKING bool read(istream &data, const string &filename = string(), - PNMFileType *type = NULL, + PNMFileType *type = nullptr, bool report_unknown_type = true); BLOCKING bool read(PNMReader *reader); - BLOCKING bool write(const Filename &filename, PNMFileType *type = NULL) const; + BLOCKING bool write(const Filename &filename, PNMFileType *type = nullptr) const; BLOCKING bool write(ostream &data, const string &filename = string(), - PNMFileType *type = NULL) const; + PNMFileType *type = nullptr) const; BLOCKING bool write(PNMWriter *writer) const; INLINE bool is_valid() const; diff --git a/panda/src/pnmimage/pnmImageHeader.I b/panda/src/pnmimage/pnmImageHeader.I index fc62587986..2801d4d89d 100644 --- a/panda/src/pnmimage/pnmImageHeader.I +++ b/panda/src/pnmimage/pnmImageHeader.I @@ -21,7 +21,7 @@ PNMImageHeader() { _num_channels = 0; _maxval = 255; _color_space = CS_unspecified; - _type = (PNMFileType *)NULL; + _type = nullptr; } /** @@ -184,7 +184,7 @@ set_comment(const string& comment) { */ INLINE bool PNMImageHeader:: has_type() const { - return _type != (PNMFileType *)NULL; + return _type != nullptr; } /** diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index a0098b58f7..b51e2d8c4d 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -29,7 +29,7 @@ bool PNMImageHeader:: read_header(const Filename &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = make_reader(filename, type, report_unknown_type); - if (reader != (PNMReader *)NULL) { + if (reader != nullptr) { (*this) = (*reader); delete reader; return true; @@ -55,7 +55,7 @@ read_header(istream &data, const string &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = PNMImageHeader::make_reader (&data, false, filename, string(), type, report_unknown_type); - if (reader != (PNMReader *)NULL) { + if (reader != nullptr) { (*this) = (*reader); delete reader; return true; @@ -80,7 +80,7 @@ make_reader(const Filename &filename, PNMFileType *type, << "Reading image from " << filename << "\n"; } bool owns_file = false; - istream *file = (istream *)NULL; + istream *file = nullptr; if (filename == "-") { owns_file = false; @@ -96,12 +96,12 @@ make_reader(const Filename &filename, PNMFileType *type, file = vfs->open_read_file(filename, true); } - if (file == (istream *)NULL) { + if (file == nullptr) { if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() << "Unable to open file.\n"; } - return NULL; + return nullptr; } return make_reader(file, owns_file, filename, string(), type, @@ -135,7 +135,7 @@ PNMReader *PNMImageHeader:: make_reader(istream *file, bool owns_file, const Filename &filename, string magic_number, PNMFileType *type, bool report_unknown_type) const { - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { if (!read_magic_number(file, magic_number, 2)) { // No magic number. No image. if (pnmimage_cat.is_debug()) { @@ -151,14 +151,14 @@ make_reader(istream *file, bool owns_file, const Filename &filename, // since vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(file); } - return NULL; + return nullptr; } type = PNMFileTypeRegistry::get_global_ptr()-> get_type_from_magic_number(magic_number); if (pnmimage_cat.is_debug()) { - if (type != (PNMFileType *)NULL) { + if (type != nullptr) { pnmimage_cat.debug() << "By magic number, image file appears to be type " << type->get_name() << ".\n"; @@ -169,13 +169,13 @@ make_reader(istream *file, bool owns_file, const Filename &filename, } } - if (type == (PNMFileType *)NULL && !filename.empty()) { + if (type == nullptr && !filename.empty()) { // We still don't know the type; attempt to guess it from the filename // extension. type = PNMFileTypeRegistry::get_global_ptr()->get_type_from_extension(filename); if (pnmimage_cat.is_debug()) { - if (type != (PNMFileType *)NULL) { + if (type != nullptr) { pnmimage_cat.debug() << "From its extension, image file is probably type " << type->get_name() << ".\n"; @@ -187,17 +187,17 @@ make_reader(istream *file, bool owns_file, const Filename &filename, } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // No? How about the default type associated with this image header. type = _type; - if (pnmimage_cat.is_debug() && type != (PNMFileType *)NULL) { + if (pnmimage_cat.is_debug() && type != nullptr) { pnmimage_cat.debug() << "Assuming image file type is " << type->get_name() << ".\n"; } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // We can't figure out what type the file is; give up. if (report_unknown_type && pnmimage_cat.is_error()) { pnmimage_cat.error() @@ -215,18 +215,18 @@ make_reader(istream *file, bool owns_file, const Filename &filename, // since vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(file); } - return NULL; + return nullptr; } PNMReader *reader = type->make_reader(file, owns_file, magic_number); - if (reader == NULL && owns_file) { + if (reader == nullptr && owns_file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(file); } if (!reader->is_valid()) { delete reader; - reader = NULL; + reader = nullptr; } return reader; @@ -247,7 +247,7 @@ make_writer(const Filename &filename, PNMFileType *type) const { << "Writing image to " << filename << "\n"; } bool owns_file = false; - ostream *file = (ostream *)NULL; + ostream *file = nullptr; if (filename == "-") { owns_file = false; @@ -262,17 +262,17 @@ make_writer(const Filename &filename, PNMFileType *type) const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); Filename actual_name = Filename::binary_filename(filename); file = vfs->open_write_file(actual_name, true, true); - if (file != NULL) { + if (file != nullptr) { owns_file = true; } } - if (file == (ostream *)NULL) { + if (file == nullptr) { if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() << "Unable to write to file.\n"; } - return NULL; + return nullptr; } return make_writer(file, owns_file, filename, type); @@ -299,13 +299,13 @@ make_writer(const Filename &filename, PNMFileType *type) const { PNMWriter *PNMImageHeader:: make_writer(ostream *file, bool owns_file, const Filename &filename, PNMFileType *type) const { - if (type == (PNMFileType *)NULL && !filename.empty()) { + if (type == nullptr && !filename.empty()) { // We don't know the type; attempt to guess it from the filename // extension. type = PNMFileTypeRegistry::get_global_ptr()->get_type_from_extension(filename); if (pnmimage_cat.is_debug()) { - if (type != (PNMFileType *)NULL) { + if (type != nullptr) { pnmimage_cat.debug() << "From its extension, image file is intended to be type " << type->get_name() << ".\n"; @@ -316,17 +316,17 @@ make_writer(ostream *file, bool owns_file, const Filename &filename, } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // No? How about the default type associated with this image header. type = _type; - if (pnmimage_cat.is_debug() && type != (PNMFileType *)NULL) { + if (pnmimage_cat.is_debug() && type != nullptr) { pnmimage_cat.debug() << "Assuming image file type is " << type->get_name() << ".\n"; } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // We can't figure out what type the file is; give up. if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() @@ -335,17 +335,17 @@ make_writer(ostream *file, bool owns_file, const Filename &filename, if (owns_file) { delete file; } - return NULL; + return nullptr; } PNMWriter *writer = type->make_writer(file, owns_file); - if (writer == NULL && owns_file) { + if (writer == nullptr && owns_file) { delete file; } - if (writer != NULL && !writer->is_valid()) { + if (writer != nullptr && !writer->is_valid()) { delete writer; - writer = NULL; + writer = nullptr; } return writer; diff --git a/panda/src/pnmimage/pnmImageHeader.h b/panda/src/pnmimage/pnmImageHeader.h index 1132bed14f..6aeb40642d 100644 --- a/panda/src/pnmimage/pnmImageHeader.h +++ b/panda/src/pnmimage/pnmImageHeader.h @@ -84,25 +84,25 @@ PUBLISHED: INLINE void set_type(PNMFileType *type); MAKE_PROPERTY2(type, has_type, get_type); - BLOCKING bool read_header(const Filename &filename, PNMFileType *type = NULL, + BLOCKING bool read_header(const Filename &filename, PNMFileType *type = nullptr, bool report_unknown_type = true); BLOCKING bool read_header(istream &data, const string &filename = string(), - PNMFileType *type = NULL, bool report_unknown_type = true); + PNMFileType *type = nullptr, bool report_unknown_type = true); PNMReader *make_reader(const Filename &filename, - PNMFileType *type = NULL, + PNMFileType *type = nullptr, bool report_unknown_type = true) const; PNMReader *make_reader(istream *file, bool owns_file = true, const Filename &filename = Filename(), string magic_number = string(), - PNMFileType *type = NULL, + PNMFileType *type = nullptr, bool report_unknown_type = true) const; PNMWriter *make_writer(const Filename &filename, - PNMFileType *type = NULL) const; + PNMFileType *type = nullptr) const; PNMWriter *make_writer(ostream *file, bool owns_file = true, const Filename &filename = Filename(), - PNMFileType *type = NULL) const; + PNMFileType *type = nullptr) const; static bool read_magic_number(istream *file, string &magic_number, int num_bytes); diff --git a/panda/src/pnmimage/pnmReader.cxx b/panda/src/pnmimage/pnmReader.cxx index 9f6c3bc2c9..b40bf3ce40 100644 --- a/panda/src/pnmimage/pnmReader.cxx +++ b/panda/src/pnmimage/pnmReader.cxx @@ -29,7 +29,7 @@ PNMReader:: // vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(_file); } - _file = (istream *)NULL; + _file = nullptr; } /** diff --git a/panda/src/pnmimage/pnmWriter.cxx b/panda/src/pnmimage/pnmWriter.cxx index 0115f261aa..936608e69e 100644 --- a/panda/src/pnmimage/pnmWriter.cxx +++ b/panda/src/pnmimage/pnmWriter.cxx @@ -22,7 +22,7 @@ PNMWriter:: if (_owns_file) { delete _file; } - _file = (ostream *)NULL; + _file = nullptr; } /** diff --git a/panda/src/pnmimage/pnmbitio.cxx b/panda/src/pnmimage/pnmbitio.cxx index ec44d05d44..2dcbfbfacc 100644 --- a/panda/src/pnmimage/pnmbitio.cxx +++ b/panda/src/pnmimage/pnmbitio.cxx @@ -48,7 +48,7 @@ struct bitstream EXPCL_PANDA_PNMIMAGE struct bitstream * pm_bitinit(istream *f, const char *mode) { - struct bitstream *ans = (struct bitstream *)0; + struct bitstream *ans = nullptr; if(!f || !mode || !*mode) return ans; @@ -68,7 +68,7 @@ pm_bitinit(istream *f, const char *mode) EXPCL_PANDA_PNMIMAGE struct bitstream * pm_bitinit(ostream *f, const char *mode) { - struct bitstream *ans = (struct bitstream *)0; + struct bitstream *ans = nullptr; if(!f || !mode || !*mode) return ans; diff --git a/panda/src/pnmimage/ppmcmap.cxx b/panda/src/pnmimage/ppmcmap.cxx index c061bfbde5..48de568d68 100644 --- a/panda/src/pnmimage/ppmcmap.cxx +++ b/panda/src/pnmimage/ppmcmap.cxx @@ -31,8 +31,8 @@ ppm_computecolorhist(pixel** pixels, colorhist_vector chv; cht = ppm_computecolorhash( pixels, cols, rows, maxcolors, colorsP ); - if ( cht == (colorhash_table) 0 ) - return (colorhist_vector) 0; + if ( cht == nullptr ) + return nullptr; chv = ppm_colorhashtocolorhist( cht, maxcolors ); ppm_freecolorhash( cht ); return chv; @@ -95,20 +95,20 @@ ppm_computecolorhash(pixel** pixels, for ( col = 0, pP = pixels[row]; col < cols; ++col, ++pP ) { hash = ppm_hashpixel( *pP ); - for ( chl = cht[hash]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[hash]; chl != nullptr; chl = chl->next ) if ( PPM_EQUAL( chl->ch.color, *pP ) ) break; - if ( chl != (colorhist_list) 0 ) + if ( chl != nullptr ) ++(chl->ch.value); else { if ( ++(*colorsP) > maxcolors ) { ppm_freecolorhash( cht ); - return (colorhash_table) 0; + return nullptr; } chl = (colorhist_list) malloc( sizeof(struct colorhist_list_item) ); - if ( chl == 0 ) + if ( chl == nullptr ) pm_error( "out of memory computing hash table" ); chl->ch.color = *pP; chl->ch.value = 1; @@ -127,11 +127,11 @@ ppm_alloccolorhash( ) int i; cht = (colorhash_table) malloc( HASH_SIZE * sizeof(colorhist_list) ); - if ( cht == 0 ) + if ( cht == nullptr ) pm_error( "out of memory allocating hash table" ); for ( i = 0; i < HASH_SIZE; ++i ) - cht[i] = (colorhist_list) 0; + cht[i] = nullptr; return cht; } @@ -145,7 +145,7 @@ ppm_addtocolorhash(colorhash_table cht, colorhist_list chl; chl = (colorhist_list) malloc( sizeof(struct colorhist_list_item) ); - if ( chl == 0 ) + if ( chl == nullptr ) return -1; hash = ppm_hashpixel( *colorP ); chl->ch.color = *colorP; @@ -166,13 +166,13 @@ ppm_colorhashtocolorhist(colorhash_table cht, /* Now collate the hash table into a simple colorhist array. */ chv = (colorhist_vector) malloc( maxcolors * sizeof(struct colorhist_item) ); /* (Leave room for expansion by caller.) */ - if ( chv == (colorhist_vector) 0 ) + if ( chv == nullptr ) pm_error( "out of memory generating histogram" ); /* Loop through the hash table. */ j = 0; for ( i = 0; i < HASH_SIZE; ++i ) - for ( chl = cht[i]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[i]; chl != nullptr; chl = chl->next ) { /* Add the new entry. */ chv[j] = chl->ch; @@ -198,13 +198,13 @@ ppm_colorhisttocolorhash(colorhist_vector chv, { color = chv[i].color; hash = ppm_hashpixel( color ); - for ( chl = cht[hash]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[hash]; chl != nullptr; chl = chl->next ) if ( PPM_EQUAL( chl->ch.color, color ) ) pm_error( "same color found twice - %d %d %d", PPM_GETR(color), PPM_GETG(color), PPM_GETB(color) ); chl = (colorhist_list) malloc( sizeof(struct colorhist_list_item) ); - if ( chl == (colorhist_list) 0 ) + if ( chl == nullptr ) pm_error( "out of memory" ); chl->ch.color = color; chl->ch.value = i; @@ -223,7 +223,7 @@ ppm_lookupcolor(colorhash_table cht, colorhist_list chl; hash = ppm_hashpixel( *colorP ); - for ( chl = cht[hash]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[hash]; chl != nullptr; chl = chl->next ) if ( PPM_EQUAL( chl->ch.color, *colorP ) ) return chl->ch.value; @@ -243,7 +243,7 @@ ppm_freecolorhash(colorhash_table cht) colorhist_list chl, chlnext; for ( i = 0; i < HASH_SIZE; ++i ) - for ( chl = cht[i]; chl != (colorhist_list) 0; chl = chlnext ) + for ( chl = cht[i]; chl != nullptr; chl = chlnext ) { chlnext = chl->next; free( (char*) chl ); diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index b115aa5213..7661696980 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -269,6 +269,7 @@ init_libpnmimagetypes() { // And register with the PandaSystem. PandaSystem *ps = PandaSystem::get_global_ptr(); + (void)ps; // Suppress unused variable warning #ifdef HAVE_JPEG ps->add_system("libjpeg"); diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx index 5d33812216..394445f257 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx @@ -332,13 +332,13 @@ BMPreadrow( pixval *G, pixval *B) { - BITSTREAM b = NULL; + BITSTREAM b = nullptr; unsigned nbyte = 0; int rc; unsigned x; if (indexed) { - if ((b = pm_bitinit(fp, "r")) == (BITSTREAM) 0) + if ((b = pm_bitinit(fp, "r")) == nullptr) { return -1; } diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx index 879682a297..b624314b6b 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx @@ -276,7 +276,7 @@ BMPwriterow( unsigned x; if (indexed) { - if ((b = pm_bitinit(fp, "w")) == (BITSTREAM) 0) + if ((b = pm_bitinit(fp, "w")) == nullptr) { return -1; } @@ -580,7 +580,7 @@ write_data(xel *array, xelval *) { // Quietly generate a 24-bit image. BMPEncode24(_file, classv, _x_size, _y_size, pixels, _maxval); - } else if (chv == (colorhist_vector) 0) { + } else if (chv == nullptr) { if (bmp_bpp != 0) { // Even though we asked for fewer bits, we have to settle for 24-bit. pnmimage_bmp_cat.info() diff --git a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx index 6f27c5e09a..157bd716be 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx @@ -216,8 +216,8 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : // grayscale/alpha images correctly, but also incorrectly detects // luminance/chroma images as grayscale only. However, these kind // of images are a pain to handle anyway, so maybe that's OK. - const char *possible_channel_names[] = { "R", "G", "B", "Y", "A", NULL }; - for (const char **pni = possible_channel_names; *pni != NULL; ++pni) { + const char *possible_channel_names[] = { "R", "G", "B", "Y", "A", nullptr }; + for (const char **pni = possible_channel_names; *pni != nullptr; ++pni) { std::string name = *pni; IMF::ChannelList::ConstIterator ci = channels.find(name.c_str()); if (ci != channels.end()) { @@ -376,7 +376,7 @@ write_pfm(const PfmFile &pfm) { const char *channel_names_2[] = { "G", "A" }; const char *channel_names_3[] = { "R", "G", "B" }; const char *channel_names_4[] = { "R", "G", "B", "A" }; - const char **channel_names = NULL; + const char **channel_names = nullptr; switch (pfm.get_num_channels()) { case 1: diff --git a/panda/src/pnmimagetypes/pnmFileTypeEXR.h b/panda/src/pnmimagetypes/pnmFileTypeEXR.h index 3a0827a74e..58292d11a8 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeEXR.h +++ b/panda/src/pnmimagetypes/pnmFileTypeEXR.h @@ -69,7 +69,6 @@ public: typedef std::vector ChannelNames; ChannelNames _channel_names; - IMF::PixelType _best_pixel_type; }; class Writer : public PNMWriter { diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.h b/panda/src/pnmimagetypes/pnmFileTypeJPG.h index b82534189a..591c7fe247 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.h @@ -89,18 +89,6 @@ public: }; typedef struct my_error_mgr *_my_error_ptr; struct my_error_mgr _jerr; - unsigned long pos; - - unsigned long offBits; - - unsigned short cBitCount; - int indexed; - int classv; - - pixval R[256]; /* reds */ - pixval G[256]; /* greens */ - pixval B[256]; /* blues */ - bool _is_valid; }; diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx index 333bac61eb..4525dda22a 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx @@ -216,7 +216,7 @@ jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) * This makes it unsafe to use this manager and a different source * manager serially with the same JPEG object. Caveat programmer. */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ + if (cinfo->src == nullptr) { /* first time for this JPEG object? */ cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(my_source_mgr)); @@ -234,7 +234,7 @@ jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) src->pub.term_source = term_source; src->infile = infile; src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ + src->pub.next_input_byte = nullptr; /* until buffer loaded */ } diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx index 5e0f52f5a6..5308a3417e 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx @@ -166,7 +166,7 @@ jpeg_ostream_dest (j_compress_ptr cinfo, ostream * outfile) * manager serially with the same JPEG object, because their private object * sizes may be different. Caveat programmer. */ - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + if (cinfo->dest == nullptr) { /* first time for this JPEG object? */ cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(my_destination_mgr)); diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx index bf4ab4ac31..3c2bb2b1d0 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx @@ -162,19 +162,19 @@ PNMFileTypePNG::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) { - _png = NULL; - _info = NULL; + _png = nullptr; + _info = nullptr; _is_valid = false; - _png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, + _png = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, png_error, png_warning); - if (_png == NULL) { + if (_png == nullptr) { return; } _info = png_create_info_struct(_png); - if (_info == NULL) { - png_destroy_read_struct(&_png, NULL, NULL); + if (_info == nullptr) { + png_destroy_read_struct(&_png, nullptr, nullptr); return; } @@ -201,7 +201,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : double gamma; png_get_IHDR(_png, _info, &width, &height, - &bit_depth, &color_type, NULL, NULL, NULL); + &bit_depth, &color_type, nullptr, nullptr, nullptr); // Look for an sRGB chunk. if (png_get_sRGB(_png, _info, &srgb_intent) == PNG_INFO_sRGB) { @@ -403,7 +403,7 @@ read_data(xel *array, xelval *alpha_data) { PANDA_FREE_ARRAY(rows); - png_read_end(_png, NULL); + png_read_end(_png, nullptr); return _y_size; } @@ -414,7 +414,7 @@ read_data(xel *array, xelval *alpha_data) { void PNMFileTypePNG::Reader:: free_png() { if (_is_valid) { - png_destroy_read_struct(&_png, &_info, NULL); + png_destroy_read_struct(&_png, &_info, nullptr); _is_valid = false; } } @@ -456,7 +456,7 @@ png_error(png_structp png_ptr, png_const_charp error_msg) { // The PNG library insists we should not return, so instead of returning, we // will do a longjmp out of the png code. Reader *self = (Reader *)png_get_io_ptr(png_ptr); - if (self == (Reader *)NULL) { + if (self == nullptr) { // Oops, we haven't got a self pointer yet. Return anyway and hope we'll // be ok. pnmimage_png_cat.error() @@ -474,19 +474,19 @@ PNMFileTypePNG::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { - _png = NULL; - _info = NULL; + _png = nullptr; + _info = nullptr; _is_valid = false; - _png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, + _png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, png_error, png_warning); - if (_png == NULL) { + if (_png == nullptr) { return; } _info = png_create_info_struct(_png); - if (_info == NULL) { - png_destroy_write_struct(&_png, NULL); + if (_info == nullptr) { + png_destroy_write_struct(&_png, nullptr); return; } @@ -610,7 +610,7 @@ write_data(xel *array, xelval *alpha_data) { if (has_alpha()) { pnmimage_png_cat.debug() << "palette contains " << num_alpha << " transparent entries.\n"; - png_set_tRNS(_png, _info, png_trans, num_alpha, NULL); + png_set_tRNS(_png, _info, png_trans, num_alpha, nullptr); } } else { pnmimage_png_cat.debug() @@ -828,7 +828,7 @@ write_data(xel *array, xelval *alpha_data) { } PANDA_FREE_ARRAY(row); - png_write_end(_png, NULL); + png_write_end(_png, nullptr); return _y_size; } @@ -918,7 +918,7 @@ png_error(png_structp png_ptr, png_const_charp error_msg) { // The PNG library insists we should not return, so instead of returning, we // will do a longjmp out of the png code. Writer *self = (Writer *)png_get_io_ptr(png_ptr); - if (self == (Writer *)NULL) { + if (self == nullptr) { // Oops, we haven't got a self pointer yet. Return anyway and hope we'll // be ok. pnmimage_png_cat.error() diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index efbee9e646..7fd918aa73 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -127,21 +127,21 @@ pm_allocarray(int const cols, int const rows, int const size ) { char * rowheap; rowIndex = (char **)PANDA_MALLOC_ARRAY((rows + 1) * sizeof(char *)); - if ( rowIndex == NULL ) + if ( rowIndex == nullptr ) pm_error("out of memory allocating row index (%u rows) for an array", rows); rowheap = (char *)PANDA_MALLOC_ARRAY( rows * cols * size ); - if ( rowheap == NULL ) { + if ( rowheap == nullptr ) { /* We couldn't get the whole heap in one block, so try fragmented format. */ int row; - rowIndex[rows] = NULL; /* Declare it fragmented format */ + rowIndex[rows] = nullptr; /* Declare it fragmented format */ for (row = 0; row < rows; ++row) { rowIndex[row] = pm_allocrow(cols, size); - if (rowIndex[row] == NULL) + if (rowIndex[row] == nullptr) pm_error("out of memory allocating Row %u " "(%u columns, %u bytes per tuple) " "of an array", row, cols, size); @@ -163,7 +163,7 @@ pm_freearray(char ** const rowIndex, void * const rowheap = rowIndex[rows]; - if (rowheap != NULL) { + if (rowheap != nullptr) { PANDA_FREE_ARRAY(rowheap); } else { int row; diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx index 597dc9296a..2f56552d18 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx @@ -86,7 +86,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) { eof_err = false; - table = NULL; + table = nullptr; if (!read_magic_number(_file, magic_number, 4)) { // No magic number. No image. @@ -146,7 +146,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : */ PNMFileTypeSGI::Reader:: ~Reader() { - if (table != NULL) { + if (table != nullptr) { free(table); } } @@ -333,7 +333,7 @@ read_channel(istream *ifp, TabEntry *table, ScanElem *channel_data, long table_start, int channel, int row) { - ScanElem *temp = NULL; + ScanElem *temp = nullptr; int sgi_index, i; long offset, length; @@ -486,10 +486,10 @@ xmalloc(int bytes) { void *mem; if( bytes == 0 ) - return NULL; + return nullptr; mem = malloc(bytes); - if( mem == NULL ) + if( mem == nullptr ) pm_error("out of memory allocating %d bytes", bytes); return mem; } diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx index f63431bba1..faf45cc093 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx @@ -88,7 +88,7 @@ Writer(PNMFileType *type, ostream *file, bool owns_file) : */ PNMFileTypeSGI::Writer:: ~Writer() { - if (table!=NULL) { + if (table!=nullptr) { // Rewrite the table with the correct values in it. _file->seekp(table_start); write_table(); @@ -119,7 +119,7 @@ supports_write_row() const { */ bool PNMFileTypeSGI::Writer:: write_header() { - table = NULL; + table = nullptr; switch (_num_channels) { case 1: @@ -155,7 +155,7 @@ write_header() { write_rgb_header(sgi_imagename.c_str()); - if (table!=NULL) { + if (table!=nullptr) { table_start = _file->tellp(); // The first time we write the table, it has zeroes. We'll correct this diff --git a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx index e17e0e9df8..93599cac83 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx @@ -91,7 +91,7 @@ static const int num_stb_extensions = sizeof(stb_extensions) / sizeof(const char // Callbacks to allow stb_image to read from VFS. static int cb_read(void *user, char *data, int size) { istream *in = (istream *)user; - nassertr(in != NULL, 0); + nassertr(in != nullptr, 0); in->read(data, size); @@ -105,7 +105,7 @@ static int cb_read(void *user, char *data, int size) { static void cb_skip(void *user, int n) { istream *in = (istream *)user; - nassertv(in != NULL); + nassertv(in != nullptr); in->seekg(n, ios::cur); @@ -118,7 +118,7 @@ static void cb_skip(void *user, int n) { static int cb_eof(void *user) { istream *in = (istream *)user; - nassertr(in != NULL, 1); + nassertr(in != nullptr, 1); return in->eof(); } @@ -358,7 +358,7 @@ read_pfm(PfmFile &pfm) { return false; } token += 3; - width = (int) strtol(token, NULL, 10); + width = (int) strtol(token, nullptr, 10); // Read data pfm.clear(width, height, 3); @@ -380,7 +380,7 @@ main_decode_loop: } } else { // Read RLE-encoded data - scanline = NULL; + scanline = nullptr; for (j = 0; j < height; ++j) { c1 = stbi__get8(&_context); diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index 75e90d630d..3be6bd1ff0 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -176,8 +176,8 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : tga_head = new ImageHeader; RLE_count = 0; RLE_flag = 0; - ColorMap = NULL; - AlphaMap = NULL; + ColorMap = nullptr; + AlphaMap = nullptr; Red = 0; Grn = 0; @@ -283,7 +283,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : temp1 = tga_head->Index_lo + tga_head->Index_hi * 256; temp2 = tga_head->Length_lo + tga_head->Length_hi * 256; int num_colors = temp1 + temp2 + 1; - nassertv(ColorMap == NULL && AlphaMap == NULL); + nassertv(ColorMap == nullptr && AlphaMap == nullptr); ColorMap = (pixel *)PANDA_MALLOC_ARRAY(num_colors * sizeof(pixel)); AlphaMap = (gray *)PANDA_MALLOC_ARRAY(num_colors * sizeof(gray)); for ( unsigned int i = temp1; i < ( temp1 + temp2 ); ++i ) @@ -311,10 +311,10 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMFileTypeTGA::Reader:: ~Reader() { delete tga_head; - if (ColorMap != NULL) { + if (ColorMap != nullptr) { PANDA_FREE_ARRAY(ColorMap); } - if (AlphaMap != NULL) { + if (AlphaMap != nullptr) { PANDA_FREE_ARRAY(AlphaMap); } } @@ -363,9 +363,9 @@ Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { tgaHeader = new ImageHeader; - chv = (colorhist_vector)0; - cht = (colorhash_table)0; - runlength = (int*)0; + chv = nullptr; + cht = nullptr; + runlength = nullptr; } /** @@ -375,13 +375,13 @@ PNMFileTypeTGA::Writer:: ~Writer() { delete tgaHeader; - if (chv != (colorhist_vector)0) { + if (chv != nullptr) { ppm_freecolorhist(chv); } - if (cht != (colorhash_table)0) { + if (cht != nullptr) { ppm_freecolorhash(cht); } - if (runlength != (int *)0) { + if (runlength != nullptr) { pm_freerow((char *)runlength); } } @@ -432,7 +432,7 @@ write_data(xel *array, xelval *) { pnmimage_tga_cat.info() << "computing colormap...\n"; chv = ppm_computecolorhist(&array, cols * rows, 1, TGA_MAXCOLORS, &ncolors ); - if ( chv == (colorhist_vector) 0 ) { + if ( chv == nullptr ) { pnmimage_tga_cat.info() << "too many colors, writing RGB.\n"; } else { @@ -498,7 +498,7 @@ write_data(xel *array, xelval *) { tgaHeader->OrgBit = 0; /* Write out the Targa header. */ - writetga( tgaHeader, (char*) 0 ); + writetga( tgaHeader, nullptr ); if ( tgaHeader->ImgType == TGA_Map || tgaHeader->ImgType == TGA_RLEMap ) { diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index d4870c22d3..e2d5cf0fa1 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -338,7 +338,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : iostream_dont_close, istream_size, iostream_map, iostream_unmap); - if ( tif == NULL ) { + if ( tif == nullptr ) { _is_valid = false; } } @@ -374,7 +374,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : if (_is_valid) { unsigned short num_extra_samples; - unsigned short *extra_samples = NULL; + unsigned short *extra_samples = nullptr; if (!TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &num_extra_samples, &extra_samples)) { @@ -547,7 +547,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : */ PNMFileTypeTIFF::Reader:: ~Reader() { - if (tif != (struct tiff *)NULL) { + if (tif != nullptr) { TIFFClose(tif); } } @@ -898,7 +898,7 @@ write_pfm(const PfmFile &pfm) { (TIFFSeekProc)ostream_seek, iostream_dont_close, ostream_size, iostream_map, iostream_unmap); - if (tif == NULL) { + if (tif == nullptr) { return false; } @@ -958,7 +958,7 @@ write_pfm(const PfmFile &pfm) { */ int PNMFileTypeTIFF::Writer:: write_data(xel *array, xelval *alpha) { - colorhist_vector chv = (colorhist_vector) 0; + colorhist_vector chv = nullptr; colorhash_table cht; unsigned short red[TIFF_COLORMAP_MAXCOLORS], @@ -986,7 +986,7 @@ write_data(xel *array, xelval *alpha) { // the number of colors we can read. chv = ppm_computecolorhist( (pixel **)&array, _x_size * _y_size, 1, 256, &colors ); - if ( chv == (colorhist_vector) 0 ) { + if ( chv == nullptr ) { pnmimage_tiff_cat.debug() << colors << " colors found; too many for a palette.\n" << "Writing a 24-bit RGB file.\n"; @@ -1011,12 +1011,12 @@ write_data(xel *array, xelval *alpha) { case CT_two_channel: // We don't yet support two-channel output for TIFF's. case CT_four_channel: - chv = (colorhist_vector) 0; + chv = nullptr; grayscale = false; break; case CT_grayscale: - chv = (colorhist_vector) 0; + chv = nullptr; grayscale = true; break; @@ -1031,7 +1031,7 @@ write_data(xel *array, xelval *alpha) { (TIFFSeekProc)ostream_seek, iostream_dont_close, ostream_size, iostream_map, iostream_unmap); - if ( tif == NULL ) { + if ( tif == nullptr ) { return 0; } @@ -1039,7 +1039,7 @@ write_data(xel *array, xelval *alpha) { switch ( get_color_type() ) { case CT_color: case CT_four_channel: - if ( chv == (colorhist_vector) 0 ) { + if ( chv == nullptr ) { samplesperpixel = _num_channels; bitspersample = 8; photometric = PHOTOMETRIC_RGB; @@ -1072,7 +1072,7 @@ write_data(xel *array, xelval *alpha) { } buf = (unsigned char*) malloc( bytesperrow ); - if ( buf == (unsigned char*) 0 ) { + if ( buf == nullptr ) { pnmimage_tiff_cat.error() << "Can't allocate memory for row buffer\n"; return 0; @@ -1100,8 +1100,8 @@ write_data(xel *array, xelval *alpha) { } TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG ); - if ( chv == (colorhist_vector) 0 ) { - cht = (colorhash_table) 0; + if ( chv == nullptr ) { + cht = nullptr; } else { /* Make TIFF colormap. */ for ( i = 0; i < colors; ++i ) { @@ -1122,7 +1122,7 @@ write_data(xel *array, xelval *alpha) { xelval *alpha_data = alpha + row*_x_size; if ( !is_grayscale() && ! grayscale ) { - if ( cht == (colorhash_table) 0 ) { + if ( cht == nullptr ) { tP = buf; for ( col = 0; col < _x_size; ++col ) { *tP++ = (unsigned char)(255 * PPM_GETR(row_data[col]) / _maxval); diff --git a/panda/src/pnmtext/freetypeFace.cxx b/panda/src/pnmtext/freetypeFace.cxx index 0366e3c49a..6dee837486 100644 --- a/panda/src/pnmtext/freetypeFace.cxx +++ b/panda/src/pnmtext/freetypeFace.cxx @@ -28,7 +28,7 @@ TypeHandle FreetypeFace::_type_handle; */ FreetypeFace:: FreetypeFace() : _lock("FreetypeFace::_lock") { - _face = NULL; + _face = nullptr; _char_size = 0; _dpi = 0; _pixel_width = 0; @@ -44,7 +44,7 @@ FreetypeFace() : _lock("FreetypeFace::_lock") { */ FreetypeFace:: ~FreetypeFace() { - if (_face != NULL){ + if (_face != nullptr){ FT_Done_Face(_face); } } @@ -101,7 +101,7 @@ void FreetypeFace:: set_face(FT_Face face) { MutexHolder holder(_lock); - if (_face != NULL){ + if (_face != nullptr){ FT_Done_Face(_face); } _face = face; @@ -111,7 +111,7 @@ set_face(FT_Face face) { _pixel_height = 0; _name = _face->family_name; - if (_face->style_name != NULL) { + if (_face->style_name != nullptr) { _name += " "; _name += _face->style_name; } @@ -129,7 +129,7 @@ set_face(FT_Face face) { pnmtext_cat.debug() << "default charmap is " << (void *)_face->charmap << "\n"; } - if (_face->charmap == NULL) { + if (_face->charmap == nullptr) { // If for some reason FreeType didn't set us up a charmap, then set it up // ourselves. if (_face->num_charmaps == 0) { diff --git a/panda/src/pnmtext/freetypeFont.I b/panda/src/pnmtext/freetypeFont.I index 897100998b..dc0f4ae60b 100644 --- a/panda/src/pnmtext/freetypeFont.I +++ b/panda/src/pnmtext/freetypeFont.I @@ -207,7 +207,7 @@ get_winding_order() const { */ INLINE FT_Face FreetypeFont:: acquire_face() const { - nassertr(_face != NULL, NULL); + nassertr(_face != nullptr, nullptr); return _face->acquire_face(_char_size, _dpi, _pixel_width, _pixel_height); } @@ -217,7 +217,7 @@ acquire_face() const { */ INLINE void FreetypeFont:: release_face(FT_Face face) const { - nassertv(_face != NULL); + nassertv(_face != nullptr); _face->release_face(face); } diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index 379a139426..78a7455b96 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -37,7 +37,7 @@ const PN_stdfloat FreetypeFont::_points_per_inch = 72.0f; */ FreetypeFont:: FreetypeFont() { - _face = NULL; + _face = nullptr; _point_size = text_point_size; _requested_pixels_per_unit = text_pixels_per_unit; @@ -183,7 +183,7 @@ load_font(const char *font_data, int data_length, int face_index) { */ void FreetypeFont:: unload_font() { - _face = NULL; + _face = nullptr; } /** @@ -297,7 +297,7 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) { */ bool FreetypeFont:: reset_scale() { - if (_face == NULL) { + if (_face == nullptr) { return false; } diff --git a/panda/src/pnmtext/pnmTextMaker.cxx b/panda/src/pnmtext/pnmTextMaker.cxx index 1c11dac21c..1cf2c92a75 100644 --- a/panda/src/pnmtext/pnmTextMaker.cxx +++ b/panda/src/pnmtext/pnmTextMaker.cxx @@ -171,7 +171,7 @@ make_glyph(int glyph_index) { FT_Face face = acquire_face(); if (!load_glyph(face, glyph_index)) { release_face(face); - return (PNMTextGlyph *)NULL; + return nullptr; } FT_GlyphSlot slot = face->glyph; diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index 2338eaa0ad..b13eb43401 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -25,7 +25,7 @@ get_num_collectors() const { */ INLINE PStatCollectorDef *PStatClient:: get_collector_def(int index) const { - nassertr(index >= 0 && index < _num_collectors, NULL); + nassertr(index >= 0 && index < _num_collectors, nullptr); return get_collector_ptr(index)->get_def(this, index); } @@ -62,7 +62,7 @@ get_thread_sync_name(int index) const { */ INLINE PT(Thread) PStatClient:: get_thread_object(int index) const { - nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), NULL); + nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), nullptr); InternalThread *thread = get_thread_ptr(index); return thread->_thread.lock(); } @@ -109,7 +109,7 @@ resume_after_pause() { */ INLINE bool PStatClient:: has_impl() const { - return (_impl != (PStatClientImpl *)NULL); + return (_impl != nullptr); } /** @@ -119,7 +119,7 @@ has_impl() const { INLINE PStatClientImpl *PStatClient:: get_impl() { ReMutexHolder holder(_lock); - if (_impl == (PStatClientImpl *)NULL) { + if (_impl == nullptr) { make_impl(); } return _impl; @@ -132,7 +132,7 @@ get_impl() { INLINE const PStatClientImpl *PStatClient:: get_impl() const { ReMutexHolder holder(_lock); - if (_impl == (PStatClientImpl *)NULL) { + if (_impl == nullptr) { make_impl(); } return _impl; @@ -162,7 +162,7 @@ get_thread_ptr(int thread_index) const { */ INLINE PStatClient::Collector:: Collector(int parent_index, const string &name) : - _def(NULL), + _def(nullptr), _parent_index(parent_index), _name(name) { @@ -191,7 +191,7 @@ get_name() const { */ INLINE bool PStatClient::Collector:: is_active() const { - return _def != (PStatCollectorDef *)NULL && _def->_is_active; + return _def != nullptr && _def->_is_active; } /** @@ -200,7 +200,7 @@ is_active() const { */ INLINE PStatCollectorDef *PStatClient::Collector:: get_def(const PStatClient *client, int this_index) const { - if (_def == (PStatCollectorDef *)NULL) { + if (_def == nullptr) { ((Collector *)this)->make_def(client, this_index); } diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index a735ea080e..8a4a9fc288 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -44,7 +44,7 @@ PStatCollector PStatClient::_clock_wait_pcollector("Wait:Clock Wait:Sleep"); PStatCollector PStatClient::_clock_busy_wait_pcollector("Wait:Clock Wait:Spin"); PStatCollector PStatClient::_thread_block_pcollector("Wait:Thread block"); -PStatClient *PStatClient::_global_pstats = NULL; +PStatClient *PStatClient::_global_pstats = nullptr; // This class is used to report memory usage per TypeHandle. We create one of @@ -73,13 +73,13 @@ PerThreadData() { PStatClient:: PStatClient() : _lock("PStatClient::_lock"), - _impl(NULL) + _impl(nullptr) { - _collectors = NULL; + _collectors = nullptr; _collectors_size = 0; _num_collectors = 0; - _threads = NULL; + _threads = nullptr; _threads_size = 0; _num_threads = 0; @@ -457,7 +457,7 @@ client_disconnect() { if (has_impl()) { _impl->client_disconnect(); delete _impl; - _impl = NULL; + _impl = nullptr; } ThreadPointer *threads = (ThreadPointer *)_threads; @@ -508,7 +508,7 @@ client_resume_after_pause() { */ PStatClient *PStatClient:: get_global_pstats() { - if (_global_pstats == (PStatClient *)NULL) { + if (_global_pstats == nullptr) { _global_pstats = new PStatClient; ClockObject::_start_clock_wait = start_clock_wait; @@ -1129,7 +1129,7 @@ deactivate_hook(Thread *thread) { // We shouldn't use a mutex here, because this code is only called during // the SIMPLE_THREADS case, so a mutex isn't necessary; and because we are // called during a context switch, so a mutex might be dangerous. - if (_impl == NULL) { + if (_impl == nullptr) { return; } int thread_index = thread->get_pstats_index(); @@ -1154,7 +1154,7 @@ activate_hook(Thread *thread) { // We shouldn't use a mutex here, because this code is only called during // the SIMPLE_THREADS case, so a mutex isn't necessary; and because we are // called during a context switch, so a mutex might be dangerous. - if (_impl == NULL) { + if (_impl == nullptr) { return; } @@ -1173,7 +1173,7 @@ activate_hook(Thread *thread) { void PStatClient::Collector:: make_def(const PStatClient *client, int this_index) { ReMutexHolder holder(client->_lock); - if (_def == (PStatCollectorDef *)NULL) { + if (_def == nullptr) { _def = new PStatCollectorDef(this_index, _name); if (_parent_index != this_index) { const PStatCollectorDef *parent_def = @@ -1205,7 +1205,7 @@ InternalThread(Thread *thread) : */ PStatClient::InternalThread:: InternalThread(const string &name, const string &sync_name) : - _thread(NULL), + _thread(nullptr), _name(name), _sync_name(sync_name), _is_active(false), diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index f103bbbae0..23a2cf6199 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -33,7 +33,7 @@ PStatCollector(PStatClient *client, int index) : */ INLINE PStatCollector:: PStatCollector() : - _client(NULL), + _client(nullptr), _index(0), _level(0.0f) { @@ -57,7 +57,7 @@ INLINE PStatCollector:: PStatCollector(const string &name, PStatClient *client) : _level(0.0f) { - if (client == (PStatClient *)NULL) { + if (client == nullptr) { client = PStatClient::get_global_pstats(); } (*this) = client->make_collector_with_relname(0, name); @@ -83,7 +83,7 @@ INLINE PStatCollector:: PStatCollector(const PStatCollector &parent, const string &name) : _level(0.0f) { - nassertv(parent._client != (PStatClient *)NULL); + nassertv(parent._client != nullptr); (*this) = parent._client->make_collector_with_relname(parent._index, name); } @@ -115,7 +115,7 @@ operator = (const PStatCollector ©) { */ INLINE bool PStatCollector:: is_valid() const { - return (_client != (PStatClient *)NULL); + return (_client != nullptr); } /** @@ -124,7 +124,7 @@ is_valid() const { */ INLINE string PStatCollector:: get_name() const { - if (_client != (PStatClient *)NULL) { + if (_client != nullptr) { return _client->get_collector_name(_index); } return string(); @@ -136,7 +136,7 @@ get_name() const { */ INLINE string PStatCollector:: get_fullname() const { - if (_client != (PStatClient *)NULL) { + if (_client != nullptr) { return _client->get_collector_fullname(_index); } return string(); @@ -384,7 +384,7 @@ is_started(const PStatThread &thread) { */ INLINE void PStatCollector:: start(const PStatThread &thread) { - nassertv(_client != NULL); + nassertv(_client != nullptr); _client->start(_index, thread._index); } @@ -498,7 +498,7 @@ PStatCollector(const string &, PStatClient *client) { // We need this bogus comparison just to prevent the SGI compiler from // dumping core. It's perfectly meaningless. #ifdef mips - if (client == (PStatClient *)NULL) { + if (client == nullptr) { return; } #endif @@ -513,7 +513,7 @@ PStatCollector(const PStatCollector &parent, const string &) { // We need this bogus comparison just to prevent the SGI compiler from // dumping core. It's perfectly meaningless. #ifdef mips - if (&parent == (const PStatCollector *)NULL) { + if (&parent == nullptr) { return; } #endif diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index 6c265f5e0c..3f96b79f41 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -51,7 +51,7 @@ public: PUBLISHED: INLINE explicit PStatCollector(const string &name, - PStatClient *client = NULL); + PStatClient *client = nullptr); INLINE explicit PStatCollector(const PStatCollector &parent, const string &name); @@ -111,7 +111,7 @@ public: PUBLISHED: INLINE PStatCollector(const string &name, - PStatClient *client = NULL); + PStatClient *client = nullptr); INLINE PStatCollector(const PStatCollector &parent, const string &name); diff --git a/panda/src/pstatclient/pStatFrameData.cxx b/panda/src/pstatclient/pStatFrameData.cxx index f15f6bc61e..9c58f8d29d 100644 --- a/panda/src/pstatclient/pStatFrameData.cxx +++ b/panda/src/pstatclient/pStatFrameData.cxx @@ -25,7 +25,7 @@ */ void PStatFrameData:: sort_time() { - stable_sort(_time_data.begin(), _time_data.end()); + std::stable_sort(_time_data.begin(), _time_data.end()); } /** diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 01411f3f74..32db833ed5 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -146,7 +146,7 @@ static TimeCollectorProperties time_properties[] = { { 1, "Draw:Set State", { 0.2, 0.6, 0.8 } }, { 1, "Draw:Wait occlusion", { 1.0, 0.5, 0.0 } }, { 1, "Draw:Bind FBO", { 0.0, 0.8, 0.8 } }, - { 0, NULL } + { 0, nullptr } }; static LevelCollectorProperties level_properties[] = { @@ -218,7 +218,7 @@ static LevelCollectorProperties level_properties[] = { { 1, "Collision Volumes", { 1.0, 0.8, 0.5 }, "", 500 }, { 1, "Collision Tests", { 0.5, 0.8, 1.0 }, "", 100 }, { 1, "Command latency", { 0.8, 0.2, 0.0 }, "ms", 10, 1.0 / 1000.0 }, - { 0, NULL } + { 0, nullptr } }; @@ -231,7 +231,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d int i; for (i = 0; - time_properties[i].name != (const char *)NULL; + time_properties[i].name != nullptr; i++) { const TimeCollectorProperties &tp = time_properties[i]; if (fullname == tp.name) { @@ -248,7 +248,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d } for (i = 0; - level_properties[i].name != (const char *)NULL; + level_properties[i].name != nullptr; i++) { const LevelCollectorProperties &lp = level_properties[i]; if (fullname == lp.name) { @@ -260,7 +260,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d if (lp.suggested_scale != 0.0) { def->_suggested_scale = lp.suggested_scale; } - if (lp.units != (const char *)NULL) { + if (lp.units != nullptr) { def->_level_units = lp.units; } if (lp.inv_factor != 0.0) { diff --git a/panda/src/pstatclient/pStatThread.I b/panda/src/pstatclient/pStatThread.I index 4fd43c5669..fb68d4d3f9 100644 --- a/panda/src/pstatclient/pStatThread.I +++ b/panda/src/pstatclient/pStatThread.I @@ -37,7 +37,7 @@ PStatThread(PStatClient *client, int index) : INLINE PStatThread:: PStatThread(Thread *thread, PStatClient *client) { #ifdef DO_PSTATS - if (client == (PStatClient *)NULL) { + if (client == nullptr) { client = PStatClient::get_global_pstats(); } @@ -51,7 +51,7 @@ PStatThread(Thread *thread, PStatClient *client) { (*this) = client->make_thread(thread); } #else - _client = (PStatClient *)NULL; + _client = nullptr; _index = 0; #endif } diff --git a/panda/src/pstatclient/pStatThread.h b/panda/src/pstatclient/pStatThread.h index 0ad8567c7a..74defa2a15 100644 --- a/panda/src/pstatclient/pStatThread.h +++ b/panda/src/pstatclient/pStatThread.h @@ -31,7 +31,7 @@ public: PUBLISHED: INLINE PStatThread(PStatClient *client, int index); - INLINE PStatThread(Thread *thread, PStatClient *client = NULL); + INLINE PStatThread(Thread *thread, PStatClient *client = nullptr); INLINE PStatThread(const PStatThread ©); INLINE void operator = (const PStatThread ©); diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index 35a79a8cbd..b60aa6c625 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -45,13 +45,13 @@ SampleData dataset_zero[] = { { "Cull", 5, 6, false }, { "App", 0, 5, false }, { "Texture memory", 8000000, 100000, true }, - { NULL }, + { nullptr }, }; SampleData dataset_one[] = { { "Draw", 10, 12, false }, { "Squeak", 25, 30, false }, - { NULL }, + { nullptr }, }; SampleData dataset_two[] = { @@ -63,7 +63,7 @@ SampleData dataset_two[] = { { "Animation:donald", 5, 6, false }, { "Animation:goofy", 5, 6, false }, { "Animation:pluto", 5, 6, false }, - { NULL }, + { nullptr }, }; #define NUM_DATASETS 3 @@ -113,7 +113,7 @@ main(int argc, char *argv[]) { exit(1); } - srand(time(NULL)); + srand(time(nullptr)); int ds_index; if (argc > 3) { @@ -132,7 +132,7 @@ main(int argc, char *argv[]) { pvector _collectors; int i = 0; - while (ds[i].category != (const char *)NULL) { + while (ds[i].category != nullptr) { _collectors.push_back(PStatCollector(ds[i].category)); if (ds[i].is_level) { _collectors[i].set_level(ds[i].min_ms); diff --git a/panda/src/putil/bamCache.I b/panda/src/putil/bamCache.I index 0d359ad29b..38a9e45540 100644 --- a/panda/src/putil/bamCache.I +++ b/panda/src/putil/bamCache.I @@ -221,7 +221,7 @@ get_read_only() const { */ INLINE BamCache *BamCache:: get_global_ptr() { - if (_global_ptr == (BamCache *)NULL) { + if (_global_ptr == nullptr) { make_global(); } return _global_ptr; @@ -232,7 +232,7 @@ get_global_ptr() { */ INLINE void BamCache:: consider_flush_global_index() { - if (_global_ptr != (BamCache *)NULL) { + if (_global_ptr != nullptr) { _global_ptr->consider_flush_index(); } } @@ -242,7 +242,7 @@ consider_flush_global_index() { */ INLINE void BamCache:: flush_global_index() { - if (_global_ptr != (BamCache *)NULL) { + if (_global_ptr != nullptr) { _global_ptr->flush_index(); } } @@ -254,6 +254,6 @@ flush_global_index() { INLINE void BamCache:: mark_index_stale() { if (_index_stale_since == 0) { - _index_stale_since = time(NULL); + _index_stale_since = time(nullptr); } } diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index cd3fab2113..385079d7ee 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -27,7 +27,7 @@ #include "configVariableFilename.h" #include "virtualFileSystem.h" -BamCache *BamCache::_global_ptr = NULL; +BamCache *BamCache::_global_ptr = nullptr; /** * @@ -101,7 +101,7 @@ BamCache:: ~BamCache() { flush_index(); delete _index; - _index = NULL; + _index = nullptr; } /** @@ -165,7 +165,7 @@ lookup(const Filename &source_filename, const string &cache_extension) { if (rel_pathname.is_local()) { // If the source pathname is already within the cache directory, don't // cache it further. - return NULL; + return nullptr; } Filename cache_filename = hash_filename(source_pathname.get_fullpath()); @@ -199,7 +199,7 @@ store(BamCacheRecord *record) { nassertr(rel_pathname.is_local(), false); #endif // NDEBUG - record->_recorded_time = time(NULL); + record->_recorded_time = time(nullptr); Filename cache_pathname = Filename::binary_filename(record->_cache_pathname); @@ -319,7 +319,7 @@ consider_flush_index() { #endif if (_index_stale_since != 0) { - int elapsed = (int)time(NULL) - (int)_index_stale_since; + int elapsed = (int)time(nullptr) - (int)_index_stale_since; if (elapsed > _flush_time) { flush_index(); } @@ -404,7 +404,7 @@ read_index() { while (true) { BamCacheIndex *new_index = do_read_index(_index_pathname); - if (new_index != (BamCacheIndex *)NULL) { + if (new_index != nullptr) { merge_index(new_index); return; } @@ -514,7 +514,7 @@ merge_index(BamCacheIndex *new_index) { if (cache_pathname.exists()) { PT(BamCacheRecord) record = do_read_record(cache_pathname, false); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { _index->_records.insert(_index->_records.end(), BamCacheIndex::Records::value_type(record->get_source_pathname(), record)); } } @@ -558,7 +558,7 @@ rebuild_index() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFileList) contents = vfs->scan_directory(_root); - if (contents == NULL) { + if (contents == nullptr) { util_cat.error() << "Unable to read directory " << _root << ", caching disabled.\n"; set_active(false); @@ -577,7 +577,7 @@ rebuild_index() { Filename pathname(_root, filename); PT(BamCacheRecord) record = do_read_record(pathname, false); - if (record == (BamCacheRecord *)NULL) { + if (record == nullptr) { // Well, it was invalid, so blow it away. if (util_cat.is_debug()) { util_cat.debug() @@ -599,7 +599,7 @@ rebuild_index() { } _index->process_new_records(); - _index_stale_since = time(NULL); + _index_stale_since = time(nullptr); check_cache_size(); flush_index(); } @@ -642,7 +642,7 @@ check_cache_size() { if (_index->_cache_size / 1024 > _max_kbytes) { while (_index->_cache_size / 1024 > _max_kbytes) { PT(BamCacheRecord) record = _index->evict_old_file(); - if (record == NULL) { + if (record == nullptr) { // Never mind; the cache is empty. break; } @@ -666,53 +666,53 @@ check_cache_size() { BamCacheIndex *BamCache:: do_read_index(const Filename &index_pathname) { if (index_pathname.empty()) { - return NULL; + return nullptr; } DatagramInputFile din; if (!din.open(index_pathname)) { util_cat.debug() << "Could not read index file: " << index_pathname << "\n"; - return NULL; + return nullptr; } string head; if (!din.read_header(head, _bam_header.size())) { util_cat.debug() << index_pathname << " is not an index file.\n"; - return NULL; + return nullptr; } if (head != _bam_header) { util_cat.debug() << index_pathname << " is not an index file.\n"; - return NULL; + return nullptr; } BamReader reader(&din); if (!reader.init()) { - return NULL; + return nullptr; } TypedWritable *object = reader.read_object(); - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { util_cat.error() << "Cache index " << index_pathname << " is empty.\n"; - return NULL; + return nullptr; } else if (!object->is_of_type(BamCacheIndex::get_class_type())) { util_cat.error() << "Cache index " << index_pathname << " contains a " << object->get_type() << ", not a BamCacheIndex.\n"; - return NULL; + return nullptr; } BamCacheIndex *index = DCAST(BamCacheIndex, object); if (!reader.resolve()) { util_cat.error() << "Unable to fully resolve cache index file.\n"; - return NULL; + return nullptr; } return index; @@ -767,7 +767,7 @@ find_and_read_record(const Filename &source_pathname, while (true) { PT(BamCacheRecord) record = read_record(source_pathname, cache_filename, pass); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { add_to_index(record); return record; } @@ -809,7 +809,7 @@ read_record(const Filename &source_pathname, } PT(BamCacheRecord) record = do_read_record(cache_pathname, true); - if (record == (BamCacheRecord *)NULL) { + if (record == nullptr) { // Well, it was invalid, so blow it away, and make a new one. if (util_cat.is_debug()) { util_cat.debug() @@ -832,7 +832,7 @@ read_record(const Filename &source_pathname, << record->get_source_pathname() << ", not " << source_pathname << "\n"; } - return NULL; + return nullptr; } if (!record->has_data()) { @@ -855,7 +855,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << "Could not read cache file: " << cache_pathname << "\n"; } - return NULL; + return nullptr; } string head; @@ -864,7 +864,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << cache_pathname << " is not a cache file.\n"; } - return NULL; + return nullptr; } if (head != _bam_header) { @@ -872,21 +872,21 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << cache_pathname << " is not a cache file.\n"; } - return NULL; + return nullptr; } BamReader reader(&din); if (!reader.init()) { - return NULL; + return nullptr; } TypedWritable *object = reader.read_object(); - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { if (util_cat.is_debug()) { util_cat.debug() << cache_pathname << " is empty.\n"; } - return NULL; + return nullptr; } else if (!object->is_of_type(BamCacheRecord::get_class_type())) { if (util_cat.is_debug()) { @@ -894,7 +894,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { << "Cache file " << cache_pathname << " contains a " << object->get_type() << ", not a BamCacheRecord.\n"; } - return NULL; + return nullptr; } PT(BamCacheRecord) record = DCAST(BamCacheRecord, object); @@ -903,7 +903,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << "Unable to fully resolve cache record in " << cache_pathname << "\n"; } - return NULL; + return nullptr; } // From this point below, we have validated that the selected filename is @@ -937,7 +937,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { record->_record_size = vfile->get_file_size(&in); // And the last access time is now, duh. - record->_record_access_time = time(NULL); + record->_record_access_time = time(nullptr); return record; } diff --git a/panda/src/putil/bamCacheIndex.cxx b/panda/src/putil/bamCacheIndex.cxx index 31c62ec3a5..889bb2a8ab 100644 --- a/panda/src/putil/bamCacheIndex.cxx +++ b/panda/src/putil/bamCacheIndex.cxx @@ -94,8 +94,8 @@ release_records() { Records::const_iterator ri; for (ri = _records.begin(); ri != _records.end(); ++ri) { BamCacheRecord *record = (*ri).second; - record->_next = NULL; - record->_prev = NULL; + record->_next = nullptr; + record->_prev = nullptr; } _next = this; _prev = this; @@ -110,13 +110,13 @@ PT(BamCacheRecord) BamCacheIndex:: evict_old_file() { if (_next == this) { // Nothing in the cache. - return NULL; + return nullptr; } // The first record in the linked list is the least-recently-used one. PT(BamCacheRecord) record = (BamCacheRecord *)_next; bool removed = remove_record(record->get_source_pathname()); - nassertr(removed, NULL); + nassertr(removed, nullptr); return record; } @@ -249,7 +249,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { int num_records = scan.get_uint32(); _record_vector.reserve(num_records); for (int i = 0; i < num_records; ++i) { - _record_vector.push_back(NULL); + _record_vector.push_back(nullptr); manager->read_pointer(scan); } } diff --git a/panda/src/putil/bamCacheRecord.I b/panda/src/putil/bamCacheRecord.I index 6693b1c694..e5288c03ac 100644 --- a/panda/src/putil/bamCacheRecord.I +++ b/panda/src/putil/bamCacheRecord.I @@ -95,7 +95,7 @@ get_dependent_pathname(int n) const { */ INLINE bool BamCacheRecord:: has_data() const { - return (_ptr != (TypedWritable *)NULL); + return (_ptr != nullptr); } /** @@ -104,12 +104,12 @@ has_data() const { */ INLINE void BamCacheRecord:: clear_data() { - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { unref_delete(_ref_ptr); } - _ptr = NULL; - _ref_ptr = NULL; + _ptr = nullptr; + _ref_ptr = nullptr; } /** @@ -135,7 +135,7 @@ extract_data(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { ptr = _ptr; ref_ptr = _ref_ptr; clear_data(); - return (ptr != (TypedWritable *)NULL); + return (ptr != nullptr); } /** @@ -155,7 +155,7 @@ set_data(TypedWritable *ptr, ReferenceCount *ref_ptr) { clear_data(); _ptr = ptr; _ref_ptr = ref_ptr; - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { _ref_ptr->ref(); } } @@ -186,7 +186,7 @@ set_data(TypedWritableReferenceCount *ptr) { INLINE void BamCacheRecord:: set_data(TypedWritable *ptr, int dummy) { nassertv(dummy == 0); - set_data(ptr, (ReferenceCount *)NULL); + set_data(ptr, nullptr); } /** diff --git a/panda/src/putil/bamCacheRecord.cxx b/panda/src/putil/bamCacheRecord.cxx index 8fabae7326..f732dbcb9e 100644 --- a/panda/src/putil/bamCacheRecord.cxx +++ b/panda/src/putil/bamCacheRecord.cxx @@ -29,8 +29,8 @@ BamCacheRecord() : _recorded_time(0), _record_size(0), _source_timestamp(0), - _ptr(NULL), - _ref_ptr(NULL), + _ptr(nullptr), + _ref_ptr(nullptr), _record_access_time(0) { } @@ -46,8 +46,8 @@ BamCacheRecord(const Filename &source_pathname, _recorded_time(0), _record_size(0), _source_timestamp(0), - _ptr(NULL), - _ref_ptr(NULL), + _ptr(nullptr), + _ref_ptr(nullptr), _record_access_time(0) { } @@ -62,8 +62,8 @@ BamCacheRecord(const BamCacheRecord ©) : _recorded_time(copy._recorded_time), _record_size(copy._record_size), _source_timestamp(copy._source_timestamp), - _ptr(NULL), - _ref_ptr(NULL), + _ptr(nullptr), + _ref_ptr(nullptr), _record_access_time(copy._record_access_time) { } @@ -93,7 +93,7 @@ dependents_unchanged() const { for (fi = _files.begin(); fi != _files.end(); ++fi) { const DependentFile &dfile = (*fi); PT(VirtualFile) file = vfs->get_file(dfile._pathname); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. if (dfile._timestamp != 0) { if (util_cat.is_debug()) { @@ -153,7 +153,7 @@ add_dependent_file(const Filename &pathname) { dfile._pathname.make_absolute(); PT(VirtualFile) file = vfs->get_file(dfile._pathname); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. dfile._timestamp = 0; dfile._size = 0; @@ -231,7 +231,7 @@ format_timestamp(time_t timestamp) { return " (no date) "; } - time_t now = time(NULL); + time_t now = time(nullptr); struct tm atm; #ifdef _WIN32 localtime_s(&atm, ×tamp); diff --git a/panda/src/putil/bamReader.I b/panda/src/putil/bamReader.I index ece2676956..d660317a71 100644 --- a/panda/src/putil/bamReader.I +++ b/panda/src/putil/bamReader.I @@ -34,7 +34,7 @@ get_source() { */ INLINE const Filename &BamReader:: get_filename() const { - if (_source != (DatagramGenerator *)NULL) { + if (_source != nullptr) { return _source->get_filename(); } static const Filename empty_filename; @@ -64,7 +64,7 @@ set_loader_options(const LoaderOptions &options) { */ INLINE bool BamReader:: is_eof() const { - nassertr(_source != NULL, true); + nassertr(_source != nullptr, true); return _source->is_eof(); } @@ -131,7 +131,7 @@ get_current_minor_ver() const { */ INLINE const FileReference *BamReader:: get_file() { - nassertr(_source != NULL, NULL); + nassertr(_source != nullptr, nullptr); return _source->get_file(); } @@ -141,7 +141,7 @@ get_file() { */ INLINE VirtualFile *BamReader:: get_vfile() { - nassertr(_source != NULL, NULL); + nassertr(_source != nullptr, nullptr); return _source->get_vfile(); } @@ -155,7 +155,7 @@ get_vfile() { */ INLINE streampos BamReader:: get_file_pos() { - nassertr(_source != NULL, 0); + nassertr(_source != nullptr, 0); return _source->get_file_pos(); } @@ -175,7 +175,7 @@ register_factory(TypeHandle handle, WritableFactory::CreateFunc *func, void *use */ INLINE WritableFactory *BamReader:: get_factory() { - if (_factory == (WritableFactory *)NULL) { + if (_factory == nullptr) { create_factory(); } return _factory; @@ -195,7 +195,7 @@ create_factory() { */ INLINE bool BamReader:: get_datagram(Datagram &datagram) { - nassertr(_source != NULL, false); + nassertr(_source != nullptr, false); if (_source->is_error()) { return false; } @@ -221,10 +221,10 @@ AuxData() { INLINE BamReader::CreatedObj:: CreatedObj() : _created(false), - _ptr(NULL), - _ref_ptr(NULL), - _change_this(NULL), - _change_this_ref(NULL) + _ptr(nullptr), + _ref_ptr(nullptr), + _change_this(nullptr), + _change_this_ref(nullptr) { } @@ -233,7 +233,7 @@ CreatedObj() : */ INLINE BamReader::CreatedObj:: ~CreatedObj() { - set_ptr(NULL, NULL); + set_ptr(nullptr, nullptr); } /** @@ -249,7 +249,7 @@ INLINE BamReader::CreatedObj:: INLINE void BamReader::CreatedObj:: set_ptr(TypedWritable *ptr, ReferenceCount *ref_ptr) { if (_ptr != ptr) { - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { nassertv(_ref_ptr != ref_ptr); unref_delete(_ref_ptr); } @@ -257,7 +257,7 @@ set_ptr(TypedWritable *ptr, ReferenceCount *ref_ptr) { _ptr = ptr; _ref_ptr = ref_ptr; - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { _ref_ptr->ref(); } } else { diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index eab309c9d6..e6cc5683d6 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -22,9 +22,9 @@ TypeHandle BamReaderAuxData::_type_handle; -WritableFactory *BamReader::_factory = (WritableFactory*)0L; -BamReader *const BamReader::Null = (BamReader*)0L; -WritableFactory *const BamReader::NullFactory = (WritableFactory*)0L; +WritableFactory *BamReader::_factory = nullptr; +BamReader *const BamReader::Null = nullptr; +WritableFactory *const BamReader::NullFactory = nullptr; BamReader::NewTypes BamReader::_new_types; @@ -43,7 +43,7 @@ BamReader(DatagramGenerator *source) _num_extra_objects = 0; _nesting_level = 0; _now_creating = _created_objs.end(); - _reading_cycler = (PipelineCyclerBase *)NULL; + _reading_cycler = nullptr; _pta_id = -1; _long_object_id = false; _long_pta_id = false; @@ -66,7 +66,7 @@ BamReader:: void BamReader:: set_source(DatagramGenerator *source) { _source = source; - if (_needs_init && _source != NULL) { + if (_needs_init && _source != nullptr) { bool success = init(); nassertv(success); } @@ -81,7 +81,7 @@ set_source(DatagramGenerator *source) { */ bool BamReader:: init() { - nassertr(_source != NULL, false); + nassertr(_source != nullptr, false); nassertr(_needs_init, false); _needs_init = false; Datagram header; @@ -163,7 +163,7 @@ init() { */ void BamReader:: set_aux_data(TypedWritable *obj, const string &name, BamReader::AuxData *data) { - if (data == (void *)NULL) { + if (data == nullptr) { AuxDataTable::iterator ti = _aux_data.find(obj); if (ti != _aux_data.end()) { AuxDataNames &names = (*ti).second; @@ -194,7 +194,7 @@ get_aux_data(TypedWritable *obj, const string &name) const { } } - return NULL; + return nullptr; } @@ -224,7 +224,7 @@ read_object() { ReferenceCount *ref_ptr; if (!read_object(ptr, ref_ptr)) { - return NULL; + return nullptr; } return ptr; @@ -241,8 +241,8 @@ read_object() { */ bool BamReader:: read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { - ptr = NULL; - ref_ptr = NULL; + ptr = nullptr; + ref_ptr = nullptr; nassertr(_num_extra_objects == 0, false); int start_level = _nesting_level; @@ -290,13 +290,13 @@ read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { ref_ptr = created_obj._ref_ptr; if (bam_cat.is_spam()) { - if (ptr != (TypedWritable *)NULL) { + if (ptr != nullptr) { bam_cat.spam() << "Returning object of type " << ptr->get_type() << "\n"; } } - if (created_obj._change_this != NULL || - created_obj._change_this_ref != NULL) { + if (created_obj._change_this != nullptr || + created_obj._change_this_ref != nullptr) { bam_cat.warning() << "Returning pointer to " << ptr->get_type() << " that might change.\n"; @@ -360,10 +360,10 @@ resolve() { any_completed_this_pass = true; // Does the pointer need to change? - if (created_obj._change_this_ref != NULL) { + if (created_obj._change_this_ref != nullptr) { // Reference-counting variant. TypedWritableReferenceCount *object_ref_ptr = (TypedWritableReferenceCount *)object_ptr; - nassertr(created_obj._ref_ptr == NULL || created_obj._ref_ptr == object_ref_ptr, false); + nassertr(created_obj._ref_ptr == nullptr || created_obj._ref_ptr == object_ref_ptr, false); PT(TypedWritableReferenceCount) new_ptr = created_obj._change_this_ref(object_ref_ptr, this); if (new_ptr != object_ref_ptr) { // Also update the reverse @@ -381,10 +381,10 @@ resolve() { _finalize_list.erase(object_ptr); } created_obj.set_ptr(new_ptr, new_ptr); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; - } else if (created_obj._change_this != NULL) { + } else if (created_obj._change_this != nullptr) { // Non-reference-counting variant. TypedWritable *new_ptr = created_obj._change_this(object_ptr, this); if (new_ptr != object_ptr) { @@ -403,8 +403,8 @@ resolve() { _finalize_list.erase(object_ptr); } created_obj.set_ptr(new_ptr, new_ptr->as_reference_count()); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; } } else { @@ -615,7 +615,7 @@ read_pointer(DatagramIterator &scan) { int object_id = read_object_id(scan); PointerReference &pref = _object_pointers[requestor_id]; - if (_reading_cycler == (PipelineCyclerBase *)NULL) { + if (_reading_cycler == nullptr) { // This is not being read within a read_cdata() call. pref._objects.push_back(object_id); } else { @@ -781,15 +781,15 @@ set_aux_tag(const string &tag, BamReaderAuxData *value) { */ BamReaderAuxData *BamReader:: get_aux_tag(const string &tag) const { - nassertr(_now_creating != _created_objs.end(), NULL); + nassertr(_now_creating != _created_objs.end(), nullptr); int requestor_id = (*_now_creating).first; ObjectPointers::const_iterator opi = _object_pointers.find(requestor_id); - nassertr(opi != _object_pointers.end(), NULL); + nassertr(opi != _object_pointers.end(), nullptr); const PointerReference &pref = (*opi).second; AuxTags::const_iterator ati = pref._aux_tags.find(tag); - nassertr(ati != pref._aux_tags.end(), NULL); + nassertr(ati != pref._aux_tags.end(), nullptr); return (*ati).second; } @@ -804,7 +804,7 @@ get_aux_tag(const string &tag) const { */ void BamReader:: register_finalize(TypedWritable *whom) { - nassertv(whom != (TypedWritable *)NULL); + nassertv(whom != nullptr); if (bam_cat.is_spam()) { bam_cat.spam() @@ -837,7 +837,7 @@ register_change_this(ChangeThisFunc func, TypedWritable *object) { #ifndef NDEBUG // Sanity check the pointer--it should always be the same pointer after we // set it the first time. - if (created_obj._ptr == (TypedWritable *)NULL) { + if (created_obj._ptr == nullptr) { created_obj.set_ptr(object, object->as_reference_count()); } else { // We've previously assigned this pointer, and we should have assigned it @@ -847,7 +847,7 @@ register_change_this(ChangeThisFunc func, TypedWritable *object) { #endif // NDEBUG created_obj._change_this = func; - created_obj._change_this_ref = NULL; + created_obj._change_this_ref = nullptr; } /** @@ -872,7 +872,7 @@ register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object #ifndef NDEBUG // Sanity check the pointer--it should always be the same pointer after we // set it the first time. - if (created_obj._ptr == (TypedWritable *)NULL) { + if (created_obj._ptr == nullptr) { created_obj.set_ptr(object, object); } else { // We've previously assigned this pointer, and we should have assigned it @@ -882,7 +882,7 @@ register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object } #endif // NDEBUG - created_obj._change_this = NULL; + created_obj._change_this = nullptr; created_obj._change_this_ref = func; } @@ -893,7 +893,7 @@ register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object */ void BamReader:: finalize_now(TypedWritable *whom) { - if (whom == (TypedWritable *)NULL) { + if (whom == nullptr) { return; } @@ -927,7 +927,7 @@ finalize_now(TypedWritable *whom) { */ void *BamReader:: get_pta(DatagramIterator &scan) { - nassertr(_pta_id == -1, (void *)NULL); + nassertr(_pta_id == -1, nullptr); int id = read_pta_id(scan); if (id == 0) { @@ -935,7 +935,7 @@ get_pta(DatagramIterator &scan) { // able to differentiate this case from that of a previously-read pointer, // but that's OK because the next data in the Bam file is the length of // the array, which will be zero--indicating an empty or NULL array. - return (void *)NULL; + return nullptr; } PTAMap::iterator pi = _pta_map.find(id); @@ -943,7 +943,7 @@ get_pta(DatagramIterator &scan) { // This is the first time we've encountered this particular ID, meaning we // need to read the data now and register it. _pta_id = id; - return (void *)NULL; + return nullptr; } return (*pi).second; @@ -1155,7 +1155,7 @@ p_read_object() { _created_objs.insert(CreatedObjs::value_type(object_id, new_created_obj)).first; CreatedObj &created_obj = (*oi).second; - if (created_obj._ptr != NULL) { + if (created_obj._ptr != nullptr) { // This object had already existed; thus, we are just receiving an // update for it. @@ -1200,15 +1200,15 @@ p_read_object() { _now_creating = was_creating; // And now we can store the new object pointer in the map. - nassertr(created_obj._ptr == object || created_obj._ptr == NULL, object_id); - if (object == NULL) { - created_obj.set_ptr(NULL, NULL); + nassertr(created_obj._ptr == object || created_obj._ptr == nullptr, object_id); + if (object == nullptr) { + created_obj.set_ptr(nullptr, nullptr); } else { created_obj.set_ptr(object, object->as_reference_count()); } created_obj._created = true; - if (created_obj._change_this_ref != NULL) { + if (created_obj._change_this_ref != nullptr) { // If the pointer is scheduled to change after complete_pointers(), // but we have no entry in _object_pointers for this object (and hence // no plan to call complete_pointers()), then just change the pointer @@ -1218,8 +1218,8 @@ p_read_object() { PT(TypedWritableReferenceCount) object_ref = (*created_obj._change_this_ref)((TypedWritableReferenceCount *)object, this); TypedWritable *new_ptr = object_ref; created_obj.set_ptr(object_ref, object_ref); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; // Remove the pointer from the finalize list (the new pointer // presumably doesn't require finalizing). @@ -1229,14 +1229,14 @@ p_read_object() { object = new_ptr; } - } else if (created_obj._change_this != NULL) { + } else if (created_obj._change_this != nullptr) { // Non-reference-counting variant. ObjectPointers::const_iterator ri = _object_pointers.find(object_id); if (ri == _object_pointers.end()) { TypedWritable *new_ptr = (*created_obj._change_this)(object, this); created_obj.set_ptr(new_ptr, new_ptr->as_reference_count()); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; if (new_ptr != object) { _finalize_list.erase(object); @@ -1248,7 +1248,7 @@ p_read_object() { _created_objs_by_pointer[created_obj._ptr].push_back(object_id); // Just some sanity checks - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { if (bam_cat.is_debug()) { bam_cat.debug() << "Unable to create an object of type " << type << endl; @@ -1355,7 +1355,7 @@ resolve_object_pointers(TypedWritable *object, int child_id = (*pi); if (child_id == 0) { // A NULL pointer is a NULL pointer. - references.push_back((TypedWritable *)NULL); + references.push_back(nullptr); continue; } @@ -1374,7 +1374,7 @@ resolve_object_pointers(TypedWritable *object, break; } - if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { + if (child_obj._change_this != nullptr || child_obj._change_this_ref != nullptr) { // It's been created, but the pointer might still change. is_complete = false; break; @@ -1447,7 +1447,7 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, if (child_id == 0) { // A NULL pointer is a NULL pointer. - references.push_back((TypedWritable *)NULL); + references.push_back(nullptr); continue; } @@ -1460,7 +1460,7 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, } const CreatedObj &child_obj = (*oi).second; - if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { + if (child_obj._change_this != nullptr || child_obj._change_this_ref != nullptr) { // It's been created, but the pointer might still change. is_complete = false; break; @@ -1513,7 +1513,7 @@ finalize() { Finalize::iterator fi = _finalize_list.begin(); while (fi != _finalize_list.end()) { TypedWritable *object = (*fi); - nassertv(object != (TypedWritable *)NULL); + nassertv(object != nullptr); _finalize_list.erase(fi); if (bam_cat.is_spam()) { bam_cat.spam() @@ -1527,14 +1527,14 @@ finalize() { // Now clear the aux data of all objects, except the NULL object. if (!_aux_data.empty()) { - AuxDataTable::iterator ti = _aux_data.find((TypedWritable *)NULL); + AuxDataTable::iterator ti = _aux_data.find(nullptr); if (ti != _aux_data.end()) { if (_aux_data.size() > 1) { // Move the NULL data to the new table; remove the rest. AuxDataTable new_aux_data; AuxDataTable::iterator nti = - new_aux_data.insert(AuxDataTable::value_type((TypedWritable *)NULL, AuxDataNames())).first; + new_aux_data.insert(AuxDataTable::value_type(nullptr, AuxDataNames())).first; (*nti).second.swap((*ti).second); _aux_data.swap(new_aux_data); } diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h index bf88ced2af..46ec5fd56c 100644 --- a/panda/src/putil/bamReader.h +++ b/panda/src/putil/bamReader.h @@ -42,7 +42,7 @@ #define READ_PTA(Manager, source, Read_func, array) \ { \ void *t; \ - if ((t = Manager->get_pta(source)) == (void*)NULL) \ + if ((t = Manager->get_pta(source)) == nullptr) \ { \ array = Read_func(Manager, source); \ Manager->register_pta(array.get_void_ptr()); \ @@ -58,7 +58,7 @@ * object's read pass. To use this, subclass BamReaderAuxData and add * whatever additional data you require. */ -class EXPCL_PANDA_PGRAPH BamReaderAuxData : public TypedReferenceCount { +class EXPCL_PANDA_PUTIL BamReaderAuxData : public TypedReferenceCount { public: INLINE BamReaderAuxData(); @@ -115,7 +115,7 @@ public: PUBLISHED: // The primary interface for a caller. - explicit BamReader(DatagramGenerator *source = NULL); + explicit BamReader(DatagramGenerator *source = nullptr); ~BamReader(); void set_source(DatagramGenerator *source); @@ -198,7 +198,7 @@ public: public: INLINE static void register_factory(TypeHandle type, WritableFactory::CreateFunc *func, - void *user_data = NULL); + void *user_data = nullptr); INLINE static WritableFactory *get_factory(); PUBLISHED: diff --git a/panda/src/putil/bamReader_ext.cxx b/panda/src/putil/bamReader_ext.cxx index 444688a654..a224a36037 100644 --- a/panda/src/putil/bamReader_ext.cxx +++ b/panda/src/putil/bamReader_ext.cxx @@ -28,7 +28,7 @@ extern Dtool_PyTypedObject Dtool_TypedWritable; */ static TypedWritable *factory_callback(const FactoryParams ¶ms){ PyObject *func = (PyObject *)params.get_user_data(); - nassertr(func != NULL, NULL); + nassertr(func != nullptr, nullptr); #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) // Use PyGILState to protect this asynchronous call. @@ -51,7 +51,7 @@ static TypedWritable *factory_callback(const FactoryParams ¶ms){ Py_DECREF(py_scan); Py_DECREF(py_manager); - if (result == (PyObject *)NULL) { + if (result == nullptr) { util_cat.error() << "Exception occurred in Python factory function\n"; @@ -59,7 +59,7 @@ static TypedWritable *factory_callback(const FactoryParams ¶ms){ util_cat.error() << "Python factory function returned None\n"; Py_DECREF(result); - result = NULL; + result = nullptr; } #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) @@ -67,15 +67,15 @@ static TypedWritable *factory_callback(const FactoryParams ¶ms){ #endif // Unwrap the returned TypedWritable object. - if (result == (PyObject *)NULL) { - return (TypedWritable *)NULL; + if (result == nullptr) { + return nullptr; } else { - void *object = NULL; + void *object = nullptr; Dtool_Call_ExtractThisPointer(result, Dtool_TypedWritable, &object); TypedWritable *ptr = (TypedWritable *)object; ReferenceCount *ref_count = ptr->as_reference_count(); - if (ref_count != NULL) { + if (ref_count != nullptr) { // If the Python pointer is the last reference to it, make sure that the // object isn't destroyed. We do this by calling unref(), which // decreases the reference count without destroying the object. @@ -109,7 +109,7 @@ get_file_version() const { */ void Extension:: register_factory(TypeHandle handle, PyObject *func) { - nassertv(func != NULL); + nassertv(func != nullptr); if (!PyCallable_Check(func)) { Dtool_Raise_TypeError("second argument to register_factory must be callable"); diff --git a/panda/src/putil/bamWriter.I b/panda/src/putil/bamWriter.I index b2fa51d146..ad8b119edf 100644 --- a/panda/src/putil/bamWriter.I +++ b/panda/src/putil/bamWriter.I @@ -27,7 +27,7 @@ get_target() { */ INLINE const Filename &BamWriter:: get_filename() const { - if (_target != (DatagramSink *)NULL) { + if (_target != nullptr) { return _target->get_filename(); } static const Filename empty_filename; diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index ac3ac6b8ad..d8aa3e0b30 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -107,12 +107,12 @@ BamWriter:: */ void BamWriter:: set_target(DatagramSink *target) { - if (_target != NULL) { + if (_target != nullptr) { _target->flush(); } _target = target; - if (_needs_init && _target != NULL) { + if (_needs_init && _target != nullptr) { init(); } } @@ -126,7 +126,7 @@ set_target(DatagramSink *target) { */ bool BamWriter:: init() { - nassertr(_target != NULL, false); + nassertr(_target != nullptr, false); nassertr(_needs_init, false); _needs_init = false; @@ -183,7 +183,7 @@ init() { */ bool BamWriter:: write_object(const TypedWritable *object) { - nassertr(_target != NULL, false); + nassertr(_target != nullptr, false); // Increment the _writing_seq, so we can check for newly stale objects // during this operation. @@ -246,7 +246,7 @@ has_object(const TypedWritable *object) const { */ void BamWriter:: flush() { - nassertv(_target != NULL); + nassertv(_target != nullptr); _target->flush(); } @@ -298,7 +298,7 @@ void BamWriter:: write_pointer(Datagram &packet, const TypedWritable *object) { // If the pointer is NULL, we always simply write a zero for an object ID // and leave it at that. - if (object == (const TypedWritable *)NULL) { + if (object == nullptr) { write_object_id(packet, 0); } else { @@ -436,7 +436,7 @@ write_cdata(Datagram &packet, const PipelineCyclerBase &cycler, */ bool BamWriter:: register_pta(Datagram &packet, const void *ptr) { - if (ptr == (const void *)NULL) { + if (ptr == nullptr) { // A zero for the PTA ID indicates a NULL pointer. This is a special // case. write_pta_id(packet, 0); @@ -649,7 +649,7 @@ enqueue_object(const TypedWritable *object) { */ bool BamWriter:: flush_queue() { - nassertr(_target != NULL, false); + nassertr(_target != nullptr, false); // Each object we write may append more to the queue. while (!_object_queue.empty()) { const TypedWritable *object = _object_queue.front(); diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index bcd4a76ce6..b8c53aac38 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -62,7 +62,7 @@ */ class EXPCL_PANDA_PUTIL BamWriter : public BamEnums { PUBLISHED: - explicit BamWriter(DatagramSink *target = NULL); + explicit BamWriter(DatagramSink *target = nullptr); ~BamWriter(); void set_target(DatagramSink *target); diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index fa1073ad4b..49e72fc3e7 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -18,17 +18,7 @@ TypeHandle BitMask::_type_handle; * */ template -INLINE BitMask:: -BitMask() : - _word(0) -{ -} - -/** - * - */ -template -INLINE BitMask:: +constexpr BitMask:: BitMask(WordType init_value) : _word(init_value) { @@ -170,7 +160,7 @@ is_zero() const { template INLINE bool BitMask:: is_all_on() const { - return (~_word == 0); + return _word == (WordType)~0; } /** @@ -178,7 +168,7 @@ is_all_on() const { * BitMask, shifted to the least-significant position. */ template -INLINE TYPENAME BitMask::WordType BitMask:: +INLINE typename BitMask::WordType BitMask:: extract(int low_bit, int size) const { return (_word >> low_bit) & BitMask::lower_on(size)._word; @@ -252,7 +242,7 @@ set_range_to(bool value, int low_bit, int size) { * Returns the entire BitMask as a single word. */ template -INLINE TYPENAME BitMask::WordType BitMask:: +INLINE typename BitMask::WordType BitMask:: get_word() const { return _word; } diff --git a/panda/src/putil/bitMask.cxx b/panda/src/putil/bitMask.cxx index 8e51315eb2..cd200ab565 100644 --- a/panda/src/putil/bitMask.cxx +++ b/panda/src/putil/bitMask.cxx @@ -16,3 +16,11 @@ template class BitMask; template class BitMask; template class BitMask; + +#if !defined(CPPPARSER) && !defined(__APPLE__) +#include + +static_assert(std::is_literal_type::value, "BitMask16 is not a literal type"); +static_assert(std::is_literal_type::value, "BitMask32 is not a literal type"); +static_assert(std::is_literal_type::value, "BitMask64 is not a literal type"); +#endif diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 3d73089b50..8eb73a2440 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -36,8 +36,8 @@ public: PUBLISHED: enum { num_bits = nbits }; - INLINE BitMask(); - INLINE BitMask(WordType init_value); + constexpr BitMask() = default; + constexpr BitMask(WordType init_value); INLINE static BitMask all_on(); INLINE static BitMask all_off(); @@ -131,7 +131,7 @@ public: INLINE void generate_hash(ChecksumHashGenerator &hashgen) const; private: - WordType _word; + WordType _word = 0u; public: static TypeHandle get_class_type() { diff --git a/panda/src/putil/buttonRegistry.I b/panda/src/putil/buttonRegistry.I index b531b444f5..8ce0b2f1ce 100644 --- a/panda/src/putil/buttonRegistry.I +++ b/panda/src/putil/buttonRegistry.I @@ -27,7 +27,7 @@ RegistryNode(ButtonHandle handle, ButtonHandle alias, const string &name) : */ INLINE ButtonRegistry *ButtonRegistry:: ptr() { - if (_global_pointer == (ButtonRegistry *)NULL) { + if (_global_pointer == nullptr) { init_global_pointer(); } return _global_pointer; @@ -39,7 +39,7 @@ ptr() { INLINE string ButtonRegistry:: get_name(ButtonHandle button) const { RegistryNode *rnode = look_up(button); - nassertr(rnode != (RegistryNode *)NULL, ""); + nassertr(rnode != nullptr, ""); return rnode->_name; } @@ -50,6 +50,6 @@ get_name(ButtonHandle button) const { INLINE ButtonHandle ButtonRegistry:: get_alias(ButtonHandle button) const { RegistryNode *rnode = look_up(button); - nassertr(rnode != (RegistryNode *)NULL, ButtonHandle::none()); + nassertr(rnode != nullptr, ButtonHandle::none()); return rnode->_alias; } diff --git a/panda/src/putil/buttonRegistry.cxx b/panda/src/putil/buttonRegistry.cxx index 594a5864fd..2537dcc0dc 100644 --- a/panda/src/putil/buttonRegistry.cxx +++ b/panda/src/putil/buttonRegistry.cxx @@ -21,7 +21,7 @@ // and we must use the arrow syntax to force initialization of the util_cat // category. -ButtonRegistry *ButtonRegistry::_global_pointer = NULL; +ButtonRegistry *ButtonRegistry::_global_pointer = nullptr; /** @@ -52,7 +52,7 @@ register_button(ButtonHandle &button_handle, const string &name, int index = -1; if (ascii_equivalent != '\0') { - if (_handle_registry[ascii_equivalent] == (RegistryNode *)NULL) { + if (_handle_registry[ascii_equivalent] == nullptr) { index = ascii_equivalent; } else { util_cat->error() @@ -73,7 +73,7 @@ register_button(ButtonHandle &button_handle, const string &name, if (index == -1) { // It's not an ASCII equivalent; make up a new number. index = _handle_registry.size(); - _handle_registry.push_back(NULL); + _handle_registry.push_back(nullptr); } ButtonHandle new_handle; @@ -145,7 +145,7 @@ find_button(const string &name) { */ ButtonHandle ButtonRegistry:: find_ascii_button(char ascii_equivalent) const { - if (_handle_registry[ascii_equivalent] == (RegistryNode *)NULL) { + if (_handle_registry[ascii_equivalent] == nullptr) { return ButtonHandle::none(); } return _handle_registry[ascii_equivalent]->_handle; @@ -158,7 +158,7 @@ void ButtonRegistry:: write(ostream &out) const { out << "ASCII equivalents:\n"; for (int i = 1; i < 128; i++) { - if (_handle_registry[i] != (RegistryNode *)NULL) { + if (_handle_registry[i] != nullptr) { char hex[12]; sprintf(hex, "%02x", (unsigned int)i); nassertv(strlen(hex) < 12); @@ -192,7 +192,7 @@ ButtonRegistry() { _handle_registry.reserve(128); int i; for (i = 0; i < 128; i++) { - _handle_registry.push_back(NULL); + _handle_registry.push_back(nullptr); } } @@ -210,14 +210,14 @@ init_global_pointer() { */ ButtonRegistry::RegistryNode *ButtonRegistry:: look_up(ButtonHandle handle) const { - nassertr(handle._index != 0, NULL); + nassertr(handle._index != 0, nullptr); if (handle._index < 0 || handle._index >= (int)_handle_registry.size()) { util_cat->fatal() << "Invalid ButtonHandle index " << handle._index << "! Is memory corrupt?\n"; - return (RegistryNode *)NULL; + return nullptr; } return _handle_registry[handle._index]; diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.I b/panda/src/putil/cachedTypedWritableReferenceCount.I index 1d60f9a614..dae8502d4b 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.I +++ b/panda/src/putil/cachedTypedWritableReferenceCount.I @@ -49,8 +49,6 @@ CachedTypedWritableReferenceCount(const CachedTypedWritableReferenceCount ©) */ INLINE void CachedTypedWritableReferenceCount:: operator = (const CachedTypedWritableReferenceCount ©) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -71,8 +69,6 @@ operator = (const CachedTypedWritableReferenceCount ©) { */ INLINE CachedTypedWritableReferenceCount:: ~CachedTypedWritableReferenceCount() { - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.cxx b/panda/src/putil/cachedTypedWritableReferenceCount.cxx index 53e4fa355a..d7ee3ed74d 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.cxx +++ b/panda/src/putil/cachedTypedWritableReferenceCount.cxx @@ -21,8 +21,6 @@ TypeHandle CachedTypedWritableReferenceCount::_type_handle; */ bool CachedTypedWritableReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/putil/callbackObject_ext.I b/panda/src/putil/callbackObject_ext.I index 12edcf6b23..536ba2ac97 100644 --- a/panda/src/putil/callbackObject_ext.I +++ b/panda/src/putil/callbackObject_ext.I @@ -20,7 +20,7 @@ INLINE PT(CallbackObject) Extension:: make(PyObject *function) { if (function != Py_None && !PyCallable_Check(function)) { PyErr_SetString(PyExc_TypeError, "expected callable or None"); - return NULL; + return nullptr; } else { return new PythonCallbackObject(function); } diff --git a/panda/src/putil/config_putil.cxx b/panda/src/putil/config_putil.cxx index 5461b73f3f..c3083f306f 100644 --- a/panda/src/putil/config_putil.cxx +++ b/panda/src/putil/config_putil.cxx @@ -103,8 +103,8 @@ ConfigureFn(config_putil) { ConfigVariableSearchPath & get_model_path() { - static ConfigVariableSearchPath *model_path = NULL; - if (model_path == NULL) { + static ConfigVariableSearchPath *model_path = nullptr; + if (model_path == nullptr) { model_path = new ConfigVariableSearchPath ("model-path", PRC_DESC("The default directories to search for all models and general " @@ -116,8 +116,8 @@ get_model_path() { ConfigVariableSearchPath & get_plugin_path() { - static ConfigVariableSearchPath *plugin_path = NULL; - if (plugin_path == NULL) { + static ConfigVariableSearchPath *plugin_path = nullptr; + if (plugin_path == nullptr) { plugin_path = new ConfigVariableSearchPath ("plugin-path", "", PRC_DESC("The directories to search for plugin shared libraries.")); diff --git a/panda/src/putil/copyOnWriteObject.I b/panda/src/putil/copyOnWriteObject.I index 304e7214c5..dccb2ec385 100644 --- a/panda/src/putil/copyOnWriteObject.I +++ b/panda/src/putil/copyOnWriteObject.I @@ -32,7 +32,7 @@ CopyOnWriteObject() #endif #ifdef COW_THREADED _lock_status = LS_unlocked; - _locking_thread = NULL; + _locking_thread = nullptr; #endif // COW_THREADED } @@ -52,7 +52,7 @@ CopyOnWriteObject(const CopyOnWriteObject ©) : #endif #ifdef COW_THREADED _lock_status = LS_unlocked; - _locking_thread = NULL; + _locking_thread = nullptr; #endif // COW_THREADED } diff --git a/panda/src/putil/copyOnWriteObject.cxx b/panda/src/putil/copyOnWriteObject.cxx index 172f354319..e039f12450 100644 --- a/panda/src/putil/copyOnWriteObject.cxx +++ b/panda/src/putil/copyOnWriteObject.cxx @@ -30,7 +30,7 @@ unref() const { bool is_zero = CachedTypedWritableReferenceCount::unref(); if (get_ref_count() == get_cache_ref_count()) { ((CopyOnWriteObject *)this)->_lock_status = LS_unlocked; - ((CopyOnWriteObject *)this)->_locking_thread = NULL; + ((CopyOnWriteObject *)this)->_locking_thread = nullptr; ((CopyOnWriteObject *)this)->_lock_cvar.notify(); } return is_zero; @@ -48,7 +48,7 @@ cache_ref_only() const { CachedTypedWritableReferenceCount::cache_ref_only(); if (get_ref_count() == get_cache_ref_count()) { ((CopyOnWriteObject *)this)->_lock_status = LS_unlocked; - ((CopyOnWriteObject *)this)->_locking_thread = NULL; + ((CopyOnWriteObject *)this)->_locking_thread = nullptr; ((CopyOnWriteObject *)this)->_lock_cvar.notify(); } } diff --git a/panda/src/putil/copyOnWritePointer.I b/panda/src/putil/copyOnWritePointer.I index 9354fe350a..2f5f79b281 100644 --- a/panda/src/putil/copyOnWritePointer.I +++ b/panda/src/putil/copyOnWritePointer.I @@ -18,7 +18,7 @@ INLINE CopyOnWritePointer:: CopyOnWritePointer(CopyOnWriteObject *object) : _cow_object(object) { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref(); } } @@ -30,7 +30,7 @@ INLINE CopyOnWritePointer:: CopyOnWritePointer(const CopyOnWritePointer ©) : _cow_object(copy._cow_object) { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref(); } } @@ -49,11 +49,11 @@ operator = (const CopyOnWritePointer ©) { INLINE void CopyOnWritePointer:: operator = (CopyOnWriteObject *object) { if (_cow_object != object) { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { cache_unref_delete(_cow_object); } _cow_object = object; - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref(); } } @@ -64,7 +64,7 @@ operator = (CopyOnWriteObject *object) { */ INLINE CopyOnWritePointer:: ~CopyOnWritePointer() { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { cache_unref_delete(_cow_object); } } @@ -77,7 +77,7 @@ CopyOnWritePointer(CopyOnWritePointer &&from) noexcept : _cow_object(from._cow_object) { // Steal the other's reference count. - from._cow_object = (CopyOnWriteObject *)NULL; + from._cow_object = nullptr; } /** @@ -89,10 +89,10 @@ CopyOnWritePointer(PointerTo &&from) noexcept : { // Steal the other's reference count, but because it is a regular pointer, // we do need to include the cache reference count. - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref_only(); } - from.cheat() = NULL; + from.cheat() = nullptr; } /** @@ -104,9 +104,9 @@ operator = (CopyOnWritePointer &&from) noexcept { if (from._cow_object != _cow_object) { CopyOnWriteObject *old_object = _cow_object; _cow_object = from._cow_object; - from._cow_object = NULL; + from._cow_object = nullptr; - if (old_object != (CopyOnWriteObject *)NULL) { + if (old_object != nullptr) { cache_unref_delete(old_object); } } @@ -124,9 +124,9 @@ operator = (PointerTo &&from) noexcept { // we do need to include the cache reference count. _cow_object = from.p(); _cow_object->cache_ref_only(); - from.cheat() = NULL; + from.cheat() = nullptr; - if (old_object != (CopyOnWriteObject *)NULL) { + if (old_object != nullptr) { cache_unref_delete(old_object); } } @@ -181,8 +181,8 @@ get_read_pointer(Thread *current_thread) const { */ INLINE CopyOnWriteObject *CopyOnWritePointer:: get_write_pointer() { - if (_cow_object == (CopyOnWriteObject *)NULL) { - return NULL; + if (_cow_object == nullptr) { + return nullptr; } if (_cow_object->get_cache_ref_count() > 1) { PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy(); @@ -210,7 +210,7 @@ get_unsafe_pointer() { */ bool CopyOnWritePointer:: is_null() const { - return (_cow_object == (CopyOnWriteObject *)NULL); + return (_cow_object == nullptr); } /** @@ -218,10 +218,10 @@ is_null() const { */ void CopyOnWritePointer:: clear() { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { cache_unref_delete(_cow_object); } - _cow_object = NULL; + _cow_object = nullptr; } /** @@ -230,7 +230,7 @@ clear() { */ INLINE bool CopyOnWritePointer:: test_ref_count_integrity() const { - nassertr(_cow_object != (CopyOnWriteObject *)NULL, false); + nassertr(_cow_object != nullptr, false); return _cow_object->test_ref_count_integrity(); } @@ -240,7 +240,7 @@ test_ref_count_integrity() const { */ INLINE bool CopyOnWritePointer:: test_ref_count_nonzero() const { - nassertr(_cow_object != (CopyOnWriteObject *)NULL, false); + nassertr(_cow_object != nullptr, false); return _cow_object->test_ref_count_nonzero(); } @@ -310,10 +310,10 @@ CopyOnWritePointerTo(PointerTo &&from) noexcept { // Steal the other's reference count, but because it is a regular pointer, // we do need to include the cache reference count. _cow_object = from.p(); - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref_only(); } - from.cheat() = NULL; + from.cheat() = nullptr; } #endif // CPPPARSER @@ -342,9 +342,9 @@ operator = (PointerTo &&from) noexcept { // we do need to include the cache reference count. _cow_object = from.p(); _cow_object->cache_ref_only(); - from.cheat() = NULL; + from.cheat() = nullptr; - if (old_object != (CopyOnWriteObject *)NULL) { + if (old_object != nullptr) { cache_unref_delete(old_object); } } @@ -357,11 +357,11 @@ operator = (PointerTo &&from) noexcept { * See CopyOnWritePointer::get_read_pointer(). */ template -INLINE CPT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: +INLINE CPT(typename CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_read_pointer(Thread *current_thread) const { // This is necessary because we don't currently have a way to cast between // two compatible PointerTo types without losing the reference count. - CPT(TYPENAME CopyOnWritePointerTo::To) to; + CPT(typename CopyOnWritePointerTo::To) to; CPT(CopyOnWriteObject) from = CopyOnWritePointer::get_read_pointer(current_thread); to.cheat() = (const To *)from.p(); from.cheat() = nullptr; @@ -372,7 +372,7 @@ get_read_pointer(Thread *current_thread) const { * See CopyOnWritePointer::get_read_pointer(). */ template -INLINE const TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: +INLINE const typename CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_read_pointer(Thread *current_thread) const { return (const To *)CopyOnWritePointer::get_read_pointer(current_thread); } @@ -385,11 +385,11 @@ get_read_pointer(Thread *current_thread) const { * See CopyOnWritePointer::get_write_pointer(). */ template -INLINE PT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: +INLINE PT(typename CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_write_pointer() { // This is necessary because we don't currently have a way to cast between // two compatible PointerTo types without losing the reference count. - PT(TYPENAME CopyOnWritePointerTo::To) to; + PT(typename CopyOnWritePointerTo::To) to; PT(CopyOnWriteObject) from = CopyOnWritePointer::get_write_pointer(); to.cheat() = (To *)from.p(); from.cheat() = nullptr; @@ -400,7 +400,7 @@ get_write_pointer() { * See CopyOnWritePointer::get_write_pointer(). */ template -INLINE TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: +INLINE typename CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_write_pointer() { return (To *)CopyOnWritePointer::get_write_pointer(); } @@ -412,7 +412,7 @@ get_write_pointer() { * See CopyOnWritePointer::get_unsafe_pointer(). */ template -INLINE TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: +INLINE typename CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_unsafe_pointer() { return (To *)(CopyOnWritePointer::get_unsafe_pointer()); } diff --git a/panda/src/putil/copyOnWritePointer.cxx b/panda/src/putil/copyOnWritePointer.cxx index 5a8f1700b6..35a4aa8da0 100644 --- a/panda/src/putil/copyOnWritePointer.cxx +++ b/panda/src/putil/copyOnWritePointer.cxx @@ -24,8 +24,8 @@ */ CPT(CopyOnWriteObject) CopyOnWritePointer:: get_read_pointer(Thread *current_thread) const { - if (_cow_object == (CopyOnWriteObject *)NULL) { - return NULL; + if (_cow_object == nullptr) { + return nullptr; } MutexHolder holder(_cow_object->_lock_mutex); @@ -60,8 +60,8 @@ get_read_pointer(Thread *current_thread) const { */ PT(CopyOnWriteObject) CopyOnWritePointer:: get_write_pointer() { - if (_cow_object == (CopyOnWriteObject *)NULL) { - return NULL; + if (_cow_object == nullptr) { + return nullptr; } Thread *current_thread = Thread::get_current_thread(); @@ -79,7 +79,7 @@ get_write_pointer() { } if (_cow_object->_lock_status == CopyOnWriteObject::LS_locked_read) { - nassertr(_cow_object->get_ref_count() > _cow_object->get_cache_ref_count(), NULL); + nassertr(_cow_object->get_ref_count() > _cow_object->get_cache_ref_count(), nullptr); if (util_cat.is_debug()) { util_cat.debug() diff --git a/panda/src/putil/copyOnWritePointer.h b/panda/src/putil/copyOnWritePointer.h index a98599361a..24e0ffff64 100644 --- a/panda/src/putil/copyOnWritePointer.h +++ b/panda/src/putil/copyOnWritePointer.h @@ -30,7 +30,7 @@ */ class EXPCL_PANDA_PUTIL CopyOnWritePointer { public: - INLINE CopyOnWritePointer(CopyOnWriteObject *object = NULL); + INLINE CopyOnWritePointer(CopyOnWriteObject *object = nullptr); INLINE CopyOnWritePointer(const CopyOnWritePointer ©); INLINE CopyOnWritePointer(CopyOnWritePointer &&from) noexcept; INLINE CopyOnWritePointer(PointerTo &&from) noexcept; @@ -78,7 +78,7 @@ public: #ifndef CPPPARSER typedef T To; - INLINE CopyOnWritePointerTo(To *object = NULL); + INLINE CopyOnWritePointerTo(To *object = nullptr); INLINE CopyOnWritePointerTo(const CopyOnWritePointerTo ©); INLINE CopyOnWritePointerTo(CopyOnWritePointerTo &&from) noexcept; INLINE CopyOnWritePointerTo(PointerTo &&from) noexcept; diff --git a/panda/src/putil/datagramInputFile.I b/panda/src/putil/datagramInputFile.I index c956fef4ac..0c4ba21cc3 100644 --- a/panda/src/putil/datagramInputFile.I +++ b/panda/src/putil/datagramInputFile.I @@ -18,7 +18,7 @@ INLINE DatagramInputFile:: DatagramInputFile() { _error = false; _read_first_datagram = false; - _in = (istream *)NULL; + _in = nullptr; _owns_in = false; _timestamp = 0; } @@ -45,7 +45,7 @@ open(const Filename &filename) { */ INLINE istream &DatagramInputFile:: get_stream() { - static ifstream null_stream; - nassertr(_in != NULL, null_stream); + static std::ifstream null_stream; + nassertr(_in != nullptr, null_stream); return *_in; } diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index 4fc9b47ffb..466d78006b 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -38,13 +38,13 @@ open(const FileReference *file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); _vfile = vfs->get_file(_filename); - if (_vfile == (VirtualFile *)NULL) { + if (_vfile == nullptr) { // No such file. return false; } _timestamp = _vfile->get_timestamp(); _in = _vfile->open_read_file(true); - _owns_in = (_in != (istream *)NULL); + _owns_in = (_in != nullptr); return _owns_in && !_in->fail(); } @@ -80,7 +80,7 @@ close() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_in); } - _in = (istream *)NULL; + _in = nullptr; _owns_in = false; _file.clear(); @@ -100,10 +100,10 @@ close() { bool DatagramInputFile:: read_header(string &header, size_t num_bytes) { nassertr(!_read_first_datagram, false); - nassertr(_in != (istream *)NULL, false); + nassertr(_in != nullptr, false); char *buffer = (char *)alloca(num_bytes); - nassertr(buffer != (char *)NULL, false); + nassertr(buffer != nullptr, false); _in->read(buffer, num_bytes); if (_in->fail() || _in->eof()) { @@ -121,7 +121,7 @@ read_header(string &header, size_t num_bytes) { */ bool DatagramInputFile:: get_datagram(Datagram &data) { - nassertr(_in != (istream *)NULL, false); + nassertr(_in != nullptr, false); _read_first_datagram = true; // First, get the size of the upcoming datagram. @@ -201,7 +201,7 @@ get_datagram(Datagram &data) { */ bool DatagramInputFile:: save_datagram(SubfileInfo &info) { - nassertr(_in != (istream *)NULL, false); + nassertr(_in != nullptr, false); _read_first_datagram = true; // First, get the size of the upcoming datagram. @@ -219,7 +219,7 @@ save_datagram(SubfileInfo &info) { // If this stream is file-based, we can just point the SubfileInfo directly // into this file. - if (_file != (FileReference *)NULL) { + if (_file != nullptr) { info = SubfileInfo(_file, _in->tellg(), num_bytes); _in->seekg(num_bytes, ios::cur); return true; @@ -279,7 +279,7 @@ save_datagram(SubfileInfo &info) { */ bool DatagramInputFile:: is_eof() { - return _in != (istream *)NULL ? _in->eof() : true; + return _in != nullptr ? _in->eof() : true; } /** @@ -287,7 +287,7 @@ is_eof() { */ bool DatagramInputFile:: is_error() { - if (_in == (istream *)NULL) { + if (_in == nullptr) { return true; } @@ -343,7 +343,7 @@ get_vfile() { */ streampos DatagramInputFile:: get_file_pos() { - if (_in == (istream *)NULL) { + if (_in == nullptr) { return 0; } return _in->tellg(); diff --git a/panda/src/putil/datagramOutputFile.I b/panda/src/putil/datagramOutputFile.I index b3dbe95c9c..5bfee6fc9c 100644 --- a/panda/src/putil/datagramOutputFile.I +++ b/panda/src/putil/datagramOutputFile.I @@ -18,7 +18,7 @@ INLINE DatagramOutputFile:: DatagramOutputFile() { _error = false; _wrote_first_datagram = false; - _out = (ostream *)NULL; + _out = nullptr; _owns_out = false; } @@ -44,7 +44,7 @@ open(const Filename &filename) { */ INLINE ostream &DatagramOutputFile:: get_stream() { - static ofstream null_stream; - nassertr(_out != NULL, null_stream); + static std::ofstream null_stream; + nassertr(_out != nullptr, null_stream); return *_out; } diff --git a/panda/src/putil/datagramOutputFile.cxx b/panda/src/putil/datagramOutputFile.cxx index cd9a1af2fc..24533ad8b0 100644 --- a/panda/src/putil/datagramOutputFile.cxx +++ b/panda/src/putil/datagramOutputFile.cxx @@ -32,12 +32,12 @@ open(const FileReference *file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); _vfile = vfs->create_file(_filename); - if (_vfile == (VirtualFile *)NULL) { + if (_vfile == nullptr) { // No such file. return false; } _out = _vfile->open_write_file(true, true); - _owns_out = (_out != (ostream *)NULL); + _owns_out = (_out != nullptr); return _owns_out && !_out->fail(); } @@ -72,7 +72,7 @@ close() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_write_file(_out); } - _out = (ostream *)NULL; + _out = nullptr; _owns_out = false; _file.clear(); @@ -90,7 +90,7 @@ close() { */ bool DatagramOutputFile:: write_header(const string &header) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); nassertr(!_wrote_first_datagram, false); _out->write(header.data(), header.size()); @@ -104,7 +104,7 @@ write_header(const string &header) { */ bool DatagramOutputFile:: put_datagram(const Datagram &data) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); _wrote_first_datagram = true; // First, write the size of the upcoming datagram. @@ -137,16 +137,16 @@ put_datagram(const Datagram &data) { */ bool DatagramOutputFile:: copy_datagram(SubfileInfo &result, const Filename &filename) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); _wrote_first_datagram = true; VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(filename); - if (vfile == NULL) { + if (vfile == nullptr) { return false; } istream *in = vfile->open_read_file(true); - if (in == NULL) { + if (in == nullptr) { return false; } @@ -206,7 +206,7 @@ copy_datagram(SubfileInfo &result, const Filename &filename) { */ bool DatagramOutputFile:: copy_datagram(SubfileInfo &result, const SubfileInfo &source) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); _wrote_first_datagram = true; pifstream in; @@ -261,7 +261,7 @@ copy_datagram(SubfileInfo &result, const SubfileInfo &source) { */ bool DatagramOutputFile:: is_error() { - if (_out == (ostream *)NULL) { + if (_out == nullptr) { return true; } @@ -277,7 +277,7 @@ is_error() { */ void DatagramOutputFile:: flush() { - if (_out != (ostream *)NULL) { + if (_out != nullptr) { _out->flush(); } } @@ -311,7 +311,7 @@ get_file() { */ streampos DatagramOutputFile:: get_file_pos() { - if (_out == (ostream *)NULL) { + if (_out == nullptr) { return 0; } return _out->tellp(); diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 0768263afe..d99f8d0da0 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -14,36 +14,6 @@ template TypeHandle DoubleBitMask::_type_handle; -/** - * - */ -template -INLINE DoubleBitMask:: -DoubleBitMask() { -} - -/** - * - */ -template -INLINE DoubleBitMask:: -DoubleBitMask(const DoubleBitMask ©) : - _lo(copy._lo), - _hi(copy._hi) -{ -} - -/** - * - */ -template -INLINE DoubleBitMask &DoubleBitMask:: -operator = (const DoubleBitMask ©) { - _lo = copy._lo; - _hi = copy._hi; - return *this; -} - /** * Returns a DoubleBitMask whose bits are all on. */ @@ -111,14 +81,6 @@ range(int low_bit, int size) { return result; } -/** - * - */ -template -INLINE DoubleBitMask:: -~DoubleBitMask() { -} - /** * Returns the number of bits available to set in the doubleBitMask. */ @@ -205,7 +167,7 @@ is_all_on() const { * DoubleBitMask, shifted to the least-significant position. */ template -INLINE TYPENAME DoubleBitMask::WordType DoubleBitMask:: +INLINE typename DoubleBitMask::WordType DoubleBitMask:: extract(int low_bit, int size) const { if (low_bit >= half_bits) { return _hi.extract(low_bit - half_bits, size); diff --git a/panda/src/putil/doubleBitMask.cxx b/panda/src/putil/doubleBitMask.cxx index c35d11613a..ff651eea61 100644 --- a/panda/src/putil/doubleBitMask.cxx +++ b/panda/src/putil/doubleBitMask.cxx @@ -15,3 +15,10 @@ template class DoubleBitMask; template class DoubleBitMask; + +#if !defined(CPPPARSER) && !defined(__APPLE__) +#include + +static_assert(std::is_literal_type::value, "DoubleBitMaskNative is not a literal type"); +static_assert(std::is_literal_type::value, "QuadBitMaskNative is not a literal type"); +#endif diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index 6c32cd0122..2f1d1c5806 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -27,7 +27,7 @@ template class DoubleBitMask { public: - typedef TYPENAME BMType::WordType WordType; + typedef typename BMType::WordType WordType; PUBLISHED: typedef BMType BitMaskType; @@ -37,9 +37,7 @@ PUBLISHED: num_bits = BMType::num_bits * 2, }; - INLINE DoubleBitMask(); - INLINE DoubleBitMask(const DoubleBitMask ©); - INLINE DoubleBitMask &operator = (const DoubleBitMask ©); + constexpr DoubleBitMask() = default; INLINE static DoubleBitMask all_on(); INLINE static DoubleBitMask all_off(); @@ -47,8 +45,6 @@ PUBLISHED: INLINE static DoubleBitMask bit(int index); INLINE static DoubleBitMask range(int low_bit, int size); - INLINE ~DoubleBitMask(); - constexpr static bool has_max_num_bits() {return true;} constexpr static int get_max_num_bits() {return num_bits;} diff --git a/panda/src/putil/factory.h b/panda/src/putil/factory.h index 4520153911..b7751feb30 100644 --- a/panda/src/putil/factory.h +++ b/panda/src/putil/factory.h @@ -50,7 +50,7 @@ public: const FactoryParams ¶ms = FactoryParams()); INLINE void register_factory(TypeHandle handle, CreateFunc *func, - void *user_data = NULL); + void *user_data = nullptr); }; #include "factory.I" diff --git a/panda/src/putil/factoryBase.I b/panda/src/putil/factoryBase.I index 3452a9758c..199d3f8d5a 100644 --- a/panda/src/putil/factoryBase.I +++ b/panda/src/putil/factoryBase.I @@ -23,7 +23,7 @@ INLINE TypedObject *FactoryBase:: make_instance(const string &type_name, const FactoryParams ¶ms) { TypeHandle handle = TypeRegistry::ptr()->find_type(type_name); - nassertr(handle != TypeHandle::none(), NULL); + nassertr(handle != TypeHandle::none(), nullptr); return make_instance(handle, params); } @@ -42,7 +42,7 @@ INLINE TypedObject *FactoryBase:: make_instance_more_general(const string &type_name, const FactoryParams ¶ms) { TypeHandle handle = TypeRegistry::ptr()->find_type(type_name); - nassertr(handle != TypeHandle::none(), NULL); + nassertr(handle != TypeHandle::none(), nullptr); return make_instance_more_general(handle, params); } diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index d34035177c..bfb803da39 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -37,10 +37,10 @@ FactoryBase:: */ TypedObject *FactoryBase:: make_instance(TypeHandle handle, const FactoryParams ¶ms) { - TypedObject *instance = (TypedObject *)NULL; + TypedObject *instance = nullptr; instance = make_instance_exact(handle, params); - if (instance == (TypedObject *)NULL) { + if (instance == nullptr) { // Can't create an exact instance; try for a derived type. instance = make_instance_more_specific(handle, params); } @@ -49,7 +49,7 @@ make_instance(TypeHandle handle, const FactoryParams ¶ms) { util_cat.debug() << "make_instance(" << handle << ", params) returns " << (void *)instance; - if (instance != (TypedObject *)NULL) { + if (instance != nullptr) { util_cat.debug(false) << ", of type " << instance->get_type(); } @@ -67,15 +67,15 @@ TypedObject *FactoryBase:: make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { TypedObject *object = make_instance_exact(handle, params); - if (object == (TypedObject *)NULL) { + if (object == nullptr) { // Recursively search through the entire inheritance tree until we find // something we know about. if (handle.get_num_parent_classes() == 0) { - return NULL; + return nullptr; } int num_parents = handle.get_num_parent_classes(); - for (int i = 0; i < num_parents && object == (TypedObject *)NULL; i++) { + for (int i = 0; i < num_parents && object == nullptr; i++) { object = make_instance_more_general(handle.get_parent_class(i), params); } } @@ -84,7 +84,7 @@ make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { util_cat.debug() << "make_instance(" << handle << ", params) returns " << (void *)object; - if (object != (TypedObject *)NULL) { + if (object != nullptr) { util_cat.debug(false) << ", of type " << object->get_type(); } @@ -134,7 +134,7 @@ find_registered_type(TypeHandle handle) { void FactoryBase:: register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data) { nassertv(handle != TypeHandle::none()); - nassertv(func != (BaseCreateFunc *)NULL); + nassertv(func != nullptr); Creator creator; creator._func = func; @@ -243,11 +243,11 @@ TypedObject *FactoryBase:: make_instance_exact(TypeHandle handle, FactoryParams params) { Creators::const_iterator ci = _creators.find(handle); if (ci == _creators.end()) { - return NULL; + return nullptr; } Creator creator = (*ci).second; - nassertr(creator._func != (BaseCreateFunc *)NULL, NULL); + nassertr(creator._func != nullptr, nullptr); params._user_data = creator._user_data; return (*creator._func)(params); } @@ -267,7 +267,7 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) { TypeHandle ptype = (*pi); if (ptype.is_derived_from(handle)) { TypedObject *object = make_instance_exact(ptype, params); - if (object != (TypedObject *)NULL) { + if (object != nullptr) { return object; } } @@ -280,14 +280,14 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) { TypeHandle ctype = (*ci).first; if (ctype.is_derived_from(handle)) { Creator creator = (*ci).second; - nassertr(creator._func != (BaseCreateFunc *)NULL, NULL); + nassertr(creator._func != nullptr, nullptr); params._user_data = creator._user_data; TypedObject *object = (*creator._func)(params); - if (object != (TypedObject *)NULL) { + if (object != nullptr) { return object; } } } - return NULL; + return nullptr; } diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h index 6fcfc2f54f..73d0e8c6e5 100644 --- a/panda/src/putil/factoryBase.h +++ b/panda/src/putil/factoryBase.h @@ -56,7 +56,7 @@ public: TypeHandle find_registered_type(TypeHandle handle); - void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = NULL); + void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = nullptr); int get_num_types() const; TypeHandle get_type(int n) const; diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I index 04b7d2c634..b62406861a 100644 --- a/panda/src/putil/factoryParams.I +++ b/panda/src/putil/factoryParams.I @@ -17,7 +17,7 @@ * */ INLINE FactoryParams:: -FactoryParams() : _user_data(NULL) { +FactoryParams() : _user_data(nullptr) { } /** @@ -70,8 +70,8 @@ template bool get_param_into(ParamType *&pointer, const FactoryParams ¶ms) { FactoryParam *param = params.get_param_of_type(ParamType::get_class_type()); - if (param == (FactoryParam *)NULL) { - pointer = NULL; + if (param == nullptr) { + pointer = nullptr; return false; } DCAST_INTO_R(pointer, param, false); diff --git a/panda/src/putil/factoryParams.cxx b/panda/src/putil/factoryParams.cxx index 6224f8b94e..362ec097c1 100644 --- a/panda/src/putil/factoryParams.cxx +++ b/panda/src/putil/factoryParams.cxx @@ -18,7 +18,7 @@ */ void FactoryParams:: add_param(FactoryParam *param) { - nassertv(param != (FactoryParam *)NULL); + nassertv(param != nullptr); _params.push_back(param); } @@ -43,7 +43,7 @@ get_num_params() const { */ FactoryParam *FactoryParams:: get_param(int n) const { - nassertr(n >= 0 && n < (int)_params.size(), NULL); + nassertr(n >= 0 && n < (int)_params.size(), nullptr); return DCAST(FactoryParam, _params[n]); } @@ -59,8 +59,8 @@ get_param_of_type(TypeHandle type) const { // First, search for the exact match. for (pi = _params.begin(); pi != _params.end(); ++pi) { FactoryParam *param; - DCAST_INTO_R(param, *pi, NULL); - nassertr(param != (FactoryParam *)NULL, NULL); + DCAST_INTO_R(param, *pi, nullptr); + nassertr(param != nullptr, nullptr); if (param->is_exact_type(type)) { return param; @@ -70,13 +70,13 @@ get_param_of_type(TypeHandle type) const { // Now, search for a derived match. for (pi = _params.begin(); pi != _params.end(); ++pi) { FactoryParam *param; - DCAST_INTO_R(param, *pi, NULL); - nassertr(param != (FactoryParam *)NULL, NULL); + DCAST_INTO_R(param, *pi, nullptr); + nassertr(param != nullptr, nullptr); if (param->is_of_type(type)) { return param; } } - return NULL; + return nullptr; } diff --git a/panda/src/putil/globalPointerRegistry.I b/panda/src/putil/globalPointerRegistry.I index 10dc289e9b..a43f3fd98d 100644 --- a/panda/src/putil/globalPointerRegistry.I +++ b/panda/src/putil/globalPointerRegistry.I @@ -49,7 +49,7 @@ clear_pointer(TypeHandle type) { */ INLINE GlobalPointerRegistry *GlobalPointerRegistry:: get_global_ptr() { - if (_global_ptr == (GlobalPointerRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GlobalPointerRegistry; } return _global_ptr; diff --git a/panda/src/putil/globalPointerRegistry.cxx b/panda/src/putil/globalPointerRegistry.cxx index 40e062d9c0..622a666f6e 100644 --- a/panda/src/putil/globalPointerRegistry.cxx +++ b/panda/src/putil/globalPointerRegistry.cxx @@ -34,7 +34,7 @@ ns_get_pointer(TypeHandle type) const { Pointers::const_iterator pi; pi = _pointers.find(type); if (pi == _pointers.end()) { - return (void *)NULL; + return nullptr; } return (*pi).second; @@ -51,7 +51,7 @@ ns_store_pointer(TypeHandle type, void *ptr) { util_cat->error() << "GlobalPointerRegistry::store_pointer() called on empty TypeHandle\n"; } - if (ptr == (void *)NULL) { + if (ptr == nullptr) { util_cat->error() << "Invalid attempt to store a NULL pointer for " << type << "\n"; clear_pointer(type); diff --git a/panda/src/putil/iterator_types.h b/panda/src/putil/iterator_types.h index 80d8f32882..ec90638237 100644 --- a/panda/src/putil/iterator_types.h +++ b/panda/src/putil/iterator_types.h @@ -24,7 +24,7 @@ template class first_of_pair_iterator : public pair_iterator { public: - typedef TYPENAME pair_iterator::value_type::first_type value_type; + typedef typename pair_iterator::value_type::first_type value_type; first_of_pair_iterator() = default; first_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } @@ -42,7 +42,7 @@ public: template class second_of_pair_iterator : public pair_iterator { public: - typedef TYPENAME pair_iterator::value_type::second_type value_type; + typedef typename pair_iterator::value_type::second_type value_type; second_of_pair_iterator() = default; second_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } diff --git a/panda/src/putil/linkedListNode.I b/panda/src/putil/linkedListNode.I index e722108702..faed3b5c96 100644 --- a/panda/src/putil/linkedListNode.I +++ b/panda/src/putil/linkedListNode.I @@ -17,8 +17,8 @@ INLINE LinkedListNode:: LinkedListNode() { #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -38,7 +38,7 @@ LinkedListNode(bool) { */ INLINE LinkedListNode:: ~LinkedListNode() { - nassertv((_next == NULL && _prev == NULL) || (_next == this && _prev == this)); + nassertv((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this)); } /** @@ -48,7 +48,7 @@ INLINE LinkedListNode:: */ INLINE bool LinkedListNode:: is_on_list() const { - return (_next != NULL); + return (_next != nullptr); } /** @@ -56,13 +56,13 @@ is_on_list() const { */ INLINE void LinkedListNode:: remove_from_list() { - nassertv(_prev != NULL && _next != NULL); + nassertv(_prev != nullptr && _next != nullptr); nassertv(_prev->_next == this && _next->_prev == this); _prev->_next = _next; _next->_prev = _prev; #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -72,9 +72,9 @@ remove_from_list() { */ INLINE void LinkedListNode:: insert_before(LinkedListNode *node) { - nassertv(node->_prev != NULL && node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (LinkedListNode *)NULL && - _next == (LinkedListNode *)NULL); + nassertv(node->_prev != nullptr && node->_prev->_next == node && node->_next->_prev == node); + nassertv(_prev == nullptr && + _next == nullptr); _prev = node->_prev; _next = node; _prev->_next = this; @@ -87,9 +87,9 @@ insert_before(LinkedListNode *node) { */ INLINE void LinkedListNode:: insert_after(LinkedListNode *node) { - nassertv(node->_prev != NULL && node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (LinkedListNode *)NULL && - _next == (LinkedListNode *)NULL); + nassertv(node->_prev != nullptr && node->_prev->_next == node && node->_next->_prev == node); + nassertv(_prev == nullptr && + _next == nullptr); _next = node->_next; _prev = node; _next->_prev = this; diff --git a/panda/src/putil/load_prc_file.cxx b/panda/src/putil/load_prc_file.cxx index 5663c49038..7da6526c9c 100644 --- a/panda/src/putil/load_prc_file.cxx +++ b/panda/src/putil/load_prc_file.cxx @@ -44,10 +44,10 @@ load_prc_file(const Filename &filename) { vfs->resolve_filename(path, get_model_path()); istream *file = vfs->open_read_file(path, true); - if (file == (istream *)NULL) { + if (file == nullptr) { util_cat.error() << "Unable to open " << path << "\n"; - return NULL; + return nullptr; } util_cat.info() @@ -64,7 +64,7 @@ load_prc_file(const Filename &filename) { util_cat.info() << "Unable to read " << path << "\n"; cp_mgr->delete_explicit_page(page); - return NULL; + return nullptr; } } @@ -94,7 +94,7 @@ load_prc_file_data(const string &name, const string &data) { util_cat.info() << "Unable to read explicit prc data " << name << "\n"; cp_mgr->delete_explicit_page(page); - return NULL; + return nullptr; } } diff --git a/panda/src/putil/loaderOptions.I b/panda/src/putil/loaderOptions.I index b15780c847..6e407e7840 100644 --- a/panda/src/putil/loaderOptions.I +++ b/panda/src/putil/loaderOptions.I @@ -14,7 +14,7 @@ /** * */ -INLINE LoaderOptions:: +constexpr LoaderOptions:: LoaderOptions(int flags, int texture_flags) : _flags(flags), _texture_flags(texture_flags), @@ -23,29 +23,6 @@ LoaderOptions(int flags, int texture_flags) : { } -/** - * - */ -INLINE LoaderOptions:: -LoaderOptions(const LoaderOptions ©) : - _flags(copy._flags), - _texture_flags(copy._texture_flags), - _texture_num_views(copy._texture_num_views), - _auto_texture_scale(copy._auto_texture_scale) -{ -} - -/** - * - */ -INLINE void LoaderOptions:: -operator = (const LoaderOptions ©) { - _flags = copy._flags; - _texture_flags = copy._texture_flags; - _texture_num_views = copy._texture_num_views; - _auto_texture_scale = copy._auto_texture_scale; -} - /** * */ diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index 7f57d77fef..167d977cd7 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/panda/src/putil/loaderOptions.cxx @@ -29,13 +29,13 @@ LoaderOptions(int flags) : static ConfigVariableBool *preload_textures; static ConfigVariableBool *preload_simple_textures; static ConfigVariableBool *compressed_textures; - if (preload_textures == NULL) { + if (preload_textures == nullptr) { preload_textures = new ConfigVariableBool("preload-textures", true); } - if (preload_simple_textures == NULL) { + if (preload_simple_textures == nullptr) { preload_simple_textures = new ConfigVariableBool("preload-simple-textures", false); } - if (compressed_textures == NULL) { + if (compressed_textures == nullptr) { compressed_textures = new ConfigVariableBool("compressed-textures", false); } diff --git a/panda/src/putil/loaderOptions.h b/panda/src/putil/loaderOptions.h index 50c73f983e..971353e723 100644 --- a/panda/src/putil/loaderOptions.h +++ b/panda/src/putil/loaderOptions.h @@ -49,9 +49,7 @@ PUBLISHED: }; LoaderOptions(int flags = LF_search | LF_report_errors); - INLINE LoaderOptions(int flags, int texture_flags); - INLINE LoaderOptions(const LoaderOptions ©); - INLINE void operator = (const LoaderOptions ©); + constexpr LoaderOptions(int flags, int texture_flags); INLINE void set_flags(int flags); INLINE int get_flags() const; diff --git a/panda/src/putil/nodeCachedReferenceCount.I b/panda/src/putil/nodeCachedReferenceCount.I index c06016d523..92abe19ce3 100644 --- a/panda/src/putil/nodeCachedReferenceCount.I +++ b/panda/src/putil/nodeCachedReferenceCount.I @@ -49,8 +49,6 @@ NodeCachedReferenceCount(const NodeCachedReferenceCount ©) : CachedTypedWrit */ INLINE void NodeCachedReferenceCount:: operator = (const NodeCachedReferenceCount ©) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -71,8 +69,6 @@ operator = (const NodeCachedReferenceCount ©) { */ INLINE NodeCachedReferenceCount:: ~NodeCachedReferenceCount() { - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/putil/nodeCachedReferenceCount.cxx b/panda/src/putil/nodeCachedReferenceCount.cxx index 62249dcd42..f53ff22b96 100644 --- a/panda/src/putil/nodeCachedReferenceCount.cxx +++ b/panda/src/putil/nodeCachedReferenceCount.cxx @@ -21,8 +21,6 @@ TypeHandle NodeCachedReferenceCount::_type_handle; */ bool NodeCachedReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/putil/paramValue.I b/panda/src/putil/paramValue.I index f446b88dad..735e4f2ca4 100644 --- a/panda/src/putil/paramValue.I +++ b/panda/src/putil/paramValue.I @@ -43,7 +43,7 @@ ParamTypedRefCount(const TypedReferenceCount *value) : */ INLINE TypeHandle ParamTypedRefCount:: get_value_type() const { - if (_value == NULL) { + if (_value == nullptr) { return TypeHandle::none(); } else { return _value->get_type(); diff --git a/panda/src/putil/paramValue.cxx b/panda/src/putil/paramValue.cxx index 6937a27faa..309f8885bd 100644 --- a/panda/src/putil/paramValue.cxx +++ b/panda/src/putil/paramValue.cxx @@ -57,7 +57,7 @@ ParamTypedRefCount:: */ void ParamTypedRefCount:: output(ostream &out) const { - if (_value == (TypedReferenceCount *)NULL) { + if (_value == nullptr) { out << "(empty)"; } else { diff --git a/panda/src/putil/pythonCallbackObject.cxx b/panda/src/putil/pythonCallbackObject.cxx index b1917c6e0e..e8ef005c2e 100644 --- a/panda/src/putil/pythonCallbackObject.cxx +++ b/panda/src/putil/pythonCallbackObject.cxx @@ -111,7 +111,7 @@ do_callback(CallbackData *cbdata) { */ void PythonCallbackObject:: do_python_callback(CallbackData *cbdata) { - nassertv(cbdata != NULL); + nassertv(cbdata != nullptr); // Wrap the cbdata up in a Python object, then put it in a tuple, for the // argument list. @@ -124,7 +124,7 @@ do_python_callback(CallbackData *cbdata) { PyObject *result = PythonThread::call_python_func(_function, args); Py_DECREF(args); - if (result == (PyObject *)NULL) { + if (result == nullptr) { if (PyErr_Occurred() != PyExc_SystemExit) { util_cat.error() << "Exception occurred in " << *this << "\n"; diff --git a/panda/src/putil/simpleHashMap.h b/panda/src/putil/simpleHashMap.h index 6d08de5554..cd759f6cbd 100644 --- a/panda/src/putil/simpleHashMap.h +++ b/panda/src/putil/simpleHashMap.h @@ -52,16 +52,16 @@ private: * values. This allows effectively using SimpleHashMap as a set. */ template -class SimpleKeyValuePair { +class SimpleKeyValuePair { public: - INLINE SimpleKeyValuePair(const Key &key, nullptr_t data) : + INLINE SimpleKeyValuePair(const Key &key, std::nullptr_t data) : _key(key) {} Key _key; - ALWAYS_INLINE constexpr static nullptr_t get_data() { return nullptr; } - ALWAYS_INLINE constexpr static nullptr_t modify_data() { return nullptr; } - ALWAYS_INLINE static void set_data(nullptr_t) {} + ALWAYS_INLINE constexpr static std::nullptr_t get_data() { return nullptr; } + ALWAYS_INLINE constexpr static std::nullptr_t modify_data() { return nullptr; } + ALWAYS_INLINE static void set_data(std::nullptr_t) {} }; /** diff --git a/panda/src/putil/test_bam.cxx b/panda/src/putil/test_bam.cxx index deef264ce1..a6103d5c5f 100644 --- a/panda/src/putil/test_bam.cxx +++ b/panda/src/putil/test_bam.cxx @@ -79,9 +79,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) void Person:: print_relationships(){ nout << "My name is " << _name << endl; - if (_bro != NULL) + if (_bro != nullptr) nout << "My brother is " << _bro->name() << endl; - if (_sis != NULL) + if (_sis != nullptr) nout << "My sister is " << _sis->name() << endl; } @@ -137,9 +137,9 @@ setDaughter(Child* daughter) void Parent:: print_relationships(){ Person::print_relationships(); - if (_son != NULL) + if (_son != nullptr) nout << "My son is " << _son->name() << endl; - if (_daughter != NULL) + if (_daughter != nullptr) nout << "My daughter is " << _daughter->name() << endl; } @@ -197,8 +197,8 @@ setMother(Parent* mom) void Child:: print_relationships(){ Person::print_relationships(); - if (_dad != NULL) + if (_dad != nullptr) nout << "My dad is " << _dad->name() << endl; - if (_mom != NULL) + if (_mom != nullptr) nout << "My mom is " << _mom->name() << endl; } diff --git a/panda/src/putil/test_bam.h b/panda/src/putil/test_bam.h index 557b9ba6b4..b49fca965a 100644 --- a/panda/src/putil/test_bam.h +++ b/panda/src/putil/test_bam.h @@ -54,7 +54,7 @@ private: public: Person() {} Person(const string &name, const sex Gender) : - _name(name), myGender(Gender), _bro((Person*)NULL), _sis((Person*)NULL) { + _name(name), myGender(Gender), _bro(nullptr), _sis(nullptr) { } virtual ~Person() { diff --git a/panda/src/putil/typedWritable.I b/panda/src/putil/typedWritable.I index 21f86f03a4..5940fd9de3 100644 --- a/panda/src/putil/typedWritable.I +++ b/panda/src/putil/typedWritable.I @@ -15,14 +15,14 @@ * */ INLINE TypedWritable:: -TypedWritable() : _bam_writers(NULL) { +TypedWritable() : _bam_writers(nullptr) { } /** * */ INLINE TypedWritable:: -TypedWritable(const TypedWritable &) : _bam_writers(NULL) { +TypedWritable(const TypedWritable &) : _bam_writers(nullptr) { } /** diff --git a/panda/src/putil/typedWritable.cxx b/panda/src/putil/typedWritable.cxx index 7cc9d93cbd..d0e5058538 100644 --- a/panda/src/putil/typedWritable.cxx +++ b/panda/src/putil/typedWritable.cxx @@ -19,7 +19,7 @@ #include "bam.h" TypeHandle TypedWritable::_type_handle; -TypedWritable* const TypedWritable::Null = (TypedWritable*)0L; +TypedWritable* const TypedWritable::Null = nullptr; /** * @@ -30,15 +30,15 @@ TypedWritable:: BamWriterLink *link; do { link = (BamWriterLink *)AtomicAdjust::get_ptr(_bam_writers); - if (link == (BamWriterLink *)NULL) { + if (link == nullptr) { // List is unlocked and empty - no writers to remove. return; } link = (BamWriterLink *)(((uintptr_t)link) & ~(uintptr_t)0x1); } while (link != AtomicAdjust:: - compare_and_exchange_ptr(_bam_writers, (void *)link, (void *)NULL)); + compare_and_exchange_ptr(_bam_writers, (void *)link, nullptr)); - while (link != (BamWriterLink *)NULL) { + while (link != nullptr) { BamWriterLink *next_link = link->_next; link->_writer->object_destructs(this); delete link; @@ -119,7 +119,7 @@ finalize(BamReader *) { */ ReferenceCount *TypedWritable:: as_reference_count() { - return NULL; + return nullptr; } /** @@ -192,7 +192,7 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, DatagramBuffer buffer(move(data)); - if (reader == NULL) { + if (reader == nullptr) { // Create a local reader. string head; if (!buffer.read_header(head, _bam_header.size())) { @@ -216,7 +216,7 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, return false; } - if (ref_ptr == NULL) { + if (ref_ptr == nullptr) { // Can't support non-reference-counted objects. return false; } @@ -229,25 +229,25 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, // Use the existing reader. reader->set_source(&buffer); if (!reader->read_object(ptr, ref_ptr)) { - reader->set_source(NULL); + reader->set_source(nullptr); return false; } if (!reader->resolve()) { - reader->set_source(NULL); + reader->set_source(nullptr); return false; } - if (ref_ptr == NULL) { + if (ref_ptr == nullptr) { // Can't support non-reference-counted objects. - reader->set_source(NULL); + reader->set_source(nullptr); return false; } // This BamReader isn't going away, but we have to balance the unref() // below. ref_ptr->ref(); - reader->set_source(NULL); + reader->set_source(nullptr); } @@ -265,7 +265,7 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, */ void TypedWritable:: add_bam_writer(BamWriter *writer) { - nassertv(writer != (BamWriter *)NULL); + nassertv(writer != nullptr); BamWriterLink *begin; BamWriterLink *new_link = new BamWriterLink; @@ -289,7 +289,7 @@ add_bam_writer(BamWriter *writer) { */ void TypedWritable:: remove_bam_writer(BamWriter *writer) { - nassertv(writer != (BamWriter *)NULL); + nassertv(writer != nullptr); BamWriterLink *begin; @@ -298,7 +298,7 @@ remove_bam_writer(BamWriter *writer) { do { begin = (BamWriterLink *)AtomicAdjust::get_ptr(_bam_writers); begin = (BamWriterLink *)(((uintptr_t)begin) & ~(uintptr_t)0x1); - if (begin == NULL) { + if (begin == nullptr) { // The list is empty, nothing to remove. return; } @@ -307,21 +307,21 @@ remove_bam_writer(BamWriter *writer) { (void *)((uintptr_t)begin | (uintptr_t)0x1))); // Find the writer in the list. - BamWriterLink *prev_link = (BamWriterLink *)NULL; + BamWriterLink *prev_link = nullptr; BamWriterLink *link = begin; - while (link != NULL && link->_writer != writer) { + while (link != nullptr && link->_writer != writer) { prev_link = link; link = link->_next; } - if (link == (BamWriterLink *)NULL) { + if (link == nullptr) { // Not found. Just unlock and leave. _bam_writers = (void *)begin; return; } - if (prev_link == (BamWriterLink *)NULL) { + if (prev_link == nullptr) { // It's the first link. Replace and unlock in one atomic op. _bam_writers = (void *)link->_next; } else { diff --git a/panda/src/putil/typedWritable.h b/panda/src/putil/typedWritable.h index b13a1991fb..2dbdc3d967 100644 --- a/panda/src/putil/typedWritable.h +++ b/panda/src/putil/typedWritable.h @@ -64,11 +64,11 @@ PUBLISHED: EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const); INLINE vector_uchar encode_to_bam_stream() const; - bool encode_to_bam_stream(vector_uchar &data, BamWriter *writer = NULL) const; + bool encode_to_bam_stream(vector_uchar &data, BamWriter *writer = nullptr) const; static bool decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, - BamReader *reader = NULL); + BamReader *reader = nullptr); private: void add_bam_writer(BamWriter *writer); diff --git a/panda/src/putil/typedWritable_ext.cxx b/panda/src/putil/typedWritable_ext.cxx index efaaac63fb..c736a6fa14 100644 --- a/panda/src/putil/typedWritable_ext.cxx +++ b/panda/src/putil/typedWritable_ext.cxx @@ -30,7 +30,7 @@ extern Dtool_PyTypedObject Dtool_BamWriter; */ PyObject *Extension:: __reduce__(PyObject *self) const { - return __reduce_persist__(self, NULL); + return __reduce_persist__(self, nullptr); } /** @@ -51,19 +51,19 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // Check that we have a decode_from_bam_stream python method. If not, we // can't use this interface. PyObject *method = PyObject_GetAttrString(self, "decode_from_bam_stream"); - if (method == NULL) { + if (method == nullptr) { ostringstream stream; stream << "Cannot pickle objects of type " << _this->get_type() << "\n"; string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; + return nullptr; } Py_DECREF(method); - BamWriter *writer = NULL; - if (pickler != NULL) { + BamWriter *writer = nullptr; + if (pickler != nullptr) { PyObject *py_writer = PyObject_GetAttrString(pickler, "bamWriter"); - if (py_writer == NULL) { + if (py_writer == nullptr) { // It's OK if there's no bamWriter. PyErr_Clear(); } else { @@ -79,35 +79,35 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { stream << "Could not bamify object of type " << _this->get_type() << "\n"; string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; + return nullptr; } // Start by getting this class object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *func; - if (writer != NULL) { + if (writer != nullptr) { // The modified pickle support: call the "persistent" version of this // function, which receives the unpickler itself as an additional // parameter. func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream_persist"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_TypedWritable_from_bam_stream_persist()"); Py_DECREF(this_class); - return NULL; + return nullptr; } } else { // The traditional pickle support: call the non-persistent version of this // function. func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_TypedWritable_from_bam_stream()"); Py_DECREF(this_class); - return NULL; + return nullptr; } } @@ -135,15 +135,15 @@ PyObject *Extension:: find_global_decode(PyObject *this_class, const char *func_name) { // Get the module in which BamWriter is defined. PyObject *module_name = PyObject_GetAttrString((PyObject *)&Dtool_BamWriter, "__module__"); - if (module_name != NULL) { + if (module_name != nullptr) { // borrowed reference PyObject *sys_modules = PyImport_GetModuleDict(); - if (sys_modules != NULL) { + if (sys_modules != nullptr) { // borrowed reference PyObject *module = PyDict_GetItem(sys_modules, module_name); - if (module != NULL) { + if (module != nullptr) { PyObject *func = PyObject_GetAttrString(module, (char *)func_name); - if (func != NULL) { + if (func != nullptr) { Py_DECREF(module_name); return func; } @@ -153,15 +153,15 @@ find_global_decode(PyObject *this_class, const char *func_name) { } PyObject *bases = PyObject_GetAttrString(this_class, "__bases__"); - if (bases != NULL) { + if (bases != nullptr) { if (PySequence_Check(bases)) { Py_ssize_t size = PySequence_Size(bases); for (Py_ssize_t i = 0; i < size; ++i) { PyObject *base = PySequence_GetItem(bases, i); - if (base != NULL) { + if (base != nullptr) { PyObject *func = find_global_decode(base, func_name); Py_DECREF(base); - if (func != NULL) { + if (func != nullptr) { Py_DECREF(bases); return func; } @@ -171,7 +171,7 @@ find_global_decode(PyObject *this_class, const char *func_name) { Py_DECREF(bases); } - return NULL; + return nullptr; } /** @@ -197,10 +197,10 @@ py_decode_TypedWritable_from_bam_stream(PyObject *this_class, const vector_uchar PyObject * py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *this_class, const vector_uchar &data) { - PyObject *py_reader = NULL; - if (pickler != NULL) { + PyObject *py_reader = nullptr; + if (pickler != nullptr) { py_reader = PyObject_GetAttrString(pickler, "bamReader"); - if (py_reader == NULL) { + if (py_reader == nullptr) { // It's OK if there's no bamReader. PyErr_Clear(); } @@ -242,7 +242,7 @@ py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *thi if (result == Py_None) { Py_DECREF(result); PyErr_SetString(PyExc_ValueError, "Could not unpack bam stream"); - return NULL; + return nullptr; } return result; diff --git a/panda/src/putil/weakKeyHashMap.I b/panda/src/putil/weakKeyHashMap.I index 514818a9be..6801df4ad1 100644 --- a/panda/src/putil/weakKeyHashMap.I +++ b/panda/src/putil/weakKeyHashMap.I @@ -17,8 +17,8 @@ template INLINE WeakKeyHashMap:: WeakKeyHashMap() : - _table(NULL), - _deleted_chain(NULL), + _table(nullptr), + _deleted_chain(nullptr), _table_size(0), _num_entries(0) { @@ -196,8 +196,8 @@ clear() { } _deleted_chain->deallocate(_table, TypeHandle::none()); - _table = NULL; - _deleted_chain = NULL; + _table = nullptr; + _deleted_chain = nullptr; _table_size = 0; _num_entries = 0; } @@ -588,7 +588,7 @@ expand_table() { // Double the table size. size_t old_table_size = old_map._table_size; _table_size = (old_table_size << 1); - nassertv(_table == NULL); + nassertv(_table == nullptr); // We allocate enough bytes for _table_size elements of TableEntry, plus // _table_size more bytes at the end (for the exists array). diff --git a/panda/src/recorder/recorderController.I b/panda/src/recorder/recorderController.I index b6312c0d82..043fb55fb4 100644 --- a/panda/src/recorder/recorderController.I +++ b/panda/src/recorder/recorderController.I @@ -46,7 +46,7 @@ get_random_seed() const { */ INLINE bool RecorderController:: is_recording() const { - return (_writer != (BamWriter *)NULL); + return (_writer != nullptr); } /** @@ -54,7 +54,7 @@ is_recording() const { */ INLINE bool RecorderController:: is_playing() const { - return (_reader != (BamReader *)NULL); + return (_reader != nullptr); } /** @@ -138,7 +138,7 @@ add_recorder(const string &name, RecorderBase *recorder) { */ INLINE bool RecorderController:: has_recorder(const string &name) const { - return (_user_table->get_recorder(name) != (RecorderBase *)NULL); + return (_user_table->get_recorder(name) != nullptr); } /** @@ -153,7 +153,7 @@ has_recorder(const string &name) const { INLINE RecorderBase *RecorderController:: get_recorder(const string &name) const { RecorderBase *recorder = _user_table->get_recorder(name); - if (is_playing() && recorder == (RecorderBase *)NULL) { + if (is_playing() && recorder == nullptr) { recorder = _active_table->get_recorder(name); } return recorder; @@ -178,7 +178,7 @@ remove_recorder(const string &name) { // it now.) if (is_recording() || is_playing()) { RecorderBase *recorder = _user_table->get_recorder(name); - if (recorder != (RecorderBase *)NULL) { + if (recorder != nullptr) { recorder->_flags &= ~(RecorderBase::F_recording | RecorderBase::F_playing); } } @@ -217,7 +217,7 @@ get_frame_tie() const { */ INLINE RecorderController::RecorderFactory *RecorderController:: get_factory() { - if (_factory == (RecorderFactory *)NULL) { + if (_factory == nullptr) { create_factory(); } return _factory; diff --git a/panda/src/recorder/recorderController.cxx b/panda/src/recorder/recorderController.cxx index 364619d5ae..b383402715 100644 --- a/panda/src/recorder/recorderController.cxx +++ b/panda/src/recorder/recorderController.cxx @@ -20,7 +20,7 @@ #include "clockObject.h" TypeHandle RecorderController::_type_handle; -RecorderController::RecorderFactory *RecorderController::_factory = NULL; +RecorderController::RecorderFactory *RecorderController::_factory = nullptr; /** * @@ -29,13 +29,13 @@ RecorderController:: RecorderController() { _clock_offset = 0.0; _frame_offset = 0; - _writer = (BamWriter *)NULL; - _reader = (BamReader *)NULL; + _writer = nullptr; + _reader = nullptr; _frame_tie = true; _user_table = new RecorderTable; _user_table_modified = false; - _file_table = NULL; - _active_table = NULL; + _file_table = nullptr; + _active_table = nullptr; _eof = false; } @@ -132,7 +132,7 @@ begin_playback(const Filename &filename) { // Start out by reading the RecorderHeader. TypedWritable *object = _reader->read_object(); - if (object == (TypedWritable *)NULL || + if (object == nullptr || !object->is_of_type(RecorderHeader::get_class_type())) { recorder_cat.error() << _filename << " does not contain a recorded session.\n"; @@ -151,7 +151,7 @@ begin_playback(const Filename &filename) { // Now read the first frame. _next_frame = read_frame(); - if (_next_frame == (RecorderFrame *)NULL) { + if (_next_frame == nullptr) { recorder_cat.error() << _filename << " does not contain any frames.\n"; close(); @@ -169,16 +169,16 @@ begin_playback(const Filename &filename) { */ void RecorderController:: close() { - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { delete _writer; - _writer = NULL; + _writer = nullptr; // Tell all of our recorders that they're no longer recording. _user_table->clear_flags(RecorderBase::F_recording); } - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { delete _reader; - _reader = NULL; + _reader = nullptr; // Tell all of our recorders that they're no longer playing. _active_table->clear_flags(RecorderBase::F_playing); @@ -186,14 +186,14 @@ close() { _dout.close(); _din.close(); - if (_file_table != (RecorderTable *)NULL) { + if (_file_table != nullptr) { delete _file_table; - _file_table = (RecorderTable *)NULL; + _file_table = nullptr; } - if (_active_table != (RecorderTable *)NULL) { + if (_active_table != nullptr) { delete _active_table; - _active_table = (RecorderTable *)NULL; + _active_table = nullptr; } } @@ -231,7 +231,7 @@ play_frame() { double now = global_clock->get_frame_time() - _clock_offset; int frame = global_clock->get_frame_count() - _frame_offset; - while (_next_frame != (RecorderFrame *)NULL) { + while (_next_frame != nullptr) { if (_frame_tie) { if (frame < _next_frame->_frame) { // We haven't reached the next frame yet. @@ -302,9 +302,9 @@ RecorderFrame *RecorderController:: read_frame() { TypedWritable *object = _reader->read_object(); - if (object == (TypedWritable *)NULL || + if (object == nullptr || !object->is_of_type(RecorderFrame::get_class_type())) { - return NULL; + return nullptr; } if (!_reader->resolve()) { diff --git a/panda/src/recorder/recorderFrame.cxx b/panda/src/recorder/recorderFrame.cxx index d53e3d46dc..6b2ea3da10 100644 --- a/panda/src/recorder/recorderFrame.cxx +++ b/panda/src/recorder/recorderFrame.cxx @@ -118,7 +118,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _timestamp = scan.get_float64(); _frame = scan.get_uint32(); _table_changed = scan.get_bool(); - _table = (RecorderTable *)NULL; + _table = nullptr; if (_table_changed) { manager->read_pointer(scan); } diff --git a/panda/src/recorder/recorderTable.I b/panda/src/recorder/recorderTable.I index 6bb2649d97..088c74c52f 100644 --- a/panda/src/recorder/recorderTable.I +++ b/panda/src/recorder/recorderTable.I @@ -46,7 +46,7 @@ operator = (const RecorderTable ©) { */ INLINE void RecorderTable:: add_recorder(const string &name, RecorderBase *recorder) { - nassertv(recorder != (RecorderBase *)NULL); + nassertv(recorder != nullptr); recorder->ref(); std::pair result = @@ -69,7 +69,7 @@ get_recorder(const string &name) const { if (ri != _recorders.end()) { return (*ri).second; } - return NULL; + return nullptr; } /** diff --git a/panda/src/recorder/recorderTable.cxx b/panda/src/recorder/recorderTable.cxx index 6b60d82ada..27fc5ed2c8 100644 --- a/panda/src/recorder/recorderTable.cxx +++ b/panda/src/recorder/recorderTable.cxx @@ -216,7 +216,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { RecorderBase *recorder = RecorderController::get_factory()->make_instance_more_general(type, fparams); - if (recorder == (RecorderBase *)NULL) { + if (recorder == nullptr) { recorder_cat.error() << "Unable to create Recorder of type " << type << "\n"; _error = true; diff --git a/panda/src/recorder/socketStreamRecorder.I b/panda/src/recorder/socketStreamRecorder.I index 90c0585860..520e6f5d40 100644 --- a/panda/src/recorder/socketStreamRecorder.I +++ b/panda/src/recorder/socketStreamRecorder.I @@ -16,7 +16,7 @@ */ INLINE SocketStreamRecorder:: SocketStreamRecorder() : - _stream(NULL), + _stream(nullptr), _owns_stream(false), _closed(true) { @@ -48,7 +48,7 @@ INLINE SocketStreamRecorder:: */ bool SocketStreamRecorder:: send_datagram(const Datagram &dg) { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->send_datagram(dg); } return true; @@ -59,7 +59,7 @@ send_datagram(const Datagram &dg) { */ INLINE bool SocketStreamRecorder:: is_closed() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->is_closed(); } return is_playing() && _closed; @@ -70,7 +70,7 @@ is_closed() { */ INLINE void SocketStreamRecorder:: close() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { _stream->close(); } _closed = true; @@ -81,7 +81,7 @@ close() { */ INLINE void SocketStreamRecorder:: set_collect_tcp(bool collect_tcp) { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { _stream->set_collect_tcp(collect_tcp); } } @@ -91,7 +91,7 @@ set_collect_tcp(bool collect_tcp) { */ INLINE bool SocketStreamRecorder:: get_collect_tcp() const { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->get_collect_tcp(); } return false; @@ -102,7 +102,7 @@ get_collect_tcp() const { */ INLINE void SocketStreamRecorder:: set_collect_tcp_interval(double interval) { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { _stream->set_collect_tcp_interval(interval); } } @@ -112,7 +112,7 @@ set_collect_tcp_interval(double interval) { */ INLINE double SocketStreamRecorder:: get_collect_tcp_interval() const { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->get_collect_tcp_interval(); } return 0.0; @@ -123,7 +123,7 @@ get_collect_tcp_interval() const { */ INLINE bool SocketStreamRecorder:: consider_flush() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->consider_flush(); } return true; @@ -134,7 +134,7 @@ consider_flush() { */ INLINE bool SocketStreamRecorder:: flush() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->flush(); } return true; diff --git a/panda/src/recorder/socketStreamRecorder.cxx b/panda/src/recorder/socketStreamRecorder.cxx index 6209239044..9c9d66b310 100644 --- a/panda/src/recorder/socketStreamRecorder.cxx +++ b/panda/src/recorder/socketStreamRecorder.cxx @@ -42,7 +42,7 @@ receive_datagram(Datagram &dg) { } else { // If we're not in playback mode, forward the request to the connection. bool got_data = false; - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { got_data = _stream->receive_datagram(dg); } diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index 99ddcd5256..0c3a25fc29 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -20,7 +20,7 @@ */ RocketFileInterface:: RocketFileInterface(VirtualFileSystem *vfs) : _vfs(vfs) { - if (_vfs == NULL) { + if (_vfs == nullptr) { _vfs = VirtualFileSystem::get_global_ptr(); } } @@ -35,25 +35,25 @@ Open(const Rocket::Core::String& path) { Filename fn = Filename::from_os_specific(path.CString()); PT(VirtualFile) file = _vfs->get_file(fn); - if (file == NULL) { + if (file == nullptr) { // failed? Try model-path as a Panda-friendly fallback. if (!_vfs->resolve_filename(fn, get_model_path())) { rocket_cat.error() << "Could not resolve " << fn << " along the model-path (currently: " << get_model_path() << ")\n"; - return (Rocket::Core::FileHandle) NULL; + return (Rocket::Core::FileHandle) nullptr; } file = _vfs->get_file(fn); - if (file == NULL) { + if (file == nullptr) { rocket_cat.error() << "Failed to get " << fn << ", found on model-path\n"; - return (Rocket::Core::FileHandle) NULL; + return (Rocket::Core::FileHandle) nullptr; } } istream *str = file->open_read_file(true); - if (str == NULL) { + if (str == nullptr) { rocket_cat.error() << "Failed to open " << fn << " for reading\n"; - return (Rocket::Core::FileHandle) NULL; + return (Rocket::Core::FileHandle) nullptr; } VirtualFileHandle *handle = new VirtualFileHandle; @@ -70,7 +70,7 @@ Open(const Rocket::Core::String& path) { void RocketFileInterface:: Close(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return; } @@ -84,7 +84,7 @@ Close(Rocket::Core::FileHandle file) { size_t RocketFileInterface:: Read(void* buffer, size_t size, Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return 0; } @@ -98,7 +98,7 @@ Read(void* buffer, size_t size, Rocket::Core::FileHandle file) { bool RocketFileInterface:: Seek(Rocket::Core::FileHandle file, long offset, int origin) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return false; } @@ -122,7 +122,7 @@ Seek(Rocket::Core::FileHandle file, long offset, int origin) { size_t RocketFileInterface:: Tell(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return 0; } @@ -135,7 +135,7 @@ Tell(Rocket::Core::FileHandle file) { size_t RocketFileInterface:: Length(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return 0; } diff --git a/panda/src/rocket/rocketFileInterface.h b/panda/src/rocket/rocketFileInterface.h index 8a340136b5..144ccc4563 100644 --- a/panda/src/rocket/rocketFileInterface.h +++ b/panda/src/rocket/rocketFileInterface.h @@ -26,7 +26,7 @@ class VirtualFileSystem; */ class RocketFileInterface : public Rocket::Core::FileInterface { public: - RocketFileInterface(VirtualFileSystem *vfs = NULL); + RocketFileInterface(VirtualFileSystem *vfs = nullptr); virtual ~RocketFileInterface() {}; Rocket::Core::FileHandle Open(const Rocket::Core::String& path); diff --git a/panda/src/rocket/rocketRegion.cxx b/panda/src/rocket/rocketRegion.cxx index ebfcd630c2..fe21d5c6c2 100644 --- a/panda/src/rocket/rocketRegion.cxx +++ b/panda/src/rocket/rocketRegion.cxx @@ -36,7 +36,7 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, // A hack I don't like. libRocket's decorator system has a bug somewhere, // and this seems to be a workaround. - if (Rocket::Core::GetRenderInterface() == NULL) { + if (Rocket::Core::GetRenderInterface() == nullptr) { Rocket::Core::SetRenderInterface(&_interface); } @@ -50,7 +50,7 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, _context = Rocket::Core::CreateContext(context_name.c_str(), dimensions, &_interface); - nassertv(_context != NULL); + nassertv(_context != nullptr); _lens = new OrthographicLens; _lens->set_film_size(dimensions.x, -dimensions.y); @@ -67,10 +67,10 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, RocketRegion:: ~RocketRegion() { if (Rocket::Core::GetRenderInterface() == &_interface) { - Rocket::Core::SetRenderInterface(NULL); + Rocket::Core::SetRenderInterface(nullptr); } - if (_context != NULL) { + if (_context != nullptr) { if (_context->GetReferenceCount() > 1) { _context->RemoveReference(); return; @@ -121,7 +121,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, _lens->set_film_offset(dimensions.x * 0.5, dimensions.y * 0.5); } - if (_input_handler != NULL) { + if (_input_handler != nullptr) { _input_handler->update_context(_context, pl, pb); } else { _context->Update(); @@ -130,7 +130,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, CullTraverser *trav = get_cull_traverser(); trav->set_cull_handler(cull_handler); trav->set_scene(scene_setup, gsg, get_incomplete_render()); - trav->set_view_frustum(NULL); + trav->set_view_frustum(nullptr); _interface.render(_context, trav); diff --git a/panda/src/rocket/rocketRegion_ext.cxx b/panda/src/rocket/rocketRegion_ext.cxx index cb79f467a1..84acb44aa0 100644 --- a/panda/src/rocket/rocketRegion_ext.cxx +++ b/panda/src/rocket/rocketRegion_ext.cxx @@ -44,7 +44,7 @@ get_context() const { (void)e; // Return NULL, which will trigger the exception in Python } - return NULL; + return nullptr; } #endif diff --git a/panda/src/rocket/rocketRenderInterface.cxx b/panda/src/rocket/rocketRenderInterface.cxx index 76e69c6e27..c5ec2eb9a7 100644 --- a/panda/src/rocket/rocketRenderInterface.cxx +++ b/panda/src/rocket/rocketRenderInterface.cxx @@ -35,7 +35,7 @@ */ void RocketRenderInterface:: render(Rocket::Core::Context* context, CullTraverser *trav) { - nassertv(context != NULL); + nassertv(context != nullptr); MutexHolder holder(_lock); _trav = trav; @@ -54,9 +54,9 @@ render(Rocket::Core::Context* context, CullTraverser *trav) { context->Render(); - _trav = NULL; - _net_transform = NULL; - _net_state = NULL; + _trav = nullptr; + _net_transform = nullptr; + _net_state = nullptr; } /** @@ -145,7 +145,7 @@ RenderGeometry(Rocket::Core::Vertex* vertices, Texture *texture = (Texture *)thandle; LVecBase2 tex_scale(1, 1); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { tex_scale = texture->get_tex_scale(); } @@ -153,7 +153,7 @@ RenderGeometry(Rocket::Core::Vertex* vertices, GeomEnums::UH_stream, tex_scale); CPT(RenderState) state; - if (texture != (Texture *)NULL) { + if (texture != nullptr) { state = RenderState::make(TextureAttrib::make(texture)); } else { state = RenderState::make_empty(); @@ -176,7 +176,7 @@ CompileGeometry(Rocket::Core::Vertex* vertices, CompiledGeometry *c = new CompiledGeometry; LVecBase2 tex_scale(1, 1); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { rocket_cat.debug() << "Compiling geom " << c->_geom << " with texture '" << texture->get_name() << "'\n"; @@ -240,7 +240,7 @@ LoadTexture(Rocket::Core::TextureHandle& texture_handle, Filename fn = Filename::from_os_specific(source.CString()); PT(Texture) tex = TexturePool::load_texture(fn, 0, false, options); - if (tex == NULL) { + if (tex == nullptr) { texture_handle = 0; texture_dimensions.x = 0; texture_dimensions.y = 0; @@ -322,7 +322,7 @@ GenerateTexture(Rocket::Core::TextureHandle& texture_handle, void RocketRenderInterface:: ReleaseTexture(Rocket::Core::TextureHandle texture_handle) { Texture *tex = (Texture *)texture_handle; - if (tex != (Texture *)NULL) { + if (tex != nullptr) { unref_delete(tex); } } diff --git a/panda/src/speedtree/config_speedtree.cxx b/panda/src/speedtree/config_speedtree.cxx index b386bcb59a..f820239665 100644 --- a/panda/src/speedtree/config_speedtree.cxx +++ b/panda/src/speedtree/config_speedtree.cxx @@ -300,7 +300,7 @@ public: } void Free(void *block) { - if (block != NULL) { + if (block != nullptr) { PANDA_FREE_ARRAY(block); } } diff --git a/panda/src/speedtree/loaderFileTypeSrt.cxx b/panda/src/speedtree/loaderFileTypeSrt.cxx index 6589e28c10..0f67d2fb96 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.cxx +++ b/panda/src/speedtree/loaderFileTypeSrt.cxx @@ -57,12 +57,12 @@ load_file(const Filename &path, const LoaderOptions &, BamCacheRecord *record) const { if (!path.is_regular_file()) { // Quietly fail if the file doesn't exist. The Loader expects this. - return NULL; + return nullptr; } PT(STTree) tree = new STTree(path); if (!tree->is_valid()) { - return NULL; + return nullptr; } PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); diff --git a/panda/src/speedtree/loaderFileTypeStf.cxx b/panda/src/speedtree/loaderFileTypeStf.cxx index 8e1e15a2e8..2f568fae3c 100644 --- a/panda/src/speedtree/loaderFileTypeStf.cxx +++ b/panda/src/speedtree/loaderFileTypeStf.cxx @@ -56,7 +56,7 @@ load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { if (!path.is_regular_file()) { // Quietly fail if the file doesn't exist. The Loader expects this. - return NULL; + return nullptr; } PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); diff --git a/panda/src/speedtree/speedTreeNode.I b/panda/src/speedtree/speedTreeNode.I index 400a26e12b..0b1b0cd23d 100644 --- a/panda/src/speedtree/speedTreeNode.I +++ b/panda/src/speedtree/speedTreeNode.I @@ -36,7 +36,7 @@ get_num_trees() const { */ INLINE const STTree *SpeedTreeNode:: get_tree(int n) const { - nassertr(n >= 0 && n < (int)_trees.size(), NULL); + nassertr(n >= 0 && n < (int)_trees.size(), nullptr); InstanceList *instance_list = _trees[n]; return instance_list->get_tree(); } @@ -47,7 +47,9 @@ get_tree(int n) const { */ INLINE const SpeedTreeNode::InstanceList &SpeedTreeNode:: get_instance_list(int n) const { - nassertr(n >= 0 && n < (int)_trees.size(), *(InstanceList *)NULL); + // TODO: This should be nassertr instead of assert, but there's nothing we + // can really return when the assert fails. + assert(n >= 0 && n < (int)_trees.size()); InstanceList *instance_list = _trees[n]; return *instance_list; } @@ -57,7 +59,7 @@ get_instance_list(int n) const { */ INLINE STTree *SpeedTreeNode:: modify_tree(int n) { - nassertr(n >= 0 && n < (int)_trees.size(), NULL); + nassertr(n >= 0 && n < (int)_trees.size(), nullptr); InstanceList *instance_list = _trees[n]; _needs_repopulate = true; return (STTree *)instance_list->get_tree(); @@ -68,7 +70,7 @@ modify_tree(int n) { */ INLINE void SpeedTreeNode:: clear_terrain() { - set_terrain(NULL); + set_terrain(nullptr); } /** @@ -77,7 +79,7 @@ clear_terrain() { */ INLINE bool SpeedTreeNode:: has_terrain() const { - return _terrain != (STTerrain *)NULL; + return _terrain != nullptr; } /** diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index c455e848f5..da8c036d8e 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -145,8 +145,10 @@ count_total_instances() const { */ SpeedTreeNode::InstanceList &SpeedTreeNode:: add_tree(const STTree *tree) { - nassertr(is_valid(), *(InstanceList *)NULL); - nassertr(tree->is_valid(), *(InstanceList *)NULL); + // TODO: These should be nassertr instead of assert, but there's nothing we + // can really return when the assert fails. + assert(is_valid()); + assert(tree->is_valid()); InstanceList ilist(tree); Trees::iterator ti = _trees.find(&ilist); @@ -245,7 +247,7 @@ get_instance_list(const STTree *tree) const { Trees::const_iterator ti = _trees.find(&ilist); if (ti == _trees.end()) { // The tree was not already present. - static InstanceList empty_list((STTree *)NULL); + static InstanceList empty_list(nullptr); return empty_list; } @@ -406,7 +408,7 @@ add_from_stf(const Filename &stf_filename, const LoaderOptions &options) { } PT(VirtualFile) file = vfs->get_file(fullpath); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. speedtree_cat.error() << "Could not find " << stf_filename << "\n"; @@ -439,7 +441,7 @@ add_from_stf(const Filename &stf_filename, const LoaderOptions &options) { bool SpeedTreeNode:: add_from_stf(istream &in, const Filename &pathname, const LoaderOptions &options, Loader *loader) { - if (loader == NULL) { + if (loader == nullptr) { loader = Loader::get_global_ptr(); } string os_filename; @@ -468,7 +470,7 @@ add_from_stf(istream &in, const Filename &pathname, // search the model-path if necessary). PT(PandaNode) srt_root = loader->load_sync(srt_filename); - if (srt_root != NULL) { + if (srt_root != nullptr) { NodePath srt(srt_root); NodePath srt_np = srt.find("**/+SpeedTreeNode"); if (!srt_np.is_empty()) { @@ -497,7 +499,7 @@ add_from_stf(istream &in, const Filename &pathname, in >> height_min >> height_max >> slope_min >> slope_max; } - if (tree != NULL) { + if (tree != nullptr) { add_instance(tree, STTransform(pos, rad_2_deg(rotate), scale)); } } @@ -505,7 +507,7 @@ add_from_stf(istream &in, const Filename &pathname, } // Consume any whitespace at the end of the file. - in >> ws; + in >> std::ws; if (!in.eof()) { // If we didn't read all the way to end-of-file, there was an error. @@ -550,10 +552,10 @@ setup_terrain(const Filename &terrain_file) { */ void SpeedTreeNode:: set_terrain(STTerrain *terrain) { - _terrain = NULL; + _terrain = nullptr; _needs_repopulate = true; - if (terrain == (STTerrain *)NULL) { + if (terrain == nullptr) { return; } @@ -606,7 +608,7 @@ snap_to_terrain() { InstanceList *instance_list = (*ti); int num_instances = instance_list->get_num_instances(); - if (_terrain != (STTerrain *)NULL) { + if (_terrain != nullptr) { for (int i = 0; i < num_instances; ++i) { STTransform trans = instance_list->get_instance(i); LPoint3 pos = trans.get_pos(); @@ -815,7 +817,7 @@ combine_with(PandaNode *other) { // But, not if they both have a terrain set. if (has_terrain() && gother->has_terrain()) { - return NULL; + return nullptr; } else if (gother->has_terrain()) { set_terrain(gother->get_terrain()); @@ -882,7 +884,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { PStatTimer timer(_cull_speedtree_pcollector); GraphicsStateGuardian *gsg = DCAST(GraphicsStateGuardian, trav->get_gsg()); - nassertr(gsg != (GraphicsStateGuardian *)NULL, true); + nassertr(gsg != nullptr, true); if (!validate_api(gsg)) { return false; } @@ -916,7 +918,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // to disable textures. bool show_textures = true; const TextureAttrib *ta = DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_slot())); - if (ta != (TextureAttrib *)NULL) { + if (ta != nullptr) { show_textures = !ta->has_all_off(); } _forest_render.EnableTexturing(show_textures); @@ -927,19 +929,19 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // direction and color to SpeedTree. We also accumulate the ambient light // colors. LColor ambient_color(0.0f, 0.0f, 0.0f, 0.0f); - DirectionalLight *dlight = NULL; + DirectionalLight *dlight = nullptr; NodePath dlight_np; LColor diffuse_color; int diffuse_priority = 0; const LightAttrib *la = DCAST(LightAttrib, state->get_attrib(LightAttrib::get_class_slot())); - if (la != (LightAttrib *)NULL) { + if (la != nullptr) { for (int i = 0; i < la->get_num_on_lights(); ++i) { NodePath light = la->get_on_light(i); if (!light.is_empty() && light.node()->is_of_type(DirectionalLight::get_class_type())) { // A directional light. DirectionalLight *light_obj = DCAST(DirectionalLight, light.node()); - if (dlight == NULL || light_obj->get_priority() > dlight->get_priority()) { + if (dlight == nullptr || light_obj->get_priority() > dlight->get_priority()) { // Here's the most important directional light. dlight = light_obj; dlight_np = light; @@ -952,7 +954,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { } } - if (dlight != (DirectionalLight *)NULL) { + if (dlight != nullptr) { CPT(TransformState) transform = dlight_np.get_transform(trav->get_scene()->get_scene_root().get_parent()); LVector3 dir = dlight->get_direction() * transform->get_mat(); dir.normalize(); @@ -1019,7 +1021,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // node, so that we can make the appropriate calls into SpeedTree to // render the forest during the actual draw. CullableObject *object = - new CullableObject(NULL, data._state, + new CullableObject(nullptr, data._state, TransformState::make_identity()); object->set_draw_callback(new DrawCallback(this)); trav->get_cull_handler()->record_object(object, trav); @@ -1117,7 +1119,7 @@ write(ostream &out, int indent_level) const { void SpeedTreeNode:: write_error(ostream &out) { const char *error = SpeedTree::CCore::GetError(); - if (error != (const char *)NULL) { + if (error != nullptr) { out << error; } out << "\n"; @@ -1279,7 +1281,7 @@ update_terrain_cells() { int num_cells = (int)cells.size(); for (int ci = 0; ci < num_cells; ++ci) { SpeedTree::CTerrainCell *cell = cells[ci]; - nassertv(cell != NULL && cell->GetVbo() != NULL); + nassertv(cell != nullptr && cell->GetVbo() != nullptr); int cell_yi = cell->Row(); int cell_xi = cell->Col(); // cerr << "populating cell " << cell_xi << " " << cell_yi << "\n"; @@ -1306,7 +1308,7 @@ update_terrain_cells() { bool SpeedTreeNode:: validate_api(GraphicsStateGuardian *gsg) { GraphicsPipe *pipe = gsg->get_pipe(); - nassertr(pipe != (GraphicsPipe *)NULL, true); + nassertr(pipe != nullptr, true); #if defined(SPEEDTREE_OPENGL) static const string compiled_api = "OpenGL"; @@ -1385,7 +1387,7 @@ draw_callback(CallbackData *data) { write_error(speedtree_cat.warning()); // Clear the terrain so we don't keep spamming error messages. - _terrain = NULL; + _terrain = nullptr; } } @@ -1718,9 +1720,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { int num_trees = scan.get_uint32(); _trees.reserve(num_trees); for (int i = 0; i < num_trees; i++) { - InstanceList *instance_list = new InstanceList(NULL); + InstanceList *instance_list = new InstanceList(nullptr); instance_list->fillin(scan, manager); - if (instance_list->get_tree() == (STTree *)NULL) { + if (instance_list->get_tree() == nullptr) { // The tree wasn't successfully loaded. Don't keep it. delete instance_list; } else { @@ -1797,7 +1799,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { Loader *loader = Loader::get_global_ptr(); PT(PandaNode) srt_root = loader->load_sync(srt_filename); - if (srt_root != NULL) { + if (srt_root != nullptr) { NodePath srt(srt_root); NodePath srt_np = srt.find("**/+SpeedTreeNode"); if (!srt_np.is_empty()) { diff --git a/panda/src/speedtree/speedTreeNode.h b/panda/src/speedtree/speedTreeNode.h index 567cb00af9..fb153d2542 100644 --- a/panda/src/speedtree/speedTreeNode.h +++ b/panda/src/speedtree/speedTreeNode.h @@ -123,7 +123,7 @@ PUBLISHED: const LoaderOptions &options = LoaderOptions()); bool add_from_stf(istream &in, const Filename &pathname, const LoaderOptions &options = LoaderOptions(), - Loader *loader = NULL); + Loader *loader = nullptr); bool setup_terrain(const Filename &terrain_file); void set_terrain(STTerrain *terrain); diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index 5ee746dcbf..2a6dba22f4 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -113,7 +113,7 @@ setup_terrain(const Filename &terrain_filename) { } istream *in = vfs->open_read_file(fullpath, true); - if (in == NULL) { + if (in == nullptr) { speedtree_cat.warning() << "Couldn't open " << terrain_filename << "\n"; return false; @@ -191,7 +191,7 @@ setup_terrain(istream &in, const Filename &pathname) { } // Consume any whitespace at the end of the file. - in >> ws; + in >> std::ws; if (!in.eof()) { // If we didn't read all the way to end-of-file, there was an error. diff --git a/panda/src/speedtree/stTerrain.cxx b/panda/src/speedtree/stTerrain.cxx index 2f5f226856..fef97b9d0d 100644 --- a/panda/src/speedtree/stTerrain.cxx +++ b/panda/src/speedtree/stTerrain.cxx @@ -62,7 +62,7 @@ clear() { _splat_map = ""; _splat_layers.clear(); - set_vertex_format(NULL); + set_vertex_format(nullptr); } /** @@ -169,7 +169,7 @@ write(ostream &out, int indent_level) const { const SpeedTree::SVertexAttribDesc *STTerrain:: get_st_vertex_format() const { // return SpeedTree::std_vertex_format; - nassertr(!_st_vertex_attribs.empty(), NULL); + nassertr(!_st_vertex_attribs.empty(), nullptr); return &_st_vertex_attribs[0]; } @@ -181,8 +181,8 @@ get_st_vertex_format() const { */ bool STTerrain:: set_vertex_format(const GeomVertexFormat *format) { - if (format == NULL) { - _vertex_format = NULL; + if (format == nullptr) { + _vertex_format = nullptr; _st_vertex_attribs.clear(); _is_valid = false; return true; diff --git a/panda/src/testbed/pgrid.cxx b/panda/src/testbed/pgrid.cxx index e028e6c03c..d93cf64382 100644 --- a/panda/src/testbed/pgrid.cxx +++ b/panda/src/testbed/pgrid.cxx @@ -177,7 +177,7 @@ void get_command_line_filenames(int argc, char *argv[], pvector &static_filenames, GriddedFilenames &gridded_filenames) { - for (int i = 1; i < argc && argv[i] != (char *)NULL; i++) { + for (int i = 1; i < argc && argv[i] != nullptr; i++) { const string &arg = argv[i]; size_t comma = arg.find(','); if (comma == string::npos) { @@ -226,7 +226,7 @@ load_gridded_models(WindowFramework *window, for (fi = filenames.begin(); fi != filenames.end(); ++fi) { GriddedFilename &gf = (*fi); PT(PandaNode) node = loader.load_sync(gf._filename, options); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { gf._model = NodePath(node); grid_count += gf._count; } @@ -252,7 +252,7 @@ load_gridded_models(WindowFramework *window, PN_stdfloat xpos = grid_pos_offset; PN_stdfloat ypos = grid_pos_offset; - srand( (unsigned)time( NULL ) ); + srand( (unsigned)time( nullptr ) ); double now = ClockObject::get_global_clock()->get_frame_time(); int model_count = 0; @@ -273,7 +273,7 @@ load_gridded_models(WindowFramework *window, ++model_count; PT(PandaNode) node = loader.load_sync(gf._filename, options); NodePath model; - if (node == (PandaNode *)NULL) { + if (node == nullptr) { model = gf._model.copy_to(NodePath()); } else { model = NodePath(node); @@ -400,7 +400,7 @@ main(int argc, char **argv) { get_command_line_filenames(argc, argv, static_filenames, gridded_filenames); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. window->enable_keyboard(); diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index b5bb629b0c..8d39104d64 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -58,8 +58,8 @@ event_W(const Event *, void *) { // shift-W: open a new window on the same scene. // If we already have a window, use the same GSG. - GraphicsPipe *pipe = (GraphicsPipe *)NULL; - GraphicsStateGuardian *gsg = (GraphicsStateGuardian *)NULL; + GraphicsPipe *pipe = nullptr; + GraphicsStateGuardian *gsg = nullptr; if (framework.get_num_windows() > 0) { WindowFramework *old_window = framework.get_window(0); @@ -69,7 +69,7 @@ event_W(const Event *, void *) { } WindowFramework *window = framework.open_window(pipe, gsg); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { window->enable_keyboard(); window->setup_trackball(); framework.get_models().instance_to(window->get_render()); @@ -87,15 +87,15 @@ event_Enter(const Event *, void *) { // alt-enter: toggle between windowfullscreen in the same scene. // If we already have a window, use the same GSG. - GraphicsPipe *pipe = (GraphicsPipe *)NULL; - GraphicsStateGuardian *gsg = (GraphicsStateGuardian *)NULL; + GraphicsPipe *pipe = nullptr; + GraphicsStateGuardian *gsg = nullptr; WindowProperties props; for (int i = 0; i < framework.get_num_windows(); ++i) { WindowFramework *old_window = framework.get_window(i); GraphicsWindow *win = old_window->get_graphics_window(); - if (win != (GraphicsWindow *)NULL) { + if (win != nullptr) { pipe = win->get_pipe(); gsg = win->get_gsg(); props = win->get_properties(); @@ -109,7 +109,7 @@ event_Enter(const Event *, void *) { int flags = GraphicsPipe::BF_require_window; WindowFramework *window = framework.open_window(props, flags, pipe, gsg); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { window->enable_keyboard(); window->setup_trackball(); framework.get_models().instance_to(window->get_render()); @@ -125,7 +125,7 @@ event_2(const Event *event, void *) { DCAST_INTO_V(wf, param.get_ptr()); WindowFramework *split = wf->split_window(); - if (split != (WindowFramework *)NULL) { + if (split != nullptr) { split->enable_keyboard(); split->setup_trackball(); framework.get_models().instance_to(split->get_render()); @@ -238,13 +238,13 @@ report_version() { class AdjustCameraClipPlanesTask : public AsyncTask { public: AdjustCameraClipPlanesTask(const string &name, Camera *camera) : - AsyncTask(name), _camera(camera), _lens(camera->get_lens(0)), _sphere(NULL) + AsyncTask(name), _camera(camera), _lens(camera->get_lens(0)), _sphere(nullptr) { NodePath np = framework.get_models(); PT(BoundingVolume) volume = np.get_bounds(); // We expect at least a geometric bounding volume around the world. - nassertv(volume != (BoundingVolume *)NULL); + nassertv(volume != nullptr); nassertv(volume->is_of_type(GeometricBoundingVolume::get_class_type())); CPT(GeometricBoundingVolume) gbv = DCAST(GeometricBoundingVolume, volume); @@ -348,7 +348,7 @@ main(int argc, char **argv) { Filename screenshotfn; bool delete_models = false; bool apply_lighting = false; - PointerTo pipe = NULL; + PointerTo pipe = nullptr; extern char *optarg; extern int optind; @@ -417,8 +417,8 @@ main(int argc, char **argv) { argc -= (optind - 1); argv += (optind - 1); - WindowFramework *window = framework.open_window(pipe, NULL); - if (window != (WindowFramework *)NULL) { + WindowFramework *window = framework.open_window(pipe, nullptr); + if (window != nullptr) { // We've successfully opened a window. NodePath loading_np; @@ -453,7 +453,7 @@ main(int argc, char **argv) { if (delete_models) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - for (int i = 1; i < argc && argv[i] != (char *)NULL; i++) { + for (int i = 1; i < argc && argv[i] != nullptr; i++) { Filename model = Filename::from_os_specific(argv[i]); if (vfs->exists(model)) { nout << "Deleting " << model << "\n"; @@ -489,12 +489,12 @@ main(int argc, char **argv) { framework.get_task_mgr().add(task); framework.enable_default_keys(); - framework.define_key("shift-w", "open a new window", event_W, NULL); - framework.define_key("shift-f", "flatten hierarchy", event_F, NULL); - framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, NULL); - framework.define_key("2", "split the window", event_2, NULL); + framework.define_key("shift-w", "open a new window", event_W, nullptr); + framework.define_key("shift-f", "flatten hierarchy", event_F, nullptr); + framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, nullptr); + framework.define_key("2", "split the window", event_2, nullptr); if (pview_test_hack) { - framework.define_key("0", "run quick hacky test", event_0, NULL); + framework.define_key("0", "run quick hacky test", event_0, nullptr); } framework.main_loop(); framework.report_frame_rate(nout); diff --git a/panda/src/testbed/test_lod.cxx b/panda/src/testbed/test_lod.cxx index fa62edd785..00e4916ffa 100644 --- a/panda/src/testbed/test_lod.cxx +++ b/panda/src/testbed/test_lod.cxx @@ -54,7 +54,7 @@ main(int argc, char *argv[]) { framework.set_window_title("LOD Test"); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. window->enable_keyboard(); @@ -69,7 +69,7 @@ main(int argc, char *argv[]) { // Open another window too. WindowFramework *window2 = framework.open_window(); - if (window2 != (WindowFramework *)NULL) { + if (window2 != nullptr) { window2->enable_keyboard(); window2->setup_trackball(); framework.get_models().instance_to(window2->get_render()); diff --git a/panda/src/testbed/test_texmem.cxx b/panda/src/testbed/test_texmem.cxx index 76f6adfc57..977c1b0209 100644 --- a/panda/src/testbed/test_texmem.cxx +++ b/panda/src/testbed/test_texmem.cxx @@ -102,7 +102,7 @@ main(int argc, char *argv[]) { framework.set_window_title("Panda Viewer"); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. window->enable_keyboard(); diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 2fff80cd0c..1bdcafcf09 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -146,14 +146,14 @@ ConfigVariableInt text_embed_graphic_key wstring get_text_soft_hyphen_output() { - static wstring *text_soft_hyphen_output = NULL; + static wstring *text_soft_hyphen_output = nullptr; static ConfigVariableString cv("text-soft-hyphen-output", "-", PRC_DESC("This is the string that is output, encoded in the default " "encoding, to represent the hyphen character that is " "introduced when the line is broken at a soft-hyphen key.")); - if (text_soft_hyphen_output == NULL) { + if (text_soft_hyphen_output == nullptr) { TextEncoder encoder; text_soft_hyphen_output = new wstring(encoder.decode_text(cv)); } @@ -169,7 +169,7 @@ ConfigVariableDouble text_hyphen_ratio wstring get_text_never_break_before() { - static wstring *text_never_break_before = NULL; + static wstring *text_never_break_before = nullptr; static ConfigVariableString cv("text-never-break-before", ",.-:?!;", PRC_DESC("This string represents a list of individual characters " @@ -177,7 +177,7 @@ get_text_never_break_before() { "following a forced break. Typically these will be " "punctuation characters.")); - if (text_never_break_before == NULL) { + if (text_never_break_before == nullptr) { TextEncoder encoder; text_never_break_before = new wstring(encoder.decode_text(cv)); } diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index f02328009e..42c040c6ed 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -162,7 +162,7 @@ get_num_pages() const { */ DynamicTextPage *DynamicTextFont:: get_page(int n) const { - nassertr(n >= 0 && n < (int)_pages.size(), (DynamicTextPage *)NULL); + nassertr(n >= 0 && n < (int)_pages.size(), nullptr); return _pages[n]; } @@ -179,7 +179,7 @@ garbage_collect() { Cache::iterator ci; for (ci = _cache.begin(); ci != _cache.end(); ++ci) { const TextGlyph *glyph = (*ci).second; - if (glyph == (TextGlyph *)NULL || glyph->get_ref_count() > 1) { + if (glyph == nullptr || glyph->get_ref_count() > 1) { // Keep this one. new_cache.insert(new_cache.end(), (*ci)); } else { @@ -267,7 +267,7 @@ write(ostream &out, int indent_level) const { bool DynamicTextFont:: get_glyph(int character, CPT(TextGlyph) &glyph) { if (!_is_valid) { - glyph = (TextGlyph *)NULL; + glyph = nullptr; return false; } @@ -487,7 +487,7 @@ determine_tex_format() { CPT(TextGlyph) DynamicTextFont:: make_glyph(int character, FT_Face face, int glyph_index) { if (!load_glyph(face, glyph_index, false)) { - return (TextGlyph *)NULL; + return nullptr; } FT_GlyphSlot slot = face->glyph; @@ -499,7 +499,7 @@ make_glyph(int character, FT_Face face, int glyph_index) { // is the empty bitmap, we return NULL, and use Panda's invalid glyph in // its place. We do this to guarantee that every invalid glyph is visible // as *something*. - return NULL; + return nullptr; } PN_stdfloat advance = slot->advance.x / 64.0; @@ -673,7 +673,7 @@ make_glyph(int character, FT_Face face, int glyph_index) { } DynamicTextPage *page = glyph->get_page(); - if (page != NULL) { + if (page != nullptr) { int bitmap_top = (int)floor(tex_y_orig + outline * _scale_factor + 0.5f); int bitmap_left = (int)floor(tex_x_orig - outline * _scale_factor + 0.5f); @@ -726,7 +726,7 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { for (int yi = 0; yi < (int)bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); memcpy(texture_row, buffer_row, bitmap.width); buffer_row += bitmap.pitch; } @@ -737,7 +737,7 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < (int)bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); int bit = 0x80; unsigned char *b = buffer_row; @@ -764,7 +764,7 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < (int)bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < (int)bitmap.width; xi++) { texture_row[xi] = (int)(buffer_row[xi] * 255) / (bitmap.num_grays - 1); } @@ -788,7 +788,7 @@ copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph) { nassertv(glyph->_page->get_num_components() == 1); for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { texture_row[xi] = image.get_gray_val(xi, yi); } @@ -853,7 +853,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -866,7 +866,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 2; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -880,7 +880,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 3; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -895,7 +895,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 4; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -931,7 +931,7 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { do { DynamicTextPage *page = _pages[pi]; DynamicTextGlyph *glyph = page->slot_glyph(character, x_size, y_size, _texture_margin, advance); - if (glyph != (DynamicTextGlyph *)NULL) { + if (glyph != nullptr) { // Once we found a page to hold the glyph, that becomes our new // preferred page. _preferred_page = pi; @@ -943,7 +943,7 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { text_cat.error() << "Glyph of size " << x_size << " by " << y_size << " pixels won't fit on an empty page.\n"; - return (DynamicTextGlyph *)NULL; + return nullptr; } pi = (pi + 1) % _pages.size(); diff --git a/panda/src/text/dynamicTextGlyph.I b/panda/src/text/dynamicTextGlyph.I index 23e44ee8ce..3f2ebebfe2 100644 --- a/panda/src/text/dynamicTextGlyph.I +++ b/panda/src/text/dynamicTextGlyph.I @@ -32,7 +32,7 @@ DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y, INLINE DynamicTextGlyph:: DynamicTextGlyph(int character, PN_stdfloat advance) : TextGlyph(character, advance), - _page((DynamicTextPage *)NULL), + _page(nullptr), _x(0), _y(0), _x_size(0), _y_size(0), _margin(0) diff --git a/panda/src/text/dynamicTextGlyph.cxx b/panda/src/text/dynamicTextGlyph.cxx index 9727b353f7..7fc2458965 100644 --- a/panda/src/text/dynamicTextGlyph.cxx +++ b/panda/src/text/dynamicTextGlyph.cxx @@ -44,8 +44,8 @@ DynamicTextGlyph:: */ unsigned char *DynamicTextGlyph:: get_row(int y) { - nassertr(y >= 0 && y < _y_size - _margin * 2, (unsigned char *)NULL); - nassertr(_page != (DynamicTextPage *)NULL, (unsigned char *)NULL); + nassertr(y >= 0 && y < _y_size - _margin * 2, nullptr); + nassertr(_page != nullptr, nullptr); // First, offset y by the glyph's start. y += _y + _margin; @@ -66,7 +66,7 @@ get_row(int y) { */ void DynamicTextGlyph:: erase(DynamicTextFont *font) { - nassertv(_page != (DynamicTextPage *)NULL); + nassertv(_page != nullptr); nassertv(_page->has_ram_image()); // The glyph covers the pixels from (_x, _y) over the rectangle (_x_size, @@ -84,7 +84,7 @@ erase(DynamicTextFont *font) { */ bool DynamicTextGlyph:: is_whitespace() const { - return (_page == (DynamicTextPage *)NULL); + return (_page == nullptr); } #endif // HAVE_FREETYPE diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index fbe1b93486..b48ba426db 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -72,7 +72,7 @@ slot_glyph(int character, int x_size, int y_size, int margin, int x, y; if (!find_hole(x, y, x_size, y_size)) { // No room for the glyph. - return (DynamicTextGlyph *)NULL; + return nullptr; } // The glyph can be fit at (x, y). Slot it. @@ -209,7 +209,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { // Consider the spot at x, y. DynamicTextGlyph *overlap = find_overlap(x, y, x_size, y_size); - if (overlap == (DynamicTextGlyph *)NULL) { + if (overlap == nullptr) { // Hooray! return true; } @@ -245,7 +245,7 @@ find_overlap(int x, int y, int x_size, int y_size) const { } } - return (DynamicTextGlyph *)NULL; + return nullptr; } diff --git a/panda/src/text/fontPool.I b/panda/src/text/fontPool.I index c24906bdcf..d0142579e1 100644 --- a/panda/src/text/fontPool.I +++ b/panda/src/text/fontPool.I @@ -27,7 +27,7 @@ has_font(const string &filename) { */ INLINE bool FontPool:: verify_font(const string &filename) { - return load_font(filename) != (TextFont *)NULL; + return load_font(filename) != nullptr; } /** diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index ac7d476c63..6217be1bae 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -21,7 +21,7 @@ #include "loader.h" #include "lightMutexHolder.h" -FontPool *FontPool::_global_ptr = (FontPool *)NULL; +FontPool *FontPool::_global_ptr = nullptr; /** * Lists the contents of the font pool to the indicated output stream. @@ -86,7 +86,7 @@ ns_load_font(const string &str) { if (extension.empty() || extension == "egg" || extension == "bam") { Loader *model_loader = Loader::get_global_ptr(); PT(PandaNode) node = model_loader->load_sync(filename); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { // It is a model. Elevate all the priorities by 1, and make a font out // of it. @@ -104,16 +104,16 @@ ns_load_font(const string &str) { } #ifdef HAVE_FREETYPE - if (font == (TextFont *)NULL || !font->is_valid()) { + if (font == nullptr || !font->is_valid()) { // If we couldn't load the font as a model, try using FreeType to load it // as a font file. font = new DynamicTextFont(filename, face_index); } #endif - if (font == (TextFont *)NULL || !font->is_valid()) { + if (font == nullptr || !font->is_valid()) { // This font was not found or could not be read. - return NULL; + return nullptr; } @@ -263,7 +263,7 @@ lookup_filename(const string &str, string &index_str, */ FontPool *FontPool:: get_ptr() { - if (_global_ptr == (FontPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new FontPool; } return _global_ptr; diff --git a/panda/src/text/geomTextGlyph.cxx b/panda/src/text/geomTextGlyph.cxx index 7af3d0d5e0..6a02f2af16 100644 --- a/panda/src/text/geomTextGlyph.cxx +++ b/panda/src/text/geomTextGlyph.cxx @@ -28,7 +28,7 @@ GeomTextGlyph(const TextGlyph *glyph, const GeomVertexData *data) : { // Initially, there is only one glyph in the Geom. There might be // additional Glyphs later when we flatten the graph and call Geom::unify(). - if (glyph != (const TextGlyph *)NULL) { + if (glyph != nullptr) { _glyphs.reserve(1); _glyphs.push_back(glyph); } @@ -61,7 +61,7 @@ GeomTextGlyph:: GeomTextGlyph(const Geom ©, const TextGlyph *glyph) : Geom(copy) { - if (glyph != (const TextGlyph *)NULL) { + if (glyph != nullptr) { _glyphs.reserve(1); _glyphs.push_back(glyph); } @@ -148,7 +148,7 @@ output(ostream &out) const { Glyphs::const_iterator gi; for (gi = _glyphs.begin(); gi != _glyphs.end(); ++gi) { const TextGlyph *glyph = (*gi); - nassertv(glyph != (const TextGlyph *)NULL); + nassertv(glyph != nullptr); out << " " << glyph->get_character(); } out << " ]"; @@ -165,7 +165,7 @@ write(ostream &out, int indent_level) const { Glyphs::const_iterator gi; for (gi = _glyphs.begin(); gi != _glyphs.end(); ++gi) { const TextGlyph *glyph = (*gi); - nassertv(glyph != (const TextGlyph *)NULL); + nassertv(glyph != nullptr); out << " " << glyph->get_character(); } out << " ]\n"; @@ -192,8 +192,8 @@ register_with_read_factory() { */ TypedWritable* GeomTextGlyph:: make_GeomTextGlyph(const FactoryParams ¶ms) { - GeomTextGlyph *me = new GeomTextGlyph((const TextGlyph *)NULL, - (GeomVertexData *)NULL); + GeomTextGlyph *me = new GeomTextGlyph(nullptr, + nullptr); DatagramIterator scan; BamReader *manager; diff --git a/panda/src/text/staticTextFont.cxx b/panda/src/text/staticTextFont.cxx index 88f4186ad7..2f68c2dba8 100644 --- a/panda/src/text/staticTextFont.cxx +++ b/panda/src/text/staticTextFont.cxx @@ -37,7 +37,7 @@ TypeHandle StaticTextFont::_type_handle; */ StaticTextFont:: StaticTextFont(PandaNode *font_def, CoordinateSystem cs) { - nassertv(font_def != (PandaNode *)NULL); + nassertv(font_def != nullptr); _font = font_def; _cs = cs; _glyphs.clear(); @@ -248,7 +248,7 @@ find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot, const Geom *geom = geode->get_geom(i); bool found_points = false; - for (int j = 0; j < geom->get_num_primitives() && !found_points; j++) { + for (size_t j = 0; j < geom->get_num_primitives() && !found_points; ++j) { const GeomPrimitive *primitive = geom->get_primitive(j); if (primitive->is_of_type(GeomPoints::get_class_type())) { dot = geom; @@ -295,10 +295,10 @@ find_characters(PandaNode *root, const RenderState *net_state) { int character = atoi(name.c_str()); CPT(Geom) ch; CPT(Geom) dot; - const RenderState *state = NULL; + const RenderState *state = nullptr; find_character_gsets(root, ch, dot, state, next_net_state); PN_stdfloat width = 0.0; - if (dot != (Geom *)NULL) { + if (dot != nullptr) { // Get the first vertex from the "dot" geoset. This will be the origin // of the next character. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); @@ -313,9 +313,9 @@ find_characters(PandaNode *root, const RenderState *net_state) { CPT(Geom) ch; CPT(Geom) dot; - const RenderState *state = NULL; + const RenderState *state = nullptr; find_character_gsets(root, ch, dot, state, next_net_state); - if (dot != (Geom *)NULL) { + if (dot != nullptr) { // Get the first vertex from the "dot" geoset. This will be the design // size indicator. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); diff --git a/panda/src/text/staticTextFont.h b/panda/src/text/staticTextFont.h index 95f8430975..99a3e2d309 100644 --- a/panda/src/text/staticTextFont.h +++ b/panda/src/text/staticTextFont.h @@ -55,7 +55,6 @@ private: typedef pmap Glyphs; Glyphs _glyphs; - PN_stdfloat _font_height; PT(PandaNode) _font; CoordinateSystem _cs; diff --git a/panda/src/text/textAssembler.I b/panda/src/text/textAssembler.I index 5132f78859..3cce3a4ad9 100644 --- a/panda/src/text/textAssembler.I +++ b/panda/src/text/textAssembler.I @@ -296,7 +296,7 @@ get_ypos(int r, int) const { */ INLINE PN_stdfloat TextAssembler:: calc_width(const TextCharacter &tch) { - if (tch._graphic != (TextGraphic *)NULL) { + if (tch._graphic != nullptr) { return calc_width(tch._graphic, tch._cprops->_properties); } else { return calc_width(tch._character, tch._cprops->_properties); @@ -310,7 +310,7 @@ INLINE TextAssembler::TextCharacter:: TextCharacter(wchar_t character, TextAssembler::ComputedProperties *cprops) : _character(character), - _graphic(NULL), + _graphic(nullptr), _cprops(cprops) { } @@ -395,7 +395,7 @@ operator = (const TextAssembler::TextRow ©) { */ INLINE TextAssembler::ComputedProperties:: ComputedProperties(const TextProperties &orig_properties) : - _based_on(NULL), + _based_on(nullptr), _depth(0), _properties(orig_properties) { @@ -420,7 +420,7 @@ ComputedProperties(ComputedProperties *based_on, const wstring &wname, string name = encoder->encode_wtext(wname); const TextProperties *named_props = manager->get_properties_ptr(name); - if (named_props != (TextProperties *)NULL) { + if (named_props != nullptr) { _properties.add_properties(*named_props); } else { text_cat.warning() diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 6abe29d7a0..c427be8c79 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -234,7 +234,7 @@ get_plain_wtext() const { TextString::const_iterator si; for (si = _text_string.begin(); si != _text_string.end(); ++si) { const TextCharacter &tch = (*si); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(0); @@ -268,7 +268,7 @@ get_wordwrapped_plain_wtext() const { TextString::const_iterator si; for (si = row._string.begin(); si != row._string.end(); ++si) { const TextCharacter &tch = (*si); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(0); @@ -295,7 +295,7 @@ get_wtext() const { for (si = _text_string.begin(); si != _text_string.end(); ++si) { const TextCharacter &tch = (*si); current_cprops->append_delta(wtext, tch._cprops); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(text_embed_graphic_key); @@ -341,7 +341,7 @@ get_wordwrapped_wtext() const { for (si = row._string.begin(); si != row._string.end(); ++si) { const TextCharacter &tch = (*si); current_cprops->append_delta(wtext, tch._cprops); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(text_embed_graphic_key); @@ -519,7 +519,7 @@ assemble_text() { PT(GeomNode) text_geom_node = new GeomNode("text_geom"); text_node->add_child(text_geom_node); - const TextProperties *properties = NULL; + const TextProperties *properties = nullptr; CPT(RenderState) text_state; CPT(RenderState) shadow_state; LVector2 shadow(0); @@ -622,7 +622,7 @@ calc_width(wchar_t character, const TextProperties &properties) { if (character == ' ') { // A space is a special case. TextFont *font = properties.get_font(); - nassertr(font != (TextFont *)NULL, 0.0f); + nassertr(font != nullptr, 0.0f); return font->get_space_advance() * properties.get_glyph_scale() * properties.get_text_scale(); } @@ -639,10 +639,10 @@ calc_width(wchar_t character, const TextProperties &properties) { PN_stdfloat advance = 0.0f; - if (first_glyph != (TextGlyph *)NULL) { + if (first_glyph != nullptr) { advance = first_glyph->get_advance() * advance_scale; } - if (second_glyph != (TextGlyph *)NULL) { + if (second_glyph != nullptr) { advance += second_glyph->get_advance(); } @@ -681,7 +681,7 @@ has_exact_character(wchar_t character, const TextProperties &properties) { } TextFont *font = properties.get_font(); - nassertr(font != (TextFont *)NULL, false); + nassertr(font != nullptr, false); CPT(TextGlyph) glyph; return font->get_glyph(character, glyph); @@ -740,7 +740,7 @@ is_whitespace(wchar_t character, const TextProperties &properties) { TextFont *font = properties.get_font(); - nassertr(font != (TextFont *)NULL, false); + nassertr(font != nullptr, false); CPT(TextGlyph) glyph; if (!font->get_glyph(character, glyph)) { @@ -834,7 +834,7 @@ scan_wtext(TextAssembler::TextString &output_string, // Get the graphic image. const TextGraphic *named_graphic = manager->get_graphic_ptr(graphic_name); - if (named_graphic != (TextGraphic *)NULL) { + if (named_graphic != nullptr) { output_string.push_back(TextCharacter(named_graphic, graphic_wname, current_cprops)); } else { @@ -1107,7 +1107,7 @@ wordwrap_text() { PN_stdfloat TextAssembler:: calc_hyphen_width(const TextCharacter &tch) { TextFont *font = tch._cprops->_properties.get_font(); - nassertr(font != (TextFont *)NULL, 0.0f); + nassertr(font != nullptr, 0.0f); PN_stdfloat hyphen_width = 0.0f; wstring text_soft_hyphen_output = get_text_soft_hyphen_output(); @@ -1284,7 +1284,7 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { } // We can compute this value much faster than GeomPrimitive can. - tris->set_minmax(0, i - 1, NULL, NULL); + tris->set_minmax(0, i - 1, nullptr, nullptr); PT(GeomTextGlyph) geom = new GeomTextGlyph(vdata); geom->_glyphs.swap(glyphs); @@ -1412,9 +1412,9 @@ assemble_row(TextAssembler::TextRow &row, bool underscore = false; PN_stdfloat underscore_start = 0.0f; const TextProperties *underscore_properties = nullptr; - const ComputedProperties *prev_cprops = nullptr; #ifdef HAVE_HARFBUZZ + const ComputedProperties *prev_cprops = nullptr; hb_buffer_t *harfbuff = nullptr; #endif @@ -1439,7 +1439,7 @@ assemble_row(TextAssembler::TextRow &row, } TextFont *font = properties->get_font(); - nassertv(font != (TextFont *)NULL); + nassertv(font != nullptr); // We get the row's alignment property from the first character of the row if ((align == TextProperties::A_left) && @@ -1454,7 +1454,7 @@ assemble_row(TextAssembler::TextRow &row, // And the height of the row is the maximum of all the fonts used within // the row. - if (graphic != (TextGraphic *)NULL) { + if (graphic != nullptr) { LVecBase4 frame = graphic->get_frame(); line_height = max(line_height, frame[3] - frame[2]); } else { @@ -1495,7 +1495,7 @@ assemble_row(TextAssembler::TextRow &row, } else if (character == text_soft_hyphen_key) { // And so is the 'soft-hyphen' key character. - } else if (graphic != (TextGraphic *)NULL) { + } else if (graphic != nullptr) { // A special embedded graphic. GlyphPlacement placement; @@ -1574,7 +1574,7 @@ assemble_row(TextAssembler::TextRow &row, // ligatures. GlyphPlacement placement; - placement._glyph = NULL; + placement._glyph = nullptr; placement._scale = glyph_scale; placement._xpos = xpos; placement._ypos = properties->get_glyph_shift(); @@ -1588,11 +1588,11 @@ assemble_row(TextAssembler::TextRow &row, // probably require the bounding volume of the glyph, so go get that. LPoint3 min_vert, max_vert; bool found_any = false; - if (first_glyph != NULL) { + if (first_glyph != nullptr) { first_glyph->calc_tight_bounds(min_vert, max_vert, found_any, current_thread); } - if (second_glyph != NULL) { + if (second_glyph != nullptr) { second_glyph->calc_tight_bounds(min_vert, max_vert, found_any, current_thread); } @@ -1625,7 +1625,7 @@ assemble_row(TextAssembler::TextRow &row, } } - if (first_glyph != (TextGlyph *)NULL) { + if (first_glyph != nullptr) { advance = first_glyph->get_advance() * advance_scale; if (!first_glyph->is_whitespace()) { swap(placement._glyph, first_glyph); @@ -1635,7 +1635,7 @@ assemble_row(TextAssembler::TextRow &row, // Check if there is a second glyph to create a hacky ligature or some // such nonsense. - if (second_glyph != (TextGlyph *)NULL) { + if (second_glyph != nullptr) { placement._xpos += advance * glyph_scale; advance += second_glyph->get_advance(); swap(placement._glyph, second_glyph); @@ -1660,14 +1660,14 @@ assemble_row(TextAssembler::TextRow &row, row_width = xpos; - if (row._eol_cprops != (ComputedProperties *)NULL) { + if (row._eol_cprops != nullptr) { // If there's an _eol_cprops, it represents the cprops of the newline // character that ended the line, which should also contribute towards the // line_height. const TextProperties *properties = &(row._eol_cprops->_properties); TextFont *font = properties->get_font(); - nassertv(font != (TextFont *)NULL); + nassertv(font != nullptr); if (line_height == 0.0f) { PN_stdfloat glyph_scale = properties->get_glyph_scale() * properties->get_text_scale(); @@ -1703,7 +1703,7 @@ shape_buffer(hb_buffer_t *buf, PlacedGlyphs &placed_glyphs, PN_stdfloat &xpos, DynamicTextFont *font = DCAST(DynamicTextFont, properties.get_font()); hb_font_t *hb_font = font->get_hb_font(); - hb_shape(hb_font, buf, NULL, 0); + hb_shape(hb_font, buf, nullptr, 0); PN_stdfloat glyph_scale = properties.get_glyph_scale() * properties.get_text_scale(); PN_stdfloat scale = glyph_scale / (font->get_pixels_per_unit() * font->get_scale_factor() * 64.0); @@ -1825,11 +1825,11 @@ get_character_glyphs(int character, const TextProperties *properties, int &additional_flags, PN_stdfloat &glyph_scale, PN_stdfloat &advance_scale) { TextFont *font = properties->get_font(); - nassertv_always(font != (TextFont *)NULL); + nassertv_always(font != nullptr); got_glyph = false; - glyph = NULL; - second_glyph = NULL; + glyph = nullptr; + second_glyph = nullptr; accent_type = UnicodeLatinMap::AT_none; additional_flags = 0; glyph_scale = 1.0f; @@ -1839,7 +1839,7 @@ get_character_glyphs(int character, const TextProperties *properties, // capital. const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(character); - if (map_entry != NULL) { + if (map_entry != nullptr) { if (properties->get_small_caps() && map_entry->_toupper_character != character) { character = map_entry->_toupper_character; @@ -1849,7 +1849,7 @@ get_character_glyphs(int character, const TextProperties *properties, } got_glyph = font->get_glyph(character, glyph); - if (!got_glyph && map_entry != NULL && map_entry->_ascii_equiv != 0) { + if (!got_glyph && map_entry != nullptr && map_entry->_ascii_equiv != 0) { // If we couldn't find the Unicode glyph, try the ASCII equivalent // (without the accent marks). if (map_entry->_ascii_equiv == 'i') { @@ -1870,7 +1870,7 @@ get_character_glyphs(int character, const TextProperties *properties, // If we still couldn't find it, try the uppercase equivalent. character = map_entry->_toupper_character; map_entry = UnicodeLatinMap::look_up(character); - if (map_entry != NULL) { + if (map_entry != nullptr) { got_glyph = font->get_glyph(map_entry->_ascii_equiv, glyph); } } @@ -2067,7 +2067,7 @@ tack_on_accent(wchar_t accent_mark, TextAssembler::CheesyPosition position, const TextProperties *properties, TextAssembler::GlyphPlacement &placement) const { TextFont *font = properties->get_font(); - nassertr(font != (TextFont *)NULL, false); + nassertr(font != nullptr, false); Thread *current_thread = Thread::get_current_thread(); @@ -2319,14 +2319,14 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { if (this != other) { if (_depth > other->_depth) { // Back up a level from this properties. - nassertv(_based_on != NULL); + nassertv(_based_on != nullptr); wtext.push_back(text_pop_properties_key); _based_on->append_delta(wtext, other); } else if (other->_depth > _depth) { // Back up a level from the other properties. - nassertv(other->_based_on != NULL); + nassertv(other->_based_on != nullptr); append_delta(wtext, other->_based_on); wtext.push_back(text_push_properties_key); @@ -2335,7 +2335,7 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { } else if (_depth != 0) { // Back up a level from both properties. - nassertv(_based_on != NULL && other->_based_on != NULL); + nassertv(_based_on != nullptr && other->_based_on != nullptr); wtext.push_back(text_pop_properties_key); _based_on->append_delta(wtext, other->_based_on); @@ -2463,7 +2463,7 @@ assign_quad_to(QuadMap &quad_map, const RenderState *state, */ void TextAssembler::GlyphPlacement:: copy_graphic_to(PandaNode *node, const RenderState *state) const { - if (_graphic_model != (PandaNode *)NULL) { + if (_graphic_model != nullptr) { // We need an intermediate node to hold the transform and state. PT(PandaNode) intermediate_node = new PandaNode(""); node->add_child(intermediate_node); @@ -2510,29 +2510,29 @@ GeomCollector(const TextAssembler::GeomCollector ©) : GeomPrimitive *TextAssembler::GeomCollector:: get_primitive(TypeHandle prim_type) { if (prim_type == GeomTriangles::get_class_type()) { - if (_triangles == (GeomPrimitive *)NULL) { + if (_triangles == nullptr) { _triangles = new GeomTriangles(Geom::UH_static); _geom->add_primitive(_triangles); } return _triangles; } else if (prim_type == GeomLines::get_class_type()) { - if (_lines == (GeomPrimitive *)NULL) { + if (_lines == nullptr) { _lines = new GeomLines(Geom::UH_static); _geom->add_primitive(_lines); } return _lines; } else if (prim_type == GeomPoints::get_class_type()) { - if (_points == (GeomPrimitive *)NULL) { + if (_points == nullptr) { _points = new GeomPoints(Geom::UH_static); _geom->add_primitive(_points); } return _points; } - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** diff --git a/panda/src/text/textFont.cxx b/panda/src/text/textFont.cxx index add86483bd..866743a5e8 100644 --- a/panda/src/text/textFont.cxx +++ b/panda/src/text/textFont.cxx @@ -86,7 +86,7 @@ write(ostream &out, int indent_level) const { */ TextGlyph *TextFont:: get_invalid_glyph() { - if (_invalid_glyph == (TextGlyph *)NULL) { + if (_invalid_glyph == nullptr) { make_invalid_glyph(); } return _invalid_glyph; diff --git a/panda/src/text/textGlyph.I b/panda/src/text/textGlyph.I index 77b3b943b0..3b8b112f79 100644 --- a/panda/src/text/textGlyph.I +++ b/panda/src/text/textGlyph.I @@ -17,7 +17,7 @@ INLINE TextGlyph:: TextGlyph(int character, PN_stdfloat advance) : _character(character), - _geom((Geom *)NULL), + _geom(nullptr), _advance(advance), _has_quad(false) { @@ -35,10 +35,10 @@ TextGlyph(int character, const Geom *geom, _advance(advance), _has_quad(false) { - if (geom != NULL) { + if (geom != nullptr) { check_quad_geom(); } - if (_state == (RenderState *)NULL) { + if (_state == nullptr) { _state = RenderState::make_empty(); } } diff --git a/panda/src/text/textGlyph.cxx b/panda/src/text/textGlyph.cxx index 0d3de18db6..d68dce6371 100644 --- a/panda/src/text/textGlyph.cxx +++ b/panda/src/text/textGlyph.cxx @@ -51,11 +51,11 @@ get_geom(Geom::UsageHint usage_hint) const { if (_has_quad) { ((TextGlyph *)this)->make_quad_geom(); if (_geom.is_null()) { - return (Geom *)NULL; + return nullptr; } } else { // Nope. - return (Geom *)NULL; + return nullptr; } } @@ -67,7 +67,7 @@ get_geom(Geom::UsageHint usage_hint) const { PT(Geom) new_geom = new GeomTextGlyph(*_geom, this); new_geom->set_usage_hint(usage_hint); const GeomVertexData *vdata = new_geom->get_vertex_data(); - nassertr(vdata != NULL, new_geom); + nassertr(vdata != nullptr, new_geom); if (vdata->get_usage_hint() != usage_hint) { new_geom->modify_vertex_data()->set_usage_hint(usage_hint); } diff --git a/panda/src/text/textNode.I b/panda/src/text/textNode.I index 41758ba28a..dd10624d27 100644 --- a/panda/src/text/textNode.I +++ b/panda/src/text/textNode.I @@ -19,7 +19,7 @@ INLINE PN_stdfloat TextNode:: get_line_height() const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return 0.0f; } @@ -182,7 +182,7 @@ get_card_color() const { */ INLINE void TextNode:: set_card_texture(Texture *card_texture) { - if (card_texture == (Texture *)NULL) { + if (card_texture == nullptr) { clear_card_texture(); } else { if (!has_card_texture() || _card_texture != card_texture) { @@ -200,7 +200,7 @@ INLINE void TextNode:: clear_card_texture() { if (has_card_texture()) { _flags &= ~F_has_card_texture; - _card_texture = NULL; + _card_texture = nullptr; invalidate_no_measure(); } } diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 454c7dd7f3..7e0e687ada 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -174,7 +174,7 @@ TextNode:: PN_stdfloat TextNode:: calc_width(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return 0.0f; } @@ -196,7 +196,7 @@ calc_width(wchar_t character) const { bool TextNode:: has_exact_character(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return false; } @@ -215,7 +215,7 @@ has_exact_character(wchar_t character) const { bool TextNode:: has_character(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return false; } @@ -239,7 +239,7 @@ has_character(wchar_t character) const { bool TextNode:: is_whitespace(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return false; } @@ -272,7 +272,7 @@ output(ostream &out) const { check_rebuild(); int geom_count = 0; - if (_internal_geom != (PandaNode *)NULL) { + if (_internal_geom != nullptr) { geom_count = count_geoms(_internal_geom); } @@ -333,7 +333,7 @@ generate() { } TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return root; } @@ -514,7 +514,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } } if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - if (attribs._color != (const RenderAttrib *)NULL) { + if (attribs._color != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attribs._color); if (ca->get_color_type() == ColorAttrib::T_flat) { const LColor &c = ca->get_color(); @@ -526,7 +526,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (attribs._color_scale != (const RenderAttrib *)NULL) { + if (attribs._color_scale != nullptr) { const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attribs._color_scale); const LVecBase4 &s = csa->get_scale(); if (s != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { @@ -561,7 +561,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // Now propagate the attributes down to our already-generated geometry, if // we have any. if ((_flags & F_needs_rebuild) == 0 && - _internal_geom != (PandaNode *)NULL) { + _internal_geom != nullptr) { SceneGraphReducer gr; gr.apply_attribs(_internal_geom, attribs, attrib_types, transformer); } @@ -587,7 +587,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, check_rebuild(); - if (_internal_geom != (PandaNode *)NULL) { + if (_internal_geom != nullptr) { _internal_geom->calc_tight_bounds(min_point, max_point, found_any, next_transform, current_thread); } @@ -616,7 +616,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, bool TextNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { check_rebuild(); - if (_internal_geom != (PandaNode *)NULL) { + if (_internal_geom != nullptr) { // Render the text with this node. CullTraverserData next_data(data, _internal_geom); trav->traverse(next_data); @@ -682,7 +682,7 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, check_rebuild(); PandaNode *child = _internal_geom; - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CPT(RenderState) child_state = node_state->compose(child->get_state()); child->r_prepare_scene(gsg, child_state, transformer, current_thread); } diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index 50266cbfd7..4e24b110b9 100644 --- a/panda/src/text/textNode.h +++ b/panda/src/text/textNode.h @@ -343,7 +343,6 @@ private: int _max_rows; GeomEnums::UsageHint _usage_hint; int _flatten_flags; - bool _dynamic_merge; PN_stdfloat _frame_width; PN_stdfloat _card_border_size; PN_stdfloat _card_border_uv_portion; diff --git a/panda/src/text/textProperties.cxx b/panda/src/text/textProperties.cxx index 341f2385a3..dea089b612 100644 --- a/panda/src/text/textProperties.cxx +++ b/panda/src/text/textProperties.cxx @@ -259,7 +259,7 @@ write(ostream &out, int indent_level) const { << "default properties\n"; } if (has_font()) { - if (get_font() != (TextFont *)NULL) { + if (get_font() != nullptr) { indent(out, indent_level) << "with font " << _font->get_name() << "\n"; } else { @@ -450,7 +450,7 @@ load_default_font() { if (!text_default_font.empty()) { // First, attempt to load the user-specified filename. _default_font = FontPool::load_font(text_default_font.get_value()); - if (_default_font != (TextFont *)NULL && _default_font->is_valid()) { + if (_default_font != nullptr && _default_font->is_valid()) { return; } } @@ -481,7 +481,7 @@ load_default_font() { BamFile bam_file; if (bam_file.open_read(in, "default font stream")) { PT(PandaNode) node = bam_file.read_node(); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { _default_font = new StaticTextFont(node); } } diff --git a/panda/src/text/textPropertiesManager.cxx b/panda/src/text/textPropertiesManager.cxx index 2d8c93fd32..c057196e52 100644 --- a/panda/src/text/textPropertiesManager.cxx +++ b/panda/src/text/textPropertiesManager.cxx @@ -14,7 +14,7 @@ #include "textPropertiesManager.h" #include "indent.h" -TextPropertiesManager *TextPropertiesManager::_global_ptr = (TextPropertiesManager *)NULL; +TextPropertiesManager *TextPropertiesManager::_global_ptr = nullptr; /** * The constructor is not intended to be called directly; there is only one @@ -193,7 +193,7 @@ write(ostream &out, int indent_level) const { */ TextPropertiesManager *TextPropertiesManager:: get_global_ptr() { - if (_global_ptr == (TextPropertiesManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TextPropertiesManager; } return _global_ptr; @@ -210,7 +210,7 @@ get_properties_ptr(const string &name) { if (pi != _properties.end()) { return &(*pi).second; } - return NULL; + return nullptr; } /** @@ -224,5 +224,5 @@ get_graphic_ptr(const string &name) { if (pi != _graphics.end()) { return &(*pi).second; } - return NULL; + return nullptr; } diff --git a/panda/src/tform/driveInterface.cxx b/panda/src/tform/driveInterface.cxx index f9324ce110..e9adfd8829 100644 --- a/panda/src/tform/driveInterface.cxx +++ b/panda/src/tform/driveInterface.cxx @@ -383,7 +383,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, } // Look for keyboard events. - if (required_buttons_match && button_events != (const ButtonEventList *)NULL) { + if (required_buttons_match && button_events != nullptr) { int num_events = button_events->get_num_events(); for (int i = 0; i < num_events; i++) { diff --git a/panda/src/tform/mouseInterfaceNode.cxx b/panda/src/tform/mouseInterfaceNode.cxx index b69a17d06e..22031c4219 100644 --- a/panda/src/tform/mouseInterfaceNode.cxx +++ b/panda/src/tform/mouseInterfaceNode.cxx @@ -117,10 +117,10 @@ watch_button(const ButtonHandle &button) { const ButtonEventList *MouseInterfaceNode:: check_button_events(const DataNodeTransmit &input, bool &required_buttons_match) { - const ButtonEventList *button_events = NULL; + const ButtonEventList *button_events = nullptr; if (input.has_data(_button_events_input)) { - DCAST_INTO_R(button_events, input.get_data(_button_events_input).get_ptr(), NULL); + DCAST_INTO_R(button_events, input.get_data(_button_events_input).get_ptr(), nullptr); button_events->update_mods(_current_button_state); } diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 389861e8d9..7d709f252e 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -101,7 +101,7 @@ get_frame() const { */ INLINE bool MouseWatcher:: is_over_region() const { - return get_over_region() != (MouseWatcherRegion *)NULL; + return get_over_region() != nullptr; } /** @@ -109,7 +109,7 @@ is_over_region() const { */ INLINE bool MouseWatcher:: is_over_region(PN_stdfloat x, PN_stdfloat y) const { - return get_over_region(x, y) != (MouseWatcherRegion *)NULL; + return get_over_region(x, y) != nullptr; } /** @@ -117,7 +117,7 @@ is_over_region(PN_stdfloat x, PN_stdfloat y) const { */ INLINE bool MouseWatcher:: is_over_region(const LPoint2 &pos) const { - return get_over_region(pos) != (MouseWatcherRegion *)NULL; + return get_over_region(pos) != nullptr; } /** @@ -391,7 +391,7 @@ get_modifier_buttons() const { INLINE void MouseWatcher:: set_display_region(DisplayRegion *dr) { _display_region = dr; - _button_down_display_region = NULL; + _button_down_display_region = nullptr; } /** @@ -400,8 +400,8 @@ set_display_region(DisplayRegion *dr) { */ INLINE void MouseWatcher:: clear_display_region() { - _display_region = NULL; - _button_down_display_region = NULL; + _display_region = nullptr; + _button_down_display_region = nullptr; } /** @@ -421,7 +421,7 @@ get_display_region() const { */ INLINE bool MouseWatcher:: has_display_region() const { - return (_display_region != (DisplayRegion *)NULL); + return (_display_region != nullptr); } /** diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 30f2c4762e..eac710d414 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -62,12 +62,12 @@ MouseWatcher(const string &name) : _has_mouse = false; _internal_suppress = 0; - _preferred_region = (MouseWatcherRegion *)NULL; - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; + _preferred_button_down_region = nullptr; _button_down = false; - _eh = (EventHandler *)NULL; - _display_region = (DisplayRegion *)NULL; - _button_down_display_region = (DisplayRegion *)NULL; + _eh = nullptr; + _display_region = nullptr; + _button_down_display_region = nullptr; _frame.set(-1.0f, 1.0f, -1.0f, 1.0f); @@ -109,13 +109,13 @@ remove_region(MouseWatcherRegion *region) { remove_region_from(_current_regions, region); if (region == _preferred_region) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, MouseWatcherParameter()); } - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } if (region == _preferred_button_down_region) { - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } return MouseWatcherBase::do_remove_region(region); @@ -190,13 +190,13 @@ remove_group(MouseWatcherGroup *group) { set_current_regions(only_a); if (has_region_in(both, _preferred_region)) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, MouseWatcherParameter()); } - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } if (has_region_in(both, _preferred_button_down_region)) { - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } #ifndef NDEBUG @@ -268,13 +268,13 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) { any_new_current_regions = true; if (has_region_in(both, _preferred_region)) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, MouseWatcherParameter()); } - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } if (has_region_in(both, _preferred_button_down_region)) { - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } } @@ -343,7 +343,7 @@ get_num_groups() const { MouseWatcherGroup *MouseWatcher:: get_group(int n) const { LightMutexHolder holder(_lock); - nassertr(n >= 0 && n < (int)_groups.size(), NULL); + nassertr(n >= 0 && n < (int)_groups.size(), nullptr); return _groups[n]; } @@ -397,7 +397,7 @@ discard_excess_trail_log() { */ PT(GeomNode) MouseWatcher:: get_trail_node() { - if (_trail_node == 0) { + if (_trail_node == nullptr) { _trail_node = new GeomNode("Mouse Trail Node"); update_trail_node(); } @@ -412,7 +412,7 @@ get_trail_node() { */ void MouseWatcher:: clear_trail_node() { - _trail_node = 0; + _trail_node = nullptr; } /** @@ -420,7 +420,7 @@ clear_trail_node() { */ void MouseWatcher:: update_trail_node() { - if (_trail_node == 0) { + if (_trail_node == nullptr) { return; } _trail_node->remove_all_geoms(); @@ -584,7 +584,7 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { MouseWatcherRegion *MouseWatcher:: get_preferred_region(const MouseWatcher::Regions ®ions) { if (regions.empty()) { - return (MouseWatcherRegion *)NULL; + return nullptr; } Regions::const_iterator ri; @@ -689,15 +689,15 @@ set_current_regions(MouseWatcher::Regions ®ions) { if (_button_down && new_preferred_region != _preferred_button_down_region) { // If the button's being held down, we're only allowed to select the // preferred button down region. - new_preferred_region = (MouseWatcherRegion *)NULL; + new_preferred_region = nullptr; } if (new_preferred_region != _preferred_region) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, param); } _preferred_region = new_preferred_region; - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { enter_region(_preferred_region, param); } } @@ -729,10 +729,10 @@ clear_current_regions() { _current_regions.clear(); - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { _preferred_region->exit_region(param); throw_event_pattern(_leave_pattern, _preferred_region, ButtonHandle::none()); - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } } } @@ -859,7 +859,7 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, return; } #ifndef NDEBUG - if (region != (MouseWatcherRegion *)NULL) { + if (region != nullptr) { region->test_ref_count_integrity(); } #endif @@ -880,7 +880,7 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, string cmd = pattern.substr(p + 1, 1); p++; if (cmd == "r") { - if (region != (MouseWatcherRegion *)NULL) { + if (region != nullptr) { event += region->get_name(); } @@ -898,7 +898,7 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, if (!event.empty()) { throw_event(event, EventParameter(region), EventParameter(button_name)); - if (_eh != (EventHandler*)0L) + if (_eh != nullptr) throw_event_directly(*_eh, event, EventParameter(region), EventParameter(button_name)); } @@ -916,7 +916,7 @@ move() { param.set_modifier_buttons(_mods); param.set_mouse(_mouse); - if (_preferred_button_down_region != (MouseWatcherRegion *)NULL) { + if (_preferred_button_down_region != nullptr) { _preferred_button_down_region->move(param); } } @@ -942,7 +942,7 @@ press(ButtonHandle button, bool keyrepeat) { } _button_down = true; - if (_preferred_button_down_region != (MouseWatcherRegion *)NULL) { + if (_preferred_button_down_region != nullptr) { _preferred_button_down_region->press(param); if (keyrepeat) { throw_event_pattern(_button_repeat_pattern, @@ -956,7 +956,7 @@ press(ButtonHandle button, bool keyrepeat) { } else { // It's a keyboard button; therefore, send the event to every region that // wants keyboard buttons, regardless of the mouse position. - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { // Our current region, the one under the mouse, always get all the // keyboard events, even if it doesn't set its keyboard flag. _preferred_region->press(param); @@ -992,7 +992,7 @@ release(ButtonHandle button) { // There is some danger of losing button-up events here. If more than one // button goes down together, we won't detect both of the button-up events // properly. - if (_preferred_button_down_region != (MouseWatcherRegion *)NULL) { + if (_preferred_button_down_region != nullptr) { param.set_outside(_preferred_button_down_region != _preferred_region); _preferred_button_down_region->release(param); throw_event_pattern(_button_up_pattern, @@ -1000,12 +1000,12 @@ release(ButtonHandle button) { } _button_down = false; - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } else { // It's a keyboard button; therefore, send the event to every region that // wants keyboard buttons, regardless of the mouse position. - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { _preferred_region->release(param); } @@ -1302,7 +1302,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, move(); } - if (_display_region != (DisplayRegion *)NULL) { + if (_display_region != nullptr) { // If we've got a display region, constrain the mouse to it. if (constrain_display_region(_display_region, f, p, current_thread)) { set_mouse(f, p); @@ -1348,7 +1348,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, // If the mouse is over a particular region, or still considered owned by a // region because of a recent button-down event, that region determines // whether we suppress events below us. - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { _internal_suppress |= _preferred_region->get_suppress_flags(); } @@ -1547,9 +1547,9 @@ constrain_display_region(DisplayRegion *display_region, LVecBase2 &f, LVecBase2 &p, Thread *current_thread) { if (!_button_down) { - _button_down_display_region = NULL; + _button_down_display_region = nullptr; } - if (_button_down_display_region != NULL) { + if (_button_down_display_region != nullptr) { // If the button went down over this DisplayRegion, we consider the button // within the same DisplayRegion until it is released (even if it wanders // outside the borders). @@ -1574,7 +1574,7 @@ constrain_display_region(DisplayRegion *display_region, PN_stdfloat x = (f[0] + 1.0f) / 2.0f; PN_stdfloat y = (f[1] + 1.0f) / 2.0f; - if (_button_down_display_region == NULL && + if (_button_down_display_region == nullptr && (x < left || x >= right || y < bottom || y >= top)) { // The mouse is outside the display region. return false; diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 6d86c384f1..820fb81d90 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -119,7 +119,7 @@ find_region(const string &name) const { } } - return (MouseWatcherRegion *)NULL; + return nullptr; } /** @@ -180,7 +180,7 @@ get_region(int n) const { if (n >= 0 && n < (int)_regions.size()) { return _regions[n]; } - return NULL; + return nullptr; } /** @@ -366,7 +366,7 @@ do_update_regions() { */ PandaNode *MouseWatcherBase:: make_viz_region(MouseWatcherRegion *region) { - nassertr(_lock.debug_is_locked(), NULL); + nassertr(_lock.debug_is_locked(), nullptr); LineSegs ls("show_regions"); ls.set_color(_color); diff --git a/panda/src/tform/transform2sg.cxx b/panda/src/tform/transform2sg.cxx index 6adfb944c4..3f7137af56 100644 --- a/panda/src/tform/transform2sg.cxx +++ b/panda/src/tform/transform2sg.cxx @@ -28,7 +28,7 @@ Transform2SG(const string &name) : { _transform_input = define_input("transform", TransformState::get_class_type()); - _node = NULL; + _node = nullptr; } /** @@ -65,7 +65,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, if (input.has_data(_transform_input)) { const TransformState *transform; DCAST_INTO_V(transform, input.get_data(_transform_input).get_ptr()); - if (_node != (PandaNode *)NULL) { + if (_node != nullptr) { _node->set_transform(transform, current_thread); } } diff --git a/panda/src/tinydisplay/init.cxx b/panda/src/tinydisplay/init.cxx index 2e11dee3c2..40ca74c31c 100644 --- a/panda/src/tinydisplay/init.cxx +++ b/panda/src/tinydisplay/init.cxx @@ -18,7 +18,7 @@ void glInit(GLContext *c, ZBuffer *zbuffer) v->updated=1; /* lights */ - c->first_light=NULL; + c->first_light=nullptr; c->ambient_light_model=gl_V4_New(0.2, 0.2, 0.2, 1.0f); c->local_light_model=0; c->lighting_enabled=0; @@ -50,7 +50,7 @@ void glInit(GLContext *c, ZBuffer *zbuffer) c->cull_face_enabled=0; /* specular buffer */ - c->specbuf_first = NULL; + c->specbuf_first = nullptr; c->specbuf_used_counter = 0; c->specbuf_num_buffers = 0; diff --git a/panda/src/tinydisplay/specbuf.cxx b/panda/src/tinydisplay/specbuf.cxx index d0c153714e..d058459e80 100644 --- a/panda/src/tinydisplay/specbuf.cxx +++ b/panda/src/tinydisplay/specbuf.cxx @@ -30,7 +30,7 @@ specbuf_get_buffer(GLContext *c, const int shininess_i, found->last_used = c->specbuf_used_counter++; return found; } - if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { + if (oldest == nullptr || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { /* create new buffer */ GLSpecBuf *buf = (GLSpecBuf *)gl_malloc(sizeof(GLSpecBuf)); if (!buf) gl_fatal_error("could not allocate specular buffer"); diff --git a/panda/src/tinydisplay/store_pixel.h b/panda/src/tinydisplay/store_pixel.h index 8352e842a4..d6fb1540c6 100644 --- a/panda/src/tinydisplay/store_pixel.h +++ b/panda/src/tinydisplay/store_pixel.h @@ -26,8 +26,8 @@ FNAME(store_pixel) (ZBuffer *zb, PIXEL &result, int r, int g, int b, int a) { r = STORE_PIXEL_0(fr, ((unsigned int)r * OP_A(fr, r) >> 16) + ((unsigned int)fr * OP_B(fr, r) >> 16)); g = STORE_PIXEL_1(fg, ((unsigned int)g * OP_A(fg, g) >> 16) + ((unsigned int)fg * OP_B(fg, g) >> 16)); - b = STORE_PIXEL_2(fg, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); - a = STORE_PIXEL_3(fg, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); + b = STORE_PIXEL_2(fb, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); + a = STORE_PIXEL_3(fa, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); result = RGBA_TO_PIXEL(r, g, b, a); } @@ -43,8 +43,8 @@ FNAME_S(store_pixel) (ZBuffer *zb, PIXEL &result, int r, int g, int b, int a) { r = STORE_PIXEL_0(fr, ((unsigned int)r * OP_A(fr, r) >> 16) + ((unsigned int)fr * OP_B(fr, r) >> 16)); g = STORE_PIXEL_1(fg, ((unsigned int)g * OP_A(fg, g) >> 16) + ((unsigned int)fg * OP_B(fg, g) >> 16)); - b = STORE_PIXEL_2(fg, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); - a = STORE_PIXEL_3(fg, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); + b = STORE_PIXEL_2(fb, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); + a = STORE_PIXEL_3(fa, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); result = SRGBA_TO_PIXEL(r, g, b, a); } diff --git a/panda/src/tinydisplay/td_light.cxx b/panda/src/tinydisplay/td_light.cxx index c49b47e4b4..c570e5347c 100644 --- a/panda/src/tinydisplay/td_light.cxx +++ b/panda/src/tinydisplay/td_light.cxx @@ -29,7 +29,7 @@ void gl_shade_vertex(GLContext *c,GLVertex *v) B=m->emission.v[2]+m->ambient.v[2]*c->ambient_light_model.v[2]; A=clampf(m->diffuse.v[3],0,1); - for(l=c->first_light;l!=NULL;l=l->next) { + for(l=c->first_light;l!=nullptr;l=l->next) { PN_stdfloat lR,lB,lG; /* ambient */ diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx index adeceabd01..95599e9b22 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx @@ -33,7 +33,7 @@ TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _frame_buffer = NULL; + _frame_buffer = nullptr; } /** @@ -52,7 +52,7 @@ TinyGraphicsBuffer:: bool TinyGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -74,7 +74,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinyGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -94,10 +94,10 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void TinyGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_V(tinygsg, _gsg); - tinygsg->_current_frame_buffer = NULL; + tinygsg->_current_frame_buffer = nullptr; _gsg.clear(); } @@ -114,14 +114,14 @@ open_buffer() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { DCAST_INTO_R(tinygsg, _gsg, false); } create_frame_buffer(); - if (_frame_buffer == NULL) { + if (_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; @@ -144,9 +144,9 @@ open_buffer() { */ void TinyGraphicsBuffer:: create_frame_buffer() { - if (_frame_buffer != NULL) { + if (_frame_buffer != nullptr) { ZB_close(_frame_buffer); - _frame_buffer = NULL; + _frame_buffer = nullptr; } _frame_buffer = ZB_open(get_fb_x_size(), get_fb_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0); diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I index cac827cf09..efda44e790 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I @@ -19,11 +19,11 @@ clear_light_state() { _c->lighting_enabled = false; #ifndef NDEBUG GLLight *gl_light = _c->first_light; - while (gl_light != (GLLight *)NULL) { + while (gl_light != nullptr) { GLLight *next = gl_light->next; - gl_light->next = NULL; + gl_light->next = nullptr; gl_light = next; } #endif // NDEBUG - _c->first_light = NULL; + _c->first_light = nullptr; } diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index a9c6b113a2..782d461dc2 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -64,10 +64,10 @@ TinyGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, TinyGraphicsStateGuardian *share_with) : GraphicsStateGuardian(CS_yup_right, engine, pipe) { - _current_frame_buffer = NULL; - _aux_frame_buffer = NULL; - _c = NULL; - _vertices = NULL; + _current_frame_buffer = nullptr; + _aux_frame_buffer = nullptr; + _c = nullptr; + _vertices = nullptr; _vertices_size = 0; } @@ -99,9 +99,9 @@ reset() { _inv_state_mask.clear_bit(LightAttrib::get_class_slot()); _inv_state_mask.clear_bit(ScissorAttrib::get_class_slot()); - if (_c != (GLContext *)NULL) { + if (_c != nullptr) { glClose(_c); - _c = NULL; + _c = nullptr; } _c = (GLContext *)gl_zalloc(sizeof(GLContext)); @@ -142,14 +142,14 @@ reset() { */ void TinyGraphicsStateGuardian:: free_pointers() { - if (_aux_frame_buffer != (ZBuffer *)NULL) { + if (_aux_frame_buffer != nullptr) { ZB_close(_aux_frame_buffer); - _aux_frame_buffer = NULL; + _aux_frame_buffer = nullptr; } - if (_vertices != (GLVertex *)NULL) { + if (_vertices != nullptr) { PANDA_FREE_ARRAY(_vertices); - _vertices = NULL; + _vertices = nullptr; } _vertices_size = 0; } @@ -163,9 +163,9 @@ void TinyGraphicsStateGuardian:: close_gsg() { GraphicsStateGuardian::close_gsg(); - if (_c != (GLContext *)NULL) { + if (_c != nullptr) { glClose(_c); - _c = NULL; + _c = nullptr; } } @@ -245,7 +245,7 @@ clear(DrawableRegion *clearable) { */ void TinyGraphicsStateGuardian:: prepare_display_region(DisplayRegionPipelineReader *dr) { - nassertv(dr != (DisplayRegionPipelineReader *)NULL); + nassertv(dr != nullptr); GraphicsStateGuardian::prepare_display_region(dr); int xmin, ymin, xsize, ysize; @@ -259,10 +259,10 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { ymin = 0; xsize = int(xsize * pixel_factor); ysize = int(ysize * pixel_factor); - if (_aux_frame_buffer == (ZBuffer *)NULL) { + if (_aux_frame_buffer == nullptr) { _aux_frame_buffer = ZB_open(xsize, ysize, ZB_MODE_RGBA, 0, 0, 0, 0); } else if (_aux_frame_buffer->xsize < xsize || _aux_frame_buffer->ysize < ysize) { - ZB_resize(_aux_frame_buffer, NULL, + ZB_resize(_aux_frame_buffer, nullptr, max(_aux_frame_buffer->xsize, xsize), max(_aux_frame_buffer->ysize, ysize)); } @@ -295,12 +295,12 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { */ CPT(TransformState) TinyGraphicsStateGuardian:: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } // The projection matrix must always be right-handed Y-up, even if our @@ -481,7 +481,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, force)) { return false; } - nassertr(_data_reader != (GeomVertexDataPipelineReader *)NULL, false); + nassertr(_data_reader != nullptr, false); PStatTimer timer(_draw_transform_pcollector); @@ -557,7 +557,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, while (_vertices_size < num_used_vertices) { _vertices_size *= 2; } - if (_vertices != (GLVertex *)NULL) { + if (_vertices != nullptr) { PANDA_FREE_ARRAY(_vertices); } _vertices = (GLVertex *)PANDA_MALLOC_ARRAY(_vertices_size * sizeof(GLVertex)); @@ -697,7 +697,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Texture coordinates. for (int si = 0; si < max_stage_index; ++si) { - LTexCoord d; (*texgen_func[si])(v->tex_coord[si], tcdata[si]); } @@ -961,7 +960,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 3) { @@ -976,7 +975,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 3) { @@ -991,7 +990,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 3) { @@ -1052,7 +1051,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } GLVertex *v0 = &_vertices[index[start] - _min_vertex]; @@ -1077,7 +1076,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } GLVertex *v0 = &_vertices[index[start] - _min_vertex]; @@ -1102,7 +1101,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } GLVertex *v0 = &_vertices[index[start] - _min_vertex]; @@ -1183,7 +1182,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 2) { @@ -1197,7 +1196,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 2) { @@ -1211,7 +1210,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 2) { @@ -1260,7 +1259,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; ++i) { @@ -1273,7 +1272,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; ++i) { @@ -1286,7 +1285,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; ++i) { @@ -1347,7 +1346,7 @@ bool TinyGraphicsStateGuardian:: framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); int xo, yo, w, h; dr->get_region_pixels_i(xo, yo, w, h); @@ -1355,7 +1354,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, tex->setup_2d_texture(w, h, Texture::T_unsigned_byte, Texture::F_rgba); TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); TinyTextureContext *gtc = DCAST(TinyTextureContext, tc); GLTexture *gltex = >c->_gltex; @@ -1395,7 +1394,7 @@ bool TinyGraphicsStateGuardian:: framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); int xo, yo, w, h; dr->get_region_pixels_i(xo, yo, w, h); @@ -1611,7 +1610,7 @@ prepare_texture(Texture *tex, int view) { tinydisplay_cat.info() << "Not loading texture " << tex->get_name() << ": " << tex->get_texture_type() << "\n"; - return NULL; + return nullptr; } // Even though the texture might be compressed now, it might have an @@ -1764,7 +1763,7 @@ do_issue_light() { // Handle the diffuse color here, since all lights have this property. GLLight *gl_light = _c->first_light; - nassertv(gl_light != NULL); + nassertv(gl_light != nullptr); const LColor &diffuse = light_obj->get_color(); gl_light->diffuse.v[0] = diffuse[0]; gl_light->diffuse.v[1] = diffuse[1]; @@ -1829,7 +1828,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { gl_light->attenuation[2] = att[2]; } - nassertv(gl_light->next == NULL); + nassertv(gl_light->next == nullptr); // Add it to the linked list of active lights. gl_light->next = _c->first_light; @@ -1888,7 +1887,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { gl_light->attenuation[2] = 0.0f; } - nassertv(gl_light->next == NULL); + nassertv(gl_light->next == nullptr); // Add it to the linked list of active lights. gl_light->next = _c->first_light; @@ -1915,7 +1914,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { gl_light->specular.v[3] = specular[3]; Lens *lens = light_obj->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); // Position needs to specify x, y, z, and w w == 1 implies non-infinite // position @@ -1953,7 +1952,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { gl_light->attenuation[2] = att[2]; } - nassertv(gl_light->next == NULL); + nassertv(gl_light->next == nullptr); // Add it to the linked list of active lights. gl_light->next = _c->first_light; @@ -2105,7 +2104,7 @@ do_issue_material() { const MaterialAttrib *target_material = DCAST(MaterialAttrib, _target_rs->get_attrib_def(MaterialAttrib::get_class_slot())); const Material *material; - if (target_material == (MaterialAttrib *)NULL || + if (target_material == nullptr || target_material->is_off()) { material = ∅ } else { @@ -2149,11 +2148,11 @@ do_issue_texture() { for (int si = 0; si < num_stages; ++si) { TextureStage *stage = _target_texture->get_on_ff_stage(si); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // Something wrong with this texture; skip it. return; } @@ -2524,10 +2523,10 @@ bool TinyGraphicsStateGuardian:: upload_simple_texture(TinyTextureContext *gtc) { PStatTimer timer(_load_texture_pcollector); Texture *tex = gtc->get_texture(); - nassertr(tex != (Texture *)NULL, false); + nassertr(tex != nullptr, false); const unsigned char *image_ptr = tex->get_simple_ram_image(); - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { return false; } @@ -2616,7 +2615,7 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { } if (gltex->total_bytecount != total_bytecount) { - if (gltex->allocated_buffer != NULL) { + if (gltex->allocated_buffer != nullptr) { TinyTextureContext::get_class_type().deallocate_array(gltex->allocated_buffer); } gltex->allocated_buffer = TinyTextureContext::get_class_type().allocate_array(total_bytecount); @@ -2627,7 +2626,7 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { char *end_of_buffer = next_buffer + total_bytecount; int level = 0; - ZTextureLevel *dest = NULL; + ZTextureLevel *dest = nullptr; while (level < num_levels) { dest = &gltex->levels[level]; int bytecount = x_size * y_size * 4; @@ -2705,7 +2704,7 @@ copy_lum_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gt #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; while (pixel_count-- > 0) { @@ -2741,7 +2740,7 @@ copy_alpha_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext * #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; while (pixel_count-- > 0) { @@ -2777,7 +2776,7 @@ copy_one_channel_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureCon #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; @@ -2842,7 +2841,7 @@ copy_la_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; int inc = 2 * cw; @@ -2879,7 +2878,7 @@ copy_rgb_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gt #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; int inc = 3 * cw; @@ -2916,7 +2915,7 @@ copy_rgba_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *g #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; int inc = 4 * cw; diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx index c1fbe12b67..2e2c517fee 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx @@ -75,11 +75,11 @@ make_output(const string &name, if (retry == 0) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx index cdb1b90f1f..6a55f05b94 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx @@ -86,7 +86,7 @@ create_cg_image(const PNMImage &pnm_image) { bool has_alpha; bool is_grayscale; - CFStringRef color_space_name = NULL; + CFStringRef color_space_name = nullptr; switch (pnm_image.get_color_type()) { case PNMImage::CT_grayscale: color_space_name = kCGColorSpaceGenericGray; @@ -114,13 +114,13 @@ create_cg_image(const PNMImage &pnm_image) { case PNMImage::CT_invalid: // Shouldn't get here. - nassertr(false, NULL); + nassertr(false, nullptr); break; } - nassertr(color_space_name != NULL, NULL); + nassertr(color_space_name != nullptr, nullptr); CGColorSpaceRef color_space = CGColorSpaceCreateWithName(color_space_name); - nassertr(color_space != NULL, NULL); + nassertr(color_space != nullptr, nullptr); CGBitmapInfo bitmap_info = 0; #ifdef PGM_BIGGRAYS @@ -148,17 +148,17 @@ create_cg_image(const PNMImage &pnm_image) { } } } - nassertr((void *)dp == (void *)(char_array + num_bytes), NULL); + nassertr((void *)dp == (void *)(char_array + num_bytes), nullptr); CGDataProviderRef provider = - CGDataProviderCreateWithData(NULL, char_array, num_bytes, release_data); - nassertr(provider != NULL, NULL); + CGDataProviderCreateWithData(nullptr, char_array, num_bytes, release_data); + nassertr(provider != nullptr, nullptr); CGImageRef image = CGImageCreate (width, height, bits_per_component, bits_per_pixel, bytes_per_row, color_space, bitmap_info, provider, - NULL, false, kCGRenderingIntentDefault); - nassertr(image != NULL, NULL); + nullptr, false, kCGRenderingIntentDefault); + nassertr(image != nullptr, nullptr); CGColorSpaceRelease(color_space); CGDataProviderRelease(provider); @@ -192,12 +192,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinyOsxGraphicsWindow @@ -210,22 +210,22 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_hrgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } WindowHandle *window_handle = win_prop.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { tinydisplay_cat.info() << "Got parent_window " << *window_handle << "\n"; #ifdef SUPPORT_SUBPROCESS_WINDOW WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL && + if (os_handle != nullptr && os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { return new SubprocessWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -240,13 +240,13 @@ make_output(const string &name, if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // IS_OSX diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx index 6189f61036..7afe0953a4 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx @@ -83,12 +83,12 @@ make_output(const string &name, int retry, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinySDLGraphicsWindow @@ -101,14 +101,14 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new TinySDLGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // HAVE_SDL diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx index 68ab836ec6..d0fe649b79 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx @@ -38,8 +38,8 @@ TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _screen = NULL; - _frame_buffer = NULL; + _screen = nullptr; + _frame_buffer = nullptr; _pitch = 0; update_pixel_factor(); @@ -64,7 +64,7 @@ TinySDLGraphicsWindow:: bool TinySDLGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -86,7 +86,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinySDLGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -137,7 +137,7 @@ end_flip() { SDL_CreateRGBSurfaceFrom(_frame_buffer->pbuf, _frame_buffer->xsize, _frame_buffer->ysize, 32, _frame_buffer->linesize, 0xff0000, 0x00ff00, 0x0000ff, 0xff000000); SDL_SetAlpha(temp, SDL_RLEACCEL, 0); - SDL_BlitSurface(temp, NULL, _screen, NULL); + SDL_BlitSurface(temp, nullptr, _screen, nullptr); SDL_FreeSurface(temp); } @@ -156,7 +156,7 @@ void TinySDLGraphicsWindow:: process_events() { GraphicsWindow::process_events(); - if (_screen == NULL) { + if (_screen == nullptr) { return; } @@ -203,7 +203,7 @@ process_events() { properties.set_size(evt.resize.w, evt.resize.h); system_changed_properties(properties); _screen = SDL_SetVideoMode(_properties.get_x_size(), _properties.get_y_size(), 32, _flags); - ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + ZB_resize(_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); _pitch = _screen->pitch * 32 / _screen->format->BitsPerPixel; break; @@ -272,7 +272,7 @@ open_window() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { @@ -291,14 +291,14 @@ open_window() { } _screen = SDL_SetVideoMode(_properties.get_x_size(), _properties.get_y_size(), 32, _flags); - if (_screen == NULL) { + if (_screen == nullptr) { tinydisplay_cat.error() << "Video mode set failed.\n"; return false; } create_frame_buffer(); - if (_frame_buffer == NULL) { + if (_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; @@ -320,9 +320,9 @@ open_window() { */ void TinySDLGraphicsWindow:: create_frame_buffer() { - if (_frame_buffer != NULL) { + if (_frame_buffer != nullptr) { ZB_close(_frame_buffer); - _frame_buffer = NULL; + _frame_buffer = nullptr; } int mode; diff --git a/panda/src/tinydisplay/tinyTextureContext.I b/panda/src/tinydisplay/tinyTextureContext.I index ca4f620db1..348c748228 100644 --- a/panda/src/tinydisplay/tinyTextureContext.I +++ b/panda/src/tinydisplay/tinyTextureContext.I @@ -19,6 +19,6 @@ TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : TextureContext(pgo, tex, view) { _gltex.num_levels = 0; - _gltex.allocated_buffer = NULL; + _gltex.allocated_buffer = nullptr; _gltex.total_bytecount = 0; } diff --git a/panda/src/tinydisplay/tinyTextureContext.cxx b/panda/src/tinydisplay/tinyTextureContext.cxx index 5a3ae3414d..d0207a1379 100644 --- a/panda/src/tinydisplay/tinyTextureContext.cxx +++ b/panda/src/tinydisplay/tinyTextureContext.cxx @@ -22,10 +22,10 @@ TypeHandle TinyTextureContext::_type_handle; TinyTextureContext:: ~TinyTextureContext() { GLTexture *gltex = &_gltex; - if (gltex->allocated_buffer != NULL) { + if (gltex->allocated_buffer != nullptr) { nassertv(gltex->num_levels != 0); get_class_type().deallocate_array(gltex->allocated_buffer); - gltex->allocated_buffer = NULL; + gltex->allocated_buffer = nullptr; gltex->total_bytecount = 0; gltex->num_levels = 0; } else { @@ -48,10 +48,10 @@ evict_lru() { dequeue_lru(); GLTexture *gltex = &_gltex; - if (gltex->allocated_buffer != NULL) { + if (gltex->allocated_buffer != nullptr) { nassertv(gltex->num_levels != 0); get_class_type().deallocate_array(gltex->allocated_buffer); - gltex->allocated_buffer = NULL; + gltex->allocated_buffer = nullptr; gltex->total_bytecount = 0; gltex->num_levels = 0; } else { diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx index 2371d17ba8..6cfb2dc7c7 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx @@ -73,12 +73,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinyWinGraphicsWindow @@ -91,13 +91,13 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_hrgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } return new TinyWinGraphicsWindow(engine, this, name, fb_prop, win_prop, @@ -108,14 +108,14 @@ make_output(const string &name, if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // WIN32 diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx index afb7d1f016..85f1776ae5 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx @@ -39,7 +39,7 @@ TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : WinGraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _frame_buffer = NULL; + _frame_buffer = nullptr; _hdc = (HDC)0; update_pixel_factor(); } @@ -60,7 +60,7 @@ TinyWinGraphicsWindow:: bool TinyWinGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -90,7 +90,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinyWinGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -166,10 +166,10 @@ supports_pixel_zoom() const { */ void TinyWinGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_V(tinygsg, _gsg); - tinygsg->_current_frame_buffer = NULL; + tinygsg->_current_frame_buffer = nullptr; _gsg.clear(); } @@ -192,7 +192,7 @@ open_window() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { DCAST_INTO_R(tinygsg, _gsg, false); @@ -201,7 +201,7 @@ open_window() { _hdc = GetDC(_hWnd); create_frame_buffer(); - if (_frame_buffer == NULL) { + if (_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; @@ -225,8 +225,8 @@ open_window() { void TinyWinGraphicsWindow:: handle_reshape() { WinGraphicsWindow::handle_reshape(); - if (_frame_buffer != NULL) { - ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + if (_frame_buffer != nullptr) { + ZB_resize(_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); setup_bitmap_info(); } } @@ -238,7 +238,7 @@ handle_reshape() { bool TinyWinGraphicsWindow:: do_fullscreen_resize(int x_size, int y_size) { bool result = WinGraphicsWindow::do_fullscreen_resize(x_size, y_size); - ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + ZB_resize(_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); setup_bitmap_info(); return result; } @@ -248,9 +248,9 @@ do_fullscreen_resize(int x_size, int y_size) { */ void TinyWinGraphicsWindow:: create_frame_buffer() { - if (_frame_buffer != NULL) { + if (_frame_buffer != nullptr) { ZB_close(_frame_buffer); - _frame_buffer = NULL; + _frame_buffer = nullptr; } _frame_buffer = ZB_open(_properties.get_x_size(), _properties.get_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0); diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx index 9bb2c4c2d6..7bbfbecf79 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx @@ -72,7 +72,7 @@ make_output(const string &name, bool &precertify) { TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinyXGraphicsWindow @@ -88,7 +88,7 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new TinyXGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -101,13 +101,13 @@ make_output(const string &name, if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // HAVE_X11 diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index 7b34ba0fb7..64f1a7c809 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -45,11 +45,11 @@ TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : x11GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _gc = (GC)NULL; + _gc = (GC)nullptr; - _reduced_frame_buffer = NULL; - _full_frame_buffer = NULL; - _ximage = NULL; + _reduced_frame_buffer = nullptr; + _full_frame_buffer = nullptr; + _ximage = nullptr; update_pixel_factor(); } @@ -58,12 +58,12 @@ TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ TinyXGraphicsWindow:: ~TinyXGraphicsWindow() { - if (_gc != NULL && _display != NULL) { + if (_gc != nullptr && _display != nullptr) { XFreeGC(_display, _gc); } - if (_ximage != NULL) { + if (_ximage != nullptr) { PANDA_FREE_ARRAY(_ximage->data); - _ximage->data = NULL; + _ximage->data = nullptr; XDestroyImage(_ximage); } } @@ -78,12 +78,12 @@ bool TinyXGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); - if (_xwindow == (X11_Window)NULL) { + if (_xwindow == (X11_Window)nullptr) { return false; } begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -95,7 +95,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_R(tinygsg, _gsg, false); - if (_reduced_frame_buffer != (ZBuffer *)NULL) { + if (_reduced_frame_buffer != nullptr) { tinygsg->_current_frame_buffer = _reduced_frame_buffer; } else { tinygsg->_current_frame_buffer = _full_frame_buffer; @@ -114,7 +114,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinyXGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -138,12 +138,12 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void TinyXGraphicsWindow:: end_flip() { - if (_xwindow == (X11_Window)NULL || !_flip_ready) { + if (_xwindow == (X11_Window)nullptr || !_flip_ready) { GraphicsWindow::end_flip(); return; } - if (_reduced_frame_buffer != (ZBuffer *)NULL) { + if (_reduced_frame_buffer != nullptr) { // Zoom the reduced buffer onto the full buffer. ZB_zoomFrameBuffer(_full_frame_buffer, 0, 0, _full_frame_buffer->xsize, _full_frame_buffer->ysize, @@ -261,7 +261,7 @@ process_events() { // A normal window may be resized by the user at will. properties.set_size(event.xconfigure.width, event.xconfigure.height); system_changed_properties(properties); - ZB_resize(_full_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + ZB_resize(_full_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); _pitch = (_full_frame_buffer->xsize * _bytes_per_pixel + 3) & ~3; create_reduced_frame_buffer(); create_ximage(); @@ -377,10 +377,10 @@ process_events() { */ void TinyXGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_V(tinygsg, _gsg); - tinygsg->_current_frame_buffer = NULL; + tinygsg->_current_frame_buffer = nullptr; _gsg.clear(); } @@ -400,7 +400,7 @@ open_window() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { DCAST_INTO_R(tinygsg, _gsg, false); @@ -478,17 +478,17 @@ open_window() { return false; } - _gc = XCreateGC(_display, _xwindow, 0, NULL); + _gc = XCreateGC(_display, _xwindow, 0, nullptr); create_full_frame_buffer(); - if (_full_frame_buffer == NULL) { + if (_full_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; } create_reduced_frame_buffer(); create_ximage(); - nassertr(_ximage != NULL, false); + nassertr(_ximage != nullptr, false); tinygsg->_current_frame_buffer = _full_frame_buffer; @@ -513,7 +513,7 @@ open_window() { _window_handle = NativeWindowHandle::make_x11(_xwindow); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } @@ -534,9 +534,9 @@ pixel_factor_changed() { */ void TinyXGraphicsWindow:: create_full_frame_buffer() { - if (_full_frame_buffer != NULL) { + if (_full_frame_buffer != nullptr) { ZB_close(_full_frame_buffer); - _full_frame_buffer = NULL; + _full_frame_buffer = nullptr; } int mode; @@ -570,9 +570,9 @@ create_reduced_frame_buffer() { return; } - if (_reduced_frame_buffer != NULL) { + if (_reduced_frame_buffer != nullptr) { ZB_close(_reduced_frame_buffer); - _reduced_frame_buffer = NULL; + _reduced_frame_buffer = nullptr; } int x_size = get_fb_x_size(); @@ -594,11 +594,11 @@ create_reduced_frame_buffer() { */ void TinyXGraphicsWindow:: create_ximage() { - if (_ximage != NULL) { + if (_ximage != nullptr) { PANDA_FREE_ARRAY(_ximage->data); - _ximage->data = NULL; + _ximage->data = nullptr; XDestroyImage(_ximage); - _ximage = NULL; + _ximage = nullptr; } int image_size = _full_frame_buffer->ysize * _pitch; diff --git a/panda/src/tinydisplay/zbuffer.cxx b/panda/src/tinydisplay/zbuffer.cxx index cc25320646..45dbe1b0a2 100644 --- a/panda/src/tinydisplay/zbuffer.cxx +++ b/panda/src/tinydisplay/zbuffer.cxx @@ -34,8 +34,8 @@ ZB_open(int xsize, int ysize, int mode, int size; zb = (ZBuffer *)gl_malloc(sizeof(ZBuffer)); - if (zb == NULL) - return NULL; + if (zb == nullptr) + return nullptr; memset(zb, 0, sizeof(ZBuffer)); /* xsize must be a multiple of 4 */ @@ -68,12 +68,12 @@ ZB_open(int xsize, int ysize, int mode, size = zb->xsize * zb->ysize * sizeof(ZPOINT); zb->zbuf = (ZPOINT *)gl_malloc(size); - if (zb->zbuf == NULL) + if (zb->zbuf == nullptr) goto error; - if (frame_buffer == NULL) { + if (frame_buffer == nullptr) { zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize); - if (zb->pbuf == NULL) { + if (zb->pbuf == nullptr) { gl_free(zb->zbuf); goto error; } @@ -86,7 +86,7 @@ ZB_open(int xsize, int ysize, int mode, return zb; error: gl_free(zb); - return NULL; + return nullptr; } void @@ -107,7 +107,7 @@ void ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize) { int size; - nassertv(zb != NULL); + nassertv(zb != nullptr); /* xsize must be a multiple of 4 */ xsize = (xsize + 3) & ~3; @@ -123,7 +123,7 @@ ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize) { if (zb->frame_buffer_allocated) gl_free(zb->pbuf); - if (frame_buffer == NULL) { + if (frame_buffer == nullptr) { zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize); zb->frame_buffer_allocated = 1; } else { diff --git a/panda/src/tinydisplay/zfeatures.h b/panda/src/tinydisplay/zfeatures.h index 6092b87c24..73a61d95c5 100644 --- a/panda/src/tinydisplay/zfeatures.h +++ b/panda/src/tinydisplay/zfeatures.h @@ -39,4 +39,10 @@ /* Number of simultaneous texture stages supported (multitexture). */ #define MAX_TEXTURE_STAGES 3 +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif + #endif /* _tgl_features_h_ */ diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index c8fdfc4c53..9b2db10f2d 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -348,10 +348,10 @@ int n; #ifdef INTERP_Z ZPOINT *pz; - unsigned int z,zz; + UNUSED unsigned int z,zz; #endif #ifdef INTERP_RGB - unsigned int or1,og1,ob1,oa1; + UNUSED unsigned int or1,og1,ob1,oa1; #endif #ifdef INTERP_ST unsigned int s,t; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 6bb255ce01..b8baba23c2 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -31,7 +31,7 @@ static void FNAME(flat_untextured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - int color; + UNUSED int color; int or0, og0, ob0, oa0; #define INTERP_Z @@ -187,7 +187,7 @@ FNAME(flat_textured) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \ @@ -249,7 +249,7 @@ FNAME(smooth_textured) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \ @@ -431,7 +431,7 @@ FNAME(flat_perspective) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \ @@ -567,7 +567,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \ @@ -695,9 +695,9 @@ FNAME(smooth_multitex2) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(&zb->current_textures[0], s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ - int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ + UNUSED int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT3(or1, PIXEL_R(tmp), PIXEL_R(tmpa)), \ PCOMPONENT_MULT3(og1, PIXEL_G(tmp), PIXEL_G(tmpa)), \ @@ -853,10 +853,10 @@ FNAME(smooth_multitex3) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(&zb->current_textures[0], s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ - int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ - int tmpb = ZB_LOOKUP_TEXTURE(&zb->current_textures[2], sb, tb, mipmap_levelb, mipmap_dxb); \ + UNUSED int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ + UNUSED int tmpb = ZB_LOOKUP_TEXTURE(&zb->current_textures[2], sb, tb, mipmap_levelb, mipmap_dxb); \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT4(or1, PIXEL_R(tmp), PIXEL_R(tmpa), PIXEL_R(tmpb)), \ PCOMPONENT_MULT4(og1, PIXEL_G(tmp), PIXEL_G(tmpa), PIXEL_G(tmpb)), \ diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index 0c68f5cd46..9d990cc26b 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/panda/src/vision/arToolKit.cxx @@ -280,7 +280,7 @@ analyze(Texture *tex, bool do_flip_texture) { CPTA_uchar ri = tex->get_ram_image(); const unsigned char *ram = ri.p(); - if (ram == NULL) { + if (ram == nullptr) { vision_cat.warning() << "No data in texture!\n"; return; } diff --git a/panda/src/vision/openCVTexture.I b/panda/src/vision/openCVTexture.I index d9f5fa6f37..91234c31b6 100644 --- a/panda/src/vision/openCVTexture.I +++ b/panda/src/vision/openCVTexture.I @@ -16,7 +16,7 @@ */ INLINE bool OpenCVTexture::VideoStream:: is_valid() const { - return (_capture != NULL); + return (_capture != nullptr); } /** diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index 5990e77321..e6deea17ea 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -92,7 +92,7 @@ consider_update() { * independently of the original. */ PT(Texture) OpenCVTexture:: -make_copy_impl() { +make_copy_impl() const { Texture::CDReader cdata_tex(Texture::_cycler); PT(OpenCVTexture) copy = new OpenCVTexture(get_name()); Texture::CDWriter cdata_copy_tex(copy->Texture::_cycler, true); @@ -371,7 +371,7 @@ do_read_one(Texture::CData *cdata, int z, int n, int primary_file_num_channels, int alpha_file_channel, const LoaderOptions &options, bool header_only, BamCacheRecord *record) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } @@ -479,7 +479,7 @@ register_with_read_factory() { */ OpenCVTexture::VideoStream:: VideoStream() : - _capture(NULL), + _capture(nullptr), _camera_index(-1), _next_frame(0) { @@ -490,7 +490,7 @@ VideoStream() : */ OpenCVTexture::VideoStream:: VideoStream(const OpenCVTexture::VideoStream ©) : - _capture(NULL), + _capture(nullptr), _camera_index(-1) { // Rather than copying the _capture pointer, we must open a new stream that @@ -541,7 +541,7 @@ get_frame_data(int frame, _next_frame = frame + 1; IplImage *image = cvQueryFrame(_capture); - if (image == NULL) { + if (image == nullptr) { return false; } @@ -583,7 +583,7 @@ read(const Filename &filename) { string os_specific = filename.to_os_specific(); _capture = cvCaptureFromFile(os_specific.c_str()); - if (_capture == NULL) { + if (_capture == nullptr) { return false; } _filename = filename; @@ -599,7 +599,7 @@ from_camera(int camera_index) { clear(); _capture = cvCaptureFromCAM(camera_index); - if (_capture == NULL) { + if (_capture == nullptr) { return false; } _camera_index = camera_index; @@ -611,9 +611,9 @@ from_camera(int camera_index) { */ void OpenCVTexture::VideoStream:: clear() { - if (_capture != NULL) { + if (_capture != nullptr) { cvReleaseCapture(&_capture); - _capture = NULL; + _capture = nullptr; } _filename = Filename(); _camera_index = -1; diff --git a/panda/src/vision/openCVTexture.h b/panda/src/vision/openCVTexture.h index 7226202a7f..ce4d279456 100644 --- a/panda/src/vision/openCVTexture.h +++ b/panda/src/vision/openCVTexture.h @@ -41,7 +41,7 @@ public: protected: virtual void consider_update(); - virtual PT(Texture) make_copy_impl(); + virtual PT(Texture) make_copy_impl() const; void do_assign(Texture::CData *cdata_tex, const OpenCVTexture *copy, const Texture::CData *cdata_copy_tex); diff --git a/panda/src/vision/webcamVideo.cxx b/panda/src/vision/webcamVideo.cxx index f13587c39b..8badc4eeec 100644 --- a/panda/src/vision/webcamVideo.cxx +++ b/panda/src/vision/webcamVideo.cxx @@ -75,6 +75,6 @@ get_num_options() { PT(WebcamVideo) WebcamVideo:: get_option(int n) { find_all_webcams(); - nassertr((n >= 0) && (n < (int)_all_webcams.size()), NULL); + nassertr((n >= 0) && (n < (int)_all_webcams.size()), nullptr); return _all_webcams[n]; } diff --git a/panda/src/vision/webcamVideoCursorOpenCV.cxx b/panda/src/vision/webcamVideoCursorOpenCV.cxx index 814ad9d5bb..444557fde8 100644 --- a/panda/src/vision/webcamVideoCursorOpenCV.cxx +++ b/panda/src/vision/webcamVideoCursorOpenCV.cxx @@ -35,7 +35,7 @@ WebcamVideoCursorOpenCV(WebcamVideoOpenCV *src) : MovieVideoCursor(src) { _ready = false; _capture = cvCaptureFromCAM(src->_camera_index); - if (_capture != NULL) { + if (_capture != nullptr) { _size_x = (int)cvGetCaptureProperty(_capture, CV_CAP_PROP_FRAME_WIDTH); _size_y = (int)cvGetCaptureProperty(_capture, CV_CAP_PROP_FRAME_HEIGHT); _ready = true; @@ -47,9 +47,9 @@ WebcamVideoCursorOpenCV(WebcamVideoOpenCV *src) : MovieVideoCursor(src) { */ WebcamVideoCursorOpenCV:: ~WebcamVideoCursorOpenCV() { - if (_capture != NULL) { + if (_capture != nullptr) { cvReleaseCapture(&_capture); - _capture = NULL; + _capture = nullptr; } } @@ -59,13 +59,13 @@ WebcamVideoCursorOpenCV:: PT(MovieVideoCursor::Buffer) WebcamVideoCursorOpenCV:: fetch_buffer() { if (!_ready) { - return NULL; + return nullptr; } PT(Buffer) buffer = get_standard_buffer(); unsigned char *dest = buffer->_block; int num_components = get_num_components(); - nassertr(num_components == 3, NULL); + nassertr(num_components == 3, nullptr); int dest_x_pitch = num_components; // Assume component_width == 1 int dest_y_pitch = _size_x * dest_x_pitch; @@ -75,7 +75,7 @@ fetch_buffer() { if (num_components == 3 && x_pitch == 3) { // The easy case--copy the whole thing in, row by row. int copy_bytes = _size_x * dest_x_pitch; - nassertr(copy_bytes <= dest_y_pitch && copy_bytes <= abs(y_pitch), NULL); + nassertr(copy_bytes <= dest_y_pitch && copy_bytes <= abs(y_pitch), nullptr); for (int y = 0; y < _size_y; ++y) { memcpy(dest, r, copy_bytes); @@ -129,7 +129,7 @@ get_frame_data(const unsigned char *&r, nassertr(ready(), false); IplImage *image = cvQueryFrame(_capture); - if (image == NULL) { + if (image == nullptr) { return false; } diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index a78c55135a..853f3e070f 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -207,8 +207,8 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { _ready = false; memset(&_format, 0, sizeof(struct v4l2_format)); - _buffers = NULL; - _buflens = NULL; + _buffers = nullptr; + _buflens = nullptr; int mode = O_RDWR; if (!v4l_blocking) { @@ -326,7 +326,7 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { } _buflens[i] = buf.length; - _buffers[i] = mmap (NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); + _buffers[i] = mmap (nullptr, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); if (_buffers[i] == MAP_FAILED) { vision_cat.error() << "Failed to map buffer!\n"; @@ -393,7 +393,7 @@ WebcamVideoCursorV4L:: PT(MovieVideoCursor::Buffer) WebcamVideoCursorV4L:: fetch_buffer() { if (!_ready) { - return NULL; + return nullptr; } PT(Buffer) buffer = get_standard_buffer(); @@ -405,12 +405,12 @@ fetch_buffer() { if (-1 == ioctl(_fd, VIDIOC_DQBUF, &vbuf) && errno != EIO) { if (errno == EAGAIN) { // Simply nothing is available yet. - return NULL; + return nullptr; } vision_cat.error() << "Failed to dequeue buffer!\n"; - return NULL; + return nullptr; } - nassertr(vbuf.index < _bufcount, NULL); + nassertr(vbuf.index < _bufcount, nullptr); size_t bufsize = _buflens[vbuf.index]; size_t old_bpl = _format.fmt.pix.bytesperline; size_t new_bpl = _size_x * _num_components; @@ -435,7 +435,7 @@ fetch_buffer() { _cinfo.src->next_input_byte = buf; if (jpeg_read_header(&_cinfo, TRUE) == JPEG_HEADER_OK) { - if (_cinfo.dc_huff_tbl_ptrs[0] == NULL) { + if (_cinfo.dc_huff_tbl_ptrs[0] == nullptr) { // Many MJPEG streams do not include huffman tables. Remedy this. _cinfo.dc_huff_tbl_ptrs[0] = &dc_luminance_tbl; _cinfo.dc_huff_tbl_ptrs[1] = &dc_chrominance_tbl; @@ -482,7 +482,7 @@ fetch_buffer() { block[i + 2] = ex; } #else - nassertr(false /* Not compiled with JPEG support*/, NULL); + nassertr(false /* Not compiled with JPEG support*/, nullptr); #endif break; } @@ -500,7 +500,7 @@ fetch_buffer() { case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_GREY: // Simplest case: copying every row verbatim. - nassertr(old_bpl == new_bpl, NULL); + nassertr(old_bpl == new_bpl, nullptr); for (size_t row = 0; row < _size_y; ++row) { memcpy(block + (_size_y - row - 1) * new_bpl, buf + row * old_bpl, new_bpl); @@ -509,7 +509,7 @@ fetch_buffer() { case V4L2_PIX_FMT_RGB24: // Swap components. - nassertr(old_bpl == new_bpl, NULL); + nassertr(old_bpl == new_bpl, nullptr); for (size_t row = 0; row < _size_y; ++row) { for (size_t i = 0; i < old_bpl; i += 3) { @@ -520,7 +520,7 @@ fetch_buffer() { case V4L2_PIX_FMT_RGB32: // Swap components. - nassertr(old_bpl == new_bpl, NULL); + nassertr(old_bpl == new_bpl, nullptr); for (size_t row = 0; row < _size_y; ++row) { for (size_t i = 0; i < old_bpl; i += 4) { diff --git a/panda/src/vision/webcamVideoDS.cxx b/panda/src/vision/webcamVideoDS.cxx index 0996070b45..79510cf24d 100644 --- a/panda/src/vision/webcamVideoDS.cxx +++ b/panda/src/vision/webcamVideoDS.cxx @@ -236,18 +236,18 @@ media_fps(AM_MEDIA_TYPE *media) { */ void WebcamVideoDS:: delete_media_type(AM_MEDIA_TYPE *pmt) { - if (pmt == NULL) { + if (pmt == nullptr) { return; } if (pmt->cbFormat != 0) { CoTaskMemFree((PVOID)pmt->pbFormat); pmt->cbFormat = 0; - pmt->pbFormat = NULL; + pmt->pbFormat = nullptr; } - if (pmt->pUnk != NULL) { + if (pmt->pUnk != nullptr) { // Unecessary because pUnk should not be used, but safest. pmt->pUnk->Release(); - pmt->pUnk = NULL; + pmt->pUnk = nullptr; } CoTaskMemFree(pmt); } @@ -272,7 +272,7 @@ bstr_to_string(const BSTR &source) { string WebcamVideoDS:: get_moniker_name(IMoniker *pMoniker) { string res = "Unknown Device"; - IPropertyBag *propBag=NULL; + IPropertyBag *propBag=nullptr; VARIANT name; HRESULT hResult; pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&propBag); VariantInit(&name); @@ -334,25 +334,25 @@ find_all_webcams_ds() { pvector list; - ICreateDevEnum *pCreateDevEnum=NULL; - IEnumMoniker *pEnumMoniker=NULL; - IGraphBuilder *pGraphBuilder=NULL; - ICaptureGraphBuilder2 *pCaptureGraphBuilder2=NULL; - IMoniker *pMoniker=NULL; - IBaseFilter *pBaseFilter=NULL; - IAMStreamConfig *pStreamConfig=NULL; + ICreateDevEnum *pCreateDevEnum=nullptr; + IEnumMoniker *pEnumMoniker=nullptr; + IGraphBuilder *pGraphBuilder=nullptr; + ICaptureGraphBuilder2 *pCaptureGraphBuilder2=nullptr; + IMoniker *pMoniker=nullptr; + IBaseFilter *pBaseFilter=nullptr; + IAMStreamConfig *pStreamConfig=nullptr; HRESULT hResult; ULONG cFetched; - hResult=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC, IID_IGraphBuilder,(void**)&pGraphBuilder); if (hResult != S_OK) goto cleanup; - hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, nullptr, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void**)&pCaptureGraphBuilder2); if (hResult != S_OK) goto cleanup; hResult = pCaptureGraphBuilder2->SetFiltergraph(pGraphBuilder); if (hResult != S_OK) goto cleanup; - hResult=CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, + hResult=CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void**)&pCreateDevEnum); if (hResult != S_OK) goto cleanup; hResult=pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, @@ -367,7 +367,7 @@ find_all_webcams_ds() { hResult = pEnumMoniker->Next(1, &pMoniker, &cFetched); if (hResult != S_OK) break; - hResult = pMoniker->BindToObject(NULL,NULL,IID_IBaseFilter, (void**)&pBaseFilter); + hResult = pMoniker->BindToObject(nullptr,nullptr,IID_IBaseFilter, (void**)&pBaseFilter); if (hResult != S_OK) continue; hResult = pCaptureGraphBuilder2->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pBaseFilter, IID_IAMStreamConfig, (void **)&pStreamConfig); @@ -425,23 +425,23 @@ open() { WebcamVideoCursorDS:: WebcamVideoCursorDS(WebcamVideoDS *src) : MovieVideoCursor(src), - _pGraphBuilder(NULL), - _pCaptureBuilder(NULL), - _pSrcFilter(NULL), - _pStreamConfig(NULL), - _pStreamRenderer(NULL), - _pMediaCtrl(NULL) + _pGraphBuilder(nullptr), + _pCaptureBuilder(nullptr), + _pSrcFilter(nullptr), + _pStreamConfig(nullptr), + _pStreamRenderer(nullptr), + _pMediaCtrl(nullptr) { AM_MEDIA_TYPE mediaType; VIDEOINFOHEADER *pVideoInfo; HRESULT hResult; - hResult=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC, IID_IGraphBuilder,(void**)&_pGraphBuilder); if(hResult != S_OK) { cleanup(); return; } - hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, nullptr, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void**)&_pCaptureBuilder); if(hResult != S_OK) { cleanup(); return; } @@ -454,8 +454,8 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cleanup(); return; } cerr << " IID_IMediaControl interface is acquired.\n"; - src->_moniker->BindToObject(NULL,NULL,IID_IBaseFilter, (void**)&_pSrcFilter); - if(_pSrcFilter == NULL) + src->_moniker->BindToObject(nullptr,nullptr,IID_IBaseFilter, (void**)&_pSrcFilter); + if(_pSrcFilter == nullptr) { cerr << " Such capture device is not found.\n"; cleanup(); return; } cerr << " The capture filter is acquired.\n"; @@ -479,7 +479,7 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cleanup(); return; } - hResult = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&_pSampleGrabber)); + hResult = CoCreateInstance(CLSID_SampleGrabber, nullptr, CLSCTX_INPROC, IID_PPV_ARGS(&_pSampleGrabber)); if(hResult != S_OK) { cerr << " Can not create the sample grabber, maybe qedit.dll is not registered?"; cleanup(); return; } @@ -487,7 +487,7 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : // hResult = CoCreateInstance(CLSID_SampleGrabber,) CComQIPtr< IBaseFilter, // &IID_IBaseFilter > pGrabberFilter(_pSampleGrabber); - IBaseFilter *pGrabberFilter = NULL; + IBaseFilter *pGrabberFilter = nullptr; hResult = _pSampleGrabber->QueryInterface(IID_PPV_ARGS(&pGrabberFilter)); cerr << " IID_IBaseFilter of CLSID_SampleGrabber is acquired.\n"; @@ -507,7 +507,7 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cerr << " The sample grabber has been added to the graph.\n"; // used to give the video stream somewhere to go to. - hResult = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&_pStreamRenderer); + hResult = CoCreateInstance(CLSID_NullRenderer, nullptr, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&_pStreamRenderer); if(hResult != S_OK) { cerr << " Can not create the null renderer."; cleanup(); return; } @@ -566,17 +566,17 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : if(mediaType.cbFormat != 0) { CoTaskMemFree((PVOID)mediaType.pbFormat); mediaType.cbFormat=0; - mediaType.pbFormat=NULL; + mediaType.pbFormat=nullptr; } - if(mediaType.pUnk != NULL) { + if(mediaType.pUnk != nullptr) { mediaType.pUnk->Release(); - mediaType.pUnk=NULL; + mediaType.pUnk=nullptr; } - if(pGrabberFilter != NULL) { + if(pGrabberFilter != nullptr) { pGrabberFilter->Release(); - pGrabberFilter=NULL; + pGrabberFilter=nullptr; } _pSampleGrabber->SetBufferSamples(FALSE); @@ -605,13 +605,13 @@ cleanup() { _pMediaCtrl->Stop(); } - if(_pMediaCtrl) { _pMediaCtrl->Release(); _pMediaCtrl=NULL; } - if(_pCaptureBuilder) { _pCaptureBuilder->Release(); _pCaptureBuilder=NULL; } - if(_pGraphBuilder) { _pGraphBuilder->Release(); _pGraphBuilder=NULL; } - if(_pSampleGrabber) { _pSampleGrabber->Release(); _pSampleGrabber=NULL; } - if(_pStreamRenderer) { _pStreamRenderer->Release(); _pStreamRenderer=NULL; } - if(_pSrcFilter) { _pSrcFilter->Release(); _pSrcFilter=NULL; } - if(_pStreamConfig) { _pStreamConfig->Release(); _pStreamConfig=NULL; } + if(_pMediaCtrl) { _pMediaCtrl->Release(); _pMediaCtrl=nullptr; } + if(_pCaptureBuilder) { _pCaptureBuilder->Release(); _pCaptureBuilder=nullptr; } + if(_pGraphBuilder) { _pGraphBuilder->Release(); _pGraphBuilder=nullptr; } + if(_pSampleGrabber) { _pSampleGrabber->Release(); _pSampleGrabber=nullptr; } + if(_pStreamRenderer) { _pStreamRenderer->Release(); _pStreamRenderer=nullptr; } + if(_pSrcFilter) { _pSrcFilter->Release(); _pSrcFilter=nullptr; } + if(_pStreamConfig) { _pStreamConfig->Release(); _pStreamConfig=nullptr; } } /** @@ -628,7 +628,7 @@ WebcamVideoCursorDS:: PT(MovieVideoCursor::Buffer) WebcamVideoCursorDS:: fetch_buffer() { if (!_ready) { - return NULL; + return nullptr; } Buffer *buffer = get_standard_buffer(); diff --git a/panda/src/vrpn/vrpnClient.cxx b/panda/src/vrpn/vrpnClient.cxx index 1e7ec5abf0..068d7614a0 100644 --- a/panda/src/vrpn/vrpnClient.cxx +++ b/panda/src/vrpn/vrpnClient.cxx @@ -41,7 +41,7 @@ VrpnClient(const string &server_name) : << "\n"; } _connection = vrpn_get_connection_by_name(_server_name.c_str()); - nassertv(_connection != (vrpn_Connection *)NULL); + nassertv(_connection != nullptr); if (!is_valid()) { vrpn_cat.warning() @@ -140,7 +140,7 @@ make_device(TypeHandle device_type, const string &device_name) { return make_dial_device(device_name); } else { - return NULL; + return nullptr; } } @@ -625,7 +625,7 @@ bool VrpnClient:: add_remote_tracker(const string &tracker, int sensor) { vrpn_Tracker_Remote *vrpn_tracker = new vrpn_Tracker_Remote(tracker.c_str(), _connection); - if (vrpn_tracker == (vrpn_Tracker_Remote *)NULL) { + if (vrpn_tracker == nullptr) { return false; } @@ -654,7 +654,7 @@ bool VrpnClient:: add_remote_analog(const string &analog) { vrpn_Analog_Remote *vrpn_analog = new vrpn_Analog_Remote(analog.c_str(), _connection); - if (vrpn_analog == (vrpn_Analog_Remote *)NULL) { + if (vrpn_analog == nullptr) { return false; } @@ -680,7 +680,7 @@ bool VrpnClient:: add_remote_button(const string &button) { vrpn_Button_Remote *vrpn_button = new vrpn_Button_Remote(button.c_str(), _connection); - if (vrpn_button == (vrpn_Button_Remote *)NULL) { + if (vrpn_button == nullptr) { return false; } @@ -706,7 +706,7 @@ bool VrpnClient:: add_remote_dial(const string &dial) { vrpn_Dial_Remote *vrpn_dial = new vrpn_Dial_Remote(dial.c_str(), _connection); - if (vrpn_dial == (vrpn_Dial_Remote *)NULL) { + if (vrpn_dial == nullptr) { return false; } diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index 309533df4b..868ff727b2 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -62,7 +62,7 @@ bool wglGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -117,7 +117,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void wglGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -171,7 +171,7 @@ bind_texture_to_pbuffer() { } } TextureContext *tc = tex->prepare_now(0, _gsg->get_prepared_objects(), _gsg); - nassertv(tc != (TextureContext *)NULL); + nassertv(tc != nullptr); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); GLenum target = wglgsg->get_texture_target(tex->get_texture_type()); if (target == GL_NONE) { @@ -205,7 +205,7 @@ select_target_tex_page(int page) { wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); - nassertv(wglgsg->_wglSetPbufferAttribARB != NULL); + nassertv(wglgsg->_wglSetPbufferAttribARB != nullptr); static const int max_attrib_list = 64; int iattrib_list[max_attrib_list]; @@ -236,7 +236,7 @@ process_events() { // Handle all the messages on the queue in a row. Some of these might be // for another window, but they will get dispatched appropriately. - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { process_1_event(); } } @@ -248,7 +248,7 @@ process_events() { */ bool wglGraphicsBuffer:: get_supports_render_texture() const { - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -262,7 +262,7 @@ get_supports_render_texture() const { */ void wglGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); @@ -294,7 +294,7 @@ open_buffer() { wglGraphicsStateGuardian *wglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, NULL); + wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, nullptr); wglgsg->choose_pixel_format(_fb_properties, true); _gsg = wglgsg; } else { @@ -315,12 +315,12 @@ open_buffer() { HDC twindow_dc = wglgsg->get_twindow_dc(); if (twindow_dc == 0) { // If we couldn't make a window, we can't get a GL context. - _gsg = NULL; + _gsg = nullptr; return false; } HGLRC context = wglgsg->get_context(twindow_dc); if (context == 0) { - _gsg = NULL; + _gsg = nullptr; return false; } wglGraphicsPipe::wgl_make_current(twindow_dc, context, @@ -329,7 +329,7 @@ open_buffer() { wglgsg->report_my_gl_errors(); if (!wglgsg->get_fb_properties().verify_hardware_software (_fb_properties,wglgsg->get_gl_renderer())) { - _gsg = NULL; + _gsg = nullptr; return false; } _fb_properties = wglgsg->get_fb_properties(); @@ -340,7 +340,7 @@ open_buffer() { if (!rebuild_bitplanes()) { wglGraphicsPipe::wgl_make_current(0, 0, &_make_current_pcollector); - _gsg = NULL; + _gsg = nullptr; return false; } @@ -366,7 +366,7 @@ release_pbuffer() { _pbuffer_bound->release(wglgsg->get_prepared_objects()); _pbuffer_bound = 0; } - wglGraphicsPipe::wgl_make_current(0, 0, NULL); + wglGraphicsPipe::wgl_make_current(0, 0, nullptr); if (_pbuffer_dc) { wglgsg->_wglReleasePbufferDCARB(_pbuffer, _pbuffer_dc); } @@ -398,7 +398,7 @@ rebuild_bitplanes() { } // Find the texture to bind to the color buffer. - Texture *bindtexture = NULL; + Texture *bindtexture = nullptr; for (int i=0; iget_format() != Texture::F_depth_stencil)) { @@ -530,7 +530,7 @@ void wglGraphicsBuffer:: process_1_event() { MSG msg; - if (!GetMessage(&msg, NULL, 0, 0)) { + if (!GetMessage(&msg, nullptr, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index ee2c2a7522..890c34e19c 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -98,12 +98,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } wglGraphicsStateGuardian *wglgsg = 0; if (gsg != 0) { - DCAST_INTO_R(wglgsg, gsg, NULL); + DCAST_INTO_R(wglgsg, gsg, nullptr); } bool support_rtt; @@ -125,13 +125,13 @@ make_output(const string &name, ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_hrgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } return new wglGraphicsWindow(engine, this, name, fb_prop, win_prop, @@ -141,9 +141,9 @@ make_output(const string &name, // Second thing to try: a GLGraphicsBuffer if (retry == 1) { - if (!gl_support_fbo || host == NULL || + if (!gl_support_fbo || host == nullptr || (flags & (BF_require_parasite | BF_require_window)) != 0) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -151,13 +151,13 @@ make_output(const string &name, if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || fb_prop.get_accum_bits() > 0) { - return NULL; + return nullptr; } } - if (wglgsg != NULL && wglgsg->is_valid() && !wglgsg->needs_reset()) { + if (wglgsg != nullptr && wglgsg->is_valid() && !wglgsg->needs_reset()) { if (!wglgsg->_supports_framebuffer_object || - wglgsg->_glDrawBuffers == NULL) { - return NULL; + wglgsg->_glDrawBuffers == nullptr) { + return nullptr; } else { // Early success - if we are sure that this buffer WILL meet specs, we // can precertify it. @@ -174,13 +174,13 @@ make_output(const string &name, if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if ((wglgsg != 0) && (wglgsg->is_valid()) && (!wglgsg->needs_reset()) && !wglgsg->_supports_pbuffer) { - return NULL; + return nullptr; } if (!support_rtt) { @@ -188,7 +188,7 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { // If we require Render-to-Texture, but can't be sure we support it, // bail. - return NULL; + return nullptr; } } @@ -198,7 +198,7 @@ make_output(const string &name, if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } // Early success - if we are sure that this buffer WILL meet specs, we can @@ -216,7 +216,7 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } /** @@ -227,7 +227,7 @@ make_output(const string &name, */ PT(GraphicsStateGuardian) wglGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { - return new wglGraphicsStateGuardian(engine, this, NULL); + return new wglGraphicsStateGuardian(engine, this, nullptr); } diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index 9d916129a4..0d6f78ae1c 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -32,7 +32,7 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _share_with(share_with) { _made_context = false; - _context = (HGLRC)NULL; + _context = (HGLRC)nullptr; _twindow = (HWND)0; _twindow_dc = (HDC)0; @@ -46,7 +46,7 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _supports_wgl_multisample = false; _supports_wgl_render_texture = false; - _wglCreateContextAttribsARB = NULL; + _wglCreateContextAttribsARB = nullptr; get_gamma_table(); atexit(atexit_function); @@ -58,9 +58,9 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, wglGraphicsStateGuardian:: ~wglGraphicsStateGuardian() { release_twindow(); - if (_context != (HGLRC)NULL) { + if (_context != (HGLRC)nullptr) { wglDeleteContext(_context); - _context = (HGLRC)NULL; + _context = (HGLRC)nullptr; } } @@ -123,7 +123,6 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { pfd.cBlueBits, pfd.cAlphaBits); } - int mode = 0; if (pfd.dwFlags & PFD_DOUBLEBUFFER) { properties.set_back_buffers(1); } @@ -193,7 +192,6 @@ get_properties_advanced(FrameBufferProperties &properties, properties.clear(); properties.set_all_specified(); - int frame_buffer_mode = 0; if (ivalue_list[acceleration_i] == WGL_NO_ACCELERATION_ARB) { properties.set_force_software(true); } else { @@ -270,9 +268,9 @@ choose_pixel_format(const FrameBufferProperties &properties, int best_quality = 0; FrameBufferProperties best_prop; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); - int max_pfnum = DescribePixelFormat(hdc, 1, 0, NULL); + int max_pfnum = DescribePixelFormat(hdc, 1, 0, nullptr); for (int pfnum = 0; pfnum 0) { attrib_list[n++] = WGL_CONTEXT_MAJOR_VERSION_ARB; @@ -614,14 +612,14 @@ make_context(HDC hdc) { attrib_list[n++] = WGL_CONTEXT_PROFILE_MASK_ARB; attrib_list[n++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; #endif - attrib_list[n] = NULL; + attrib_list[n] = 0; _context = _wglCreateContextAttribsARB(hdc, 0, attrib_list); } else { _context = wglCreateContext(hdc); } - if (_context == NULL) { + if (_context == nullptr) { wgldisplay_cat.error() << "Could not create GL context.\n"; _is_valid = false; @@ -629,9 +627,9 @@ make_context(HDC hdc) { } // Now share texture context with the indicated GSG. - if (_share_with != (wglGraphicsStateGuardian *)NULL) { + if (_share_with != nullptr) { HGLRC share_context = _share_with->get_share_context(); - if (share_context == NULL) { + if (share_context == nullptr) { // Whoops, the target context hasn't yet made its own context. In that // case, it will share context with us. _share_with->redirect_share_pool(this); @@ -649,7 +647,7 @@ make_context(HDC hdc) { } } - _share_with = (wglGraphicsStateGuardian *)NULL; + _share_with = nullptr; } } @@ -665,10 +663,10 @@ get_share_context() const { if (_made_context) { return _context; } - if (_share_with != (wglGraphicsStateGuardian *)NULL) { + if (_share_with != nullptr) { return _share_with->get_share_context(); } - return NULL; + return nullptr; } /** @@ -682,7 +680,7 @@ get_share_context() const { void wglGraphicsStateGuardian:: redirect_share_pool(wglGraphicsStateGuardian *share_with) { nassertv(!_made_context); - if (_share_with != (wglGraphicsStateGuardian *)NULL) { + if (_share_with != nullptr) { _share_with->redirect_share_pool(share_with); } else { _share_with = share_with; @@ -702,9 +700,9 @@ make_twindow() { DWORD window_style = 0; register_twindow_class(); - HINSTANCE hinstance = GetModuleHandle(NULL); + HINSTANCE hinstance = GetModuleHandle(nullptr); _twindow = CreateWindow(_twindow_class_name, "twindow", window_style, - 0, 0, 1, 1, NULL, NULL, hinstance, 0); + 0, 0, 1, 1, nullptr, nullptr, hinstance, 0); if (!_twindow) { wgldisplay_cat.error() @@ -755,7 +753,7 @@ register_twindow_class() { WNDCLASS wc; - HINSTANCE instance = GetModuleHandle(NULL); + HINSTANCE instance = GetModuleHandle(nullptr); // Clear before filling in window structure! ZeroMemory(&wc, sizeof(WNDCLASS)); @@ -836,7 +834,7 @@ get_gamma_table(void) { get = false; if (_gamma_table_initialized == false) { - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); if (hdc) { if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { @@ -844,7 +842,7 @@ get_gamma_table(void) { get = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } } @@ -857,7 +855,7 @@ get_gamma_table(void) { bool wglGraphicsStateGuardian:: static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); set = false; if (hdc) { @@ -874,7 +872,7 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { set = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } return set; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index 06fc3d3ed4..a0cfb1a785 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -56,7 +56,7 @@ bool wglGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -99,7 +99,7 @@ void wglGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -164,7 +164,7 @@ ready_flip() { */ void wglGraphicsWindow:: end_flip() { - if (_hdc != NULL && _flip_ready) { + if (_hdc != nullptr && _flip_ready) { // The documentation on SwapBuffers() is not at all clear on whether the // GL context needs to be current before it can be called. Empirically, // it appears that it is not necessary in many cases, but it definitely is @@ -184,8 +184,8 @@ end_flip() { */ void wglGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - wglGraphicsPipe::wgl_make_current(_hdc, NULL, &_make_current_pcollector); + if (_gsg != nullptr) { + wglGraphicsPipe::wgl_make_current(_hdc, nullptr, &_make_current_pcollector); _gsg.clear(); } ReleaseDC(_hWnd, _hdc); @@ -208,7 +208,7 @@ open_window() { wglGraphicsStateGuardian *wglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, NULL); + wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, nullptr); wglgsg->choose_pixel_format(_fb_properties, false); _gsg = wglgsg; } else { @@ -358,7 +358,7 @@ setup_colormap(const PIXELFORMATDESCRIPTOR &pixelformat) { #ifdef NOTIFY_DEBUG // typedef enum {Software, MCD, ICD} OGLDriverType; -static char *OGLDrvStrings[3] = {"Software","MCD","ICD"}; +static const char *OGLDrvStrings[3] = {"Software","MCD","ICD"}; /** * Reports information about the selected pixel format descriptor, along with diff --git a/panda/src/windisplay/winDetectDx.h b/panda/src/windisplay/winDetectDx.h index 8a3a9c340e..e350c37564 100644 --- a/panda/src/windisplay/winDetectDx.h +++ b/panda/src/windisplay/winDetectDx.h @@ -72,8 +72,8 @@ static DWORD _GetLastError (char *message_prefix) { error = GetLastError ( ); if (FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), - (LPTSTR)&ptr,0, NULL)) { + nullptr, error, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), + (LPTSTR)&ptr,0, nullptr)) { cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; LocalFree( ptr ); } @@ -94,11 +94,11 @@ static DWORD print_GetLastError (char *message_prefix) error = GetLastError ( ); if (FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, error, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), (LPTSTR)&ptr, - 0, NULL)) + 0, nullptr)) { cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; LocalFree( ptr ); @@ -153,7 +153,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para window_height = 0; window_bits_per_pixel = 0; total_display_modes = 0; - display_mode_array = NULL; + display_mode_array = nullptr; minimum_width = display_search_parameters._minimum_width; minimum_height = display_search_parameters._minimum_height; @@ -195,7 +195,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para DIRECT_3D direct_3d; direct_3d = Direct3DCreate (D3D_SDK_VERSION); - if (direct_3d != NULL) { + if (direct_3d != nullptr) { DWORD flags; UINT adapter; D3DDEVTYPE device_type; @@ -471,15 +471,15 @@ static int get_display_information (DisplaySearchParameters &display_search_para WNDCLASSEX window_class = { sizeof (WNDCLASSEX), CS_CLASSDC, window_procedure, 0L, 0L, - GetModuleHandle(NULL), NULL, NULL, NULL, NULL, - "class_name", NULL + GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, + "class_name", nullptr }; RegisterClassEx (&window_class); HWND window_handle; - window_handle = CreateWindow ("class_name", "window_name", WS_DISABLED, 0, 0, width, height, (HWND) NULL, (HMENU) NULL, window_class.hInstance, NULL); - if (window_handle != NULL) { + window_handle = CreateWindow ("class_name", "window_name", WS_DISABLED, 0, 0, width, height, (HWND) nullptr, (HMENU) nullptr, window_class.hInstance, nullptr); + if (window_handle != nullptr) { ShowWindow (window_handle, SW_HIDE); DIRECT_3D_DEVICE direct_3d_device; @@ -538,7 +538,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture_array [total_textures], - NULL); + nullptr); if (texture_result == D3D_OK) { total_textures++; } diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index cf76e06296..973567a4aa 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -123,7 +123,7 @@ int update_cpu_frequency_function(int processor_number, DisplayInformation *disp } information_level = ProcessorInformation; - input_buffer = NULL; + input_buffer = nullptr; output_buffer = processor_power_information_array; input_buffer_size = 0; output_buffer_size = sizeof(PROCESSOR_POWER_INFORMATION) * MAXIMUM_PROCESSORS; @@ -162,7 +162,7 @@ count_number_of_cpus(DisplayInformation *display_information) { LPFN_GLPI glpi; glpi = (LPFN_GLPI)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation"); - if (glpi == NULL) { + if (glpi == nullptr) { windisplay_cat.info() << "GetLogicalProcessorInformation is not supported.\n"; return; @@ -170,17 +170,17 @@ count_number_of_cpus(DisplayInformation *display_information) { // Allocate a buffer to hold the result of the // GetLogicalProcessorInformation call. - PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = NULL; + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = nullptr; DWORD buffer_length = 0; DWORD rc = glpi(buffer, &buffer_length); while (!rc) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - if (buffer != NULL) { + if (buffer != nullptr) { PANDA_FREE_ARRAY(buffer); } buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)PANDA_MALLOC_ARRAY(buffer_length); - nassertv(buffer != NULL); + nassertv(buffer != nullptr); } else { windisplay_cat.info() << "GetLogicalProcessorInformation failed: " << GetLastError() @@ -225,13 +225,13 @@ WinGraphicsPipe() { _supported_types = OT_window | OT_fullscreen_window; HMODULE user32 = GetModuleHandleA("user32.dll"); - if (user32 != NULL) { + if (user32 != nullptr) { if (dpi_aware) { typedef HRESULT (WINAPI *PFN_SETPROCESSDPIAWARENESS)(Process_DPI_Awareness); PFN_SETPROCESSDPIAWARENESS pfnSetProcessDpiAwareness = (PFN_SETPROCESSDPIAWARENESS)GetProcAddress(user32, "SetProcessDpiAwarenessInternal"); - if (pfnSetProcessDpiAwareness == NULL) { + if (pfnSetProcessDpiAwareness == nullptr) { if (windisplay_cat.is_debug()) { windisplay_cat.debug() << "Unable to find SetProcessDpiAwareness in user32.dll.\n"; } @@ -261,9 +261,9 @@ WinGraphicsPipe() { windisplay_cat.debug() << "Using EnumDisplaySettings to fetch display information.\n"; } pvector display_modes; - DEVMODE dm = {0}; + DEVMODE dm{}; dm.dmSize = sizeof(dm); - for (int i = 0; EnumDisplaySettings(NULL, i, &dm) != 0; ++i) { + for (int i = 0; EnumDisplaySettings(nullptr, i, &dm) != 0; ++i) { DisplayMode mode; mode.width = dm.dmPelsWidth; mode.height = dm.dmPelsHeight; @@ -293,7 +293,7 @@ WinGraphicsPipe() { version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&version_info)) { if (windisplay_cat.is_info()) { - sprintf(string, "OS version: %d.%d.%d.%d\n", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwPlatformId, version_info.dwBuildNumber); + sprintf(string, "OS version: %lu.%lu.%lu.%lu\n", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwPlatformId, version_info.dwBuildNumber); windisplay_cat.info() << string; windisplay_cat.info() << " " << version_info.szCSDVersion << "\n"; } diff --git a/panda/src/windisplay/winGraphicsWindow.I b/panda/src/windisplay/winGraphicsWindow.I index 1a51d47988..9a873d9181 100644 --- a/panda/src/windisplay/winGraphicsWindow.I +++ b/panda/src/windisplay/winGraphicsWindow.I @@ -49,7 +49,7 @@ set_cursor_in_window() { INLINE void WinGraphicsWindow:: set_cursor_out_of_window() { if (_cursor_window == this) { - update_cursor_window(NULL); + update_cursor_window(nullptr); } } @@ -74,7 +74,7 @@ get_ime_hwnd() { if (_ime_active) return _ime_hWnd; else - return NULL; + return nullptr; } /** diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index f8fa283020..bd8244e880 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -44,9 +44,9 @@ TypeHandle WinGraphicsWindow::_type_handle; TypeHandle WinGraphicsWindow::WinWindowHandle::_type_handle; WinGraphicsWindow::WindowHandles WinGraphicsWindow::_window_handles; -WinGraphicsWindow *WinGraphicsWindow::_creating_window = NULL; +WinGraphicsWindow *WinGraphicsWindow::_creating_window = nullptr; -WinGraphicsWindow *WinGraphicsWindow::_cursor_window = NULL; +WinGraphicsWindow *WinGraphicsWindow::_cursor_window = nullptr; bool WinGraphicsWindow::_cursor_hidden = false; RECT WinGraphicsWindow::_mouse_unconfined_cliprect; @@ -69,9 +69,9 @@ static const char * const errorbox_title = "Panda3D Error"; // These static variables contain pointers to the touch input functions, which // are dynamically extracted from USER32.DLL -typedef WINUSERAPI BOOL (WINAPI *PFN_REGISTERTOUCHWINDOW)(IN HWND hWnd, IN ULONG ulFlags); -typedef WINUSERAPI BOOL (WINAPI *PFN_GETTOUCHINPUTINFO)(IN HTOUCHINPUT hTouchInput, IN UINT cInputs, OUT PTOUCHINPUT pInputs, IN int cbSize); -typedef WINUSERAPI BOOL (WINAPI *PFN_CLOSETOUCHINPUTHANDLE)(IN HTOUCHINPUT hTouchInput); +typedef BOOL (WINAPI *PFN_REGISTERTOUCHWINDOW)(IN HWND hWnd, IN ULONG ulFlags); +typedef BOOL (WINAPI *PFN_GETTOUCHINPUTINFO)(IN HTOUCHINPUT hTouchInput, IN UINT cInputs, OUT PTOUCHINPUT pInputs, IN int cbSize); +typedef BOOL (WINAPI *PFN_CLOSETOUCHINPUTHANDLE)(IN HTOUCHINPUT hTouchInput); static PFN_REGISTERTOUCHWINDOW pRegisterTouchWindow = 0; static PFN_GETTOUCHINPUTINFO pGetTouchInputInfo = 0; @@ -103,7 +103,7 @@ WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _rcontrol_down = false; _lalt_down = false; _ralt_down = false; - _hparent = NULL; + _hparent = nullptr; _num_touches = 0; } @@ -112,7 +112,7 @@ WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ WinGraphicsWindow:: ~WinGraphicsWindow() { - if (_window_handle != (WindowHandle *)NULL) { + if (_window_handle != nullptr) { DCAST(WinWindowHandle, _window_handle)->clear_window(); } } @@ -229,7 +229,7 @@ process_events() { // Handle all the messages on the queue in a row. Some of these might be // for another window, but they will get dispatched appropriately. - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { process_1_event(); } } @@ -292,7 +292,7 @@ set_properties_now(WindowProperties &properties) { _cursor = get_cursor(filename); if (_cursor == 0) { - _cursor = LoadCursor(NULL, IDC_ARROW); + _cursor = LoadCursor(nullptr, IDC_ARROW); } if (_cursor_window == this) { @@ -361,7 +361,7 @@ set_properties_now(WindowProperties &properties) { case WindowProperties::M_relative: // not implemented, treat as absolute if (_properties.get_mouse_mode() == WindowProperties::M_confined) { - ClipCursor(NULL); + ClipCursor(nullptr); windisplay_cat.info() << "Unconfining cursor from window\n"; } _properties.set_mouse_mode(WindowProperties::M_absolute); @@ -409,7 +409,7 @@ trigger_flip() { // Now that we've drawn or whatever, invalidate the rectangle so we won't // redraw again until we get the WM_PAINT message. - InvalidateRect(_hWnd, NULL, FALSE); + InvalidateRect(_hWnd, nullptr, FALSE); _got_expose_event = false; if (windisplay_cat.is_spam()) { @@ -449,7 +449,7 @@ open_window() { _cursor = get_cursor(_properties.get_cursor_filename()); } if (_cursor == 0) { - _cursor = LoadCursor(NULL, IDC_ARROW); + _cursor = LoadCursor(nullptr, IDC_ARROW); } bool want_foreground = (!_properties.has_foreground() || _properties.get_foreground()); bool want_minimized = (_properties.has_minimized() && _properties.get_minimized()) && !want_foreground; @@ -461,7 +461,7 @@ open_window() { // it gives us a handle. Warning: this is not thread safe! _creating_window = this; bool opened = open_graphic_window(is_fullscreen()); - _creating_window = (WinGraphicsWindow *)NULL; + _creating_window = nullptr; if (!opened) { return false; @@ -530,7 +530,7 @@ open_window() { _window_handle = new WinWindowHandle(this, *_window_handle); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } @@ -551,7 +551,7 @@ open_window() { } // Register for Win7 touch events. - if (pRegisterTouchWindow != NULL) { + if (pRegisterTouchWindow != nullptr) { pRegisterTouchWindow(_hWnd, 0); } @@ -579,7 +579,7 @@ initialize_input_devices() { add_input_device(device); // Get the number of devices. - if (GetRawInputDeviceList(NULL, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) { + if (GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) { return; } @@ -704,7 +704,7 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin, flags |= SWP_NOMOVE; } - SetWindowPos(_hWnd, NULL, x_origin, y_origin, + SetWindowPos(_hWnd, nullptr, x_origin, y_origin, view_rect.right - view_rect.left, view_rect.bottom - view_rect.top, flags); @@ -801,7 +801,7 @@ do_fullscreen_resize(int x_size, int y_size) { } // this causes WM_SIZE msg to be produced - SetWindowPos(_hWnd, NULL, 0,0, x_size, y_size, + SetWindowPos(_hWnd, nullptr, 0,0, x_size, y_size, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSENDCHANGING); int chg_result = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); @@ -1009,17 +1009,17 @@ open_graphic_window(bool fullscreen) { } const WindowClass &wclass = register_window_class(_properties); - HINSTANCE hinstance = GetModuleHandle(NULL); + HINSTANCE hinstance = GetModuleHandle(nullptr); - _hparent = NULL; + _hparent = nullptr; if (!fullscreen){ WindowHandle *window_handle = _properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { windisplay_cat.info() << "Got parent_window " << *window_handle << "\n"; WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { windisplay_cat.info() << "os_handle type " << os_handle->get_type() << "\n"; @@ -1034,7 +1034,7 @@ open_graphic_window(bool fullscreen) { } _parent_window_handle = window_handle; } else { - _parent_window_handle = NULL; + _parent_window_handle = nullptr; } if (!_hparent) { // This can be a regular window or a fullscreen window @@ -1042,7 +1042,7 @@ open_graphic_window(bool fullscreen) { metrics.x, metrics.y, metrics.width, metrics.height, - NULL, NULL, hinstance, 0); + nullptr, nullptr, hinstance, 0); } else { // This is a regular window with a parent int x_origin = 0; int y_origin = 0; @@ -1056,7 +1056,7 @@ open_graphic_window(bool fullscreen) { WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS , x_origin, y_origin, _properties.get_x_size(), _properties.get_y_size(), - _hparent, NULL, hinstance, 0); + _hparent, nullptr, hinstance, 0); if (_hWnd) { // join our keyboard state with the parents @@ -1151,7 +1151,7 @@ do_fullscreen_enable() { */ bool WinGraphicsWindow:: do_fullscreen_disable() { - int chg_result = ChangeDisplaySettings(NULL, 0x0); + int chg_result = ChangeDisplaySettings(nullptr, 0x0); if (chg_result != DISP_CHANGE_SUCCESSFUL) { windisplay_cat.warning() << "ChangeDisplaySettings failed to restore Windowed mode\n"; @@ -1247,13 +1247,13 @@ track_mouse_leaving(HWND hwnd) { */ void WinGraphicsWindow:: set_focus() { - if (SetFocus(_hWnd) == NULL && GetLastError() != 0) { + if (SetFocus(_hWnd) == nullptr && GetLastError() != 0) { // If the SetFocus() request failed, maybe we're running in the plugin // environment on Vista, with UAC enabled. In this case, we're not // allowed to assign focus to the Panda window for some stupid reason. So // instead, we have to ask the parent window (in the browser process) to // proxy our keyboard events for us. - if (_parent_window_handle != NULL && _window_handle != NULL) { + if (_parent_window_handle != nullptr && _window_handle != nullptr) { _parent_window_handle->request_keyboard_focus(_window_handle); } else { // Otherwise, something is wrong. @@ -1292,7 +1292,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { << msg << ", " << wparam << ", " << lparam << ")\n"; } WindowProperties properties; - int button = -1; switch (msg) { case WM_MOUSEMOVE: @@ -1457,7 +1456,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { windisplay_cat.debug() << "WM_WINDOWPOSCHANGED: " << hwnd << ", " << wparam << "\n"; } - if (_hWnd != NULL) { + if (_hWnd != nullptr) { handle_reshape(); } adjust_z_order(); @@ -1467,7 +1466,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // In response to WM_PAINT, we check to see if there are any update // regions at all; if there are, we declare the window exposed. This is // used to implement !_unexposed_draw. - if (GetUpdateRect(_hWnd, NULL, false)) { + if (GetUpdateRect(_hWnd, nullptr, false)) { if (windisplay_cat.is_spam()) { windisplay_cat.spam() << "Got update regions: " << this << "\n"; @@ -1716,10 +1715,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } if (lparam & GCS_COMPSTR) { - result_size = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, NULL, 0); + result_size = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, nullptr, 0); cursor_pos = result_size & 0xffff; - result_size = ImmGetCompositionStringW(hIMC, GCS_DELTASTART, NULL, 0); + result_size = ImmGetCompositionStringW(hIMC, GCS_DELTASTART, nullptr, 0); delta_start = result_size & 0xffff; result_size = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, ime_buffer, ime_buffer_size); size_t num_chars = result_size / sizeof(wchar_t); @@ -1864,14 +1863,14 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { HGLOBAL hglb; char *lptstr; - if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL)) { + if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(nullptr)) { // Maybe we should support CF_UNICODETEXT if it is available too? hglb = GetClipboardData(CF_TEXT); - if (hglb!=NULL) { + if (hglb!=nullptr) { lptstr = (char *) GlobalLock(hglb); - if (lptstr != NULL) { + if (lptstr != nullptr) { char *pChar; - for (pChar=lptstr; *pChar!=NULL; pChar++) { + for (pChar=lptstr; *pChar; pChar++) { _input_devices[0].keystroke((uchar)*pChar); } GlobalUnlock(hglb); @@ -2106,7 +2105,7 @@ static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } // The window wasn't in the map; we must be creating it right now. - if (_creating_window != (WinGraphicsWindow *)NULL) { + if (_creating_window != nullptr) { return _creating_window->window_proc(hwnd, msg, wparam, lparam); } @@ -2122,7 +2121,7 @@ void WinGraphicsWindow:: process_1_event() { MSG msg; - if (!GetMessage(&msg, NULL, 0, 0)) { + if (!GetMessage(&msg, nullptr, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn @@ -2156,16 +2155,16 @@ resend_lost_keypresses() { void WinGraphicsWindow:: update_cursor_window(WinGraphicsWindow *to_window) { bool hide_cursor = false; - if (to_window == (WinGraphicsWindow *)NULL) { + if (to_window == nullptr) { // We are leaving a graphics window; we should restore the Win2000 // effects. if (_got_saved_params) { - SystemParametersInfo(SPI_SETMOUSETRAILS, NULL, - (PVOID)_saved_mouse_trails, NULL); - SystemParametersInfo(SPI_SETCURSORSHADOW, NULL, - (PVOID)_saved_cursor_shadow, NULL); - SystemParametersInfo(SPI_SETMOUSEVANISH, NULL, - (PVOID)_saved_mouse_vanish, NULL); + SystemParametersInfo(SPI_SETMOUSETRAILS, 0, + (PVOID)_saved_mouse_trails, 0); + SystemParametersInfo(SPI_SETCURSORSHADOW, 0, + (PVOID)_saved_cursor_shadow, 0); + SystemParametersInfo(SPI_SETMOUSEVANISH, 0, + (PVOID)_saved_mouse_vanish, 0); _got_saved_params = false; } @@ -2179,17 +2178,17 @@ update_cursor_window(WinGraphicsWindow *to_window) { // These parameters are only defined for Win2000XP, but they should just // cause a silent error on earlier OS's, which is OK. if (!_got_saved_params) { - SystemParametersInfo(SPI_GETMOUSETRAILS, NULL, - &_saved_mouse_trails, NULL); - SystemParametersInfo(SPI_GETCURSORSHADOW, NULL, - &_saved_cursor_shadow, NULL); - SystemParametersInfo(SPI_GETMOUSEVANISH, NULL, - &_saved_mouse_vanish, NULL); + SystemParametersInfo(SPI_GETMOUSETRAILS, 0, + &_saved_mouse_trails, 0); + SystemParametersInfo(SPI_GETCURSORSHADOW, 0, + &_saved_cursor_shadow, 0); + SystemParametersInfo(SPI_GETMOUSEVANISH, 0, + &_saved_mouse_vanish, 0); _got_saved_params = true; - SystemParametersInfo(SPI_SETMOUSETRAILS, NULL, (PVOID)0, NULL); - SystemParametersInfo(SPI_SETCURSORSHADOW, NULL, (PVOID)false, NULL); - SystemParametersInfo(SPI_SETMOUSEVANISH, NULL, (PVOID)false, NULL); + SystemParametersInfo(SPI_SETMOUSETRAILS, 0, (PVOID)0, 0); + SystemParametersInfo(SPI_SETCURSORSHADOW, 0, (PVOID)false, 0); + SystemParametersInfo(SPI_SETMOUSEVANISH, 0, (PVOID)false, 0); } SetCursor(to_window->_cursor); @@ -2238,7 +2237,7 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, DEVMODE cur_dm; ZeroMemory(&cur_dm, sizeof(cur_dm)); cur_dm.dmSize = sizeof(cur_dm); - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &cur_dm); + EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &cur_dm); int modenum = 0; int saved_modenum = -1; @@ -2247,7 +2246,7 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - if (!EnumDisplaySettings(NULL, modenum, &dm)) { + if (!EnumDisplaySettings(nullptr, modenum, &dm)) { break; } @@ -2270,7 +2269,7 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - if (EnumDisplaySettings(NULL, saved_modenum, &dm)) { + if (EnumDisplaySettings(nullptr, saved_modenum, &dm)) { return true; } } @@ -2291,10 +2290,10 @@ show_error_message(DWORD message_id) { } FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, message_id, + nullptr, message_id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language (LPTSTR)&message_buffer, // the weird ptrptr->ptr cast is intentional, see FORMAT_MESSAGE_ALLOCATE_BUFFER - 1024, NULL); + 1024, nullptr); MessageBox(GetDesktopWindow(), message_buffer, _T(errorbox_title), MB_OK); windisplay_cat.fatal() << "System error msg: " << message_buffer << endl; LocalFree(message_buffer); @@ -2637,12 +2636,12 @@ handle_raw_input(HRAWINPUT hraw) { if (hraw == 0) { return; } - if (GetRawInputData(hraw, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) { + if (GetRawInputData(hraw, RID_INPUT, nullptr, &dwSize, sizeof(RAWINPUTHEADER)) == -1) { return; } lpb = (LPBYTE)alloca(sizeof(LPBYTE) * dwSize); - if (lpb == NULL) { + if (lpb == nullptr) { return; } @@ -2756,7 +2755,7 @@ get_icon(const Filename &filename) { Filename os = resolved.to_os_specific(); - HANDLE h = LoadImage(NULL, os.c_str(), + HANDLE h = LoadImage(nullptr, os.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE); if (h == 0) { windisplay_cat.warning() @@ -2804,7 +2803,7 @@ get_cursor(const Filename &filename) { Filename os = resolved.to_os_specific(); - HANDLE h = LoadImage(NULL, os.c_str(), + HANDLE h = LoadImage(nullptr, os.c_str(), IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE); if (h == 0) { windisplay_cat.warning() @@ -2826,7 +2825,7 @@ static HCURSOR get_cursor(const Filename &filename); const WinGraphicsWindow::WindowClass &WinGraphicsWindow:: register_window_class(const WindowProperties &props) { WindowClass wcreg(props); - wostringstream wclass_name; + std::wostringstream wclass_name; wclass_name << L"WinGraphicsWindow" << _window_class_index; wcreg._name = wclass_name.str(); @@ -2843,7 +2842,7 @@ register_window_class(const WindowProperties &props) { WNDCLASSW wc; - HINSTANCE instance = GetModuleHandle(NULL); + HINSTANCE instance = GetModuleHandle(nullptr); // Clear before filling in window structure! ZeroMemory(&wc, sizeof(wc)); @@ -2854,7 +2853,7 @@ register_window_class(const WindowProperties &props) { wc.hIcon = wclass._icon; wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = wclass._name.c_str(); if (!RegisterClassW(&wc)) { @@ -2883,7 +2882,7 @@ WinWindowHandle(WinGraphicsWindow *window, const WindowHandle ©) : */ void WinGraphicsWindow::WinWindowHandle:: clear_window() { - _window = NULL; + _window = nullptr; } /** @@ -2892,7 +2891,7 @@ clear_window() { */ void WinGraphicsWindow::WinWindowHandle:: receive_windows_message(unsigned int msg, int wparam, int lparam) { - if (_window != NULL) { + if (_window != nullptr) { _window->receive_windows_message(msg, wparam, lparam); } } @@ -2906,10 +2905,10 @@ void PrintErrorMessage(DWORD msgID) { msgID=GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL,msgID, + nullptr,msgID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language (LPTSTR) &pMessageBuffer, // the weird ptrptr->ptr cast is intentional, see FORMAT_MESSAGE_ALLOCATE_BUFFER - 1024, NULL); + 1024, nullptr); MessageBox(GetDesktopWindow(),pMessageBuffer,_T(errorbox_title),MB_OK); windisplay_cat.fatal() << "System error msg: " << pMessageBuffer << endl; LocalFree( pMessageBuffer ); @@ -2969,7 +2968,7 @@ void get_client_rect_screen(HWND hwnd, RECT *view_rect) { * */ void WinGraphicsWindow::add_window_proc( const GraphicsWindowProc* wnd_proc ){ - nassertv(wnd_proc != NULL); + nassertv(wnd_proc != nullptr); _window_proc_classes.insert( (GraphicsWindowProc*)wnd_proc ); } @@ -2978,7 +2977,7 @@ void WinGraphicsWindow::add_window_proc( const GraphicsWindowProc* wnd_proc ){ * */ void WinGraphicsWindow::remove_window_proc( const GraphicsWindowProc* wnd_proc ){ - nassertv(wnd_proc != NULL); + nassertv(wnd_proc != nullptr); _window_proc_classes.erase( (GraphicsWindowProc*)wnd_proc ); } diff --git a/panda/src/x11display/x11GraphicsPipe.I b/panda/src/x11display/x11GraphicsPipe.I index fb56700299..a516b2e6a2 100644 --- a/panda/src/x11display/x11GraphicsPipe.I +++ b/panda/src/x11display/x11GraphicsPipe.I @@ -62,7 +62,7 @@ get_hidden_cursor() { */ INLINE bool x11GraphicsPipe:: supports_relative_mouse() const { - return (_XF86DGADirectVideo != NULL); + return (_XF86DGADirectVideo != nullptr); } /** @@ -70,7 +70,7 @@ supports_relative_mouse() const { */ INLINE bool x11GraphicsPipe:: enable_relative_mouse() { - if (_XF86DGADirectVideo != NULL) { + if (_XF86DGADirectVideo != nullptr) { x11display_cat.info() << "Enabling relative mouse using XF86DGA extension\n"; _XF86DGADirectVideo(_display, _screen, XF86DGADirectMouse); return true; @@ -83,7 +83,7 @@ enable_relative_mouse() { */ INLINE void x11GraphicsPipe:: disable_relative_mouse() { - if (_XF86DGADirectVideo != NULL) { + if (_XF86DGADirectVideo != nullptr) { x11display_cat.info() << "Disabling relative mouse using XF86DGA extension\n"; _XF86DGADirectVideo(_display, _screen, 0); } diff --git a/panda/src/x11display/x11GraphicsPipe.cxx b/panda/src/x11display/x11GraphicsPipe.cxx index a0d4e8ffae..494da180da 100644 --- a/panda/src/x11display/x11GraphicsPipe.cxx +++ b/panda/src/x11display/x11GraphicsPipe.cxx @@ -36,7 +36,7 @@ x11GraphicsPipe:: x11GraphicsPipe(const string &display) : _have_xrandr(false), _xcursor_size(-1), - _XF86DGADirectVideo(NULL) { + _XF86DGADirectVideo(nullptr) { string display_spec = display; if (display_spec.empty()) { @@ -60,10 +60,10 @@ x11GraphicsPipe(const string &display) : _is_valid = false; _supported_types = OT_window | OT_buffer | OT_texture_buffer; - _display = NULL; + _display = nullptr; _screen = 0; - _root = (X11_Window)NULL; - _im = (XIM)NULL; + _root = (X11_Window)nullptr; + _im = (XIM)nullptr; _hidden_cursor = None; install_error_handlers(); @@ -82,7 +82,7 @@ x11GraphicsPipe(const string &display) : if (!XSupportsLocale()) { x11display_cat.warning() - << "X does not support locale " << setlocale(LC_ALL, NULL) << "\n"; + << "X does not support locale " << setlocale(LC_ALL, nullptr) << "\n"; } XSetLocaleModifiers(""); @@ -94,20 +94,20 @@ x11GraphicsPipe(const string &display) : // Dynamically load the xf86dga extension. void *xf86dga = dlopen("libXxf86dga.so.1", RTLD_NOW | RTLD_LOCAL); - if (xf86dga != NULL) { + if (xf86dga != nullptr) { pfn_XF86DGAQueryVersion _XF86DGAQueryVersion = (pfn_XF86DGAQueryVersion)dlsym(xf86dga, "XF86DGAQueryVersion"); _XF86DGADirectVideo = (pfn_XF86DGADirectVideo)dlsym(xf86dga, "XF86DGADirectVideo"); int major_ver, minor_ver; - if (_XF86DGAQueryVersion == NULL || _XF86DGADirectVideo == NULL) { + if (_XF86DGAQueryVersion == nullptr || _XF86DGADirectVideo == nullptr) { x11display_cat.warning() << "libXxf86dga.so.1 does not provide required functions; relative mouse mode will not work.\n"; } else if (!_XF86DGAQueryVersion(_display, &major_ver, &minor_ver)) { - _XF86DGADirectVideo = NULL; + _XF86DGADirectVideo = nullptr; } } else { - _XF86DGADirectVideo = NULL; + _XF86DGADirectVideo = nullptr; if (x11display_cat.is_debug()) { x11display_cat.debug() << "cannot dlopen libXxf86dga.so.1; cursor changing will not work.\n"; @@ -116,7 +116,7 @@ x11GraphicsPipe(const string &display) : // Dynamically load the XCursor extension. void *xcursor = dlopen("libXcursor.so.1", RTLD_NOW | RTLD_LOCAL); - if (xcursor != NULL) { + if (xcursor != nullptr) { pfn_XcursorGetDefaultSize _XcursorGetDefaultSize = (pfn_XcursorGetDefaultSize)dlsym(xcursor, "XcursorGetDefaultSize"); _XcursorXcFileLoadImages = (pfn_XcursorXcFileLoadImages)dlsym(xcursor, "XcursorXcFileLoadImages"); _XcursorImagesLoadCursor = (pfn_XcursorImagesLoadCursor)dlsym(xcursor, "XcursorImagesLoadCursor"); @@ -125,10 +125,10 @@ x11GraphicsPipe(const string &display) : _XcursorImageLoadCursor = (pfn_XcursorImageLoadCursor)dlsym(xcursor, "XcursorImageLoadCursor"); _XcursorImageDestroy = (pfn_XcursorImageDestroy)dlsym(xcursor, "XcursorImageDestroy"); - if (_XcursorGetDefaultSize == NULL || _XcursorXcFileLoadImages == NULL || - _XcursorImagesLoadCursor == NULL || _XcursorImagesDestroy == NULL || - _XcursorImageCreate == NULL || _XcursorImageLoadCursor == NULL || - _XcursorImageDestroy == NULL) { + if (_XcursorGetDefaultSize == nullptr || _XcursorXcFileLoadImages == nullptr || + _XcursorImagesLoadCursor == nullptr || _XcursorImagesDestroy == nullptr || + _XcursorImageCreate == nullptr || _XcursorImageLoadCursor == nullptr || + _XcursorImageDestroy == nullptr) { _xcursor_size = -1; x11display_cat.warning() << "libXcursor.so.1 does not provide required functions; cursor changing will not work.\n"; @@ -148,7 +148,7 @@ x11GraphicsPipe(const string &display) : // Dynamically load the XRandr extension. void *xrandr = dlopen("libXrandr.so.2", RTLD_NOW | RTLD_LOCAL); - if (xrandr != NULL) { + if (xrandr != nullptr) { pfn_XRRQueryExtension _XRRQueryExtension = (pfn_XRRQueryExtension)dlsym(xrandr, "XRRQueryExtension"); _XRRSizes = (pfn_XRRSizes)dlsym(xrandr, "XRRSizes"); _XRRRates = (pfn_XRRRates)dlsym(xrandr, "XRRRates"); @@ -156,9 +156,9 @@ x11GraphicsPipe(const string &display) : _XRRConfigCurrentConfiguration = (pfn_XRRConfigCurrentConfiguration)dlsym(xrandr, "XRRConfigCurrentConfiguration"); _XRRSetScreenConfig = (pfn_XRRSetScreenConfig)dlsym(xrandr, "XRRSetScreenConfig"); - if (_XRRQueryExtension == NULL || _XRRSizes == NULL || _XRRRates == NULL || - _XRRGetScreenInfo == NULL || _XRRConfigCurrentConfiguration == NULL || - _XRRSetScreenConfig == NULL) { + if (_XRRQueryExtension == nullptr || _XRRSizes == nullptr || _XRRRates == nullptr || + _XRRGetScreenInfo == nullptr || _XRRConfigCurrentConfiguration == nullptr || + _XRRSetScreenConfig == nullptr) { _have_xrandr = false; x11display_cat.warning() << "libXrandr.so.2 does not provide required functions; resolution setting will not work.\n"; @@ -204,8 +204,8 @@ x11GraphicsPipe(const string &display) : } // Connect to an input method for supporting international text entry. - _im = XOpenIM(_display, NULL, NULL, NULL); - if (_im == (XIM)NULL) { + _im = XOpenIM(_display, nullptr, nullptr, nullptr); + if (_im == (XIM)nullptr) { x11display_cat.warning() << "Couldn't open input method.\n"; } diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 0a1539bd42..5fb290e315 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -105,9 +105,9 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, DCAST_INTO_V(x11_pipe, _pipe); _display = x11_pipe->get_display(); _screen = x11_pipe->get_screen(); - _xwindow = (X11_Window)NULL; - _ic = (XIC)NULL; - _visual_info = NULL; + _xwindow = (X11_Window)nullptr; + _ic = (XIC)nullptr; + _visual_info = nullptr; _orig_size_id = -1; if (x11_pipe->_have_xrandr) { @@ -189,7 +189,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -220,7 +220,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void x11GraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -489,7 +489,7 @@ process_events() { */ void x11GraphicsWindow:: set_properties_now(WindowProperties &properties) { - if (_pipe == (GraphicsPipe *)NULL) { + if (_pipe == nullptr) { // If the pipe is null, we're probably closing down. GraphicsWindow::set_properties_now(properties); return; @@ -820,18 +820,18 @@ mouse_mode_relative() { */ void x11GraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { _gsg.clear(); } - if (_ic != (XIC)NULL) { + if (_ic != (XIC)nullptr) { XDestroyIC(_ic); - _ic = (XIC)NULL; + _ic = (XIC)nullptr; } - if (_xwindow != (X11_Window)NULL) { + if (_xwindow != (X11_Window)nullptr) { XDestroyWindow(_display, _xwindow); - _xwindow = (X11_Window)NULL; + _xwindow = (X11_Window)nullptr; // This may be necessary if we just closed the last X window in an // application, so the server hears the close request. @@ -842,7 +842,7 @@ close_window() { // typecast! if (_orig_size_id != (SizeID) -1) { X11_Window root; - if (_pipe != NULL) { + if (_pipe != nullptr) { x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); root = x11_pipe->get_root(); @@ -865,7 +865,7 @@ close_window() { */ bool x11GraphicsWindow:: open_window() { - if (_visual_info == NULL) { + if (_visual_info == nullptr) { // No X visual for this fbconfig; how can we open the window? x11display_cat.error() << "No X visual: cannot open window.\n"; @@ -912,11 +912,11 @@ open_window() { X11_Window parent_window = x11_pipe->get_root(); WindowHandle *window_handle = _properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { x11display_cat.info() << "Got parent_window " << *window_handle << "\n"; WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { x11display_cat.info() << "os_handle type " << os_handle->get_type() << "\n"; @@ -973,13 +973,13 @@ open_window() { // can wait until we have an X server that actually supports these to test // it on. XIM im = x11_pipe->get_im(); - _ic = NULL; + _ic = nullptr; if (im) { _ic = XCreateIC (im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - (void*)NULL); - if (_ic == (XIC)NULL) { + nullptr); + if (_ic == (XIC)nullptr) { x11display_cat.warning() << "Couldn't create input context.\n"; } @@ -1009,7 +1009,7 @@ open_window() { _window_handle = NativeWindowHandle::make_x11(_xwindow); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } @@ -1033,7 +1033,7 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // Name the window if there is a name XTextProperty window_name; - XTextProperty *window_name_p = (XTextProperty *)NULL; + XTextProperty *window_name_p = nullptr; if (properties.has_title()) { const char *name = properties.get_title().c_str(); if (XStringListToTextProperty((char **)&name, 1, &window_name) != 0) { @@ -1043,10 +1043,10 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // The size hints request a window of a particular size andor a particular // placement onscreen. - XSizeHints *size_hints_p = NULL; + XSizeHints *size_hints_p = nullptr; if (properties.has_origin() || properties.has_size()) { size_hints_p = XAllocSizeHints(); - if (size_hints_p != (XSizeHints *)NULL) { + if (size_hints_p != nullptr) { if (properties.has_origin()) { if (_properties.get_fullscreen()) { size_hints_p->x = 0; @@ -1076,9 +1076,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // The window manager hints include requests to the window manager other // than those specific to window geometry. - XWMHints *wm_hints_p = NULL; + XWMHints *wm_hints_p = nullptr; wm_hints_p = XAllocWMHints(); - if (wm_hints_p != (XWMHints *)NULL) { + if (wm_hints_p != nullptr) { if (properties.has_minimized() && properties.get_minimized()) { wm_hints_p->initial_state = IconicState; } else { @@ -1135,7 +1135,7 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // For other users, we'll totally punt and just set the window's Class to // "Undecorated", and let the user configure hisher window manager not to // put a border around windows of this class. - XClassHint *class_hints_p = NULL; + XClassHint *class_hints_p = nullptr; if (!x_wm_class.empty()) { // Unless the user wanted to use his own WM_CLASS, of course. class_hints_p = XAllocClassHint(); @@ -1226,15 +1226,15 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { } XSetWMProperties(_display, _xwindow, window_name_p, window_name_p, - NULL, 0, size_hints_p, wm_hints_p, class_hints_p); + nullptr, 0, size_hints_p, wm_hints_p, class_hints_p); - if (size_hints_p != (XSizeHints *)NULL) { + if (size_hints_p != nullptr) { XFree(size_hints_p); } - if (wm_hints_p != (XWMHints *)NULL) { + if (wm_hints_p != nullptr) { XFree(wm_hints_p); } - if (class_hints_p != (XClassHint *)NULL) { + if (class_hints_p != nullptr) { XFree(class_hints_p); } @@ -1417,7 +1417,7 @@ handle_keystroke(XKeyEvent &event) { static const int buffer_size = 256; wchar_t buffer[buffer_size]; Status status; - int len = XwcLookupString(_ic, &event, buffer, buffer_size, NULL, + int len = XwcLookupString(_ic, &event, buffer, buffer_size, nullptr, &status); if (status == XBufferOverflow) { x11display_cat.error() @@ -2133,7 +2133,7 @@ get_cursor(const Filename &filename) { // Open the file through the virtual file system. istream *str = vfs->open_read_file(resolved, true); - if (str == NULL) { + if (str == nullptr) { x11display_cat.warning() << "Could not open cursor file " << filename << "\n"; return None; @@ -2161,7 +2161,7 @@ get_cursor(const Filename &filename) { xcfile.seek = &xcursor_seek; XcursorImages *images = x11_pipe->_XcursorXcFileLoadImages(&xcfile, x11_pipe->_xcursor_size); - if (images != NULL) { + if (images != nullptr) { h = x11_pipe->_XcursorImagesLoadCursor(_display, images); x11_pipe->_XcursorImagesDestroy(images); } @@ -2221,13 +2221,13 @@ read_ico(istream &ico) { size_t colorCount, bitsPerPixel; IcoHeader header; IcoInfoHeader infoHeader; - IcoEntry *entries = NULL; - IcoColor color, *palette = NULL; + IcoEntry *entries = nullptr; + IcoColor color, *palette = nullptr; size_t xorBmpSize, andBmpSize; char *curXor, *curAnd; - char *xorBmp = NULL, *andBmp = NULL; - XcursorImage *image = NULL; + char *xorBmp = nullptr, *andBmp = nullptr; + XcursorImage *image = nullptr; X11_Cursor ret = None; int def_size = x11_pipe->_xcursor_size; @@ -2273,7 +2273,7 @@ read_ico(istream &ico) { size_t num_pixels = (size_t)img.get_x_size() * (size_t)img.get_y_size(); unsigned int *dest = image->pixels; - if (alpha != NULL) { + if (alpha != nullptr) { for (size_t p = 0; p < num_pixels; ++p) { *dest++ = (*alpha << 24U) | (ptr->r << 16U) | (ptr->g << 8U) | (ptr->b); ++ptr; diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index fb383a1b7f..4694e89217 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -57,7 +57,7 @@ typedef pvector BoneWeightList; AssimpLoader:: AssimpLoader() : _error (false), - _geoms (NULL) { + _geoms (nullptr) { PandaLogger::set_default(); _importer.SetIOHandler(new PandaIOSystem); @@ -82,11 +82,11 @@ get_extensions(string &ext) const { // The format is like: *.mdc;*.mdl;*.mesh.xml;*.mot char *sub = strtok(aexts.data, ";"); - while (sub != NULL) { + while (sub != nullptr) { ext += sub + 2; - sub = strtok(NULL, ";"); + sub = strtok(nullptr, ";"); - if (sub != NULL) { + if (sub != nullptr) { ext += ' '; } } @@ -102,7 +102,7 @@ read(const Filename &filename) { // I really don't know why we need to flip the winding order, but otherwise // the models I tested with are showing inside out. _scene = _importer.ReadFile(_filename.c_str(), aiProcess_Triangulate | aiProcess_GenUVCoords | aiProcess_FlipWindingOrder); - if (_scene == NULL) { + if (_scene == nullptr) { _error = true; return false; } @@ -117,7 +117,7 @@ read(const Filename &filename) { */ void AssimpLoader:: build_graph() { - nassertv(_scene != NULL); // read() must be called first + nassertv(_scene != nullptr); // read() must be called first nassertv(!_error); // and have succeeded // Protect the import process @@ -145,7 +145,7 @@ build_graph() { } // And now the node structure. - if (_scene->mRootNode != NULL) { + if (_scene->mRootNode != nullptr) { load_node(*_scene->mRootNode, _root); } @@ -178,7 +178,7 @@ find_node(const aiNode &root, const aiString &name) { } } - return NULL; + return nullptr; } /** @@ -215,7 +215,7 @@ load_texture(size_t index) { if (img.read(str, "", ftype)) { ptex->load(img); } else { - ptex = NULL; + ptex = nullptr; } } } else { @@ -255,7 +255,7 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur aiTextureMapMode mapmode; for (size_t i = 0; i < mat.GetTextureCount(ttype); ++i) { - mat.GetTexture(ttype, i, &path, &mapping, NULL, &blend, &op, &mapmode); + mat.GetTexture(ttype, i, &path, &mapping, nullptr, &blend, &op, &mapmode); if (AI_SUCCESS != mat.Get(AI_MATKEY_UVWSRC(ttype, i), uvindex)) { // If there's no texture coordinate set for this texture, assume that @@ -270,12 +270,12 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur if (uvindex > 0) { stage->set_texcoord_name(InternalName::get_texcoord_name(str.str())); } - PT(Texture) ptex = NULL; + PT(Texture) ptex = nullptr; // I'm not sure if this is the right way to handle it, as I couldn't find // much information on embedded textures. if (path.data[0] == '*') { - long num = strtol(path.data + 1, NULL, 10); + long num = strtol(path.data + 1, nullptr, 10); ptex = _textures[num]; } else if (path.length > 0) { @@ -308,7 +308,7 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur ptex = TexturePool::load_texture(fn); } - if (ptex != NULL) { + if (ptex != nullptr) { tattr = DCAST(TextureAttrib, tattr->add_on_stage(stage, ptex)); } } @@ -424,7 +424,7 @@ create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *pare PT(AnimChannelMatrixXfmTable) group = new AnimChannelMatrixXfmTable(parent, node.mName.C_Str()); // See if there is a channel for this node - aiNodeAnim *node_anim = NULL; + aiNodeAnim *node_anim = nullptr; for (size_t i = 0; i < anim.mNumChannels; ++i) { if (anim.mChannels[i]->mNodeName == node.mName) { node_anim = anim.mChannels[i]; @@ -502,7 +502,7 @@ load_mesh(size_t index) { const aiMesh &mesh = *_scene->mMeshes[index]; // Check if we need to make a Character - PT(Character) character = NULL; + PT(Character) character = nullptr; if (mesh.HasBones()) { assimp_cat.debug() << "Creating character for " << mesh.mName.C_Str() << "\n"; @@ -544,7 +544,7 @@ load_mesh(size_t index) { for (size_t i = 0; i < mesh.mNumBones; ++i) { const aiBone &bone = *mesh.mBones[i]; CharacterJoint *joint = character->find_joint(bone.mName.C_Str()); - if (joint == NULL) { + if (joint == nullptr) { assimp_cat.debug() << "Could not find joint for bone: " << bone.mName.C_Str() << "\n"; continue; diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.cxx b/pandatool/src/assimp/loaderFileTypeAssimp.cxx index b4a667d5fe..3f344b2674 100644 --- a/pandatool/src/assimp/loaderFileTypeAssimp.cxx +++ b/pandatool/src/assimp/loaderFileTypeAssimp.cxx @@ -29,7 +29,7 @@ LoaderFileTypeAssimp() : _loader(new AssimpLoader) { */ LoaderFileTypeAssimp:: ~LoaderFileTypeAssimp() { - if (_loader != NULL) { + if (_loader != nullptr) { delete _loader; } } @@ -81,7 +81,7 @@ load_file(const Filename &path, const LoaderOptions &options, << "Reading " << path << "\n"; if (!_loader->read(path)) { - return NULL; + return nullptr; } _loader->build_graph(); diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx index d64b52466f..ff400bd285 100644 --- a/pandatool/src/assimp/pandaIOSystem.cxx +++ b/pandatool/src/assimp/pandaIOSystem.cxx @@ -73,13 +73,13 @@ Open(const char *file, const char *mode) { if (mode[0] == 'r') { istream *stream = _vfs->open_read_file(file, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } return new PandaIOStream(*stream); } else { - nassertr(false, NULL); // Not implemented on purpose. - return NULL; + nassertr(false, nullptr); // Not implemented on purpose. + return nullptr; } } diff --git a/pandatool/src/assimp/pandaLogger.cxx b/pandatool/src/assimp/pandaLogger.cxx index cab31e1c06..b6432e132e 100644 --- a/pandatool/src/assimp/pandaLogger.cxx +++ b/pandatool/src/assimp/pandaLogger.cxx @@ -15,7 +15,7 @@ #include "DefaultLogger.hpp" -PandaLogger *PandaLogger::_ptr = NULL; +PandaLogger *PandaLogger::_ptr = nullptr; /** * Makes sure there's a global PandaLogger object and makes sure that it is @@ -23,7 +23,7 @@ PandaLogger *PandaLogger::_ptr = NULL; */ void PandaLogger:: set_default() { - if (_ptr == NULL) { + if (_ptr == nullptr) { _ptr = new PandaLogger; } if (_ptr != Assimp::DefaultLogger::get()) { diff --git a/pandatool/src/bam/bamInfo.cxx b/pandatool/src/bam/bamInfo.cxx index 44d015c2fe..bda00908a5 100644 --- a/pandatool/src/bam/bamInfo.cxx +++ b/pandatool/src/bam/bamInfo.cxx @@ -132,7 +132,7 @@ get_info(const Filename &filename) { Objects objects; TypedWritable *object = bam_file.read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's a cache data file; in this case, we output the @@ -142,8 +142,8 @@ get_info(const Filename &filename) { object = bam_file.read_object(); } - while (object != (TypedWritable *)NULL || !bam_file.is_eof()) { - if (object != (TypedWritable *)NULL) { + while (object != nullptr || !bam_file.is_eof()) { + if (object != nullptr) { objects.push_back(object); } object = bam_file.read_object(); @@ -271,7 +271,7 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { */ void BamInfo:: describe_general_object(TypedWritable *object) { - nassertv(object != (TypedWritable *)NULL); + nassertv(object != nullptr); nout << " " << object->get_type() << "\n"; } diff --git a/pandatool/src/bam/bamToEgg.cxx b/pandatool/src/bam/bamToEgg.cxx index 7f70255ce9..96aa14e449 100644 --- a/pandatool/src/bam/bamToEgg.cxx +++ b/pandatool/src/bam/bamToEgg.cxx @@ -59,7 +59,7 @@ run() { Objects objects; TypedWritable *object = bam_file.read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's really a cache data file and not a true bam file; @@ -68,10 +68,10 @@ run() { object = bam_file.read_object(); } - while (object != (TypedWritable *)NULL || !bam_file.is_eof()) { - if (object != (TypedWritable *)NULL) { + while (object != nullptr || !bam_file.is_eof()) { + if (object != nullptr) { ReferenceCount *ref_ptr = object->as_reference_count(); - if (ref_ptr != NULL) { + if (ref_ptr != nullptr) { ref_ptr->ref(); } objects.push_back(object); diff --git a/pandatool/src/bam/eggToBam.cxx b/pandatool/src/bam/eggToBam.cxx index f6c9bf4b52..7522a70cc6 100644 --- a/pandatool/src/bam/eggToBam.cxx +++ b/pandatool/src/bam/eggToBam.cxx @@ -80,7 +80,7 @@ EggToBam() : "egg geometry tagged as \"hidden\" will be removed from the final " "scene graph; otherwise, it will be preserved (but stashed). The " "default is nonzero, to remove it.", - &EggToBam::dispatch_int, NULL, &_egg_suppress_hidden); + &EggToBam::dispatch_int, nullptr, &_egg_suppress_hidden); add_option ("ls", "", 0, @@ -185,7 +185,7 @@ EggToBam() : "Set it to 'default' to use whatever is specified by the Config.prc " "file. This is a global setting only; individual texture quality " "settings appearing within the egg file will override this.", - &EggToBam::dispatch_string, NULL, &_ctex_quality); + &EggToBam::dispatch_string, nullptr, &_ctex_quality); add_option ("load-display", "display name", 0, @@ -197,7 +197,7 @@ EggToBam() : "Panda can compress textures without loading a display module." #endif // HAVE_SQUISH , - &EggToBam::dispatch_string, NULL, &_load_display); + &EggToBam::dispatch_string, nullptr, &_load_display); redescribe_option ("cs", @@ -257,7 +257,7 @@ run() { } PT(PandaNode) root = load_egg_data(_data); - if (root == (PandaNode *)NULL) { + if (root == nullptr) { nout << "Unable to build scene graph from egg file.\n"; exit(1); } @@ -385,7 +385,7 @@ collect_textures(PandaNode *node) { void EggToBam:: collect_textures(const RenderState *state) { const TextureAttrib *tex_attrib = DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_type())); - if (tex_attrib != (TextureAttrib *)NULL) { + if (tex_attrib != nullptr) { int num_on_stages = tex_attrib->get_num_on_stages(); for (int i = 0; i < num_on_stages; ++i) { _textures.insert(tex_attrib->get_on_texture(tex_attrib->get_on_stage(i))); @@ -448,7 +448,7 @@ make_buffer() { GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); _pipe = selection->make_default_pipe(); - if (_pipe == (GraphicsPipe *)NULL) { + if (_pipe == nullptr) { nout << "Unable to create graphics pipe.\n"; return false; } @@ -473,7 +473,7 @@ make_buffer() { fbprops, winprops, GraphicsPipe::BF_fb_props_optional); _engine->open_windows(); - if (_buffer == (GraphicsOutput *)NULL || !_buffer->is_valid()) { + if (_buffer == nullptr || !_buffer->is_valid()) { nout << "Unable to create graphics window.\n"; return false; } diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx index 4db96663ca..538022bfbc 100644 --- a/pandatool/src/bam/ptsToBam.cxx +++ b/pandatool/src/bam/ptsToBam.cxx @@ -49,7 +49,7 @@ PtsToBam() : WithOutputFile(true, false, true) "Decimates the point cloud by the indicated divisor. The number of points\n" "added is 1/divisor; numbers larger than 1.0 mean correspondingly fewer\n" "points.", - &PtsToBam::dispatch_double, NULL, &_decimate_divisor); + &PtsToBam::dispatch_double, nullptr, &_decimate_divisor); _decimate_divisor = 1.0; } @@ -77,7 +77,7 @@ run() { _decimated_point_number = 0.0; _num_vdatas = 0; string line; - while (getline(pts, line)) { + while (std::getline(pts, line)) { process_line(line); } close_vertex_data(); @@ -132,7 +132,7 @@ process_line(const string &line) { _line_number++; if (_line_number % 1000000 == 0) { - cerr << "." << flush; + std::cerr << "." << std::flush; } if (line.empty() || !isdigit(line[0])) { @@ -172,7 +172,7 @@ process_line(const string &line) { */ void PtsToBam:: add_point(const vector_string &words) { - if (_data == NULL || _data->get_num_rows() >= egg_max_vertices) { + if (_data == nullptr || _data->get_num_rows() >= egg_max_vertices) { open_vertex_data(); } @@ -190,7 +190,7 @@ add_point(const vector_string &words) { */ void PtsToBam:: open_vertex_data() { - if (_data != (GeomVertexData *)NULL) { + if (_data != nullptr) { close_vertex_data(); } CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3(); @@ -203,7 +203,7 @@ open_vertex_data() { */ void PtsToBam:: close_vertex_data() { - if (_data == NULL) { + if (_data == nullptr) { return; } @@ -225,7 +225,7 @@ close_vertex_data() { _gnode->add_geom(geom); - _data = NULL; + _data = nullptr; } int main(int argc, char *argv[]) { diff --git a/pandatool/src/converter/eggToSomethingConverter.I b/pandatool/src/converter/eggToSomethingConverter.I index 5e80c2cad8..5432082413 100644 --- a/pandatool/src/converter/eggToSomethingConverter.I +++ b/pandatool/src/converter/eggToSomethingConverter.I @@ -34,7 +34,7 @@ had_error() const { */ INLINE void EggToSomethingConverter:: clear_egg_data() { - set_egg_data((EggData *)NULL); + set_egg_data(nullptr); } /** diff --git a/pandatool/src/converter/eggToSomethingConverter.cxx b/pandatool/src/converter/eggToSomethingConverter.cxx index f786c81f00..1e1629fe1b 100644 --- a/pandatool/src/converter/eggToSomethingConverter.cxx +++ b/pandatool/src/converter/eggToSomethingConverter.cxx @@ -20,7 +20,7 @@ */ EggToSomethingConverter:: EggToSomethingConverter() { - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } @@ -29,7 +29,7 @@ EggToSomethingConverter() { */ EggToSomethingConverter:: EggToSomethingConverter(const EggToSomethingConverter ©) { - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } diff --git a/pandatool/src/converter/somethingToEggConverter.I b/pandatool/src/converter/somethingToEggConverter.I index 42e9f4b2cf..a0259bc13d 100644 --- a/pandatool/src/converter/somethingToEggConverter.I +++ b/pandatool/src/converter/somethingToEggConverter.I @@ -370,7 +370,7 @@ get_merge_externals() const { */ INLINE void SomethingToEggConverter:: clear_egg_data() { - set_egg_data((EggData *)NULL); + set_egg_data(nullptr); } /** diff --git a/pandatool/src/converter/somethingToEggConverter.cxx b/pandatool/src/converter/somethingToEggConverter.cxx index fd5a17abf7..58c914b7f5 100644 --- a/pandatool/src/converter/somethingToEggConverter.cxx +++ b/pandatool/src/converter/somethingToEggConverter.cxx @@ -33,7 +33,7 @@ SomethingToEggConverter() { _output_frame_rate = 0.0; _control_flags = 0; _merge_externals = false; - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } @@ -46,7 +46,7 @@ SomethingToEggConverter(const SomethingToEggConverter ©) : _path_replace(copy._path_replace), _merge_externals(copy._merge_externals) { - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } @@ -116,7 +116,7 @@ get_input_units() { */ PT(PandaNode) SomethingToEggConverter:: convert_to_node(const LoaderOptions &options, const Filename &filename) { - return NULL; + return nullptr; } /** diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index 1b8b43449a..cc970748a0 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -26,8 +26,8 @@ CVSCopy() { _key_filename = "Sources.pp"; _cvs_binary = "cvs"; _user_aborted = false; - _model_dir = (CVSSourceDirectory *)NULL; - _map_dir = (CVSSourceDirectory *)NULL; + _model_dir = nullptr; + _map_dir = nullptr; clear_runlines(); add_runline("[opts] file [file ... ]"); @@ -73,7 +73,7 @@ CVSCopy() { "is the ppremake convention, \"Sources.pp\". Other likely candidates " "are \"CVS\" to search a CVS hierarchy, or \".\" to include " "all subdirectories indiscriminately.", - &CVSCopy::dispatch_filename, NULL, &_key_filename); + &CVSCopy::dispatch_filename, nullptr, &_key_filename); add_option ("nc", "", 80, @@ -85,7 +85,7 @@ CVSCopy() { ("cvs", "cvs_binary", 80, "Specify how to run the cvs program for adding newly-created files. " "The default is simply \"cvs\".", - &CVSCopy::dispatch_string, NULL, &_cvs_binary); + &CVSCopy::dispatch_string, nullptr, &_cvs_binary); } /** @@ -212,7 +212,7 @@ post_command_line() { } _model_dir = _tree.find_directory(_model_dirname); - if (_model_dir == (CVSSourceDirectory *)NULL) { + if (_model_dir == nullptr) { if (_got_model_dirname) { nout << "Warning: model directory " << _model_dirname << " is not within the source hierarchy.\n"; @@ -222,7 +222,7 @@ post_command_line() { if (_got_map_dirname) { _map_dir = _tree.find_directory(_map_dirname); - if (_map_dir == (CVSSourceDirectory *)NULL) { + if (_map_dir == nullptr) { nout << "Warning: map directory " << _map_dirname << " is not within the source hierarchy.\n"; } @@ -230,7 +230,7 @@ post_command_line() { } else { _map_dir = _tree.find_relpath("src/maps"); - if (_map_dir == (CVSSourceDirectory *)NULL) { + if (_map_dir == nullptr) { nout << "Warning: no directory " << _tree.get_root_dirname() << "/src/maps.\n"; _map_dir = _model_dir; @@ -264,7 +264,7 @@ verify_binary_file(Filename source, Filename dest) { source.set_binary(); dest.set_binary(); - ifstream s, d; + std::ifstream s, d; if (!source.open_read(s)) { return false; } @@ -313,8 +313,8 @@ copy_binary_file(Filename source, Filename dest) { source.set_binary(); dest.set_binary(); - ifstream in; - ofstream out; + std::ifstream in; + std::ofstream out; if (!source.open_read(in)) { nout << "Cannot read " << source << "\n"; return false; @@ -475,11 +475,11 @@ scan_for_root(const string &dirname) { */ string CVSCopy:: prompt(const string &message) { - nout << flush; + nout << std::flush; while (true) { - cerr << message << flush; - string response; - getline(cin, response); + std::cerr << message << std::flush; + std::string response; + std::getline(std::cin, response); // Remove leading and trailing whitespace. size_t p = 0; diff --git a/pandatool/src/cvscopy/cvsSourceDirectory.cxx b/pandatool/src/cvscopy/cvsSourceDirectory.cxx index 02e6a9ced1..9ccacc3afd 100644 --- a/pandatool/src/cvscopy/cvsSourceDirectory.cxx +++ b/pandatool/src/cvscopy/cvsSourceDirectory.cxx @@ -27,7 +27,7 @@ CVSSourceDirectory(CVSSourceTree *tree, CVSSourceDirectory *parent, _parent(parent), _dirname(dirname) { - if (_parent == (CVSSourceDirectory *)NULL) { + if (_parent == nullptr) { _depth = 0; } else { _depth = _parent->_depth + 1; @@ -58,7 +58,7 @@ get_dirname() const { */ Filename CVSSourceDirectory:: get_fullpath() const { - if (_parent == (CVSSourceDirectory *)NULL) { + if (_parent == nullptr) { return _tree->get_root_fullpath(); } return Filename(_parent->get_fullpath(), _dirname); @@ -70,7 +70,7 @@ get_fullpath() const { */ Filename CVSSourceDirectory:: get_path() const { - if (_parent == (CVSSourceDirectory *)NULL) { + if (_parent == nullptr) { return _dirname; } return Filename(_parent->get_path(), _dirname); @@ -93,13 +93,13 @@ get_rel_to(const CVSSourceDirectory *other) const { while (a->_depth > b->_depth) { prefix += "../"; a = a->_parent; - nassertr(a != (CVSSourceDirectory *)NULL, string()); + nassertr(a != nullptr, string()); } while (b->_depth > a->_depth) { postfix = b->_dirname + "/" + postfix; b = b->_parent; - nassertr(b != (CVSSourceDirectory *)NULL, string()); + nassertr(b != nullptr, string()); } while (a != b) { @@ -107,8 +107,8 @@ get_rel_to(const CVSSourceDirectory *other) const { postfix = b->_dirname + "/" + postfix; a = a->_parent; b = b->_parent; - nassertr(a != (CVSSourceDirectory *)NULL, string()); - nassertr(b != (CVSSourceDirectory *)NULL, string()); + nassertr(a != nullptr, string()); + nassertr(b != nullptr, string()); } string result = prefix + postfix; @@ -129,7 +129,7 @@ get_num_children() const { */ CVSSourceDirectory *CVSSourceDirectory:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -154,11 +154,11 @@ find_relpath(const string &relpath) { return find_relpath(rest); } else if (first == "..") { - if (_parent != NULL) { + if (_parent != nullptr) { return _parent->find_relpath(rest); } // Tried to back out past the root directory. - return (CVSSourceDirectory *)NULL; + return nullptr; } // Check for a child with the name indicated by first. @@ -170,7 +170,7 @@ find_relpath(const string &relpath) { } // No match. - return (CVSSourceDirectory *)NULL; + return nullptr; } /** @@ -186,12 +186,12 @@ find_dirname(const string &dirname) { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { CVSSourceDirectory *result = (*ci)->find_dirname(dirname); - if (result != (CVSSourceDirectory *)NULL) { + if (result != nullptr) { return result; } } - return (CVSSourceDirectory *)NULL; + return nullptr; } /** diff --git a/pandatool/src/cvscopy/cvsSourceTree.cxx b/pandatool/src/cvscopy/cvsSourceTree.cxx index 5fea69e430..69b483fa3c 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.cxx +++ b/pandatool/src/cvscopy/cvsSourceTree.cxx @@ -36,7 +36,7 @@ Filename CVSSourceTree::_start_fullpath; */ CVSSourceTree:: CVSSourceTree() { - _root = (CVSSourceDirectory *)NULL; + _root = nullptr; _got_root_fullpath = false; } @@ -45,7 +45,7 @@ CVSSourceTree() { */ CVSSourceTree:: ~CVSSourceTree() { - if (_root != (CVSSourceDirectory *)NULL) { + if (_root != nullptr) { delete _root; } } @@ -67,9 +67,9 @@ set_root(const Filename &root_path) { */ bool CVSSourceTree:: scan(const Filename &key_filename) { - nassertr(_root == (CVSSourceDirectory *)NULL, false); + nassertr(_root == nullptr, false); Filename root_fullpath = get_root_fullpath(); - _root = new CVSSourceDirectory(this, NULL, root_fullpath.get_basename()); + _root = new CVSSourceDirectory(this, nullptr, root_fullpath.get_basename()); return _root->scan(_path, key_filename); } @@ -95,7 +95,7 @@ find_directory(const Filename &path) { if (root_fullpath.length() > fullpath.length() || cmp_nocase(fullpath.substr(0, root_fullpath.length()), root_fullpath) != 0) { // Nope! - return (CVSSourceDirectory *)NULL; + return nullptr; } // The relative name is the part of fullpath not in root_fullpath. @@ -112,7 +112,7 @@ find_directory(const Filename &path) { CVSSourceDirectory *CVSSourceTree:: find_relpath(const string &relpath) { CVSSourceDirectory *result = _root->find_relpath(relpath); - if (result != (CVSSourceDirectory *)NULL) { + if (result != nullptr) { return result; } @@ -129,7 +129,7 @@ find_relpath(const string &relpath) { return _root->find_relpath(rest); } - return (CVSSourceDirectory *)NULL; + return nullptr; } /** @@ -185,7 +185,7 @@ get_root_fullpath() { */ Filename CVSSourceTree:: get_root_dirname() const { - nassertr(_root != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_root != nullptr, Filename()); return _root->get_dirname(); } @@ -407,14 +407,14 @@ ask_any(const string &basename, // relative path from the root (with or without the root's dirname), or // the dirname of the particular directory. CVSSourceDirectory *dir = find_directory(result); - if (dir == (CVSSourceDirectory *)NULL) { + if (dir == nullptr) { dir = find_relpath(result); } - if (dir == (CVSSourceDirectory *)NULL) { + if (dir == nullptr) { dir = find_dirname(result); } - if (dir != (CVSSourceDirectory *)NULL) { + if (dir != nullptr) { // If the file is already in this directory, we must preserve its // existing case. FilePaths::const_iterator pi; @@ -438,11 +438,11 @@ ask_any(const string &basename, */ string CVSSourceTree:: prompt(const string &message) { - nout << flush; + nout << std::flush; while (true) { - cerr << message << flush; - string response; - getline(cin, response); + cerr << message << std::flush; + std::string response; + std::getline(std::cin, response); // Remove leading and trailing whitespace. size_t p = 0; @@ -491,7 +491,7 @@ get_start_fullpath() { */ CVSSourceTree::FilePath:: FilePath() : - _dir(NULL) + _dir(nullptr) { } @@ -512,7 +512,7 @@ FilePath(CVSSourceDirectory *dir, const string &basename) : */ bool CVSSourceTree::FilePath:: is_valid() const { - return (_dir != (CVSSourceDirectory *)NULL); + return (_dir != nullptr); } /** @@ -520,7 +520,7 @@ is_valid() const { */ Filename CVSSourceTree::FilePath:: get_path() const { - nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_dir != nullptr, Filename()); return Filename(_dir->get_path(), _basename); } @@ -529,7 +529,7 @@ get_path() const { */ Filename CVSSourceTree::FilePath:: get_fullpath() const { - nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_dir != nullptr, Filename()); return Filename(_dir->get_fullpath(), _basename); } @@ -539,6 +539,6 @@ get_fullpath() const { */ Filename CVSSourceTree::FilePath:: get_rel_from(const CVSSourceDirectory *other) const { - nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_dir != nullptr, Filename()); return Filename(other->get_rel_to(_dir), _basename); } diff --git a/pandatool/src/cvscopy/testCopy.cxx b/pandatool/src/cvscopy/testCopy.cxx index 4947bc8d5c..78010c58bb 100644 --- a/pandatool/src/cvscopy/testCopy.cxx +++ b/pandatool/src/cvscopy/testCopy.cxx @@ -39,7 +39,7 @@ run() { SourceFiles::iterator fi; for (fi = _source_files.begin(); fi != _source_files.end(); ++fi) { CVSSourceDirectory *dest = import(*fi, 0, _model_dir); - if (dest == (CVSSourceDirectory *)NULL) { + if (dest == nullptr) { exit(1); } } diff --git a/pandatool/src/daeegg/daeCharacter.cxx b/pandatool/src/daeegg/daeCharacter.cxx index 31d8db02cb..3b98fa80a7 100644 --- a/pandatool/src/daeegg/daeCharacter.cxx +++ b/pandatool/src/daeegg/daeCharacter.cxx @@ -42,14 +42,14 @@ DaeCharacter(EggGroup *node_group, const FCDControllerInstance *instance) : _node_group(node_group), _name(node_group->get_name()), _instance(instance), - _skin_controller(NULL), - _skin_mesh(NULL) { + _skin_controller(nullptr), + _skin_mesh(nullptr) { _bind_shape_mat = LMatrix4d::ident_mat(); // If it's a skin controller, add the controller joints. const FCDController *controller = (const FCDController *)instance->GetEntity(); - if (controller == NULL) { + if (controller == nullptr) { return; } _skin_mesh = controller->GetBaseGeometry()->GetMesh(); @@ -86,7 +86,7 @@ bind_joints(JointMap &joint_map) { if (ji != joint_map.end()) { Joint &joint = ji->second; - if (joint._character != (DaeCharacter *)NULL) { + if (joint._character != nullptr) { // In some cases, though, multiple controllers share the same joints. // We can't support this without duplicating the joint structure, so // we check if the bind poses are the same. @@ -108,7 +108,7 @@ bind_joints(JointMap &joint_map) { << "Unknown joint sid being referenced: '" << sid << "'\n"; // We still have to add a dummy joint or the index will be off. - _joints.push_back(Joint(NULL, NULL)); + _joints.push_back(Joint(nullptr, nullptr)); } } } @@ -179,7 +179,7 @@ influence_vertex(int index, EggVertex *vertex) { if (jwpair->jointIndex >= 0 && jwpair->jointIndex < (int)_joints.size()) { EggGroup *joint = _joints[jwpair->jointIndex]._group.p(); - if (joint != NULL) { + if (joint != nullptr) { joint->ref_vertex(vertex, jwpair->weight); } } else { @@ -218,7 +218,7 @@ r_collect_keys(FCDSceneNode* node, pset &keys) { FCDTransform *transform = node->GetTransform(t); FCDAnimated *animated = transform->GetAnimated(); - if (animated != NULL) { + if (animated != nullptr) { const FCDAnimationCurveListList &all_curves = animated->GetCurves(); for (size_t ci = 0; ci < all_curves.size(); ++ci) { @@ -243,7 +243,7 @@ r_collect_keys(FCDSceneNode* node, pset &keys) { */ void DaeCharacter:: build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { - nassertv(node != NULL); + nassertv(node != nullptr); if (!node->IsJoint()) { for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) { @@ -267,7 +267,7 @@ build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { for (size_t t = 0; t < node->GetTransformCount(); ++t) { FCDTransform *transform = node->GetTransform(t); FCDAnimated *animated = transform->GetAnimated(); - if (animated != (FCDAnimated *)NULL) { + if (animated != nullptr) { if (animated->HasCurve()) { animateds.push_back(animated); } diff --git a/pandatool/src/daeegg/daeCharacter.h b/pandatool/src/daeegg/daeCharacter.h index 78ff504e2e..76339368c9 100644 --- a/pandatool/src/daeegg/daeCharacter.h +++ b/pandatool/src/daeegg/daeCharacter.h @@ -40,7 +40,7 @@ public: INLINE Joint(EggGroup *group, const FCDSceneNode *scene_node) : _group(group), _scene_node(scene_node), - _character(NULL), + _character(nullptr), _bind_pose(LMatrix4d::ident_mat()) {} LMatrix4d _bind_pose; diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index e345c4b6bd..0c15fe819d 100644 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -45,7 +45,7 @@ DaeMaterials(const FCDGeometryInstance* geometry_instance) { * Adds a material instance. Normally automatically done by constructor. */ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { - nassertv(instance != NULL); + nassertv(instance != nullptr); const string semantic (FROM_FSTRING(instance->GetSemantic())); if (_materials.count(semantic) > 0) { daeegg_cat.warning() << "Ignoring duplicate material with semantic " << semantic << endl; @@ -56,7 +56,7 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { // Load in the uvsets for (size_t vib = 0; vib < instance->GetVertexInputBindingCount(); ++vib) { const FCDMaterialInstanceBindVertexInput* mivib = instance->GetVertexInputBinding(vib); - assert(mivib != NULL); + assert(mivib != nullptr); PT(DaeVertexInputBinding) bvi = new DaeVertexInputBinding(); bvi->_input_set = mivib->inputSet; #if FCOLLADA_VERSION >= 0x00030005 @@ -74,12 +74,12 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { PT_EggMaterial egg_material = new EggMaterial(semantic); pvector egg_textures; const FCDEffect* effect = instance->GetMaterial()->GetEffect(); - if (effect == NULL) { + if (effect == nullptr) { daeegg_cat.debug() << "Ignoring material (semantic: " << semantic << ") without assigned effect" << endl; } else { // Grab the common profile effect const FCDEffectStandard* effect_common = (FCDEffectStandard *)effect->FindProfile(FUDaeProfileType::COMMON); - if (effect_common == NULL) { + if (effect_common == nullptr) { daeegg_cat.info() << "Ignoring effect referenced by material with semantic " << semantic << " because it has no common profile" << endl; } else { @@ -124,7 +124,7 @@ void DaeMaterials:: process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype, EggTexture::Format format) { for (size_t tx = 0; tx < effect_common->GetTextureCount(bucket); ++tx) { const FCDImage* image = effect_common->GetTexture(bucket, tx)->GetImage(); - if (image == NULL) { + if (image == nullptr) { daeegg_cat.warning() << "Texture references a nonexisting image!" << endl; } else { const FCDEffectParameterSampler* sampler = effect_common->GetTexture(bucket, tx)->GetSampler(); @@ -145,7 +145,7 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co PT_EggTexture egg_texture = new EggTexture(FROM_FSTRING(image->GetDaeId()), texpath.to_os_generic()); // Find a set of UV coordinates const FCDEffectParameterInt* uvset = effect_common->GetTexture(bucket, tx)->GetSet(); - if (uvset != NULL) { + if (uvset != nullptr) { daeegg_cat.debug() << "Texture has uv name '" << FROM_FSTRING(uvset->GetSemantic()) << "'\n"; string uvset_semantic (FROM_FSTRING(uvset->GetSemantic())); @@ -158,7 +158,7 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co } } // Apply sampler stuff - if (sampler != NULL) { + if (sampler != nullptr) { egg_texture->set_texture_type(convert_texture_type(sampler->GetSamplerType())); egg_texture->set_wrap_u(convert_wrap_mode(sampler->GetWrapS())); if (sampler->GetSamplerType() != FCDEffectParameterSampler::SAMPLER1D) { @@ -187,12 +187,12 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co */ void DaeMaterials:: process_extra(const string semantic, const FCDExtra* extra) { - if (extra == NULL) return; + if (extra == nullptr) return; const FCDEType* etype = extra->GetDefaultType(); - if (etype == NULL) return; + if (etype == nullptr) return; for (size_t et = 0; et < etype->GetTechniqueCount(); ++et) { const FCDENode* enode = ((const FCDENode*)(etype->GetTechnique(et)))->FindChildNode("double_sided"); - if (enode != NULL) { + if (enode != nullptr) { string content = trim(enode->GetContent()); if (content == "1" || content == "true") { _materials[semantic]->_double_sided = true; diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index 0b3844549f..f054643d7b 100644 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -55,9 +55,9 @@ DAEToEggConverter:: DAEToEggConverter() { _unit_name = "meter"; _unit_meters = 1.0; - _document = NULL; - _table = NULL; - _error_handler = NULL; + _document = nullptr; + _table = nullptr; + _error_handler = nullptr; _invert_transparency = false; } @@ -75,7 +75,7 @@ DAEToEggConverter(const DAEToEggConverter ©) : */ DAEToEggConverter:: ~DAEToEggConverter() { - if (_error_handler != NULL) { + if (_error_handler != nullptr) { delete _error_handler; } } @@ -114,7 +114,7 @@ convert_file(const Filename &filename) { // Reset stuff clear_error(); _joints.clear(); - if (_error_handler == NULL) { + if (_error_handler == nullptr) { _error_handler = new FUErrorSimpleHandler; } @@ -126,13 +126,13 @@ convert_file(const Filename &filename) { // Read the file FCollada::Initialize(); _document = FCollada::LoadDocument(filename.to_os_specific().c_str()); - if (_document == NULL) { + if (_document == nullptr) { daeegg_cat.error() << "Failed to load document: " << _error_handler->GetErrorString() << endl; FCollada::Release(); return false; } // Make sure the file uses consistent coordinate system and length - if (_document->GetAsset() != NULL) { + if (_document->GetAsset() != nullptr) { FCDocumentTools::StandardizeUpAxisAndLength(_document); } @@ -142,7 +142,7 @@ convert_file(const Filename &filename) { string model_name = _character_name; FCDSceneNode* visual_scene = _document->GetVisualSceneInstance(); - if (visual_scene != NULL) { + if (visual_scene != nullptr) { if (model_name.empty()) { // By lack of anything better... model_name = FROM_FSTRING(visual_scene->GetName()); @@ -170,7 +170,7 @@ convert_file(const Filename &filename) { const FCDGeometryMesh *mesh = character->_skin_mesh; - if (mesh != NULL) { + if (mesh != nullptr) { PT(DaeMaterials) materials = new DaeMaterials(character->_instance); daeegg_cat.spam() << "Processing mesh for controller\n"; process_mesh(character->_node_group, mesh, materials, character); @@ -183,7 +183,7 @@ convert_file(const Filename &filename) { character->adjust_joints(visual_scene->GetChild(ch), _joints, LMatrix4d::ident_mat()); } - if (scene_group != NULL) { + if (scene_group != nullptr) { // Mark the scene as character. if (get_animation_convert() == AC_chan) { _egg_data->remove_child(scene_group); @@ -342,7 +342,7 @@ get_input_units() { void DAEToEggConverter:: process_asset() { const FCDAsset *asset = _document->GetAsset(); - if (_document->GetAsset() == NULL) { + if (_document->GetAsset() == nullptr) { return; } @@ -368,7 +368,7 @@ process_asset() { // to be a skeleton root. void DAEToEggConverter:: process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { - nassertv(node != NULL); + nassertv(node != nullptr); string node_id = FROM_FSTRING(node->GetDaeId()); daeegg_cat.spam() << "Processing node with ID '" << node_id << "'" << endl; @@ -416,15 +416,15 @@ process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { void DAEToEggConverter:: process_instance(EggGroup *parent, const FCDEntityInstance* instance) { - nassertv(instance != NULL); - nassertv(instance->GetEntity() != NULL); + nassertv(instance != nullptr); + nassertv(instance->GetEntity() != nullptr); // Check what kind of instance this is switch (instance->GetType()) { case FCDEntityInstance::GEOMETRY: { if (get_animation_convert() != AC_chan) { const FCDGeometry* geometry = (const FCDGeometry*) instance->GetEntity(); - assert(geometry != NULL); + assert(geometry != nullptr); if (geometry->IsMesh()) { // Now, handle the mesh. process_mesh(parent, geometry->GetMesh(), new DaeMaterials((const FCDGeometryInstance*) instance)); @@ -466,7 +466,7 @@ void DAEToEggConverter:: process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, DaeMaterials *materials, DaeCharacter *character) { - nassertv(mesh != NULL); + nassertv(mesh != nullptr); daeegg_cat.debug() << "Processing mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << endl; // Create the egg stuff to hold this mesh @@ -481,7 +481,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, return; } const FCDGeometrySource* vsource = mesh->FindSourceByType(FUDaeGeometryInput::POSITION); - if (vsource == NULL) { + if (vsource == nullptr) { daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no source for POSITION data" << endl; return; } @@ -501,7 +501,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, PT(EggGroup) primitiveholder; // If we have materials, make a group for each material. Then, apply the // material's per-group stuff. - if (materials != NULL && (!polygons->GetMaterialSemantic().empty()) && mesh->GetPolygonsCount() > 1) { + if (materials != nullptr && (!polygons->GetMaterialSemantic().empty()) && mesh->GetPolygonsCount() > 1) { // primitiveholder = new EggGroup(FROM_FSTRING(mesh->GetDaeId()) + "." + // material_semantic); primitiveholder = new EggGroup; @@ -511,41 +511,41 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, } primitive_holders[gr] = primitiveholder; // Apply the per-group data of the materials, if we have it. - if (materials != NULL) { + if (materials != nullptr) { materials->apply_to_group(material_semantic, primitiveholder, _invert_transparency); } // Find the position sources const FCDGeometryPolygonsInput* pinput = polygons->FindInput(FUDaeGeometryInput::POSITION); - assert(pinput != NULL); + assert(pinput != nullptr); const uint32* indices = pinput->GetIndices(); // Find the normal sources const FCDGeometrySource* nsource = mesh->FindSourceByType(FUDaeGeometryInput::NORMAL); const FCDGeometryPolygonsInput* ninput = polygons->FindInput(FUDaeGeometryInput::NORMAL); const uint32* nindices; - if (ninput != NULL) nindices = ninput->GetIndices(); + if (ninput != nullptr) nindices = ninput->GetIndices(); // Find texcoord sources const FCDGeometrySource* tcsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXCOORD); const FCDGeometryPolygonsInput* tcinput = polygons->FindInput(FUDaeGeometryInput::TEXCOORD); const uint32* tcindices; - if (tcinput != NULL) tcindices = tcinput->GetIndices(); + if (tcinput != nullptr) tcindices = tcinput->GetIndices(); // Find vcolor sources const FCDGeometrySource* csource = mesh->FindSourceByType(FUDaeGeometryInput::COLOR); const FCDGeometryPolygonsInput* cinput = polygons->FindInput(FUDaeGeometryInput::COLOR); const uint32* cindices; - if (cinput != NULL) cindices = cinput->GetIndices(); + if (cinput != nullptr) cindices = cinput->GetIndices(); // Find binormal sources const FCDGeometrySource* bsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXBINORMAL); const FCDGeometryPolygonsInput* binput = polygons->FindInput(FUDaeGeometryInput::TEXBINORMAL); const uint32* bindices; - if (binput != NULL) bindices = binput->GetIndices(); + if (binput != nullptr) bindices = binput->GetIndices(); // Find tangent sources const FCDGeometrySource* tsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXTANGENT); const FCDGeometryPolygonsInput* tinput = polygons->FindInput(FUDaeGeometryInput::TEXTANGENT); const uint32* tindices; - if (tinput != NULL) tindices = tinput->GetIndices(); + if (tinput != nullptr) tindices = tinput->GetIndices(); // Get a name for potential coordinate sets string tcsetname; - if (materials != NULL && tcinput != NULL) { + if (materials != nullptr && tcinput != nullptr) { if (daeegg_cat.is_debug()) { daeegg_cat.debug() << "Assigning texcoord set " << tcinput->GetSet() @@ -555,7 +555,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, FUDaeGeometryInput::TEXCOORD, tcinput->GetSet()); } string tbsetname; - if (materials != NULL && binput != NULL) { + if (materials != nullptr && binput != nullptr) { if (daeegg_cat.is_debug()) { daeegg_cat.debug() << "Assigning texbinormal set " << binput->GetSet() @@ -565,7 +565,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, FUDaeGeometryInput::TEXBINORMAL, binput->GetSet()); } string ttsetname; - if (materials != NULL && tinput != NULL) { + if (materials != nullptr && tinput != nullptr) { if (daeegg_cat.is_debug()) { daeegg_cat.debug() << "Assigning textangent set " << tinput->GetSet() @@ -580,19 +580,19 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, const float* data = &vsource->GetData()[indices[ix]*3]; vertex->set_pos(LPoint3d(data[0], data[1], data[2])); - if (character != NULL) { + if (character != nullptr) { // If this is skinned geometry, add the vertex influences. character->influence_vertex(indices[ix], vertex); } // Process the normal - if (nsource != NULL && ninput != NULL) { + if (nsource != nullptr && ninput != nullptr) { assert(nsource->GetStride() == 3); data = &nsource->GetData()[nindices[ix]*3]; vertex->set_normal(LVecBase3d(data[0], data[1], data[2])); } // Process the texcoords - if (tcsource != NULL && tcinput != NULL) { + if (tcsource != nullptr && tcinput != nullptr) { assert(tcsource->GetStride() == 2 || tcsource->GetStride() == 3); data = &tcsource->GetData()[tcindices[ix]*tcsource->GetStride()]; if (tcsource->GetStride() == 2) { @@ -602,7 +602,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, } } // Process the color - if (csource != NULL && cinput != NULL) { + if (csource != nullptr && cinput != nullptr) { assert(csource->GetStride() == 3 || csource->GetStride() == 4); if (csource->GetStride() == 3) { data = &csource->GetData()[cindices[ix]*3]; @@ -613,21 +613,21 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, } } // Possibly add a UV object - if ((bsource != NULL && binput != NULL) || (tsource != NULL && tinput != NULL)) { - if (bsource != NULL && binput != NULL) { + if ((bsource != nullptr && binput != nullptr) || (tsource != nullptr && tinput != nullptr)) { + if (bsource != nullptr && binput != nullptr) { assert(bsource->GetStride() == 3); data = &bsource->GetData()[bindices[ix]*3]; PT(EggVertexUV) uv_obj = vertex->modify_uv_obj(tbsetname); - if (uv_obj == NULL) { + if (uv_obj == nullptr) { uv_obj = new EggVertexUV(tbsetname, LTexCoordd()); } uv_obj->set_binormal(LVecBase3d(data[0], data[1], data[2])); } - if (tsource != NULL && tinput != NULL) { + if (tsource != nullptr && tinput != nullptr) { assert(tsource->GetStride() == 3); data = &tsource->GetData()[tindices[ix]*3]; PT(EggVertexUV) uv_obj = vertex->modify_uv_obj(ttsetname); - if (uv_obj == NULL) { + if (uv_obj == nullptr) { uv_obj = new EggVertexUV(ttsetname, LTexCoordd()); } uv_obj->set_tangent(LVecBase3d(data[0], data[1], data[2])); @@ -642,7 +642,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, // Now loop through the faces uint32 offset = 0; for (size_t fa = 0; fa < polygons->GetFaceVertexCountCount(); ++fa) { - PT(EggPrimitive) primitive = NULL; + PT(EggPrimitive) primitive = nullptr; // Create a primitive that matches the fcollada type switch (polygons->GetPrimitiveType()) { case FCDGeometryPolygons::LINES: @@ -666,9 +666,9 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, default: daeegg_cat.warning() << "Unsupported primitive type found!" << endl; } - if (primitive != NULL) { + if (primitive != nullptr) { primitive_holders[gr]->add_child(primitive); - if (materials != NULL) { + if (materials != nullptr) { materials->apply_to_primitive(FROM_FSTRING(polygons->GetMaterialSemantic()), primitive); } for (size_t ve = 0; ve < polygons->GetFaceVertexCount(fa); ++ve) { @@ -684,7 +684,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, void DAEToEggConverter:: process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geometry_spline) { - assert(geometry_spline != NULL); + assert(geometry_spline != nullptr); PT(EggGroup) result = new EggGroup(group_name); parent->add_child(result); // TODO: if its not a nurbs, make it convert between the types @@ -700,7 +700,7 @@ process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geo void DAEToEggConverter:: process_spline(EggGroup *parent, const FCDSpline* spline) { - assert(spline != NULL); + assert(spline != nullptr); nassertv(spline->GetSplineType() == FUDaeSplineType::NURBS); // Now load in the nurbs curve to the egg library PT(EggNurbsCurve) nurbs_curve = new EggNurbsCurve(FROM_FSTRING(spline->GetName())); @@ -709,7 +709,7 @@ process_spline(EggGroup *parent, const FCDSpline* spline) { nurbs_curve->setup(0, ((const FCDNURBSSpline*) spline)->GetKnotCount()); for (size_t kn = 0; kn < ((const FCDNURBSSpline*) spline)->GetKnotCount(); ++kn) { const float* knot = ((const FCDNURBSSpline*) spline)->GetKnot(kn); - assert(knot != NULL); + assert(knot != nullptr); nurbs_curve->set_knot(kn, *knot); } for (size_t cv = 0; cv < spline->GetCVCount(); ++cv) { @@ -722,14 +722,14 @@ process_spline(EggGroup *parent, const FCDSpline* spline) { void DAEToEggConverter:: process_controller(EggGroup *parent, const FCDControllerInstance *instance) { - assert(instance != NULL); + assert(instance != nullptr); const FCDController* controller = (const FCDController *)instance->GetEntity(); - assert(controller != NULL); + assert(controller != nullptr); if (get_animation_convert() == AC_none) { // If we're exporting a static mesh, export the base geometry as-is. const FCDGeometryMesh *mesh = controller->GetBaseGeometry()->GetMesh(); - if (mesh != NULL) { + if (mesh != nullptr) { PT(DaeMaterials) materials = new DaeMaterials(instance); daeegg_cat.spam() << "Processing mesh for controller\n"; process_mesh(parent, mesh, materials); @@ -741,9 +741,9 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { } if (controller->IsMorph()) { - assert(controller != NULL); + assert(controller != nullptr); const FCDMorphController* morph_controller = controller->GetMorphController(); - assert(morph_controller != NULL); + assert(morph_controller != nullptr); PT(EggTable) bundle = new EggTable(parent->get_name()); bundle->set_table_type(EggTable::TT_bundle); PT(EggTable) morph = new EggTable("morph"); @@ -752,7 +752,7 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { // Loop through the morph targets. for (size_t mt = 0; mt < morph_controller->GetTargetCount(); ++mt) { const FCDMorphTarget* morph_target = morph_controller->GetTarget(mt); - assert(morph_target != NULL); + assert(morph_target != nullptr); PT(EggSAnimData) target = new EggSAnimData(FROM_FSTRING(morph_target->GetGeometry()->GetName())); if (morph_target->IsAnimated()) { // TODO @@ -766,18 +766,18 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { void DAEToEggConverter:: process_extra(EggGroup *group, const FCDExtra* extra) { - if (extra == NULL) { + if (extra == nullptr) { return; } - nassertv(group != NULL); + nassertv(group != nullptr); const FCDEType* etype = extra->GetDefaultType(); - if (etype == NULL) { + if (etype == nullptr) { return; } const FCDENode* enode = (const FCDENode*) etype->FindTechnique("PANDA3D"); - if (enode == NULL) { + if (enode == nullptr) { return; } @@ -802,8 +802,8 @@ convert_matrix(const FMMatrix44 &matrix) { void DAEToEggConverter:: apply_transform(EggGroup *to, const FCDTransform* from) { - assert(from != NULL); - assert(to != NULL); + assert(from != nullptr); + assert(to != nullptr); // to->set_transform3d(convert_matrix(from->ToMatrix()) * // to->get_transform3d()); switch (from->GetType()) { diff --git a/pandatool/src/daeegg/daeToEggConverter.h b/pandatool/src/daeegg/daeToEggConverter.h index b31d439526..2c1dc234c1 100644 --- a/pandatool/src/daeegg/daeToEggConverter.h +++ b/pandatool/src/daeegg/daeToEggConverter.h @@ -72,7 +72,7 @@ private: void process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced = false); void process_instance(EggGroup *parent, const FCDEntityInstance* instance); void process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, - DaeMaterials *materials, DaeCharacter *character = NULL); + DaeMaterials *materials, DaeCharacter *character = nullptr); void process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geometry_spline); void process_spline(EggGroup *parent, const FCDSpline* spline); void process_controller(EggGroup *parent, const FCDControllerInstance* instance); diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx index dff2286b88..cc3d9facf4 100644 --- a/pandatool/src/daeprogs/eggToDAE.cxx +++ b/pandatool/src/daeprogs/eggToDAE.cxx @@ -41,7 +41,7 @@ EggToDAE() : ("This program converts files from the egg format to the COLLADA " ".dae (Digital Asset Exchange) format."); - _document = NULL; + _document = nullptr; } /** @@ -50,7 +50,7 @@ EggToDAE() : void EggToDAE:: run() { nassertv(has_output_filename()); - nassertv(_data != NULL); + nassertv(_data != nullptr); FCollada::Initialize(); _document = FCollada::NewTopDocument(); @@ -58,8 +58,8 @@ run() { // Add the contributor part to the asset FCDAssetContributor* contributor = _document->GetAsset()->AddContributor(); const char* user_name = getenv("USER"); - if (user_name == NULL) user_name = getenv("USERNAME"); - if (user_name != NULL) contributor->SetAuthor(TO_FSTRING(user_name)); + if (user_name == nullptr) user_name = getenv("USERNAME"); + if (user_name != nullptr) contributor->SetAuthor(TO_FSTRING(user_name)); // contributor->SetSourceData(); char authoring_tool[1024]; snprintf(authoring_tool, 1024, "Panda3D %s eggToDAE converter | FCollada v%d.%02d", PANDA_VERSION_STR, FCOLLADA_VERSION >> 16, FCOLLADA_VERSION & 0xFFFF); @@ -93,7 +93,7 @@ run() { } void EggToDAE::process_node(FCDSceneNode* parent, const PT(EggGroup) node) { - assert(node != NULL); + assert(node != nullptr); FCDSceneNode* scene_node = parent->AddChildNode(); // Set the parameters scene_node->SetDaeId(node->get_name().c_str()); @@ -109,8 +109,8 @@ void EggToDAE::process_node(FCDSceneNode* parent, const PT(EggGroup) node) { } void EggToDAE::apply_transform(FCDSceneNode* to, const PT(EggGroup) from) { - assert(to != NULL); - assert(from != NULL); + assert(to != nullptr); + assert(from != nullptr); for (int co = 0; co < from->get_num_components(); ++co) { switch (from->get_component_type(co)) { case EggTransform::CT_translate2d: diff --git a/pandatool/src/dxf/dxfFile.cxx b/pandatool/src/dxf/dxfFile.cxx index b716ea11ba..0637c97d39 100644 --- a/pandatool/src/dxf/dxfFile.cxx +++ b/pandatool/src/dxf/dxfFile.cxx @@ -280,9 +280,9 @@ DXFFile::Color DXFFile::_colors[DXF_num_colors] = { */ DXFFile:: DXFFile() { - _in = NULL; + _in = nullptr; _owns_in = false; - _layer = NULL; + _layer = nullptr; reset_entity(); _color_index = -1; } @@ -308,7 +308,7 @@ process(Filename filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { return; } process(in, true); @@ -552,7 +552,7 @@ get_group() { in.get(); } - getline(in, _string); + std::getline(in, _string); _string = trim_right(_string); if (!in) { @@ -620,7 +620,7 @@ change_section(Section new_section) { */ void DXFFile:: change_layer(const string &layer_name) { - if (_layer == NULL || _layer->get_name() != layer_name) { + if (_layer == nullptr || _layer->get_name() != layer_name) { _layer = _layers.get_layer(layer_name, this); } } diff --git a/pandatool/src/dxfegg/dxfToEggConverter.cxx b/pandatool/src/dxfegg/dxfToEggConverter.cxx index 58f2c7a758..3620f96abd 100644 --- a/pandatool/src/dxfegg/dxfToEggConverter.cxx +++ b/pandatool/src/dxfegg/dxfToEggConverter.cxx @@ -112,11 +112,11 @@ done_entity() { if (_flags & PF_closed) { // it's closed; create a polygon. - nassertv(_layer!=NULL); + nassertv(_layer!=nullptr); ((DXFToEggLayer *)_layer)->add_polygon(this); } else { // It's open; create a series of line segments. - nassertv(_layer!=NULL); + nassertv(_layer!=nullptr); ((DXFToEggLayer *)_layer)->add_line(this); } @@ -130,7 +130,7 @@ done_entity() { _verts.push_back(DXFVertex(_q)); _verts.push_back(DXFVertex(_p)); - nassertv(_layer!=NULL); + nassertv(_layer!=nullptr); ((DXFToEggLayer *)_layer)->add_polygon(this); } } diff --git a/pandatool/src/egg-mkfont/eggMakeFont.cxx b/pandatool/src/egg-mkfont/eggMakeFont.cxx index 024f302199..8ae277126b 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.cxx +++ b/pandatool/src/egg-mkfont/eggMakeFont.cxx @@ -60,7 +60,7 @@ EggMakeFont() : EggWriter(true, false) { "Specifies the foreground color of the generated texture map. The " "default is white: 1,1,1,1, which leads to the most flexibility " "as the color can be modulated at runtime to any suitable color.", - &EggMakeFont::dispatch_color, NULL, &_fg[0]); + &EggMakeFont::dispatch_color, nullptr, &_fg[0]); add_option ("bg", "r,g,b[,a]", 0, @@ -72,7 +72,7 @@ EggMakeFont() : EggWriter(true, false) { "alpha component; if both colors specify an alpha component of 1 " "(or do not specify an alpha compenent), then the generated images " "will not include an alpha component.", - &EggMakeFont::dispatch_color, NULL, &_bg[0]); + &EggMakeFont::dispatch_color, nullptr, &_bg[0]); add_option ("interior", "r,g,b[,a]", 0, @@ -93,7 +93,7 @@ EggMakeFont() : EggWriter(true, false) { "within square brackets, e.g. '[A-Za-z0-9]'. If this is not specified, " "the default set has all ASCII characters and an assorted set of " "latin-1 characters, diacritics and punctuation marks.", - &EggMakeFont::dispatch_range, NULL, &_range); + &EggMakeFont::dispatch_range, nullptr, &_range); add_option ("extra", "file.egg", 0, @@ -103,7 +103,7 @@ EggMakeFont() : EggWriter(true, false) { "number of a character and should contain one polygon. These groups " "are simply copied into the output egg file as if they were generated " "locally. This option may be repeated.", - &EggMakeFont::dispatch_vector_string, NULL, &_extra_filenames); + &EggMakeFont::dispatch_vector_string, nullptr, &_extra_filenames); add_option ("ppu", "pixels", 0, @@ -112,27 +112,27 @@ EggMakeFont() : EggWriter(true, false) { "10 points of font; see -ps). Setting this number larger results in " "an easier-to-read font, but at the cost of more texture memory. " "The default is 40.", - &EggMakeFont::dispatch_double, NULL, &_pixels_per_unit); + &EggMakeFont::dispatch_double, nullptr, &_pixels_per_unit); add_option ("ps", "size", 0, "Specify the point size of the resulting font. This controls the " "apparent size of the font when it is rendered onscreen. By convention, " "a 10 point font is 1 screen unit high, so the default is 10.", - &EggMakeFont::dispatch_double, NULL, &_point_size); + &EggMakeFont::dispatch_double, nullptr, &_point_size); add_option ("sdf", "", 0, "If this is set, a signed distance field will be generated, which " "results in crisp text even when the text is enlarged or zoomed in.", - &EggMakeFont::dispatch_true, NULL, &_generate_distance_field); + &EggMakeFont::dispatch_true, nullptr, &_generate_distance_field); add_option ("pm", "n", 0, "The number of extra pixels around a single character in the " "generated polygon. This may be a floating-point number. The " "default is 1.", - &EggMakeFont::dispatch_double, NULL, &_poly_margin); + &EggMakeFont::dispatch_double, nullptr, &_poly_margin); add_option ("tm", "n", 0, @@ -140,7 +140,7 @@ EggMakeFont() : EggWriter(true, false) { "This may only be an integer. The default is 2. This is meaningful " "when -nopal is also used; in the normal case, use -pm to control " "both the polygon size and the texture map spacing.", - &EggMakeFont::dispatch_int, NULL, &_tex_margin); + &EggMakeFont::dispatch_int, nullptr, &_tex_margin); add_option ("rm", "n", 0, @@ -149,7 +149,7 @@ EggMakeFont() : EggWriter(true, false) { "generated texture map, only on the generated egg. Use this in order to " "space the characters out in case they appear to be too close together " "when rendered. The default is 0.", - &EggMakeFont::dispatch_double, NULL, &_render_margin); + &EggMakeFont::dispatch_double, nullptr, &_render_margin); add_option ("sf", "factor", 0, @@ -192,7 +192,7 @@ EggMakeFont() : EggWriter(true, false) { "If it is omitted, the default is based on the name of the egg file. " "This is used only if -nopal is specified; in the normal case, " "without -nopal, use -pp instead.", - &EggMakeFont::dispatch_string, NULL, &_output_glyph_pattern); + &EggMakeFont::dispatch_string, nullptr, &_output_glyph_pattern); add_option ("pp", "pattern", 0, @@ -200,20 +200,20 @@ EggMakeFont() : EggWriter(true, false) { "string is effectively passed to egg-palettize as the -tn option, and " "thus should contain %i for the palette index number. This is used " "if -nopal is not specified.", - &EggMakeFont::dispatch_string, NULL, &_output_palette_pattern); + &EggMakeFont::dispatch_string, nullptr, &_output_palette_pattern); add_option ("palsize", "xsize,ysize", 0, "Specify the size of the palette texture images. This is used if " "-nopal is not specified.", - &EggMakeFont::dispatch_int_pair, NULL, _palette_size); + &EggMakeFont::dispatch_int_pair, nullptr, _palette_size); add_option ("face", "index", 0, "Specify the face index of the particular face within the font file " "to use. Some font files contain multiple faces, indexed beginning " "at 0. The default is face 0.", - &EggMakeFont::dispatch_int, NULL, &_face_index); + &EggMakeFont::dispatch_int, nullptr, &_face_index); _fg.set(1.0, 1.0, 1.0, 1.0); _bg.set(1.0, 1.0, 1.0, 0.0); @@ -227,9 +227,9 @@ EggMakeFont() : EggWriter(true, false) { _face_index = 0; _generate_distance_field = false; - _text_maker = NULL; - _vpool = NULL; - _group = NULL; + _text_maker = nullptr; + _vpool = nullptr; + _group = nullptr; } @@ -538,7 +538,7 @@ make_vertex(const LPoint2d &xy) { void EggMakeFont:: add_character(int code) { PNMTextGlyph *glyph = _text_maker->get_glyph(code); - if (glyph == (PNMTextGlyph *)NULL) { + if (glyph == nullptr) { nout << "No definition in font for character " << code << ".\n"; return; } diff --git a/pandatool/src/egg-optchar/eggOptchar.cxx b/pandatool/src/egg-optchar/eggOptchar.cxx index bc1d3058b3..c7027ec9ec 100644 --- a/pandatool/src/egg-optchar/eggOptchar.cxx +++ b/pandatool/src/egg-optchar/eggOptchar.cxx @@ -74,19 +74,19 @@ EggOptchar() { ("keep", "joint[,joint...]", 0, "Keep the named joints (or sliders) in the character, even if they do " "not appear to be needed by the animation.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_keep_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_keep_components); add_option ("drop", "joint[,joint...]", 0, "Removes the named joints or sliders, even if they appear to be needed.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_drop_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_drop_components); add_option ("expose", "joint[,joint...]", 0, "Expose the named joints by flagging them with a DCS attribute, so " "each one can be found in the scene graph when the character is loaded, " "and objects can be parented to it. This implies -keep.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_expose_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_expose_components); add_option ("suppress", "joint[,joint...]", 0, @@ -95,7 +95,7 @@ EggOptchar() { "rigid geometry. The default is to create an implicit node for any " "joint that contains rigid geometry, to take advantage of display " "list and/or vertex buffer caching. This does not imply -keep.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_suppress_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_suppress_components); add_option ("flag", "node[,node...][=name]", 0, @@ -107,7 +107,7 @@ EggOptchar() { "joints; the revealed node can be hidden or its attributes changed " "at runtime, but it will be animated by its vertices, not the node, so " "objects parented to this node will not inherit its animation.", - &EggOptchar::dispatch_flag_groups, NULL, &_flag_groups); + &EggOptchar::dispatch_flag_groups, nullptr, &_flag_groups); add_option ("defpose", "anim.egg,frame", 0, @@ -117,7 +117,7 @@ EggOptchar() { "pose will be held by the model in " "the absence of any animation, and need not be the same " "pose in which the model was originally skinned.", - &EggOptchar::dispatch_string, NULL, &_defpose); + &EggOptchar::dispatch_string, nullptr, &_defpose); add_option ("preload", "", 0, @@ -132,7 +132,7 @@ EggOptchar() { "a subset of the component letters hprxyzijkabc is included, the " "operation is restricted to just those components; otherwise the " "entire transform is cleared.", - &EggOptchar::dispatch_name_components, NULL, &_zero_channels); + &EggOptchar::dispatch_name_components, nullptr, &_zero_channels); add_option ("keepall", "", 0, @@ -146,18 +146,18 @@ EggOptchar() { "\"-p joint,\" to reparent a joint to the root. The joint transform " "is recomputed appropriately under its new parent so that the animation " "is not affected (the effect is similar to NodePath::wrt_reparent_to).", - &EggOptchar::dispatch_vector_string_pair, NULL, &_reparent_joints); + &EggOptchar::dispatch_vector_string_pair, nullptr, &_reparent_joints); add_option ("new", "joint,source", 0, "Creates a new joint under the named parent joint. The new " "joint will inherit the same net transform as its parent.", - &EggOptchar::dispatch_vector_string_pair, NULL, &_new_joints); + &EggOptchar::dispatch_vector_string_pair, nullptr, &_new_joints); add_option ("rename", "joint,newjoint", 0, "Renames the indicated joint, if present, to the given name.", - &EggOptchar::dispatch_vector_string_pair, NULL, &_rename_joints); + &EggOptchar::dispatch_vector_string_pair, nullptr, &_rename_joints); if (FFTCompressor::is_compression_available()) { add_option @@ -182,7 +182,7 @@ EggOptchar() { "benefit for eliminating small differences in joint memberships " "between neighboring vertices. The default is 0.01; specifying " "0 means to preserve the original values.", - &EggOptchar::dispatch_double, NULL, &_vref_quantum); + &EggOptchar::dispatch_double, nullptr, &_vref_quantum); add_option ("qa", "quantum[,hprxyzijkabc]", 0, @@ -193,12 +193,12 @@ EggOptchar() { "animation. However, sometimes it is a useful tool for animation " "analysis and comparison. This option may be repeated several times " "to quantize different channels by a different amount.", - &EggOptchar::dispatch_double_components, NULL, &_quantize_anims); + &EggOptchar::dispatch_double_components, nullptr, &_quantize_anims); add_option ("dart", "[default, sync, nosync, or structured]", 0, "change the dart value in the given eggs", - &EggOptchar::dispatch_string, NULL, &_dart_type); + &EggOptchar::dispatch_string, nullptr, &_dart_type); _optimal_hierarchy = false; @@ -381,7 +381,7 @@ dispatch_name_components(const string &opt, const string &arg, void *var) { sp._b = matrix_component_letters; } else { for (string::const_iterator si = sp._b.begin(); si != sp._b.end(); ++si) { - if (strchr(matrix_component_letters, *si) == NULL) { + if (strchr(matrix_component_letters, *si) == nullptr) { nout << "Not a standard matrix component: \"" << *si << "\"\n" << "-" << opt << " requires a joint name followed by a set " << "of component names. The standard component names are \"" @@ -436,7 +436,7 @@ dispatch_double_components(const string &opt, const string &arg, void *var) { sp._b = matrix_component_letters; } else { for (string::const_iterator si = sp._b.begin(); si != sp._b.end(); ++si) { - if (strchr(matrix_component_letters, *si) == NULL) { + if (strchr(matrix_component_letters, *si) == nullptr) { nout << "Not a standard matrix component: \"" << *si << "\"\n" << "-" << opt << " requires a joint name followed by a set " << "of component names. The standard component names are \"" @@ -535,11 +535,11 @@ determine_removed_components() { nout << char_data->get_name() << " has " << num_components << " components.\n"; for (int i = 0; i < num_components; i++) { EggComponentData *comp_data = char_data->get_component(i); - nassertv(comp_data != (EggComponentData *)NULL); + nassertv(comp_data != nullptr); EggOptcharUserData *user_data = DCAST(EggOptcharUserData, comp_data->get_user_data()); - nassertv(user_data != (EggOptcharUserData *)NULL); + nassertv(user_data != nullptr); const string &name = comp_data->get_name(); if (suppress_names.find(name) != suppress_names.end()) { @@ -636,7 +636,7 @@ move_vertices() { joint_data->move_vertices_to(best_joint); // Now we can't remove the joint. - if (best_joint != (EggJointData *)NULL) { + if (best_joint != nullptr) { EggOptcharUserData *best_user_data = DCAST(EggOptcharUserData, best_joint->get_user_data()); best_user_data->_flags &= ~(EggOptcharUserData::F_empty | EggOptcharUserData::F_remove); @@ -673,7 +673,7 @@ process_joints() { if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) { // This joint will be removed, so reparent it to nothing. - joint_data->reparent_to((EggJointData *)NULL); + joint_data->reparent_to(nullptr); // Determine what kind of node it is we're removing, for the user's // information. @@ -740,7 +740,7 @@ find_best_parent(EggJointData *joint_data) const { if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) { // Keep going. - if (joint_data->get_parent() != (EggJointData *)NULL) { + if (joint_data->get_parent() != nullptr) { return find_best_parent(joint_data->get_parent()); } } @@ -755,8 +755,8 @@ find_best_parent(EggJointData *joint_data) const { */ EggJointData *EggOptchar:: find_best_vertex_joint(EggJointData *joint_data) const { - if (joint_data == (EggJointData *)NULL) { - return NULL; + if (joint_data == nullptr) { + return nullptr; } EggOptcharUserData *user_data = @@ -794,11 +794,11 @@ apply_user_reparents() { node_b = char_data->find_joint(p._b); } - if (node_b == (EggJointData *)NULL) { + if (node_b == nullptr) { nout << "No joint named " << p._b << " in " << char_data->get_name() << ".\n"; - } else if (node_a != (EggJointData *)NULL) { + } else if (node_a != nullptr) { nout << "Joint " << p._a << " already exists in " << char_data->get_name() << ".\n"; @@ -823,10 +823,10 @@ apply_user_reparents() { node_b = char_data->find_joint(p._b); } - if (node_b == (EggJointData *)NULL) { + if (node_b == nullptr) { nout << "No joint named " << p._b << " in " << char_data->get_name() << ".\n"; - } else if (node_a == (EggJointData *)NULL) { + } else if (node_a == nullptr) { nout << "No joint named " << p._a << " in " << char_data->get_name() << ".\n"; } else { @@ -869,7 +869,7 @@ zero_channels() { EggCharacterData *char_data = _collection->get_character(ci); EggJointData *joint_data = char_data->find_joint(p._a); - if (joint_data == (EggJointData *)NULL) { + if (joint_data == nullptr) { nout << "No joint named " << p._a << " in " << char_data->get_name() << ".\n"; } else { @@ -900,7 +900,7 @@ quantize_channels() { EggCharacterData *char_data = _collection->get_character(ci); EggJointData *joint_data = char_data->get_root_joint(); - if (joint_data != (EggJointData *)NULL) { + if (joint_data != nullptr) { joint_data->quantize_channels(p._b, p._a); did_anything = true; } @@ -1314,7 +1314,7 @@ rename_joints() { for (ci = 0; ci < num_characters; ++ci) { EggCharacterData *char_data = _collection->get_character(ci); EggJointData *joint = char_data->find_joint(sp._a); - if (joint != (EggJointData *)NULL) { + if (joint != nullptr) { nout << "Renaming joint " << sp._a << " to " << sp._b << "\n"; joint->set_name(sp._b); diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index 200b62e798..e81290f06c 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -571,7 +571,7 @@ run() { // instead. Notify *notify = Notify::ptr(); NotifyCategory *loader_cat = notify->get_category(":loader"); - if (loader_cat != (NotifyCategory *)NULL && + if (loader_cat != nullptr && loader_cat->get_severity() == NS_info) { loader_cat->set_severity(NS_warning); } @@ -639,7 +639,7 @@ run() { } TypedWritable *obj = state_file.read_object(); - if (obj == (TypedWritable *)NULL || !state_file.resolve()) { + if (obj == nullptr || !state_file.resolve()) { nout << FilenameUnifier::make_user_filename(state_filename) << " exists, but appears to be corrupt. Perhaps you " << "should remove it so a new one can be created.\n"; @@ -701,7 +701,7 @@ run() { } else { _txa_filename.set_text(); - ifstream txa_file; + std::ifstream txa_file; if (!_txa_filename.open_read(txa_file)) { nout << "Unable to open " << _txa_filename << "\n"; exit(1); diff --git a/pandatool/src/egg-palettize/eggPalettize.h b/pandatool/src/egg-palettize/eggPalettize.h index a0c6208d31..8bb1c65774 100644 --- a/pandatool/src/egg-palettize/eggPalettize.h +++ b/pandatool/src/egg-palettize/eggPalettize.h @@ -62,7 +62,6 @@ private: bool _omitall; bool _redo_all; bool _redo_eggs; - bool _dont_lock_txa; bool _describe_input_file; bool _remove_eggs; diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx index 5c673c51a1..980dc7d114 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.cxx +++ b/pandatool/src/egg-palettize/txaFileFilter.cxx @@ -111,7 +111,7 @@ read_txa_file() { // We need to create a global Palettizer object to hold some of the global // properties that may be specified in a txa file. - if (pal == (Palettizer *)NULL) { + if (pal == nullptr) { pal = new Palettizer; } @@ -132,7 +132,7 @@ read_txa_file() { } else { filename.set_text(); istream *ifile = vfs->open_read_file(filename, true); - if (ifile == (istream *)NULL) { + if (ifile == nullptr) { txafile_cat.warning() << "Filename " << filename << " cannot be read.\n"; } else { diff --git a/pandatool/src/egg-qtess/eggQtess.cxx b/pandatool/src/egg-qtess/eggQtess.cxx index 21bc6317fb..fea4d09344 100644 --- a/pandatool/src/egg-qtess/eggQtess.cxx +++ b/pandatool/src/egg-qtess/eggQtess.cxx @@ -37,14 +37,14 @@ EggQtess() { ("f", "filename", 0, "Read the indicated parameter file. Type egg-qtess -H " "to print a description of the parameter file format.", - &EggQtess::dispatch_filename, NULL, &_qtess_filename); + &EggQtess::dispatch_filename, nullptr, &_qtess_filename); add_option ("up", "subdiv", 0, "Specify a uniform subdivision per patch (isoparam). Each NURBS " "surface is made up of N x M patches, each of which is divided " "into subdiv x subdiv quads. A fractional number is allowed.", - &EggQtess::dispatch_double, NULL, &_uniform_per_isoparam); + &EggQtess::dispatch_double, nullptr, &_uniform_per_isoparam); add_option ("us", "subdiv", 0, @@ -52,7 +52,7 @@ EggQtess() { "surface is subdivided into subdiv x subdiv quads, regardless " "of the number of isoparams it has. A fractional number is " "meaningless.", - &EggQtess::dispatch_int, NULL, &_uniform_per_surface); + &EggQtess::dispatch_int, nullptr, &_uniform_per_surface); add_option ("t", "tris", 0, @@ -60,7 +60,7 @@ EggQtess() { "is the total number of triangles for the entire egg file, " "including those surfaces that have already been given an " "explicit tessellation by a parameter file.", - &EggQtess::dispatch_int, NULL, &_total_tris); + &EggQtess::dispatch_int, nullptr, &_total_tris); add_option ("ap", "", 0, @@ -83,7 +83,7 @@ EggQtess() { "-ad. A value of 0 forces placement by curvature only; a very " "large value (like 1000) forces placement by size only. The " "default is 5.0.", - &EggQtess::dispatch_double, NULL, &QtessGlobals::_curvature_ratio); + &EggQtess::dispatch_double, nullptr, &QtessGlobals::_curvature_ratio); add_option ("e", "", 0, diff --git a/pandatool/src/egg-qtess/qtessInputEntry.I b/pandatool/src/egg-qtess/qtessInputEntry.I index 5c8adde257..1386256913 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.I +++ b/pandatool/src/egg-qtess/qtessInputEntry.I @@ -42,7 +42,7 @@ set_importance(double i) { INLINE void QtessInputEntry:: set_match_uu() { _type = T_match_uu; - _constrain_u = NULL; + _constrain_u = nullptr; } /** @@ -51,7 +51,7 @@ set_match_uu() { INLINE void QtessInputEntry:: set_match_vv() { _type = T_match_vv; - _constrain_v = NULL; + _constrain_v = nullptr; } /** @@ -60,7 +60,7 @@ set_match_vv() { INLINE void QtessInputEntry:: set_match_uv() { _type = T_match_uv; - _constrain_u = NULL; + _constrain_u = nullptr; } /** @@ -69,7 +69,7 @@ set_match_uv() { INLINE void QtessInputEntry:: set_match_vu() { _type = T_match_vu; - _constrain_v = NULL; + _constrain_v = nullptr; } /** @@ -120,7 +120,7 @@ set_num_tris(int nt) { */ INLINE void QtessInputEntry:: set_uv(int u, int v) { - set_uv(u, v, NULL, 0); + set_uv(u, v, nullptr, 0); } /** diff --git a/pandatool/src/egg-qtess/qtessInputEntry.cxx b/pandatool/src/egg-qtess/qtessInputEntry.cxx index e7547e359e..da7e940545 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.cxx +++ b/pandatool/src/egg-qtess/qtessInputEntry.cxx @@ -222,7 +222,7 @@ match(QtessSurface *surface) { // Similarly for type "matchUU". This indicates that all the surfaces // that match this one must all share the U-tesselation with whichever // surface first matched against the first node name. - if (nni == _node_names.begin() && _constrain_u==NULL) { + if (nni == _node_names.begin() && _constrain_u==nullptr) { // This is the lucky surface that dominates! _constrain_u = surface; } else { @@ -237,7 +237,7 @@ match(QtessSurface *surface) { case T_match_vv: case T_match_vu: // Ditto for "matchVV". - if (nni == _node_names.begin() && _constrain_v==NULL) { + if (nni == _node_names.begin() && _constrain_v==nullptr) { // This is the lucky surface that dominates! _constrain_v = surface; } else { diff --git a/pandatool/src/egg-qtess/qtessInputFile.cxx b/pandatool/src/egg-qtess/qtessInputFile.cxx index 647f0b8471..850ad638f9 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.cxx +++ b/pandatool/src/egg-qtess/qtessInputFile.cxx @@ -30,7 +30,7 @@ read(const Filename &filename) { _filename = Filename::text_filename(filename); _entries.clear(); - ifstream input; + std::ifstream input; if (!_filename.open_read(input)) { qtess_cat.error() << "Unable to open input file " << _filename << "\n"; @@ -41,7 +41,7 @@ read(const Filename &filename) { int line_number = 0; string line; - while (getline(input, line)) { + while (std::getline(input, line)) { line_number++; // Eliminate comments. We have to scan the line repeatedly until we find diff --git a/pandatool/src/egg-qtess/qtessSurface.I b/pandatool/src/egg-qtess/qtessSurface.I index cc53d0f403..f603bf830f 100644 --- a/pandatool/src/egg-qtess/qtessSurface.I +++ b/pandatool/src/egg-qtess/qtessSurface.I @@ -24,7 +24,7 @@ get_name() const { */ INLINE bool QtessSurface:: is_valid() const { - return (_nurbs != (NurbsSurfaceEvaluator *)NULL); + return (_nurbs != nullptr); } /** diff --git a/pandatool/src/egg-qtess/qtessSurface.cxx b/pandatool/src/egg-qtess/qtessSurface.cxx index c0bfc175f9..896fd68079 100644 --- a/pandatool/src/egg-qtess/qtessSurface.cxx +++ b/pandatool/src/egg-qtess/qtessSurface.cxx @@ -38,7 +38,7 @@ QtessSurface(EggNurbsSurface *egg_surface) : _importance = 1.0; _importance2 = 1.0; - _match_u = _match_v = NULL; + _match_u = _match_v = nullptr; _tess_u = _tess_v = 0; _got_scores = false; @@ -53,7 +53,7 @@ QtessSurface(EggNurbsSurface *egg_surface) : _min_v = 3; } - if (_nurbs == (NurbsSurfaceEvaluator *)NULL) { + if (_nurbs == nullptr) { _num_u = _num_v = 0; } else { @@ -86,7 +86,7 @@ QtessSurface(EggNurbsSurface *egg_surface) : */ double QtessSurface:: get_score(double ratio) { - if (_nurbs == (NurbsSurfaceEvaluator *)NULL) { + if (_nurbs == nullptr) { return 0.0; } @@ -115,13 +115,13 @@ tesselate() { PT(EggGroup) group = do_uniform_tesselate(tris); PT(EggNode) new_node = group.p(); - if (new_node == (EggNode *)NULL) { + if (new_node == nullptr) { new_node = new EggComment(_egg_surface->get_name(), "Omitted NURBS surface."); tris = 0; } EggGroupNode *parent = _egg_surface->get_parent(); - nassertr(parent != (EggGroupNode *)NULL, 0); + nassertr(parent != nullptr, 0); parent->remove_child(_egg_surface); parent->add_child(new_node); @@ -301,9 +301,9 @@ record_vertex_extras() { */ void QtessSurface:: apply_match() { - if (_match_u != NULL) { + if (_match_u != nullptr) { QtessSurface *m = *_match_u; - if (m == NULL) { + if (m == nullptr) { qtess_cat.warning() << "No surface to match " << get_name() << " to in U.\n"; } else { @@ -322,9 +322,9 @@ apply_match() { } } - if (_match_v != NULL) { + if (_match_v != nullptr) { QtessSurface *m = *_match_v; - if (m == NULL) { + if (m == nullptr) { qtess_cat.warning() << "No surface to match " << get_name() << " in V.\n"; } else { @@ -358,7 +358,7 @@ do_uniform_tesselate(int &tris) const { qtess_cat.debug() << get_name() << " : omit\n"; } - return NULL; + return nullptr; } PT(EggGroup) group = new EggGroup(_egg_surface->get_name()); @@ -416,7 +416,7 @@ do_uniform_tesselate(int &tris) const { n_collection[egg_vertex->get_pos3()].insert(egg_vertex); } } - nassertr((int)new_verts.size() == num_verts, NULL); + nassertr((int)new_verts.size() == num_verts, nullptr); // Now create a bunch of quads. for (vi = 1; vi < num_v; vi++) { @@ -460,7 +460,7 @@ do_uniform_tesselate(int &tris) const { pri != egg_vertex->pref_end(); ++pri) { EggPrimitive *egg_primitive = (*pri); - nassertr(egg_primitive->has_normal(), NULL); + nassertr(egg_primitive->has_normal(), nullptr); normal += egg_primitive->get_normal(); num_polys++; } diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx index 7fa0889610..1ebd65a28e 100644 --- a/pandatool/src/eggbase/eggBase.cxx +++ b/pandatool/src/eggbase/eggBase.cxx @@ -63,24 +63,24 @@ add_normals_options() { add_option ("no", "", 48, "Strip all normals.", - &EggBase::dispatch_normals, NULL, &strip); + &EggBase::dispatch_normals, nullptr, &strip); add_option ("np", "", 48, "Strip existing normals and redefine polygon normals.", - &EggBase::dispatch_normals, NULL, &polygon); + &EggBase::dispatch_normals, nullptr, &polygon); add_option ("nv", "threshold", 48, "Strip existing normals and redefine vertex normals. Consider an edge " "between adjacent polygons to be smooth if the angle between them " "is less than threshold degrees.", - &EggBase::dispatch_normals, NULL, &vertex); + &EggBase::dispatch_normals, nullptr, &vertex); add_option ("nn", "", 48, "Preserve normals exactly as they are. This is the default.", - &EggBase::dispatch_normals, NULL, &preserve); + &EggBase::dispatch_normals, nullptr, &preserve); add_option ("tbn", "name", 48, @@ -90,7 +90,7 @@ add_normals_options() { "above options. The tangent and binormal are used to implement " "bump mapping and related texture-based lighting effects. This option " "may be repeated as necessary to name multiple texture coordinate sets.", - &EggBase::dispatch_vector_string, NULL, &_tbn_names); + &EggBase::dispatch_vector_string, nullptr, &_tbn_names); add_option ("tbnall", "", 48, diff --git a/pandatool/src/eggbase/eggMultiBase.cxx b/pandatool/src/eggbase/eggMultiBase.cxx index cc591d4c18..426b62a956 100644 --- a/pandatool/src/eggbase/eggMultiBase.cxx +++ b/pandatool/src/eggbase/eggMultiBase.cxx @@ -148,13 +148,13 @@ read_egg(const Filename &filename) { if (!data->read(filename)) { // Failure reading. - return (EggData *)NULL; + return nullptr; } if (_noabs && data->original_had_absolute_pathnames()) { nout << filename.get_basename() << " includes absolute pathnames!\n"; - return (EggData *)NULL; + return nullptr; } DSearchPath file_path; @@ -168,7 +168,7 @@ read_egg(const Filename &filename) { if (_force_complete) { if (!data->load_externals()) { - return (EggData *)NULL; + return nullptr; } } diff --git a/pandatool/src/eggbase/eggMultiFilter.cxx b/pandatool/src/eggbase/eggMultiFilter.cxx index 8b8fd61a15..87900624f6 100644 --- a/pandatool/src/eggbase/eggMultiFilter.cxx +++ b/pandatool/src/eggbase/eggMultiFilter.cxx @@ -76,14 +76,14 @@ handle_args(ProgramBase::Args &args) { nout << "Populating args from input file: " << _input_filename << "\n"; // Makes sure the file is set is_text _filename = Filename::text_filename(_input_filename); - ifstream input; + std::ifstream input; if (!_filename.open_read(input)) { nout << "Error opening file: " << _input_filename << "\n"; return false; } string line; // File should be a space-delimited list of egg files - while (getline(input, line, ' ')) { + while (std::getline(input, line, ' ')) { args.push_back(line); } } @@ -135,7 +135,7 @@ handle_args(ProgramBase::Args &args) { Args::const_iterator ai; for (ai = args.begin(); ai != args.end(); ++ai) { PT(EggData) data = read_egg(Filename::from_os_specific(*ai)); - if (data == (EggData *)NULL) { + if (data == nullptr) { // Rather than returning false, we simply exit here, so the ProgramBase // won't try to tell the user how to run the program just because we got // a bad egg file. diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx index e570b8aa9d..428e07710a 100644 --- a/pandatool/src/eggbase/eggReader.cxx +++ b/pandatool/src/eggbase/eggReader.cxx @@ -50,7 +50,7 @@ EggReader() { "which should be self-contained and include only relative pathnames.", &EggReader::dispatch_none, &_noabs); - _tex_type = (PNMFileType *)NULL; + _tex_type = nullptr; _delod = -1.0; _got_tex_dirname = false; @@ -90,7 +90,7 @@ add_texture_options() { "the image format can be determined by the extension, but sometimes " "the extension is insufficient to unambiguously specify an image " "type.", - &EggReader::dispatch_image_type, NULL, &_tex_type); + &EggReader::dispatch_image_type, nullptr, &_tex_type); } /** @@ -111,7 +111,7 @@ add_delod_options(double default_delod) { "a camera at the indicated fixed distance from each LOD. " "Use -delod -1 to keep all the LOD's as they are, which is " "the default.\n", - &EggReader::dispatch_double, NULL, &_delod); + &EggReader::dispatch_double, nullptr, &_delod); } else { add_option @@ -120,7 +120,7 @@ add_delod_options(double default_delod) { "a camera at the indicated fixed distance from each LOD. " "Use -delod -1 to keep all the LOD's as they are. The default value " "is " + format_string(default_delod) + ".", - &EggReader::dispatch_double, NULL, &_delod); + &EggReader::dispatch_double, nullptr, &_delod); } } diff --git a/pandatool/src/eggbase/eggSingleBase.cxx b/pandatool/src/eggbase/eggSingleBase.cxx index b7fc71c45b..a3cda11736 100644 --- a/pandatool/src/eggbase/eggSingleBase.cxx +++ b/pandatool/src/eggbase/eggSingleBase.cxx @@ -40,7 +40,7 @@ EggSingleBase() : */ EggReader *EggSingleBase:: as_reader() { - return (EggReader *)NULL; + return nullptr; } /** @@ -54,7 +54,7 @@ as_reader() { */ EggWriter *EggSingleBase:: as_writer() { - return (EggWriter *)NULL; + return nullptr; } /** diff --git a/pandatool/src/eggbase/eggToSomething.cxx b/pandatool/src/eggbase/eggToSomething.cxx index 942a0d82db..3aa290ee32 100644 --- a/pandatool/src/eggbase/eggToSomething.cxx +++ b/pandatool/src/eggbase/eggToSomething.cxx @@ -93,13 +93,13 @@ add_units_options() { "specified, the vertices in the egg file will be scaled as " "necessary to make the appropriate units conversion; otherwise, " "the vertices will be left as they are.", - &EggToSomething::dispatch_units, NULL, &_input_units); + &EggToSomething::dispatch_units, nullptr, &_input_units); add_option ("uo", "units", 40, "Specify the units of the resulting " + _format_name + " file. Normally, the default units for the format are used.", - &EggToSomething::dispatch_units, NULL, &_output_units); + &EggToSomething::dispatch_units, nullptr, &_output_units); } /** diff --git a/pandatool/src/eggbase/eggWriter.h b/pandatool/src/eggbase/eggWriter.h index 7d08eab3a0..9037fe7e54 100644 --- a/pandatool/src/eggbase/eggWriter.h +++ b/pandatool/src/eggbase/eggWriter.h @@ -39,8 +39,7 @@ protected: virtual bool post_command_line(); private: - ofstream _output_stream; - ostream *_output_ptr; + std::ofstream _output_stream; }; #endif diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx index 4f33599761..6c8017d988 100644 --- a/pandatool/src/eggbase/somethingToEgg.cxx +++ b/pandatool/src/eggbase/somethingToEgg.cxx @@ -89,7 +89,7 @@ add_units_options() { ("ui", "units", 40, "Specify the units of the input " + _format_name + " file. Normally, this can be inferred from the file itself.", - &SomethingToEgg::dispatch_units, NULL, &_input_units); + &SomethingToEgg::dispatch_units, nullptr, &_input_units); add_option ("uo", "units", 40, @@ -97,7 +97,7 @@ add_units_options() { "specified, the vertices in the egg file will be scaled as " "necessary to make the appropriate units conversion; otherwise, " "the vertices will be left as they are.", - &SomethingToEgg::dispatch_units, NULL, &_output_units); + &SomethingToEgg::dispatch_units, nullptr, &_output_units); } /** @@ -111,14 +111,14 @@ add_animation_options() { "converted to egg, if at all. At present, the following keywords " "are supported: none, pose, flip, strobe, model, chan, or both. " "The default is none, which means not to convert animation.", - &SomethingToEgg::dispatch_animation_convert, NULL, &_animation_convert); + &SomethingToEgg::dispatch_animation_convert, nullptr, &_animation_convert); add_option ("cn", "name", 40, "Specifies the name of the animation character. This should match " "between all of the model files and all of the channel files for a " "particular model and its associated channels.", - &SomethingToEgg::dispatch_string, NULL, &_character_name); + &SomethingToEgg::dispatch_string, nullptr, &_character_name); add_option ("sf", "start-frame", 40, diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.I b/pandatool/src/eggcharbase/eggCharacterCollection.I index 0e1c81f62a..fc1f26964d 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.I +++ b/pandatool/src/eggcharbase/eggCharacterCollection.I @@ -25,7 +25,7 @@ get_num_eggs() const { */ INLINE EggData *EggCharacterCollection:: get_egg(int i) const { - nassertr(i >= 0 && i < (int)_eggs.size(), (EggData *)NULL); + nassertr(i >= 0 && i < (int)_eggs.size(), nullptr); return _eggs[i]._egg; } @@ -71,7 +71,7 @@ get_num_characters() const { */ INLINE EggCharacterData *EggCharacterCollection:: get_character(int i) const { - nassertr(i >= 0 && i < (int)_characters.size(), (EggCharacterData *)NULL); + nassertr(i >= 0 && i < (int)_characters.size(), nullptr); return _characters[i]; } @@ -81,7 +81,7 @@ get_character(int i) const { INLINE EggCharacterData *EggCharacterCollection:: get_character_by_model_index(int model_index) const { nassertr(model_index >= 0 && model_index < (int)_characters_by_model_index.size(), - (EggCharacterData *)NULL); + nullptr); return _characters_by_model_index[model_index]; } @@ -90,5 +90,5 @@ get_character_by_model_index(int model_index) const { */ INLINE EggCharacterCollection::ModelDescription:: ModelDescription() { - _root_node = (EggObject *)NULL; + _root_node = nullptr; } diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.cxx b/pandatool/src/eggcharbase/eggCharacterCollection.cxx index 2a97862ea6..3dfa5aaee8 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.cxx +++ b/pandatool/src/eggcharbase/eggCharacterCollection.cxx @@ -125,7 +125,7 @@ get_character_by_name(const string &character_name) const { } } - return (EggCharacterData *)NULL; + return nullptr; } @@ -617,7 +617,7 @@ rename_char(int i, const string &name) { EggCharacterData *char_data = _characters[i]; if (char_data->get_name() != name) { - nassertv(get_character_by_name(name) == (EggCharacterData *)NULL); + nassertv(get_character_by_name(name) == nullptr); char_data->rename_char(name); } } diff --git a/pandatool/src/eggcharbase/eggCharacterData.I b/pandatool/src/eggcharbase/eggCharacterData.I index 7b19b079b6..7ea131a3ec 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.I +++ b/pandatool/src/eggcharbase/eggCharacterData.I @@ -47,7 +47,7 @@ get_model_index(int n) const { */ INLINE EggNode *EggCharacterData:: get_model_root(int n) const { - nassertr(n >= 0 && n < (int)_models.size(), (EggNode *)NULL); + nassertr(n >= 0 && n < (int)_models.size(), nullptr); return _models[n]._model_root; } @@ -57,7 +57,7 @@ get_model_root(int n) const { */ INLINE EggData *EggCharacterData:: get_egg_data(int n) const { - nassertr(n >= 0 && n < (int)_models.size(), (EggData *)NULL); + nassertr(n >= 0 && n < (int)_models.size(), nullptr); return _models[n]._egg_data; } @@ -108,7 +108,7 @@ get_num_joints() const { */ INLINE EggJointData *EggCharacterData:: get_joint(int n) const { - nassertr(n >= 0 && n < (int)_joints.size(), NULL); + nassertr(n >= 0 && n < (int)_joints.size(), nullptr); return _joints[n]; } @@ -125,7 +125,7 @@ get_num_sliders() const { */ INLINE EggSliderData *EggCharacterData:: get_slider(int n) const { - nassertr(n >= 0 && n < (int)_sliders.size(), NULL); + nassertr(n >= 0 && n < (int)_sliders.size(), nullptr); return _sliders[n]; } @@ -145,6 +145,6 @@ get_num_components() const { */ INLINE EggComponentData *EggCharacterData:: get_component(int n) const { - nassertr(n >= 0 && n < (int)_components.size(), NULL); + nassertr(n >= 0 && n < (int)_components.size(), nullptr); return _components[n]; } diff --git a/pandatool/src/eggcharbase/eggCharacterData.cxx b/pandatool/src/eggcharbase/eggCharacterData.cxx index 6c444e6c91..03cffa7d47 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.cxx +++ b/pandatool/src/eggcharbase/eggCharacterData.cxx @@ -265,7 +265,7 @@ do_reparent() { EggJointData *joint_data = (*si); // Don't bother reporting joints that no longer have a parent, since we // don't care about joints that are now outside the hierarchy. - if (joint_data->get_parent() != (EggJointData *)NULL) { + if (joint_data->get_parent() != nullptr) { nout << "Warning: reparenting " << joint_data->get_name() << " to "; if (joint_data->get_parent() == _root_joint) { @@ -324,7 +324,7 @@ choose_optimal_hierarchy() { } } - if (best_parent != (EggJointData *)NULL && + if (best_parent != nullptr && best_parent != joint_data->_parent) { nout << "best parent for " << joint_data->get_name() << " is " << best_parent->get_name() << "\n"; @@ -345,7 +345,7 @@ find_slider(const string &name) const { return (*si).second; } - return NULL; + return nullptr; } /** diff --git a/pandatool/src/eggcharbase/eggCharacterFilter.cxx b/pandatool/src/eggcharbase/eggCharacterFilter.cxx index aba5834a66..9b23e7804d 100644 --- a/pandatool/src/eggcharbase/eggCharacterFilter.cxx +++ b/pandatool/src/eggcharbase/eggCharacterFilter.cxx @@ -21,7 +21,7 @@ */ EggCharacterFilter:: EggCharacterFilter() : EggMultiFilter(false) { - _collection = (EggCharacterCollection *)NULL; + _collection = nullptr; _force_initial_rest_frame = false; } @@ -31,7 +31,7 @@ EggCharacterFilter() : EggMultiFilter(false) { */ EggCharacterFilter:: ~EggCharacterFilter() { - if (_collection != (EggCharacterCollection *)NULL) { + if (_collection != nullptr) { delete _collection; } } @@ -57,7 +57,7 @@ add_fixrest_option() { */ bool EggCharacterFilter:: post_command_line() { - if (_collection == (EggCharacterCollection *)NULL) { + if (_collection == nullptr) { _collection = make_collection(); } diff --git a/pandatool/src/eggcharbase/eggComponentData.I b/pandatool/src/eggcharbase/eggComponentData.I index f706ab4b5a..e0064948de 100644 --- a/pandatool/src/eggcharbase/eggComponentData.I +++ b/pandatool/src/eggcharbase/eggComponentData.I @@ -29,7 +29,7 @@ get_num_models() const { INLINE bool EggComponentData:: has_model(int model_index) const { if (model_index >= 0 && model_index < (int)_back_pointers.size()) { - return _back_pointers[model_index] != (EggBackPointer *)NULL; + return _back_pointers[model_index] != nullptr; } return false; } @@ -43,5 +43,5 @@ get_model(int model_index) const { if (model_index >= 0 && model_index < (int)_back_pointers.size()) { return _back_pointers[model_index]; } - return (EggBackPointer *)NULL; + return nullptr; } diff --git a/pandatool/src/eggcharbase/eggComponentData.cxx b/pandatool/src/eggcharbase/eggComponentData.cxx index ceea3582a7..6a30bc4969 100644 --- a/pandatool/src/eggcharbase/eggComponentData.cxx +++ b/pandatool/src/eggcharbase/eggComponentData.cxx @@ -39,7 +39,7 @@ EggComponentData:: BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { delete back; } } @@ -85,7 +85,7 @@ matches_name(const string &name) const { int EggComponentData:: get_num_frames(int model_index) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return 0; } return back->get_num_frames(); @@ -98,7 +98,7 @@ get_num_frames(int model_index) const { void EggComponentData:: extend_to(int model_index, int num_frames) const { EggBackPointer *back = get_model(model_index); - nassertv(back != (EggBackPointer *)NULL); + nassertv(back != nullptr); back->extend_to(num_frames); } @@ -109,7 +109,7 @@ extend_to(int model_index, int num_frames) const { double EggComponentData:: get_frame_rate(int model_index) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return 0.0; } return back->get_frame_rate(); @@ -121,10 +121,10 @@ get_frame_rate(int model_index) const { void EggComponentData:: set_model(int model_index, EggBackPointer *back) { while ((int)_back_pointers.size() <= model_index) { - _back_pointers.push_back((EggBackPointer *)NULL); + _back_pointers.push_back(nullptr); } - if (_back_pointers[model_index] != (EggBackPointer *)NULL) { + if (_back_pointers[model_index] != nullptr) { nout << "Warning: deleting old back pointer.\n"; delete _back_pointers[model_index]; } diff --git a/pandatool/src/eggcharbase/eggJointData.I b/pandatool/src/eggcharbase/eggJointData.I index c6349809ae..ad0b91aee5 100644 --- a/pandatool/src/eggcharbase/eggJointData.I +++ b/pandatool/src/eggcharbase/eggJointData.I @@ -32,7 +32,7 @@ get_num_children() const { */ INLINE EggJointData *EggJointData:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), (EggJointData *)NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -43,7 +43,7 @@ get_child(int n) const { INLINE EggJointData *EggJointData:: find_joint(const string &name) { EggJointData *joint = find_joint_exact(name); - if (joint == (EggJointData *)NULL) { + if (joint == nullptr) { joint = find_joint_matches(name); } return joint; diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx index 8104ee1ad7..8197a1ec84 100644 --- a/pandatool/src/eggcharbase/eggJointData.cxx +++ b/pandatool/src/eggcharbase/eggJointData.cxx @@ -33,8 +33,8 @@ EggJointData(EggCharacterCollection *collection, EggCharacterData *char_data) : EggComponentData(collection, char_data) { - _parent = (EggJointData *)NULL; - _new_parent = (EggJointData *)NULL; + _parent = nullptr; + _new_parent = nullptr; _has_rest_frame = false; _rest_frames_differ = false; } @@ -46,7 +46,7 @@ EggJointData(EggCharacterCollection *collection, LMatrix4d EggJointData:: get_frame(int model_index, int n) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } @@ -63,7 +63,7 @@ get_frame(int model_index, int n) const { LMatrix4d EggJointData:: get_net_frame(int model_index, int n, EggCharacterDb &db) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } @@ -74,7 +74,7 @@ get_net_frame(int model_index, int n, EggCharacterDb &db) const { if (!db.get_matrix(joint, EggCharacterDb::TT_net_frame, n, mat)) { // Compute this frame's net, and stuff it in. mat = get_frame(model_index, n); - if (_parent != (EggJointData *)NULL) { + if (_parent != nullptr) { mat = mat * _parent->get_net_frame(model_index, n, db); } db.set_matrix(joint, EggCharacterDb::TT_net_frame, n, mat); @@ -89,7 +89,7 @@ get_net_frame(int model_index, int n, EggCharacterDb &db) const { LMatrix4d EggJointData:: get_net_frame_inv(int model_index, int n, EggCharacterDb &db) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } @@ -139,12 +139,12 @@ void EggJointData:: move_vertices_to(EggJointData *new_owner) { int num_models = get_num_models(); - if (new_owner == (EggJointData *)NULL) { + if (new_owner == nullptr) { for (int model_index = 0; model_index < num_models; model_index++) { if (has_model(model_index)) { EggJointPointer *joint; DCAST_INTO_V(joint, get_model(model_index)); - joint->move_vertices_to((EggJointPointer *)NULL); + joint->move_vertices_to(nullptr); } } } else { @@ -184,7 +184,7 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { int num_models = get_num_models(); for (int model_index = 0; model_index < num_models; model_index++) { EggBackPointer *back = get_model(model_index); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_R(joint, back, false); @@ -195,11 +195,11 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { // We already have this parent. transform = LMatrix4d::ident_mat(); - } else if (_parent == (EggJointData *)NULL) { + } else if (_parent == nullptr) { // We are moving from outside the joint hierarchy to within it. transform = new_parent->get_net_frame_inv(model_index, n, db); - } else if (new_parent == (EggJointData *)NULL) { + } else if (new_parent == nullptr) { // We are moving from within the hierarchy to outside it. transform = _parent->get_net_frame(model_index, n, db); @@ -278,7 +278,7 @@ do_rebuild_all(EggCharacterDb &db) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_R(joint, back, false); if (!joint->do_rebuild(db)) { @@ -307,7 +307,7 @@ optimize() { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->optimize(); @@ -330,7 +330,7 @@ expose(EggGroup::DCSType dcs_type) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->expose(dcs_type); @@ -347,7 +347,7 @@ zero_channels(const string &components) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->zero_channels(components); @@ -364,7 +364,7 @@ quantize_channels(const string &components, double quantum) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->quantize_channels(components, quantum); @@ -391,7 +391,7 @@ apply_default_pose(int source_model, int frame) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->apply_default_pose(source_joint, frame); @@ -411,7 +411,7 @@ apply_default_pose(int source_model, int frame) { */ void EggJointData:: add_back_pointer(int model_index, EggObject *egg_object) { - nassertv(egg_object != (EggObject *)NULL); + nassertv(egg_object != nullptr); if (egg_object->is_of_type(EggGroup::get_class_type())) { // It must be a . EggJointNodePointer *joint = new EggJointNodePointer(egg_object); @@ -488,7 +488,7 @@ calc_new_parent_depth(pset &chain) { if (_got_new_parent_depth) { return false; } - if (_new_parent == (EggJointData *)NULL) { + if (_new_parent == nullptr) { // Here's the top of the new hierarchy. _got_new_parent_depth = true; _new_parent_depth = 0; @@ -537,7 +537,7 @@ do_compute_reparent(int model_index, int n, EggCharacterDb &db) { } EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { // This joint doesn't have any data to modify. _computed_ok = true; return true; @@ -547,11 +547,11 @@ do_compute_reparent(int model_index, int n, EggCharacterDb &db) { DCAST_INTO_R(joint, back, false); LMatrix4d transform; - if (_parent == (EggJointData *)NULL) { + if (_parent == nullptr) { // We are moving from outside the joint hierarchy to within it. transform = _new_parent->get_new_net_frame_inv(model_index, n, db); - } else if (_new_parent == (EggJointData *)NULL) { + } else if (_new_parent == nullptr) { // We are moving from within the hierarchy to outside it. transform = _parent->get_net_frame(model_index, n, db); @@ -577,8 +577,8 @@ bool EggJointData:: do_joint_rebuild(int model_index, EggCharacterDb &db) { bool all_ok = true; - EggJointPointer *parent_joint = NULL; - if (_new_parent != NULL && _new_parent->has_model(model_index)) { + EggJointPointer *parent_joint = nullptr; + if (_new_parent != nullptr && _new_parent->has_model(model_index)) { DCAST_INTO_R(parent_joint, _new_parent->get_model(model_index), false); } @@ -601,8 +601,8 @@ void EggJointData:: do_finish_reparent() { int num_models = get_num_models(); for (int model_index = 0; model_index < num_models; model_index++) { - EggJointPointer *parent_joint = NULL; - if (_new_parent != NULL && _new_parent->has_model(model_index)) { + EggJointPointer *parent_joint = nullptr; + if (_new_parent != nullptr && _new_parent->has_model(model_index)) { DCAST_INTO_V(parent_joint, _new_parent->get_model(model_index)); } @@ -614,7 +614,7 @@ do_finish_reparent() { } _parent = _new_parent; - if (_parent != (EggJointData *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } } @@ -636,7 +636,7 @@ make_new_joint(const string &name) { for (int i = 0; i < num_models; i++) { if (has_model(i)) { EggJointPointer *joint; - DCAST_INTO_R(joint, get_model(i), NULL); + DCAST_INTO_R(joint, get_model(i), nullptr); EggJointPointer *new_joint = joint->make_new_joint(name); child->set_model(i, new_joint); } @@ -658,12 +658,12 @@ find_joint_exact(const string &name) { return child; } EggJointData *result = child->find_joint_exact(name); - if (result != (EggJointData *)NULL) { + if (result != nullptr) { return result; } } - return (EggJointData *)NULL; + return nullptr; } /** @@ -679,12 +679,12 @@ find_joint_matches(const string &name) { return child; } EggJointData *result = child->find_joint_matches(name); - if (result != (EggJointData *)NULL) { + if (result != nullptr) { return result; } } - return (EggJointData *)NULL; + return nullptr; } /** @@ -698,7 +698,7 @@ is_new_ancestor(EggJointData *child) const { return true; } - if (child->_new_parent == (EggJointData *)NULL) { + if (child->_new_parent == nullptr) { return false; } @@ -714,7 +714,7 @@ const LMatrix4d &EggJointData:: get_new_net_frame(int model_index, int n, EggCharacterDb &db) { if (!_got_new_net_frame) { _new_net_frame = get_new_frame(model_index, n, db); - if (_new_parent != (EggJointData *)NULL) { + if (_new_parent != nullptr) { _new_net_frame = _new_net_frame * _new_parent->get_new_net_frame(model_index, n, db); } _got_new_net_frame = true; @@ -729,7 +729,7 @@ const LMatrix4d &EggJointData:: get_new_net_frame_inv(int model_index, int n, EggCharacterDb &db) { if (!_got_new_net_frame_inv) { _new_net_frame_inv.invert_from(get_new_frame(model_index, n, db)); - if (_new_parent != (EggJointData *)NULL) { + if (_new_parent != nullptr) { _new_net_frame_inv = _new_parent->get_new_net_frame_inv(model_index, n, db) * _new_net_frame_inv; } _got_new_net_frame_inv = true; @@ -747,7 +747,7 @@ get_new_frame(int model_index, int n, EggCharacterDb &db) { do_compute_reparent(model_index, n, db); EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx index 3ebc85c3d4..4ab8a7227a 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx +++ b/pandatool/src/eggcharbase/eggJointNodePointer.cxx @@ -28,7 +28,7 @@ EggJointNodePointer:: EggJointNodePointer(EggObject *object) { _joint = DCAST(EggGroup, object); - if (_joint != (EggGroup *)NULL && _joint->is_joint()) { + if (_joint != nullptr && _joint->is_joint()) { // Quietly insist that the joint has a transform, for neatness. If it // does not, give it the identity transform. if (!_joint->has_transform()) { @@ -83,10 +83,10 @@ set_frame(int n, const LMatrix4d &mat) { */ void EggJointNodePointer:: do_finish_reparent(EggJointPointer *new_parent) { - if (new_parent == (EggJointPointer *)NULL) { + if (new_parent == nullptr) { // No new parent; unparent the joint. EggGroupNode *egg_parent = _joint->get_parent(); - if (egg_parent != (EggGroupNode *)NULL) { + if (egg_parent != nullptr) { egg_parent->remove_child(_joint.p()); egg_parent->steal_children(*_joint); } @@ -107,7 +107,7 @@ do_finish_reparent(EggJointPointer *new_parent) { */ void EggJointNodePointer:: move_vertices_to(EggJointPointer *new_joint) { - if (new_joint == (EggJointPointer *)NULL) { + if (new_joint == nullptr) { _joint->unref_all_vertices(); } else { @@ -150,7 +150,7 @@ do_rebuild(EggCharacterDb &db) { */ void EggJointNodePointer:: expose(EggGroup::DCSType dcs_type) { - if (_joint != (EggGroup *)NULL) { + if (_joint != nullptr) { _joint->set_dcs_type(dcs_type); } } @@ -161,7 +161,7 @@ expose(EggGroup::DCSType dcs_type) { */ void EggJointNodePointer:: apply_default_pose(EggJointPointer *source_joint, int frame) { - if (_joint != (EggGroup *)NULL) { + if (_joint != nullptr) { LMatrix4d pose; if (frame >= 0 && frame < source_joint->get_num_frames()) { pose = source_joint->get_frame(frame); @@ -180,7 +180,7 @@ apply_default_pose(EggJointPointer *source_joint, int frame) { */ bool EggJointNodePointer:: has_vertices() const { - if (_joint != (EggGroup *)NULL) { + if (_joint != nullptr) { return (_joint->vref_size() != 0) || _joint->joint_has_primitives(); } diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx index c81ae1bd1a..130975fc0b 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx @@ -26,7 +26,7 @@ EggMatrixTablePointer:: EggMatrixTablePointer(EggObject *object) { _table = DCAST(EggTable, object); - if (_table != (EggTable *)NULL) { + if (_table != nullptr) { // Now search for the child named "xform". This contains the actual table // data. EggGroupNode::iterator ci; @@ -58,7 +58,7 @@ EggMatrixTablePointer(EggObject *object) { */ double EggMatrixTablePointer:: get_frame_rate() const { - if (_xform == (EggXfmSAnim *)NULL || !_xform->has_fps()) { + if (_xform == nullptr || !_xform->has_fps()) { return 0.0; } else { return _xform->get_fps(); @@ -70,7 +70,7 @@ get_frame_rate() const { */ int EggMatrixTablePointer:: get_num_frames() const { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return 0; } else { return _xform->get_num_rows(); @@ -82,7 +82,7 @@ get_num_frames() const { */ void EggMatrixTablePointer:: extend_to(int num_frames) { - nassertv(_xform != (EggXfmSAnim *)NULL); + nassertv(_xform != nullptr); _xform->normalize(); int num_rows = _xform->get_num_rows(); LMatrix4d last_mat; @@ -136,7 +136,7 @@ set_frame(int n, const LMatrix4d &mat) { */ bool EggMatrixTablePointer:: add_frame(const LMatrix4d &mat) { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return false; } @@ -149,10 +149,10 @@ add_frame(const LMatrix4d &mat) { */ void EggMatrixTablePointer:: do_finish_reparent(EggJointPointer *new_parent) { - if (new_parent == (EggJointPointer *)NULL) { + if (new_parent == nullptr) { // No new parent; unparent the joint. EggGroupNode *egg_parent = _table->get_parent(); - if (egg_parent != (EggGroupNode *)NULL) { + if (egg_parent != nullptr) { egg_parent->remove_child(_table.p()); } @@ -184,7 +184,7 @@ do_rebuild(EggCharacterDb &db) { return true; } - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return false; } @@ -213,7 +213,7 @@ do_rebuild(EggCharacterDb &db) { */ void EggMatrixTablePointer:: optimize() { - if (_xform != (EggXfmSAnim *)NULL) { + if (_xform != nullptr) { _xform->optimize(); } } @@ -223,7 +223,7 @@ optimize() { */ void EggMatrixTablePointer:: zero_channels(const string &components) { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return; } @@ -233,7 +233,7 @@ zero_channels(const string &components) { for (si = components.begin(); si != components.end(); ++si) { string table_name(1, *si); EggNode *child = _xform->find_child(table_name); - if (child != (EggNode *)NULL) { + if (child != nullptr) { _xform->remove_child(child); } } @@ -245,7 +245,7 @@ zero_channels(const string &components) { */ void EggMatrixTablePointer:: quantize_channels(const string &components, double quantum) { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return; } @@ -255,7 +255,7 @@ quantize_channels(const string &components, double quantum) { for (si = components.begin(); si != components.end(); ++si) { string table_name(1, *si); EggNode *child = _xform->find_child(table_name); - if (child != (EggNode *)NULL && + if (child != nullptr && child->is_of_type(EggSAnimData::get_class_type())) { EggSAnimData *anim = DCAST(EggSAnimData, child); anim->quantize(quantum); @@ -272,7 +272,7 @@ make_new_joint(const string &name) { EggTable *new_table = new EggTable(name); _table->add_child(new_table); CoordinateSystem cs = CS_default; - if (_xform != (EggXfmSAnim *)NULL) { + if (_xform != nullptr) { cs = _xform->get_coordinate_system(); } EggXfmSAnim *new_xform = new EggXfmSAnim("xform", cs); diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx index da104af2bd..18f4aaaf5c 100644 --- a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx @@ -31,7 +31,7 @@ EggScalarTablePointer(EggObject *object) { */ double EggScalarTablePointer:: get_frame_rate() const { - if (_data == (EggSAnimData *)NULL || !_data->has_fps()) { + if (_data == nullptr || !_data->has_fps()) { return 0.0; } else { return _data->get_fps(); @@ -43,7 +43,7 @@ get_frame_rate() const { */ int EggScalarTablePointer:: get_num_frames() const { - if (_data == (EggSAnimData *)NULL) { + if (_data == nullptr) { return 0; } else { return _data->get_num_rows(); @@ -55,7 +55,7 @@ get_num_frames() const { */ void EggScalarTablePointer:: extend_to(int num_frames) { - nassertv(_data != (EggSAnimData *)NULL); + nassertv(_data != nullptr); int num_rows = _data->get_num_rows(); double last_value; if (num_rows == 0) { diff --git a/pandatool/src/eggcharbase/eggSliderData.cxx b/pandatool/src/eggcharbase/eggSliderData.cxx index d597adcc17..25bbae1140 100644 --- a/pandatool/src/eggcharbase/eggSliderData.cxx +++ b/pandatool/src/eggcharbase/eggSliderData.cxx @@ -40,7 +40,7 @@ EggSliderData(EggCharacterCollection *collection, double EggSliderData:: get_frame(int model_index, int n) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return 0.0; } @@ -58,7 +58,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { if (egg_object->is_of_type(EggPrimitive::get_class_type())) { // A primitive! EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { back = new EggVertexPointer(egg_object); set_model(model_index, back); } @@ -66,7 +66,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { } else if (egg_object->is_of_type(EggVertex::get_class_type())) { // A vertex! EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { back = new EggVertexPointer(egg_object); set_model(model_index, back); } @@ -74,7 +74,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { } else if (egg_object->is_of_type(EggSAnimData::get_class_type())) { // A slider animation table! Woo hoo! EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { back = new EggScalarTablePointer(egg_object); set_model(model_index, back); } diff --git a/pandatool/src/eggprogs/eggMakeTube.cxx b/pandatool/src/eggprogs/eggMakeTube.cxx index 37adfd8d59..7017e97dcd 100644 --- a/pandatool/src/eggprogs/eggMakeTube.cxx +++ b/pandatool/src/eggprogs/eggMakeTube.cxx @@ -36,7 +36,7 @@ EggMakeTube() { add_option ("a", "x,y,z", 0, "Specify the first endpoint of the tube.", - &EggWriter::dispatch_double_triple, NULL, _point_a); + &EggWriter::dispatch_double_triple, nullptr, _point_a); add_option ("b", "x,y,z", 0, @@ -47,23 +47,23 @@ EggMakeTube() { ("r", "radius", 0, "Specify the radius of the tube. The tube will extend beyond " "the endpoints in each direction by the amount of radius.", - &EggWriter::dispatch_double, NULL, &_radius); + &EggWriter::dispatch_double, nullptr, &_radius); add_option ("slices", "count", 0, "Specify the number of slices appearing radially around the tube.", - &EggWriter::dispatch_int, NULL, &_num_slices); + &EggWriter::dispatch_int, nullptr, &_num_slices); add_option ("crings", "count", 0, "Specify the number of rings appearing in each endcap of the tube.", - &EggWriter::dispatch_int, NULL, &_num_crings); + &EggWriter::dispatch_int, nullptr, &_num_crings); add_option ("trings", "count", 0, "Specify the number of rings appearing in the cylindrical body " "of the tube.", - &EggWriter::dispatch_int, NULL, &_num_trings); + &EggWriter::dispatch_int, nullptr, &_num_trings); _point_a[0] = 0.0; _point_a[1] = 0.0; @@ -111,8 +111,8 @@ run() { EggVertex *vtx_2; for (ri = 0; ri < _num_crings; ri++) { - vtx_1 = NULL; - vtx_2 = NULL; + vtx_1 = nullptr; + vtx_2 = nullptr; for (si = 0; si <= _num_slices; si++) { EggVertex *vtx_3 = calc_sphere1_vertex(ri, si); EggVertex *vtx_4 = calc_sphere1_vertex(ri + 1, si); @@ -125,8 +125,8 @@ run() { // Now the cylinder sides. if (_length != 0.0) { for (ri = 0; ri < _num_trings; ri++) { - vtx_1 = NULL; - vtx_2 = NULL; + vtx_1 = nullptr; + vtx_2 = nullptr; for (si = 0; si <= _num_slices; si++) { EggVertex *vtx_3 = calc_tube_vertex(ri, si); EggVertex *vtx_4 = calc_tube_vertex(ri + 1, si); @@ -139,8 +139,8 @@ run() { // And the second endcap. for (ri = _num_crings - 1; ri >= 0; ri--) { - vtx_1 = NULL; - vtx_2 = NULL; + vtx_1 = nullptr; + vtx_2 = nullptr; for (si = 0; si <= _num_slices; si++) { EggVertex *vtx_3 = calc_sphere2_vertex(ri + 1, si); EggVertex *vtx_4 = calc_sphere2_vertex(ri, si); @@ -244,7 +244,7 @@ calc_sphere2_vertex(int ri, int si) { */ void EggMakeTube:: add_polygon(EggVertex *a, EggVertex *b, EggVertex *c, EggVertex *d) { - if (a == (EggVertex *)NULL) { + if (a == nullptr) { return; } diff --git a/pandatool/src/eggprogs/eggRename.cxx b/pandatool/src/eggprogs/eggRename.cxx index abde299e2d..532f096dbb 100644 --- a/pandatool/src/eggprogs/eggRename.cxx +++ b/pandatool/src/eggprogs/eggRename.cxx @@ -26,7 +26,7 @@ EggRename() { add_option ("strip_prefix", "name", 0, "strips out the prefix that is put on all nodes, by maya ext. ref", - &EggRename::dispatch_vector_string, NULL, &_strip_prefix); + &EggRename::dispatch_vector_string, nullptr, &_strip_prefix); } /** diff --git a/pandatool/src/eggprogs/eggRetargetAnim.cxx b/pandatool/src/eggprogs/eggRetargetAnim.cxx index f354eb57b9..0c522652e1 100644 --- a/pandatool/src/eggprogs/eggRetargetAnim.cxx +++ b/pandatool/src/eggprogs/eggRetargetAnim.cxx @@ -48,13 +48,13 @@ EggRetargetAnim() { ("r", "file.egg", 0, "Read the reference model from the indicated egg file. All of the " "animations will be retargeted to match the indicated file.", - &EggRetargetAnim::dispatch_filename, NULL, &_reference_filename); + &EggRetargetAnim::dispatch_filename, nullptr, &_reference_filename); add_option ("keep", "joint[,joint...]", 0, "Preserve the full animation on the named joint(s). This is especially " "appropriate for the root joint.", - &EggRetargetAnim::dispatch_vector_string_comma, NULL, &_keep_joints); + &EggRetargetAnim::dispatch_vector_string_comma, nullptr, &_keep_joints); } /** @@ -62,7 +62,7 @@ EggRetargetAnim() { */ void EggRetargetAnim:: run() { - nassertv(_collection != (EggCharacterCollection *)NULL); + nassertv(_collection != nullptr); nassertv(_collection->get_num_eggs() > 0); if (_reference_filename.empty()) { @@ -78,7 +78,7 @@ run() { // Read in the extra egg file that we use for extracting the references out. PT(EggData) reference_egg = read_egg(_reference_filename); - if (reference_egg == (EggData *)NULL) { + if (reference_egg == nullptr) { nout << "Cannot read " << _reference_filename << "\n"; exit(1); } @@ -146,7 +146,7 @@ retarget_anim(EggCharacterData *char_data, EggJointData *joint_data, int num_frames = char_data->get_num_frames(i); EggBackPointer *back = joint_data->get_model(i); - nassertv(back != (EggBackPointer *)NULL); + nassertv(back != nullptr); EggJointPointer *joint; DCAST_INTO_V(joint, back); diff --git a/pandatool/src/eggprogs/eggTextureCards.cxx b/pandatool/src/eggprogs/eggTextureCards.cxx index 03cb811809..bf7032230f 100644 --- a/pandatool/src/eggprogs/eggTextureCards.cxx +++ b/pandatool/src/eggprogs/eggTextureCards.cxx @@ -49,7 +49,7 @@ EggTextureCards() : EggWriter(true, true) { "centered on the origin: -0.5,0.5,-0.5,0.5. Polygons are always created " "on the X-Y plane. If -p is not also specified, all polygons will be " "the same size and shape.", - &EggTextureCards::dispatch_double_quad, NULL, &_polygon_geometry[0]); + &EggTextureCards::dispatch_double_quad, nullptr, &_polygon_geometry[0]); add_option ("p", "xpixels,ypixels", 0, @@ -70,44 +70,44 @@ EggTextureCards() : EggWriter(true, true) { "This option specifies an ignorable suffix in the texture filename(s); " "if this suffix is present, it is not included in the polygon's name. " "This option may be repeated multiple times.", - &EggTextureCards::dispatch_vector_string, NULL, &_suffixes); + &EggTextureCards::dispatch_vector_string, nullptr, &_suffixes); add_option ("c", "r,g,b[,a]", 0, "Specifies the color of each polygon. The default is white: 1,1,1,1.", - &EggTextureCards::dispatch_color, NULL, &_polygon_color[0]); + &EggTextureCards::dispatch_color, nullptr, &_polygon_color[0]); add_option ("wm", "wrap", 0, "Indicates the wrap mode of the texture: \"repeat\", \"clamp\", " "or any of the other modes supported by egg syntax. " "The default is to leave this unspecified.", - &EggTextureCards::dispatch_wrap_mode, NULL, &_wrap_mode); + &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_mode); add_option ("wmu", "wrap_u", 0, "Indicates the wrap mode of the texture in the U direction. This " "overrides -wm, if specified.", - &EggTextureCards::dispatch_wrap_mode, NULL, &_wrap_u); + &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_u); add_option ("wmv", "wrap_v", 0, "Indicates the wrap mode of the texture in the V direction. This " "overrides -wm, if specified.", - &EggTextureCards::dispatch_wrap_mode, NULL, &_wrap_v); + &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_v); add_option ("minf", "filter", 0, "Indicates the minfilter mode of the texture: \"linear\", \"mipmap\", " "or any of the other modes supported by egg syntax. " "The default is to leave this unspecified.", - &EggTextureCards::dispatch_filter_type, NULL, &_minfilter); + &EggTextureCards::dispatch_filter_type, nullptr, &_minfilter); add_option ("magf", "filter", 0, "Indicates the magfilter mode of the texture: \"linear\" or \"nearest\". " "The default is to leave this unspecified.", - &EggTextureCards::dispatch_filter_type, NULL, &_magfilter); + &EggTextureCards::dispatch_filter_type, nullptr, &_magfilter); add_option ("aniso", "degree", 0, @@ -119,37 +119,37 @@ EggTextureCards() : EggWriter(true, true) { ("ql", "[default | fastest | normal | best]", 0, "Specifies the quality level of the texture. This mainly affects " "the tinydisplay software renderer.", - &EggTextureCards::dispatch_quality_level, NULL, &_quality_level); + &EggTextureCards::dispatch_quality_level, nullptr, &_quality_level); add_option ("f", "format", 0, "Indicates the format for all textures: typical choices are \"rgba12\" " "or \"rgb5\" or \"alpha\". The default is to leave this unspecified.", - &EggTextureCards::dispatch_format, NULL, &_format); + &EggTextureCards::dispatch_format, nullptr, &_format); add_option ("f1", "format", 0, "Indicates the format for one-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_1); + &EggTextureCards::dispatch_format, nullptr, &_format_1); add_option ("f2", "format", 0, "Indicates the format for two-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_2); + &EggTextureCards::dispatch_format, nullptr, &_format_2); add_option ("f3", "format", 0, "Indicates the format for three-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_3); + &EggTextureCards::dispatch_format, nullptr, &_format_3); add_option ("f4", "format", 0, "Indicates the format for four-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_4); + &EggTextureCards::dispatch_format, nullptr, &_format_4); add_option ("b", "", 0, @@ -164,7 +164,7 @@ EggTextureCards() : EggWriter(true, true) { "nice side-effect of creating an automatic texture flip that can be " "used directly by applications; use this parameter to specify the " "frame rate of that texture flip.", - &EggTextureCards::dispatch_double, NULL, &_frame_rate); + &EggTextureCards::dispatch_double, nullptr, &_frame_rate); add_option ("noexist", "", 0, diff --git a/pandatool/src/eggprogs/eggToC.cxx b/pandatool/src/eggprogs/eggToC.cxx index 28fcb2f36e..a1f0a4d081 100644 --- a/pandatool/src/eggprogs/eggToC.cxx +++ b/pandatool/src/eggprogs/eggToC.cxx @@ -158,7 +158,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL) { + if (vert == nullptr) { out << " vertex(), /* " << i << " */\n"; } else { LPoint4d p = vert->get_pos4(); @@ -196,7 +196,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL || !vert->has_uv()) { + if (vert == nullptr || !vert->has_uv()) { out << " uv(), /* " << i << " */\n"; } else { LTexCoordd uv = vert->get_uv(); @@ -213,7 +213,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL || !vert->has_normal()) { + if (vert == nullptr || !vert->has_normal()) { out << " normal(), /* " << i << " */\n"; } else { LNormald n = vert->get_normal(); @@ -230,7 +230,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL || !vert->has_color()) { + if (vert == nullptr || !vert->has_color()) { out << " color(), /* " << i << " */\n"; } else { LColor c = vert->get_color(); diff --git a/pandatool/src/eggprogs/eggTopstrip.cxx b/pandatool/src/eggprogs/eggTopstrip.cxx index e0bbcf4e7e..4b0397e065 100644 --- a/pandatool/src/eggprogs/eggTopstrip.cxx +++ b/pandatool/src/eggprogs/eggTopstrip.cxx @@ -44,7 +44,7 @@ EggTopstrip() { ("t", "name", 0, "Specify the name of the 'top' joint, from which to draw the " "animation channels which will be applied to the entire animation.", - &EggTopstrip::dispatch_string, NULL, &_top_joint_name); + &EggTopstrip::dispatch_string, nullptr, &_top_joint_name); add_option ("i", "", 0, @@ -64,13 +64,13 @@ EggTopstrip() { "any combination of the nine token letters: i, j, k represent the " "three scale axes; h, p, r represent rotation; and x, y, z represent " "translation. The default is everything: -s ijkphrxyz.", - &EggTopstrip::dispatch_string, NULL, &_transform_channels); + &EggTopstrip::dispatch_string, nullptr, &_transform_channels); add_option ("r", "file.egg", 0, "Read the animation channel from the indicated egg file. If this " "is not specified, each egg file will supply its own animation channel.", - &EggTopstrip::dispatch_filename, NULL, &_channel_filename); + &EggTopstrip::dispatch_filename, nullptr, &_channel_filename); _invert_transform = true; _transform_channels = "ijkphrxyz"; @@ -81,7 +81,7 @@ EggTopstrip() { */ void EggTopstrip:: run() { - nassertv(_collection != (EggCharacterCollection *)NULL); + nassertv(_collection != nullptr); nassertv(_collection->get_num_eggs() > 0); check_transform_channels(); @@ -97,7 +97,7 @@ run() { if (!_channel_filename.empty()) { // Read in the extra egg file that we use for extracting the channels out. PT(EggData) channel_egg = read_egg(_channel_filename); - if (channel_egg == (EggData *)NULL) { + if (channel_egg == nullptr) { nout << "Cannot read " << _channel_filename << "\n"; exit(1); } @@ -134,7 +134,7 @@ run() { } // Determine which joint we'll use to extract the transform to apply. - EggJointData *top_joint = (EggJointData *)NULL; + EggJointData *top_joint = nullptr; if (_top_joint_name.empty()) { // The default top joint name is the alphabetically first joint in the // top level. @@ -145,7 +145,7 @@ run() { top_joint = root_joint->get_child(0); } else { top_joint = from_char->find_joint(_top_joint_name); - if (top_joint == (EggJointData *)NULL) { + if (top_joint == nullptr) { nout << "Character " << from_char->get_name() << " has no joint named " << _top_joint_name << "\n"; exit(1); @@ -238,7 +238,7 @@ strip_anim(EggCharacterData *char_data, EggJointData *joint_data, int num_frames = max(num_into_frames, num_from_frames); EggBackPointer *back = joint_data->get_model(i); - nassertv(back != (EggBackPointer *)NULL); + nassertv(back != nullptr); EggJointPointer *joint; DCAST_INTO_V(joint, back); diff --git a/pandatool/src/flt/fltBead.cxx b/pandatool/src/flt/fltBead.cxx index bfa5b3f656..8cc21f8c4f 100644 --- a/pandatool/src/flt/fltBead.cxx +++ b/pandatool/src/flt/fltBead.cxx @@ -100,7 +100,7 @@ get_num_transform_steps() const { FltTransformRecord *FltBead:: get_transform_step(int n) { nassertr(n >= 0 && n < (int)_transform_steps.size(), - (FltTransformRecord *)NULL); + nullptr); return _transform_steps[n]; } @@ -111,7 +111,7 @@ get_transform_step(int n) { const FltTransformRecord *FltBead:: get_transform_step(int n) const { nassertr(n >= 0 && n < (int)_transform_steps.size(), - (const FltTransformRecord *)NULL); + nullptr); return _transform_steps[n]; } @@ -172,7 +172,7 @@ extract_record(FltRecordReader &reader) { */ bool FltBead:: extract_ancillary(FltRecordReader &reader) { - FltTransformRecord *step = (FltTransformRecord *)NULL; + FltTransformRecord *step = nullptr; switch (reader.get_opcode()) { case FO_transform_matrix: @@ -214,7 +214,7 @@ extract_ancillary(FltRecordReader &reader) { } // A transform step. - nassertr(step != (FltTransformRecord *)NULL, false); + nassertr(step != nullptr, false); if (!step->extract_record(reader)) { return false; } diff --git a/pandatool/src/flt/fltGeometry.I b/pandatool/src/flt/fltGeometry.I index 3c4fae7918..c584c52003 100644 --- a/pandatool/src/flt/fltGeometry.I +++ b/pandatool/src/flt/fltGeometry.I @@ -34,7 +34,7 @@ get_texture() const { */ INLINE void FltGeometry:: set_texture(FltTexture *texture) { - if (texture == (FltTexture *)NULL) { + if (texture == nullptr) { _texture_index = -1; } else { _header->add_texture(texture); @@ -65,7 +65,7 @@ get_material() const { */ INLINE void FltGeometry:: set_material(FltMaterial *material) { - if (material == (FltMaterial *)NULL) { + if (material == nullptr) { _material_index = -1; } else { _header->add_material(material); diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index 062afe15fa..e6cd4dbd10 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -37,7 +37,7 @@ TypeHandle FltHeader::_type_handle; */ FltHeader:: FltHeader(PathReplace *path_replace) : FltBeadID(this) { - if (path_replace == (PathReplace *)NULL) { + if (path_replace == nullptr) { _path_replace = new PathReplace; _path_replace->_path_store = PS_absolute; } else { @@ -191,7 +191,7 @@ read_flt(Filename filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { assert(!flt_error_abort); return FE_could_not_open; } @@ -237,7 +237,7 @@ FltError FltHeader:: write_flt(Filename filename) { filename.set_binary(); - ofstream out; + std::ofstream out; if (!filename.open_write(out)) { assert(!flt_error_abort); return FE_could_not_open; @@ -425,7 +425,7 @@ get_instance(int instance_index) const { if (mi != _instances.end()) { return (*mi).second; } - return (FltInstanceDefinition *)NULL; + return nullptr; } /** @@ -467,7 +467,7 @@ get_num_vertices() const { */ FltVertex *FltHeader:: get_vertex(int n) const { - nassertr(n >= 0 && n < (int)_vertices.size(), 0); + nassertr(n >= 0 && n < (int)_vertices.size(), nullptr); return _vertices[n]; } @@ -512,7 +512,7 @@ get_vertex_by_offset(int offset) { vi = _vertices_by_offset.find(offset); if (vi == _vertices_by_offset.end()) { nout << "No vertex with offset " << offset << "\n"; - return (FltVertex *)NULL; + return nullptr; } return (*vi).second; } @@ -810,7 +810,7 @@ get_material(int material_index) const { if (mi != _materials.end()) { return (*mi).second; } - return (FltMaterial *)NULL; + return nullptr; } /** @@ -869,7 +869,7 @@ get_texture(int texture_index) const { if (mi != _textures.end()) { return (*mi).second; } - return (FltTexture *)NULL; + return nullptr; } /** @@ -928,7 +928,7 @@ get_light_source(int light_index) const { if (li != _light_sources.end()) { return (*li).second; } - return (FltLightSourceDefinition *)NULL; + return nullptr; } /** @@ -993,7 +993,7 @@ get_num_eyepoints() const { */ FltEyepoint *FltHeader:: get_eyepoint(int n) { - nassertr(n >= 0 && n < get_num_eyepoints(), (FltEyepoint *)NULL); + nassertr(n >= 0 && n < get_num_eyepoints(), nullptr); return &_eyepoints[n]; } @@ -1011,7 +1011,7 @@ get_num_trackplanes() const { */ FltTrackplane *FltHeader:: get_trackplane(int n) { - nassertr(n >= 0 && n < get_num_trackplanes(), (FltTrackplane *)NULL); + nassertr(n >= 0 && n < get_num_trackplanes(), nullptr); return &_trackplanes[n]; } diff --git a/pandatool/src/flt/fltInstanceRef.cxx b/pandatool/src/flt/fltInstanceRef.cxx index 7f0ffd2e67..8622f6180b 100644 --- a/pandatool/src/flt/fltInstanceRef.cxx +++ b/pandatool/src/flt/fltInstanceRef.cxx @@ -45,7 +45,7 @@ void FltInstanceRef:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "instance"; FltInstanceDefinition *def = _header->get_instance(_instance_index); - if (def != (FltInstanceDefinition *)NULL) { + if (def != nullptr) { def->write_children(out, indent_level + 2); indent(out, indent_level) << "}\n"; } else { diff --git a/pandatool/src/flt/fltMesh.cxx b/pandatool/src/flt/fltMesh.cxx index 47506e732a..e77b8636d6 100644 --- a/pandatool/src/flt/fltMesh.cxx +++ b/pandatool/src/flt/fltMesh.cxx @@ -95,7 +95,7 @@ build_record(FltRecordWriter &writer) const { */ FltError FltMesh:: write_ancillary(FltRecordWriter &writer) const { - if (_vpool != (FltLocalVertexPool *)NULL) { + if (_vpool != nullptr) { if (!_vpool->build_record(writer)) { assert(!flt_error_abort); return FE_bad_data; diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index 53844f0636..5325259ec6 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -69,7 +69,7 @@ get_num_children() const { */ FltRecord *FltRecord:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -104,7 +104,7 @@ get_num_subfaces() const { */ FltRecord *FltRecord:: get_subface(int n) const { - nassertr(n >= 0 && n < (int)_subfaces.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_subfaces.size(), nullptr); return _subfaces[n]; } @@ -139,7 +139,7 @@ get_num_extensions() const { */ FltRecord *FltRecord:: get_extension(int n) const { - nassertr(n >= 0 && n < (int)_extensions.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_extensions.size(), nullptr); return _extensions[n]; } @@ -178,7 +178,7 @@ get_num_ancillary() const { */ FltRecord *FltRecord:: get_ancillary(int n) const { - nassertr(n >= 0 && n < (int)_ancillary.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_ancillary.size(), nullptr); return _ancillary[n]; } diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx index b90e911964..f2650fa423 100644 --- a/pandatool/src/flt/fltRecordReader.cxx +++ b/pandatool/src/flt/fltRecordReader.cxx @@ -27,7 +27,7 @@ FltRecordReader(istream &in) : { _opcode = FO_none; _record_length = 0; - _iterator = (DatagramIterator *)NULL; + _iterator = nullptr; _state = S_begin; _next_error = FE_ok; _next_opcode = FO_none; @@ -42,9 +42,9 @@ FltRecordReader(istream &in) : */ FltRecordReader:: ~FltRecordReader() { - if (_iterator != (DatagramIterator *)NULL) { + if (_iterator != nullptr) { delete _iterator; - _iterator = (DatagramIterator *)NULL; + _iterator = nullptr; } } @@ -101,9 +101,9 @@ advance(bool ok_eof) { assert(!flt_error_abort); return FE_read_error; } - if (_iterator != (DatagramIterator *)NULL) { + if (_iterator != nullptr) { delete _iterator; - _iterator = (DatagramIterator *)NULL; + _iterator = nullptr; } if (_next_error == FE_end_of_file) { diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx index 55ca9fc0d4..df3d904d27 100644 --- a/pandatool/src/flt/fltRecordWriter.cxx +++ b/pandatool/src/flt/fltRecordWriter.cxx @@ -142,7 +142,7 @@ write_instance_def(FltHeader *header, int instance_index) { } FltInstanceDefinition *instance = header->get_instance(instance_index); - if (instance == (FltInstanceDefinition *)NULL) { + if (instance == nullptr) { assert(!flt_error_abort); return FE_undefined_instance; } diff --git a/pandatool/src/flt/fltTexture.cxx b/pandatool/src/flt/fltTexture.cxx index c3c61cf130..ee56205c6f 100644 --- a/pandatool/src/flt/fltTexture.cxx +++ b/pandatool/src/flt/fltTexture.cxx @@ -136,7 +136,7 @@ FltError FltTexture:: read_attr_data() { Filename attr_filename = get_attr_filename(); - ifstream attr; + std::ifstream attr; if (!attr_filename.open_read(attr)) { return FE_could_not_open; } @@ -184,7 +184,7 @@ write_attr_data(Filename attr_filename) const { } attr_filename.set_binary(); - ofstream attr; + std::ofstream attr; if (!attr_filename.open_write(attr)) { return FE_could_not_open; } diff --git a/pandatool/src/flt/fltVertexList.cxx b/pandatool/src/flt/fltVertexList.cxx index 9659a56063..941d35c300 100644 --- a/pandatool/src/flt/fltVertexList.cxx +++ b/pandatool/src/flt/fltVertexList.cxx @@ -38,7 +38,7 @@ get_num_vertices() const { */ FltVertex *FltVertexList:: get_vertex(int n) const { - nassertr(n >= 0 && n < (int)_vertices.size(), 0); + nassertr(n >= 0 && n < (int)_vertices.size(), nullptr); return _vertices[n]; } diff --git a/pandatool/src/fltegg/fltToEggConverter.cxx b/pandatool/src/fltegg/fltToEggConverter.cxx index 0f2b78e268..bd4898b0c5 100644 --- a/pandatool/src/fltegg/fltToEggConverter.cxx +++ b/pandatool/src/fltegg/fltToEggConverter.cxx @@ -353,16 +353,16 @@ convert_face(const FltFace *flt_face, FltToEggLevelState &state) { // Collect the vertices for this primitive. pvector< PT_EggVertex > vertices; - const FltVertexList *vlist = (FltVertexList *)NULL; + const FltVertexList *vlist = nullptr; int num_children = flt_face->get_num_children(); - for (int i = 0; i < num_children && vlist == (FltVertexList *)NULL; i++) { + for (int i = 0; i < num_children && vlist == nullptr; i++) { const FltRecord *child = flt_face->get_child(i); if (child->is_of_type(FltVertexList::get_class_type())) { vlist = DCAST(FltVertexList, child); } } - if (vlist != (FltVertexList *)NULL) { + if (vlist != nullptr) { int num_vertices = vlist->get_num_vertices(); for (int i = 0; i < num_vertices; i++) { FltVertex *flt_vertex = vlist->get_vertex(i); @@ -440,7 +440,7 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, LColor face_color = flt_geom->get_color(); - if (state._flt_object != (FltObject *)NULL) { + if (state._flt_object != nullptr) { // If we have a FltObject above us, it might also specify a transparency. // This combines with our existing transparency. PN_stdfloat alpha = 1.0 - (state._flt_object->_transparency / 65535.0); diff --git a/pandatool/src/fltegg/fltToEggLevelState.I b/pandatool/src/fltegg/fltToEggLevelState.I index 0a1cef8f43..e5460717a6 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.I +++ b/pandatool/src/fltegg/fltToEggLevelState.I @@ -18,8 +18,8 @@ INLINE FltToEggLevelState:: FltToEggLevelState(FltToEggConverter *converter) : _converter(converter) { - _flt_object = (FltObject *)NULL; - _egg_parent = (EggGroupNode *)NULL; + _flt_object = nullptr; + _egg_parent = nullptr; } /** diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx index 1fbe548d50..238208527e 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.cxx +++ b/pandatool/src/fltegg/fltToEggLevelState.cxx @@ -39,9 +39,9 @@ FltToEggLevelState:: */ FltToEggLevelState::ParentNodes:: ParentNodes() { - _axial_billboard = (EggGroup *)NULL; - _point_billboard = (EggGroup *)NULL; - _plain = (EggGroup *)NULL; + _axial_billboard = nullptr; + _point_billboard = nullptr; + _plain = nullptr; } /** @@ -82,7 +82,7 @@ get_synthetic_group(const string &name, switch (type) { case FltGeometry::BT_axial: - if (nodes->_axial_billboard == (EggGroupNode *)NULL) { + if (nodes->_axial_billboard == nullptr) { nodes->_axial_billboard = new EggGroup(name); _egg_parent->add_child(nodes->_axial_billboard); nodes->_axial_billboard->set_billboard_type(EggGroup::BT_axis); @@ -94,7 +94,7 @@ get_synthetic_group(const string &name, return nodes->_axial_billboard; case FltGeometry::BT_point: - if (nodes->_point_billboard == (EggGroupNode *)NULL) { + if (nodes->_point_billboard == nullptr) { nodes->_point_billboard = new EggGroup(name); _egg_parent->add_child(nodes->_point_billboard); nodes->_point_billboard->set_billboard_type(EggGroup::BT_point_world_relative); @@ -107,7 +107,7 @@ get_synthetic_group(const string &name, default: // Normally, BT_none, although we've occasionally seen a // value of 3 come in here, whatever that's supposed to mean. - if (nodes->_plain == (EggGroupNode *)NULL) { + if (nodes->_plain == nullptr) { nodes->_plain = new EggGroup(name); _egg_parent->add_child(nodes->_plain); if (!is_identity) { diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx index 90e9d123a3..5ca9224225 100644 --- a/pandatool/src/fltprogs/eggToFlt.cxx +++ b/pandatool/src/fltprogs/eggToFlt.cxx @@ -61,7 +61,7 @@ EggToFlt() : "if this is \"new\", these files will only be generated if they " "do not already exist (even if the properties have changed). " "Specifying \"all\" causes these to be rewritten every time.", - &EggToFlt::dispatch_attr, NULL, &_auto_attr_update); + &EggToFlt::dispatch_attr, nullptr, &_auto_attr_update); // Flt files are always in the z-up coordinate system. Don't confuse the // user with this meaningless option. @@ -489,7 +489,7 @@ get_flt_vertex(EggVertex *egg_vertex, EggNode *context) { flt_vertex->_has_uv = true; } - if (frame != (const LMatrix4d *)NULL) { + if (frame != nullptr) { flt_vertex->_pos = flt_vertex->_pos * (*frame); flt_vertex->_normal = flt_vertex->_normal * LCAST(PN_stdfloat, (*frame)); } diff --git a/pandatool/src/gtk-stats/gtkStats.cxx b/pandatool/src/gtk-stats/gtkStats.cxx index 5f3cf83e82..fad28f1a4b 100644 --- a/pandatool/src/gtk-stats/gtkStats.cxx +++ b/pandatool/src/gtk-stats/gtkStats.cxx @@ -17,7 +17,7 @@ #include "config_pstatclient.h" GtkWidget *main_window; -static GtkStatsServer *server = NULL; +static GtkStatsServer *server = nullptr; static gboolean delete_event(GtkWidget *widget, @@ -61,10 +61,10 @@ main(int argc, char *argv[]) { // Connect the delete and destroy events, so the user can exit the // application by closing the main window. g_signal_connect(G_OBJECT(main_window), "delete_event", - G_CALLBACK(delete_event), NULL); + G_CALLBACK(delete_event), nullptr); g_signal_connect(G_OBJECT(main_window), "destroy", - G_CALLBACK(destroy), NULL); + G_CALLBACK(destroy), nullptr); ostringstream stream; stream << "Listening on port " << pstats_port; @@ -97,7 +97,7 @@ main(int argc, char *argv[]) { gtk_widget_show(main_window); // Set up a timer to poll the pstats every so often. - g_timeout_add(200, timer, NULL); + g_timeout_add(200, timer, nullptr); // Now get lost in the message loop. gtk_main(); diff --git a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx index dfed8e1028..5bd5a7691f 100644 --- a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx +++ b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx @@ -185,7 +185,7 @@ handle_menu(gpointer data) { const GtkStatsMonitor::MenuDef *menu_def = (GtkStatsMonitor::MenuDef *)data; GtkStatsMonitor *monitor = menu_def->_monitor; - if (monitor == NULL) { + if (monitor == nullptr) { return; } diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.cxx b/pandatool/src/gtk-stats/gtkStatsGraph.cxx index 0c2b21f355..2f1b1e7189 100644 --- a/pandatool/src/gtk-stats/gtkStatsGraph.cxx +++ b/pandatool/src/gtk-stats/gtkStatsGraph.cxx @@ -38,18 +38,18 @@ GtkStatsGraph:: GtkStatsGraph(GtkStatsMonitor *monitor) : _monitor(monitor) { - _parent_window = NULL; - _window = NULL; - _graph_window = NULL; - _scale_area = NULL; + _parent_window = nullptr; + _window = nullptr; + _graph_window = nullptr; + _scale_area = nullptr; GtkWidget *parent_window = monitor->get_window(); GdkDisplay *display = gdk_drawable_get_display(parent_window->window); _hand_cursor = gdk_cursor_new_for_display(display, GDK_HAND2); - _pixmap = 0; - _pixmap_gc = 0; + _pixmap = nullptr; + _pixmap_gc = nullptr; _pixmap_xsize = 0; _pixmap_ysize = 0; @@ -91,7 +91,7 @@ GtkStatsGraph(GtkStatsMonitor *monitor) : G_CALLBACK(motion_notify_event_callback), this); // A Frame to hold the graph. - GtkWidget *graph_frame = gtk_frame_new(NULL); + GtkWidget *graph_frame = gtk_frame_new(nullptr); gtk_frame_set_shadow_type(GTK_FRAME(graph_frame), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(graph_frame), _graph_window); @@ -127,7 +127,7 @@ GtkStatsGraph(GtkStatsMonitor *monitor) : */ GtkStatsGraph:: ~GtkStatsGraph() { - _monitor = (GtkStatsMonitor *)NULL; + _monitor = nullptr; release_pixmap(); Brushes::iterator bi; @@ -138,9 +138,9 @@ GtkStatsGraph:: _label_stack.clear_labels(); - if (_window != (GtkWidget *)NULL) { + if (_window != nullptr) { GtkWidget *window = _window; - _window = NULL; + _window = nullptr; gtk_widget_destroy(window); } } @@ -204,7 +204,7 @@ set_pause(bool pause) { */ void GtkStatsGraph:: user_guide_bars_changed() { - if (_scale_area != NULL) { + if (_scale_area != nullptr) { gtk_widget_queue_draw(_scale_area); } gtk_widget_queue_draw(_graph_window); @@ -224,12 +224,12 @@ clicked_label(int collector_index) { void GtkStatsGraph:: close() { _label_stack.clear_labels(false); - if (_window != (GtkWidget *)NULL) { - _window = NULL; + if (_window != nullptr) { + _window = nullptr; GtkStatsMonitor *monitor = _monitor; - _monitor = (GtkStatsMonitor *)NULL; - if (monitor != (GtkStatsMonitor *)NULL) { + _monitor = nullptr; + if (monitor != nullptr) { monitor->remove_graph(this); } } @@ -328,7 +328,7 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { gdk_window_set_cursor(_window->window, _hand_cursor); } else { - gdk_window_set_cursor(_window->window, NULL); + gdk_window_set_cursor(_window->window, nullptr); } return TRUE; @@ -359,7 +359,7 @@ setup_pixmap(int xsize, int ysize) { */ void GtkStatsGraph:: release_pixmap() { - if (_pixmap != NULL) { + if (_pixmap != nullptr) { g_object_unref(_pixmap); g_object_unref(_pixmap_gc); } @@ -391,7 +391,7 @@ gboolean GtkStatsGraph:: graph_expose_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; - if (self->_pixmap != NULL) { + if (self->_pixmap != nullptr) { gdk_draw_drawable(self->_graph_window->window, self->_graph_window->style->fg_gc[0], self->_pixmap, 0, 0, 0, 0, diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.cxx b/pandatool/src/gtk-stats/gtkStatsLabel.cxx index 846aeb8a15..cac7be3859 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.cxx +++ b/pandatool/src/gtk-stats/gtkStatsLabel.cxx @@ -31,7 +31,7 @@ GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, _thread_index(thread_index), _collector_index(collector_index) { - _widget = NULL; + _widget = nullptr; if (use_fullname) { _text = _monitor->get_client_data()->get_collector_fullname(_collector_index); } else { @@ -117,6 +117,14 @@ get_collector_index() const { return _collector_index; } +/** + * Returns the thread index. + */ +int GtkStatsLabel:: +get_thread_index() const { + return _thread_index; +} + /** * Enables or disables the visual highlight for this label. */ diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.h b/pandatool/src/gtk-stats/gtkStatsLabel.h index 80f697dc4f..bf4834985e 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.h +++ b/pandatool/src/gtk-stats/gtkStatsLabel.h @@ -36,6 +36,7 @@ public: int get_height() const; int get_collector_index() const; + int get_thread_index() const; void set_highlight(bool highlight); bool get_highlight() const; diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.I b/pandatool/src/gtk-stats/gtkStatsMonitor.I index 71f5b43404..65a5bfbf64 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.I +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.I @@ -19,7 +19,7 @@ MenuDef(int thread_index, int collector_index, bool show_level) : _thread_index(thread_index), _collector_index(collector_index), _show_level(show_level), - _monitor(NULL) + _monitor(nullptr) { } diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx index fe4926cbc5..1c7a8b1f1f 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx @@ -25,18 +25,18 @@ typedef void vc(); GtkItemFactoryEntry GtkStatsMonitor::menu_entries[] = { - { (gchar *)"/Options", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Options/Units", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Options/Units/ms", NULL, (vc *)&handle_menu_command, MI_time_ms, (gchar *)"" }, - { (gchar *)"/Options/Units/Hz", NULL, (vc *)&handle_menu_command, MI_time_hz, (gchar *)"/Options/Units/ms" }, - { (gchar *)"/Speed", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Speed/1", NULL, (vc *)&handle_menu_command, MI_speed_1, (gchar *)"" }, - { (gchar *)"/Speed/2", NULL, (vc *)&handle_menu_command, MI_speed_2, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/3", NULL, (vc *)&handle_menu_command, MI_speed_3, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/6", NULL, (vc *)&handle_menu_command, MI_speed_6, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/12", NULL, (vc *)&handle_menu_command, MI_speed_12, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/sep", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Speed/pause", NULL, (vc *)&handle_menu_command, MI_pause, (gchar *)"" }, + { (gchar *)"/Options", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Options/Units", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Options/Units/ms", nullptr, (vc *)&handle_menu_command, MI_time_ms, (gchar *)"" }, + { (gchar *)"/Options/Units/Hz", nullptr, (vc *)&handle_menu_command, MI_time_hz, (gchar *)"/Options/Units/ms" }, + { (gchar *)"/Speed", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Speed/1", nullptr, (vc *)&handle_menu_command, MI_speed_1, (gchar *)"" }, + { (gchar *)"/Speed/2", nullptr, (vc *)&handle_menu_command, MI_speed_2, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/3", nullptr, (vc *)&handle_menu_command, MI_speed_3, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/6", nullptr, (vc *)&handle_menu_command, MI_speed_6, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/12", nullptr, (vc *)&handle_menu_command, MI_speed_12, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/sep", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Speed/pause", nullptr, (vc *)&handle_menu_command, MI_pause, (gchar *)"" }, }; int GtkStatsMonitor::num_menu_entries = sizeof(menu_entries) / sizeof(GtkItemFactoryEntry); @@ -46,8 +46,8 @@ int GtkStatsMonitor::num_menu_entries = sizeof(menu_entries) / sizeof(GtkItemFac */ GtkStatsMonitor:: GtkStatsMonitor(GtkStatsServer *server) : PStatMonitor(server) { - _window = NULL; - _item_factory = NULL; + _window = nullptr; + _item_factory = nullptr; // These will be filled in later when the menu is created. _time_units = 0; @@ -362,7 +362,7 @@ remove_graph(GtkStatsGraph *graph) { */ void GtkStatsMonitor:: create_window() { - if (_window != NULL) { + if (_window != nullptr) { return; } @@ -432,9 +432,9 @@ shutdown() { } _chart_menus.clear(); - if (_window != NULL) { + if (_window != nullptr) { gtk_widget_destroy(_window); - _window = NULL; + _window = nullptr; } #ifdef DEVELOP_GTKSTATS diff --git a/pandatool/src/imageprogs/imageFixHiddenColor.cxx b/pandatool/src/imageprogs/imageFixHiddenColor.cxx index bb56bcc659..a3d176bfb4 100644 --- a/pandatool/src/imageprogs/imageFixHiddenColor.cxx +++ b/pandatool/src/imageprogs/imageFixHiddenColor.cxx @@ -41,19 +41,19 @@ ImageFixHiddenColor() : ImageFilter(true) { "alpha channel on the source image. If this file has an alpha " "channel, that alpha channel is used; otherwise, the grayscale " "value of the image is used.", - &ImageFixHiddenColor::dispatch_filename, NULL, &_alpha_filename); + &ImageFixHiddenColor::dispatch_filename, nullptr, &_alpha_filename); add_option ("opaque", "alpha", 0, "Specifies the minimum alpha value (in the range of 0 to 1) for a " "pixel to be considered fully opaque. The default is 1.", - &ImageFixHiddenColor::dispatch_double, NULL, &_min_opaque_alpha); + &ImageFixHiddenColor::dispatch_double, nullptr, &_min_opaque_alpha); add_option ("transparent", "alpha", 0, "Specifies the maximum alpha value (in the range of 0 to 1) for a " "pixel to be considered fully transparent. The default is 0.", - &ImageFixHiddenColor::dispatch_double, NULL, &_max_transparent_alpha); + &ImageFixHiddenColor::dispatch_double, nullptr, &_max_transparent_alpha); _min_opaque_alpha = 1.0; _max_transparent_alpha = 0.0; diff --git a/pandatool/src/imageprogs/imageInfo.cxx b/pandatool/src/imageprogs/imageInfo.cxx index 175a5dba1d..7cbde06913 100644 --- a/pandatool/src/imageprogs/imageInfo.cxx +++ b/pandatool/src/imageprogs/imageInfo.cxx @@ -29,7 +29,7 @@ ImageInfo() { "Report only images that have a non-power-of-two size in either " "dimension. Images whose dimensions are both a power of two will " "not be mentioned.", - &ImageInfo::dispatch_none, &_report_power_2, NULL); + &ImageInfo::dispatch_none, &_report_power_2, nullptr); } /** diff --git a/pandatool/src/imageprogs/imageResize.cxx b/pandatool/src/imageprogs/imageResize.cxx index ae5a746c1a..f3c51c8554 100644 --- a/pandatool/src/imageprogs/imageResize.cxx +++ b/pandatool/src/imageprogs/imageResize.cxx @@ -29,14 +29,14 @@ ImageResize() : ImageFilter(true) { "Specify the width of the output image in pixels, or as a percentage " "of the original width (if a trailing percent sign is included). " "If this is omitted, the ratio is taken from the ysize parameter.", - &ImageResize::dispatch_size_request, NULL, &_x_size); + &ImageResize::dispatch_size_request, nullptr, &_x_size); add_option ("y", "ysize", 0, "Specify the height of the output image in pixels, or as a percentage " "of the original height (if a trailing percent sign is included). " "If this is omitted, the ratio is taken from the xsize parameter.", - &ImageResize::dispatch_size_request, NULL, &_y_size); + &ImageResize::dispatch_size_request, nullptr, &_y_size); add_option ("g", "radius", 0, @@ -47,7 +47,7 @@ ImageResize() : ImageFilter(true) { ("1", "", 0, "This option is ignored. It is provided only for backward compatibility " "with a previous version of image-resize.", - &ImageResize::dispatch_none, NULL, NULL); + &ImageResize::dispatch_none, nullptr, nullptr); _filter_radius = 1.0; } diff --git a/pandatool/src/imageprogs/imageTrans.cxx b/pandatool/src/imageprogs/imageTrans.cxx index da33516eeb..48bc98c5d2 100644 --- a/pandatool/src/imageprogs/imageTrans.cxx +++ b/pandatool/src/imageprogs/imageTrans.cxx @@ -33,7 +33,7 @@ ImageTrans() : ImageFilter(true) { "l, la, rgb, or rgba, respectively, or any of the keywords r, g, b, or " "a to extract out just the indicated channel as a single grayscale " "image.", - &ImageTrans::dispatch_channels, NULL, &_channels); + &ImageTrans::dispatch_channels, nullptr, &_channels); add_option ("cscale", "r,g,b[,a]", 50, diff --git a/pandatool/src/imageprogs/imageTransformColors.cxx b/pandatool/src/imageprogs/imageTransformColors.cxx index a18629f798..0600956a91 100644 --- a/pandatool/src/imageprogs/imageTransformColors.cxx +++ b/pandatool/src/imageprogs/imageTransformColors.cxx @@ -40,36 +40,36 @@ ImageTransformColors() { "space, instead of the default RGB space. In this mode, the first " "component controls hue, the second controls lightness, and the third " "controls saturation.", - &ImageTransformColors::dispatch_none, &_hls, NULL); + &ImageTransformColors::dispatch_none, &_hls, nullptr); add_option ("range", "min,max", 0, "Compresses the overall dynamic range from 0,1 to min,max. If min,max " "exceed 0,1, the dynamic range is expanded. This doesn't make sense in " "HLS mode.", - &ImageTransformColors::dispatch_range, NULL, &_mat); + &ImageTransformColors::dispatch_range, nullptr, &_mat); add_option ("scale", "r,g,b", 0, "Scales the r,g,b components by the indicated values. In HLS mode, " "the scale is applied to the h,l,s components.", - &ImageTransformColors::dispatch_scale, NULL, &_mat); + &ImageTransformColors::dispatch_scale, nullptr, &_mat); add_option ("add", "r,g,b", 0, "Adds the indicated values to the r,g,b components. In HLS mode, " "the sum is applied to the h,l,s components.", - &ImageTransformColors::dispatch_add, NULL, &_mat); + &ImageTransformColors::dispatch_add, nullptr, &_mat); add_option ("mat4", "m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33", 0, "Defines an arbitrary 4x4 RGB matrix.", - &ImageTransformColors::dispatch_mat4, NULL, &_mat); + &ImageTransformColors::dispatch_mat4, nullptr, &_mat); add_option ("mat3", "m00,m01,m02,m10,m11,m12,m20,m21,m22", 0, "Defines an arbitrary 3x3 RGB matrix.", - &ImageTransformColors::dispatch_mat3, NULL, &_mat); + &ImageTransformColors::dispatch_mat3, nullptr, &_mat); add_option ("o", "filename", 50, diff --git a/pandatool/src/lwo/iffInputFile.cxx b/pandatool/src/lwo/iffInputFile.cxx index 17f4225625..e3ffa34044 100644 --- a/pandatool/src/lwo/iffInputFile.cxx +++ b/pandatool/src/lwo/iffInputFile.cxx @@ -24,7 +24,7 @@ TypeHandle IffInputFile::_type_handle; */ IffInputFile:: IffInputFile() { - _input = (istream *)NULL; + _input = nullptr; _owns_istream = false; _eof = true; _unexpected_eof = false; @@ -52,7 +52,7 @@ open_read(Filename filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { return false; } @@ -211,7 +211,7 @@ get_id() { PT(IffChunk) IffInputFile:: get_chunk() { if (is_eof()) { - return (IffChunk *)NULL; + return nullptr; } IffId id = get_id(); @@ -230,14 +230,14 @@ get_chunk() { nout << "Unexpected EOF on file reading " << *chunk << "\n"; _unexpected_eof = true; } - return (IffChunk *)NULL; + return nullptr; } size_t num_bytes_read = get_bytes_read() - start_point; if (num_bytes_read > length) { nout << *chunk << " read " << num_bytes_read << " instead of " << length << " bytes.\n"; - return (IffChunk *)NULL; + return nullptr; } else if (num_bytes_read < length) { size_t skip_count = length - num_bytes_read; @@ -249,7 +249,7 @@ get_chunk() { } } - return (IffChunk *)NULL; + return nullptr; } /** @@ -261,7 +261,7 @@ get_chunk() { PT(IffChunk) IffInputFile:: get_subchunk(IffChunk *context) { if (is_eof()) { - return (IffChunk *)NULL; + return nullptr; } IffId id = get_id(); @@ -280,14 +280,14 @@ get_subchunk(IffChunk *context) { nout << "Unexpected EOF on file reading " << *chunk << "\n"; _unexpected_eof = true; } - return (IffChunk *)NULL; + return nullptr; } size_t num_bytes_read = get_bytes_read() - start_point; if (num_bytes_read > length) { nout << *chunk << " read " << num_bytes_read << " instead of " << length << " bytes.\n"; - return (IffChunk *)NULL; + return nullptr; } else if (num_bytes_read < length) { size_t skip_count = length - num_bytes_read; @@ -299,7 +299,7 @@ get_subchunk(IffChunk *context) { } } - return (IffChunk *)NULL; + return nullptr; } /** diff --git a/pandatool/src/lwo/lwoGroupChunk.cxx b/pandatool/src/lwo/lwoGroupChunk.cxx index 69cd426f57..a9bb29fbe7 100644 --- a/pandatool/src/lwo/lwoGroupChunk.cxx +++ b/pandatool/src/lwo/lwoGroupChunk.cxx @@ -31,7 +31,7 @@ get_num_chunks() const { */ IffChunk *LwoGroupChunk:: get_chunk(int n) const { - nassertr(n >= 0 && n < (int)_chunks.size(), (IffChunk *)NULL); + nassertr(n >= 0 && n < (int)_chunks.size(), nullptr); return _chunks[n]; } @@ -44,7 +44,7 @@ bool LwoGroupChunk:: read_chunks_iff(IffInputFile *in, size_t stop_at) { while (in->get_bytes_read() < stop_at && !in->is_eof()) { PT(IffChunk) chunk = in->get_chunk(); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { return false; } _chunks.push_back(chunk); @@ -60,7 +60,7 @@ bool LwoGroupChunk:: read_subchunks_iff(IffInputFile *in, size_t stop_at) { while (in->get_bytes_read() < stop_at && !in->is_eof()) { PT(IffChunk) chunk = in->get_subchunk(this); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { return false; } _chunks.push_back(chunk); diff --git a/pandatool/src/lwo/lwoPolygons.cxx b/pandatool/src/lwo/lwoPolygons.cxx index 76736c4f41..4e51d3ee26 100644 --- a/pandatool/src/lwo/lwoPolygons.cxx +++ b/pandatool/src/lwo/lwoPolygons.cxx @@ -32,7 +32,7 @@ get_num_polygons() const { */ LwoPolygons::Polygon *LwoPolygons:: get_polygon(int n) const { - nassertr(n >= 0 && n < (int)_polygons.size(), (Polygon *)NULL); + nassertr(n >= 0 && n < (int)_polygons.size(), nullptr); return _polygons[n]; } diff --git a/pandatool/src/lwo/lwoSurfaceBlock.cxx b/pandatool/src/lwo/lwoSurfaceBlock.cxx index c1482bdb7d..76babe281c 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlock.cxx @@ -36,7 +36,7 @@ TypeHandle LwoSurfaceBlock::_type_handle; bool LwoSurfaceBlock:: read_iff(IffInputFile *in, size_t stop_at) { PT(IffChunk) chunk = in->get_subchunk(this); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { return false; } if (!chunk->is_of_type(LwoSurfaceBlockHeader::get_class_type())) { diff --git a/pandatool/src/lwo/test_lwo.cxx b/pandatool/src/lwo/test_lwo.cxx index b541fb8360..baba598440 100644 --- a/pandatool/src/lwo/test_lwo.cxx +++ b/pandatool/src/lwo/test_lwo.cxx @@ -30,7 +30,7 @@ main(int argc, char *argv[]) { } PT(IffChunk) chunk = in.get_chunk(); - while (chunk != (IffChunk *)NULL) { + while (chunk != nullptr) { nout << "Got chunk type " << chunk->get_type() << ":\n"; chunk->write(nout, 2); chunk = in.get_chunk(); diff --git a/pandatool/src/lwoegg/cLwoLayer.cxx b/pandatool/src/lwoegg/cLwoLayer.cxx index 4794ef1429..7356212545 100644 --- a/pandatool/src/lwoegg/cLwoLayer.cxx +++ b/pandatool/src/lwoegg/cLwoLayer.cxx @@ -39,7 +39,7 @@ void CLwoLayer:: connect_egg() { if (_layer->_parent != -1) { const CLwoLayer *parent = _converter->get_layer(_layer->_parent); - if (parent != (CLwoLayer *)NULL) { + if (parent != nullptr) { parent->_egg_group->add_child(_egg_group.p()); return; } diff --git a/pandatool/src/lwoegg/cLwoPolygons.I b/pandatool/src/lwoegg/cLwoPolygons.I index 691d706324..94908debd9 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.I +++ b/pandatool/src/lwoegg/cLwoPolygons.I @@ -21,6 +21,6 @@ CLwoPolygons(LwoToEggConverter *converter, const LwoPolygons *polygons, _polygons(polygons), _points(points) { - _tags = (LwoTags *)NULL; - _surf_ptags = (LwoPolygonTags *)NULL; + _tags = nullptr; + _surf_ptags = nullptr; } diff --git a/pandatool/src/lwoegg/cLwoPolygons.cxx b/pandatool/src/lwoegg/cLwoPolygons.cxx index ad1f600a04..3f64a6ee83 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.cxx +++ b/pandatool/src/lwoegg/cLwoPolygons.cxx @@ -32,7 +32,7 @@ */ void CLwoPolygons:: add_ptags(const LwoPolygonTags *lwo_ptags, const LwoTags *tags) { - if (_tags != (LwoTags *)NULL && _tags != tags) { + if (_tags != nullptr && _tags != tags) { nout << "Multiple Tags fields in effect on the same polygons.\n"; } _tags = tags; @@ -82,31 +82,31 @@ add_vmad(const LwoDiscontinuousVertexMap *lwo_vmad) { */ CLwoSurface *CLwoPolygons:: get_surface(int polygon_index) const { - if (_surf_ptags == (LwoPolygonTags *)NULL) { + if (_surf_ptags == nullptr) { // No surface definitions. - return (CLwoSurface *)NULL; + return nullptr; } if (!_surf_ptags->has_tag(polygon_index)) { // The polygon isn't tagged. - return (CLwoSurface *)NULL; + return nullptr; } int tag_index = _surf_ptags->get_tag(polygon_index); - if (_tags == (LwoTags *)NULL || tag_index < 0 || + if (_tags == nullptr || tag_index < 0 || tag_index >= _tags->get_num_tags()) { // The tag index is out-of-bounds. nout << "Invalid polygon tag index " << tag_index << "\n"; - return (CLwoSurface *)NULL; + return nullptr; } string tag = _tags->get_tag(tag_index); // Now look up the surface name in the header. CLwoSurface *surface = _converter->get_surface(tag); - if (surface == (CLwoSurface *)NULL) { + if (surface == nullptr) { nout << "Unknown surface " << tag << "\n"; - return (CLwoSurface *)NULL; + return nullptr; } return surface; @@ -182,8 +182,8 @@ make_egg() { */ void CLwoPolygons:: connect_egg() { - nassertv(_points->_layer->_egg_group != (EggGroup *)NULL); - nassertv(_egg_group != (EggGroup *)NULL); + nassertv(_points->_layer->_egg_group != nullptr); + nassertv(_egg_group != nullptr); _points->_layer->_egg_group->steal_children(*_egg_group); } @@ -236,7 +236,7 @@ make_faces() { egg_vertex->set_pos(pos); // Does the vertex used named UV's? - if (surface != (CLwoSurface *)NULL && surface->has_named_uvs()) { + if (surface != nullptr && surface->has_named_uvs()) { string uv_name = surface->get_uv_name(); LPoint2 uv; if (get_uv(uv_name, pindex, vindex, uv)) { @@ -256,7 +256,7 @@ make_faces() { } if (is_valid) { - if (surface != (CLwoSurface *)NULL) { + if (surface != nullptr) { surface->apply_properties(egg_prim, egg_vertices, smooth_angle); } diff --git a/pandatool/src/lwoegg/cLwoSurface.I b/pandatool/src/lwoegg/cLwoSurface.I index 80c4c2c3d6..49c6eaf6bc 100644 --- a/pandatool/src/lwoegg/cLwoSurface.I +++ b/pandatool/src/lwoegg/cLwoSurface.I @@ -28,7 +28,7 @@ get_name() const { */ INLINE bool CLwoSurface:: has_named_uvs() const { - return (_block != (CLwoSurfaceBlock *)NULL && + return (_block != nullptr && _block->_projection_mode == LwoSurfaceBlockProjection::M_uv); } diff --git a/pandatool/src/lwoegg/cLwoSurface.cxx b/pandatool/src/lwoegg/cLwoSurface.cxx index f75932b975..b3a1c78d1d 100644 --- a/pandatool/src/lwoegg/cLwoSurface.cxx +++ b/pandatool/src/lwoegg/cLwoSurface.cxx @@ -39,8 +39,8 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : _rgb.set(1.0, 1.0, 1.0); _checked_material = false; _checked_texture = false; - _map_uvs = NULL; - _block = (CLwoSurfaceBlock *)NULL; + _map_uvs = nullptr; + _block = nullptr; // Walk through the chunk list, looking for some basic properties. int num_chunks = _surface->get_num_chunks(); @@ -107,7 +107,7 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : block->_channel_id == IffId("COLR") && block->_enabled) { // Now save the block with the lowest ordinal. - if (_block == (CLwoSurfaceBlock *)NULL) { + if (_block == nullptr) { _block = block; } else if (block->_ordinal < _block->_ordinal) { @@ -146,7 +146,7 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : */ CLwoSurface:: ~CLwoSurface() { - if (_block != (CLwoSurfaceBlock *)NULL) { + if (_block != nullptr) { delete _block; } } @@ -164,7 +164,7 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, if (!_surface->_source.empty()) { // This surface is derived from another surface; apply that one first. CLwoSurface *parent = _converter->get_surface(_surface->_source); - if (parent != (CLwoSurface *)NULL && parent != this) { + if (parent != nullptr && parent != this) { parent->apply_properties(egg_prim, egg_vertices, smooth_angle); } } @@ -204,13 +204,13 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, bool CLwoSurface:: check_texture() { if (_checked_texture) { - return (_egg_texture != (EggTexture *)NULL); + return (_egg_texture != nullptr); } _checked_texture = true; - _egg_texture = (EggTexture *)NULL; - _map_uvs = NULL; + _egg_texture = nullptr; + _map_uvs = nullptr; - if (_block == (CLwoSurfaceBlock *)NULL) { + if (_block == nullptr) { // No texture. Not even a shader block. return false; } @@ -222,7 +222,7 @@ check_texture() { } CLwoClip *clip = _converter->get_clip(clip_index); - if (clip == (CLwoClip *)NULL) { + if (clip == nullptr) { nout << "No clip image with index " << clip_index << "\n"; return false; } @@ -281,10 +281,10 @@ check_texture() { bool CLwoSurface:: check_material() { if (_checked_material) { - return (_egg_material != (EggMaterial *)NULL); + return (_egg_material != nullptr); } _checked_material = true; - _egg_material = (EggMaterial *)NULL; + _egg_material = nullptr; if (!_converter->_make_materials) { // If we aren't making materials, then don't make a material. @@ -336,7 +336,7 @@ check_material() { */ void CLwoSurface:: generate_uvs(vector_PT_EggVertex &egg_vertices) { - if (_map_uvs == NULL) { + if (_map_uvs == nullptr) { return; } diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx b/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx index 1902a28377..98d4c502f0 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx +++ b/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx @@ -45,7 +45,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : _h_wrap = LwoSurfaceBlockWrap::M_repeat; _w_repeat = 1.0; _h_repeat = 1.0; - _tmap = (CLwoSurfaceBlockTMap *)NULL; + _tmap = nullptr; // Scan the chunks in the header. int num_hchunks = _block->_header->get_num_chunks(); @@ -71,7 +71,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : if (chunk->is_of_type(LwoSurfaceBlockTMap::get_class_type())) { const LwoSurfaceBlockTMap *lwo_tmap = DCAST(LwoSurfaceBlockTMap, chunk); - if (_tmap != (CLwoSurfaceBlockTMap *)NULL) { + if (_tmap != nullptr) { nout << "Two TMAP chunks encountered within surface block.\n"; delete _tmap; } @@ -113,7 +113,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : } } - if (_tmap != (CLwoSurfaceBlockTMap *)NULL) { + if (_tmap != nullptr) { _tmap->get_transform(_transform); } @@ -144,7 +144,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : */ CLwoSurfaceBlock:: ~CLwoSurfaceBlock() { - if (_tmap != (CLwoSurfaceBlockTMap *)NULL) { + if (_tmap != nullptr) { delete _tmap; } } diff --git a/pandatool/src/lwoegg/lwoToEggConverter.cxx b/pandatool/src/lwoegg/lwoToEggConverter.cxx index fa94f560be..94aa3b7fe6 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.cxx +++ b/pandatool/src/lwoegg/lwoToEggConverter.cxx @@ -37,7 +37,7 @@ */ LwoToEggConverter:: LwoToEggConverter() { - _generic_layer = (CLwoLayer *)NULL; + _generic_layer = nullptr; _make_materials = true; } @@ -110,7 +110,7 @@ convert_file(const Filename &filename) { } PT(IffChunk) chunk = in.get_chunk(); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { nout << "Unable to read " << filename << "\n"; return false; } @@ -162,7 +162,7 @@ get_layer(int number) const { if (number >= 0 && number < (int)_layers.size()) { return _layers[number]; } - return (CLwoLayer *)NULL; + return nullptr; } /** @@ -174,7 +174,7 @@ get_clip(int number) const { if (number >= 0 && number < (int)_clips.size()) { return _clips[number]; } - return (CLwoClip *)NULL; + return nullptr; } /** @@ -188,7 +188,7 @@ get_surface(const string &name) const { if (si != _surfaces.end()) { return (*si).second; } - return (CLwoSurface *)NULL; + return nullptr; } /** @@ -199,15 +199,15 @@ void LwoToEggConverter:: cleanup() { _lwo_header.clear(); - if (_generic_layer != (CLwoLayer *)NULL) { + if (_generic_layer != nullptr) { delete _generic_layer; - _generic_layer = (CLwoLayer *)NULL; + _generic_layer = nullptr; } Layers::iterator li; for (li = _layers.begin(); li != _layers.end(); ++li) { CLwoLayer *layer = (*li); - if (layer != (CLwoLayer *)NULL) { + if (layer != nullptr) { delete layer; } } @@ -216,7 +216,7 @@ cleanup() { Clips::iterator ci; for (ci = _clips.begin(); ci != _clips.end(); ++ci) { CLwoClip *clip = (*ci); - if (clip != (CLwoClip *)NULL) { + if (clip != nullptr) { delete clip; } } @@ -250,11 +250,11 @@ cleanup() { */ void LwoToEggConverter:: collect_lwo() { - CLwoLayer *last_layer = (CLwoLayer *)NULL; - CLwoPoints *last_points = (CLwoPoints *)NULL; - CLwoPolygons *last_polygons = (CLwoPolygons *)NULL; + CLwoLayer *last_layer = nullptr; + CLwoPoints *last_points = nullptr; + CLwoPolygons *last_polygons = nullptr; - const LwoTags *tags = (const LwoTags *)NULL; + const LwoTags *tags = nullptr; int num_chunks = _lwo_header->get_num_chunks(); for (int i = 0; i < num_chunks; i++) { @@ -266,13 +266,13 @@ collect_lwo() { int number = layer->get_number(); slot_layer(number); - if (_layers[number] != (CLwoLayer *)NULL) { + if (_layers[number] != nullptr) { nout << "Warning: multiple layers with number " << number << "\n"; } _layers[number] = layer; last_layer = layer; - last_points = (CLwoPoints *)NULL; - last_polygons = (CLwoPolygons *)NULL; + last_points = nullptr; + last_polygons = nullptr; } else if (chunk->is_of_type(LwoClip::get_class_type())) { const LwoClip *lwo_clip = DCAST(LwoClip, chunk); @@ -281,13 +281,13 @@ collect_lwo() { int index = clip->get_index(); slot_clip(index); - if (_clips[index] != (CLwoClip *)NULL) { + if (_clips[index] != nullptr) { nout << "Warning: multiple clips with index " << index << "\n"; } _clips[index] = clip; } else if (chunk->is_of_type(LwoPoints::get_class_type())) { - if (last_layer == (CLwoLayer *)NULL) { + if (last_layer == nullptr) { last_layer = make_generic_layer(); } @@ -297,7 +297,7 @@ collect_lwo() { last_points = points; } else if (chunk->is_of_type(LwoVertexMap::get_class_type())) { - if (last_points == (CLwoPoints *)NULL) { + if (last_points == nullptr) { nout << "Vertex map chunk encountered without a preceding points chunk.\n"; } else { const LwoVertexMap *lwo_vmap = DCAST(LwoVertexMap, chunk); @@ -305,7 +305,7 @@ collect_lwo() { } } else if (chunk->is_of_type(LwoDiscontinuousVertexMap::get_class_type())) { - if (last_polygons == (CLwoPolygons *)NULL) { + if (last_polygons == nullptr) { nout << "Discontinous vertex map chunk encountered without a preceding polygons chunk.\n"; } else { const LwoDiscontinuousVertexMap *lwo_vmad = DCAST(LwoDiscontinuousVertexMap, chunk); @@ -316,7 +316,7 @@ collect_lwo() { tags = DCAST(LwoTags, chunk); } else if (chunk->is_of_type(LwoPolygons::get_class_type())) { - if (last_points == (CLwoPoints *)NULL) { + if (last_points == nullptr) { nout << "Polygon chunk encountered without a preceding points chunk.\n"; } else { const LwoPolygons *lwo_polygons = DCAST(LwoPolygons, chunk); @@ -327,9 +327,9 @@ collect_lwo() { } } else if (chunk->is_of_type(LwoPolygonTags::get_class_type())) { - if (last_polygons == (CLwoPolygons *)NULL) { + if (last_polygons == nullptr) { nout << "Polygon tags chunk encountered without a preceding polygons chunk.\n"; - } else if (tags == (LwoTags *)NULL) { + } else if (tags == nullptr) { nout << "Polygon tags chunk encountered without a preceding tags chunk.\n"; } else { const LwoPolygonTags *lwo_ptags = DCAST(LwoPolygonTags, chunk); @@ -337,7 +337,7 @@ collect_lwo() { } } else if (chunk->is_of_type(LwoSurface::get_class_type())) { - if (last_layer == (CLwoLayer *)NULL) { + if (last_layer == nullptr) { last_layer = make_generic_layer(); } @@ -358,14 +358,14 @@ collect_lwo() { */ void LwoToEggConverter:: make_egg() { - if (_generic_layer != (CLwoLayer *)NULL) { + if (_generic_layer != nullptr) { _generic_layer->make_egg(); } Layers::iterator li; for (li = _layers.begin(); li != _layers.end(); ++li) { CLwoLayer *layer = (*li); - if (layer != (CLwoLayer *)NULL) { + if (layer != nullptr) { layer->make_egg(); } } @@ -388,14 +388,14 @@ make_egg() { */ void LwoToEggConverter:: connect_egg() { - if (_generic_layer != (CLwoLayer *)NULL) { + if (_generic_layer != nullptr) { _generic_layer->connect_egg(); } Layers::iterator li; for (li = _layers.begin(); li != _layers.end(); ++li) { CLwoLayer *layer = (*li); - if (layer != (CLwoLayer *)NULL) { + if (layer != nullptr) { layer->connect_egg(); } } @@ -421,7 +421,7 @@ void LwoToEggConverter:: slot_layer(int number) { nassertv(number - (int)_layers.size() < 1000); while (number >= (int)_layers.size()) { - _layers.push_back((CLwoLayer *)NULL); + _layers.push_back(nullptr); } nassertv(number >= 0 && number < (int)_layers.size()); } @@ -434,7 +434,7 @@ void LwoToEggConverter:: slot_clip(int number) { nassertv(number - (int)_clips.size() < 1000); while (number >= (int)_clips.size()) { - _clips.push_back((CLwoClip *)NULL); + _clips.push_back(nullptr); } nassertv(number >= 0 && number < (int)_clips.size()); } @@ -447,7 +447,7 @@ slot_clip(int number) { */ CLwoLayer *LwoToEggConverter:: make_generic_layer() { - nassertr(_generic_layer == (CLwoLayer *)NULL, _generic_layer); + nassertr(_generic_layer == nullptr, _generic_layer); PT(LwoLayer) layer = new LwoLayer; layer->make_generic(); diff --git a/pandatool/src/lwoprogs/lwoScan.cxx b/pandatool/src/lwoprogs/lwoScan.cxx index a7fbf46933..5bb0f5a600 100644 --- a/pandatool/src/lwoprogs/lwoScan.cxx +++ b/pandatool/src/lwoprogs/lwoScan.cxx @@ -44,10 +44,10 @@ run() { } PT(IffChunk) chunk = in.get_chunk(); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { nout << "Unable to read file.\n"; } else { - while (chunk != (IffChunk *)NULL) { + while (chunk != nullptr) { chunk->write(cout, 0); chunk = in.get_chunk(); } diff --git a/pandatool/src/maxegg/maxEgg.cxx b/pandatool/src/maxegg/maxEgg.cxx index 2b77f06767..798192e26c 100644 --- a/pandatool/src/maxegg/maxEgg.cxx +++ b/pandatool/src/maxegg/maxEgg.cxx @@ -297,7 +297,7 @@ ClassDesc* GetMaxEggPluginDesc() { return &MaxEggPluginDesc; } // Initialize class-static variables Mesh MaxEggPlugin::mesh; short MaxEggPlugin::meshBuilt=0; -HWND MaxEggPlugin::hMaxEggParams = NULL; +HWND MaxEggPlugin::hMaxEggParams = nullptr; IObjParam *MaxEggPlugin::iObjParams; /* MaxEggPluginOptionsDlgProc() - This is the callback function for the @@ -454,9 +454,9 @@ void MaxEggPlugin::EndEditParams( IObjParam *ip, ULONG flags,Animatable *prev) if ( flags&END_EDIT_REMOVEUI ) { ip->UnRegisterDlgWnd(hMaxEggParams); ip->DeleteRollupPage(hMaxEggParams); - hMaxEggParams = NULL; + hMaxEggParams = nullptr; } else { - SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, NULL ); + SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, 0L ); } } @@ -585,8 +585,8 @@ void MaxEggPlugin::DoExport() { } else { _stprintf(cmdLine, _T("pview \"%s\""), eggList[i]->_file_name); } - CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, - NULL, NULL, &si, &pi); + CreateProcess(nullptr, cmdLine, nullptr, nullptr, FALSE, CREATE_NEW_CONSOLE, + nullptr, nullptr, &si, &pi); pviewed += 1; } } @@ -634,10 +634,10 @@ int MaxEggPluginCreateMouseCallBack::proc(ViewExp *vpt,int msg, int point, int f if (msg==MOUSE_POINT||msg==MOUSE_MOVE) { switch(point) { case 0: - mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_PLANE)); + mat.SetTrans(vpt->SnapPoint(m,m,nullptr,SNAP_IN_PLANE)); break; case 1: - mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_PLANE)); + mat.SetTrans(vpt->SnapPoint(m,m,nullptr,SNAP_IN_PLANE)); if (msg==MOUSE_POINT) return CREATE_STOP; break; } @@ -718,7 +718,7 @@ int MaxEggPlugin::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) gw->setColor( LINE_COLOR, GetSelColor()); else if(!inode->IsFrozen()) gw->setColor( LINE_COLOR, GetUIColor(COLOR_TAPE_OBJ)); - mesh.render( gw, mtl, NULL, COMP_ALL); + mesh.render( gw, mtl, nullptr, COMP_ALL); return 0; } @@ -838,7 +838,7 @@ __declspec( dllexport ) ClassDesc* LibClassDesc(int i) { switch(i) { case 0: return GetMaxEggPluginDesc(); - default: return NULL; + default: return nullptr; } } @@ -855,6 +855,6 @@ TCHAR *GetString(int id) static TCHAR buf[256]; if (hInstance) - return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : NULL; - return NULL; + return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : nullptr; + return nullptr; } diff --git a/pandatool/src/maxegg/maxEgg.h b/pandatool/src/maxegg/maxEgg.h index d10d449a0f..88ae826490 100644 --- a/pandatool/src/maxegg/maxEgg.h +++ b/pandatool/src/maxegg/maxEgg.h @@ -119,7 +119,7 @@ class MaxEggPlugin : public HelperObject void AddEgg(MaxOptionsDialog *newEgg); void RemoveEgg(int i); - MaxOptionsDialog *GetEgg(int i) { return (i >= 0 && i < numEggs) ? eggList[i] : NULL; } + MaxOptionsDialog *GetEgg(int i) { return (i >= 0 && i < numEggs) ? eggList[i] : nullptr; } // Required implimented virtual methods: inherited virtual methods for // Reference-management diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index ba4c705965..e2747e6dd0 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -637,7 +637,7 @@ bool MaxEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool an AnimateOff(); _next_tex = 0; - TraverseEggNode(data, NULL); + TraverseEggNode(data, nullptr); for (ci = _mesh_tab.begin(); ci != _mesh_tab.end(); ++ci) { MaxEggMesh *mesh = (*ci); diff --git a/pandatool/src/maxegg/maxNodeDesc.cxx b/pandatool/src/maxegg/maxNodeDesc.cxx index 57a9d7385f..7e0ed3d964 100644 --- a/pandatool/src/maxegg/maxNodeDesc.cxx +++ b/pandatool/src/maxegg/maxNodeDesc.cxx @@ -23,7 +23,7 @@ MaxNodeDesc:: MaxNodeDesc(MaxNodeDesc *parent, INode *max_node) : _parent(parent) { - if (max_node != NULL) { + if (max_node != nullptr) { const TCHAR *max_name = max_node->GetName(); #ifdef _UNICODE char name_mb [1024]; @@ -35,15 +35,15 @@ MaxNodeDesc(MaxNodeDesc *parent, INode *max_node) : #endif } - _max_node = (INode *)NULL; - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _max_node = nullptr; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; _joint_type = JT_none; - _joint_entry = NULL; + _joint_entry = nullptr; // Add ourselves to our parent. - if (_parent != (MaxNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } } @@ -59,7 +59,7 @@ MaxNodeDesc:: */ void MaxNodeDesc:: from_INode(INode *max_node) { - if (_max_node == (INode *)NULL) { + if (_max_node == nullptr) { _max_node = max_node; // This is how I decided to check to see if this max node is a joint. It @@ -78,7 +78,7 @@ from_INode(INode *max_node) { // This node is a joint. _joint_type = JT_node_joint; - if (_parent != (MaxNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } @@ -91,7 +91,7 @@ from_INode(INode *max_node) { */ bool MaxNodeDesc:: has_max_node() const { - return (_max_node != (INode *)NULL); + return (_max_node != nullptr); } /** @@ -100,7 +100,7 @@ has_max_node() const { */ INode *MaxNodeDesc:: get_max_node() const { - nassertr(_max_node != (INode *)NULL, _max_node); + nassertr(_max_node != nullptr, _max_node); return _max_node; } @@ -142,9 +142,9 @@ is_node_joint() const { */ void MaxNodeDesc:: clear_egg() { - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -161,7 +161,7 @@ void MaxNodeDesc:: mark_joint_parent() { if (_joint_type == JT_none) { _joint_type = JT_joint_parent; - if (_parent != (MaxNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } diff --git a/pandatool/src/maxegg/maxNodeDesc.h b/pandatool/src/maxegg/maxNodeDesc.h index 42bb1f4acc..3b45fe0793 100644 --- a/pandatool/src/maxegg/maxNodeDesc.h +++ b/pandatool/src/maxegg/maxNodeDesc.h @@ -21,7 +21,7 @@ */ class MaxNodeDesc : public ReferenceCount, public Namable { public: - MaxNodeDesc(MaxNodeDesc *parent = NULL, INode *max_node = NULL); + MaxNodeDesc(MaxNodeDesc *parent = nullptr, INode *max_node = nullptr); ~MaxNodeDesc(); void from_INode(INode *max_node); diff --git a/pandatool/src/maxegg/maxNodeTree.cxx b/pandatool/src/maxegg/maxNodeTree.cxx index 58f980c281..bb52b887f1 100644 --- a/pandatool/src/maxegg/maxNodeTree.cxx +++ b/pandatool/src/maxegg/maxNodeTree.cxx @@ -21,9 +21,9 @@ MaxNodeTree() { _root = new MaxNodeDesc; _fps = 0.0; _export_mesh = false; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; } /** @@ -88,7 +88,7 @@ bool MaxNodeTree:: build_complete_hierarchy(INode *root, ULONG *selection_list, int len) { // Get the entire Max scene. - if (root == NULL) { + if (root == nullptr) { // *** Log an error return false; } @@ -117,7 +117,7 @@ get_num_nodes() const { */ MaxNodeDesc *MaxNodeTree:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } @@ -140,13 +140,13 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, */ EggGroup *MaxNodeTree:: get_egg_group(MaxNodeDesc *node_desc) { - nassertr(_egg_root != (EggGroupNode *)NULL, NULL); + nassertr(_egg_root != nullptr, nullptr); - if (node_desc->_egg_group == (EggGroup *)NULL) { + if (node_desc->_egg_group == nullptr) { // We need to make a new group node. EggGroup *egg_group; - nassertr(node_desc->_parent != (MaxNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); egg_group = new EggGroup(node_desc->get_name()); if (node_desc->is_joint()) { egg_group->set_group_type(EggGroup::GT_joint); @@ -186,12 +186,12 @@ get_egg_group(MaxNodeDesc *node_desc) { */ EggTable *MaxNodeTree:: get_egg_table(MaxNodeDesc *node_desc) { - nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); - nassertr(node_desc->is_joint(), NULL); + nassertr(_skeleton_node != nullptr, nullptr); + nassertr(node_desc->is_joint(), nullptr); - if (node_desc->_egg_table == (EggTable *)NULL) { + if (node_desc->_egg_table == nullptr) { // We need to make a new table node. - nassertr(node_desc->_parent != (MaxNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); EggTable *egg_table = new EggTable(node_desc->get_name()); node_desc->_anim = new EggXfmSAnim("xform", @@ -256,7 +256,7 @@ r_build_node(INode* max_node) { INode *parent_node; if (max_node->IsRootNode()) { - parent_node = NULL; + parent_node = nullptr; } else { parent_node = max_node->GetParentNode(); } @@ -309,7 +309,7 @@ find_node(INode* max_node) { return (*ni).second; } - return NULL; + return nullptr; } /** diff --git a/pandatool/src/maxegg/maxOptionsDialog.cxx b/pandatool/src/maxegg/maxOptionsDialog.cxx index 556b1a0888..fdcd46cf3e 100644 --- a/pandatool/src/maxegg/maxOptionsDialog.cxx +++ b/pandatool/src/maxegg/maxOptionsDialog.cxx @@ -245,7 +245,7 @@ void RemoveNodeCB::proc(INodeTab &nodeTab) { } MaxEggOptions::MaxEggOptions() { - _max_interface = NULL; + _max_interface = nullptr; _anim_type = MaxEggOptions::AT_model; _start_frame = INT_MIN; _end_frame = INT_MIN; @@ -593,7 +593,7 @@ bool MaxOptionsDialog::UpdateFromUI(HWND hWnd) { _stprintf(_short_name, _T("%.*s..."), sizeof(_short_name)-4, temp); else { _tcscpy(_short_name, temp); - _short_name[_tcslen(_short_name) - 4] = NULL; //Cut off the .egg + _short_name[_tcslen(_short_name) - 4] = 0; //Cut off the .egg } _start_frame = newSF; diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index 6e79178fc5..85b909a6e2 100644 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -51,7 +51,7 @@ void MaxToEggConverter::reset() { _cur_tref = 0; _current_frame = 0; _textures.clear(); - _egg_data = NULL; + _egg_data = nullptr; } /** @@ -103,7 +103,7 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { if (_options->_export_whole_scene) { _tree._export_mesh = false; - all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), NULL, 0); + all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), nullptr, 0); } else { _tree._export_mesh = true; all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), &_options->_node_list.front(), _options->_node_list.size()); @@ -211,7 +211,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, // Set the frame rate before we start asking for anim tables to be // created. _tree._fps = output_frame_rate / frame_inc; - _tree.clear_egg(_egg_data, NULL, skeleton_node); + _tree.clear_egg(_egg_data, nullptr, skeleton_node); // Now we can get the animation data by walking through all of the frames, // one at a time, and getting the joint angles at each frame. @@ -241,7 +241,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, get_joint_transform(max_node, node_desc->_parent->get_max_node(), tgroup); } else { - get_joint_transform(max_node, NULL, tgroup); + get_joint_transform(max_node, nullptr, tgroup); } EggXfmSAnim *anim = _tree.get_egg_anim(node_desc); @@ -275,7 +275,7 @@ bool MaxToEggConverter:: convert_hierarchy(EggGroupNode *egg_root) { // int num_nodes = _tree.get_num_nodes(); - _tree.clear_egg(_egg_data, egg_root, NULL); + _tree.clear_egg(_egg_data, egg_root, nullptr); for (int i = 0; i < _tree.get_num_nodes(); i++) { if (!process_model_node(_tree.get_node(i))) { return false; @@ -316,7 +316,7 @@ process_model_node(MaxNodeDesc *node_desc) { } } else { if (state.obj) { - EggGroup *egg_group = NULL; + EggGroup *egg_group = nullptr; TriObject *myMaxTriObject; Mesh max_mesh; // Call the correct exporter based on what type of object this is. @@ -885,7 +885,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); if (joint_node_desc){ EggGroup *joint = _tree.get_egg_group(joint_node_desc); - if (joint != (EggGroup *)NULL) + if (joint != nullptr) joint->ref_vertex(vert, 1.0f); } } @@ -900,7 +900,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); if (joint_node_desc){ EggGroup *joint = _tree.get_egg_group(joint_node_desc); - if (joint != (EggGroup *)NULL) + if (joint != nullptr) joint->ref_vertex(vert, weight); } } @@ -936,7 +936,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); if (joint_node_desc){ EggGroup *joint = _tree.get_egg_group(joint_node_desc); - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { joint->ref_vertex(vert, weight); } } @@ -1322,7 +1322,7 @@ reparent_decals(EggGroupNode *egg_parent) { // First, walk through all children of this node, looking for the one // decal base, if any. - EggGroup *decal_base = (EggGroup *)NULL; + EggGroup *decal_base = nullptr; pvector decal_children; EggGroupNode::iterator ci; @@ -1331,7 +1331,7 @@ reparent_decals(EggGroupNode *egg_parent) { if (child->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = (EggGroup *) child; if (child_group->has_object_type("decalbase")) { - if (decal_base != (EggNode *)NULL) { + if (decal_base != nullptr) { // error okflag = false; } @@ -1345,7 +1345,7 @@ reparent_decals(EggGroupNode *egg_parent) { } } - if (decal_base == (EggGroup *)NULL) { + if (decal_base == nullptr) { if (!decal_children.empty()) { // warning } @@ -1388,7 +1388,7 @@ Modifier* MaxToEggConverter::FindSkinModifier (INode* node, const Class_ID &type { // Get object from node. Abort if no object. Object* pObj = node->GetObjectRef(); - if (!pObj) return NULL; + if (!pObj) return nullptr; // Is derived object ? while (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID) { @@ -1410,5 +1410,5 @@ Modifier* MaxToEggConverter::FindSkinModifier (INode* node, const Class_ID &type } // Not found. - return NULL; + return nullptr; } diff --git a/pandatool/src/maxegg/maxToEggConverter.h b/pandatool/src/maxegg/maxToEggConverter.h index 0225565843..fc2ed1843f 100644 --- a/pandatool/src/maxegg/maxToEggConverter.h +++ b/pandatool/src/maxegg/maxToEggConverter.h @@ -81,7 +81,7 @@ class MaxToEggConverter { void make_polyset(INode *max_node, Mesh *mesh, EggGroup *egg_group, - Shader *default_shader = NULL); + Shader *default_shader = nullptr); Point3 get_max_vertex_normal(Mesh *mesh, int faceNo, int vertNo); VertColor get_max_vertex_color(Mesh *mesh, int FaceNo, int VertexNo); diff --git a/pandatool/src/maxprogs/maxEggImport.cxx b/pandatool/src/maxprogs/maxEggImport.cxx index 8565a612b4..717b877122 100644 --- a/pandatool/src/maxprogs/maxEggImport.cxx +++ b/pandatool/src/maxprogs/maxEggImport.cxx @@ -200,12 +200,12 @@ DoImport(const TCHAR *name, ImpInterface *ii, Interface *i, BOOL suppressPrompts string txt = log.str(); if (txt != "") { - MessageBoxA(NULL, txt.c_str(), "Panda3D Importer", MB_OK); + MessageBoxA(nullptr, txt.c_str(), "Panda3D Importer", MB_OK); } else if (!ok) { - MessageBoxA(NULL, "Import Failed, unknown reason\n", "Panda3D Importer", MB_OK); + MessageBoxA(nullptr, "Import Failed, unknown reason\n", "Panda3D Importer", MB_OK); } - Notify::ptr()->set_ostream_ptr(NULL, false); + Notify::ptr()->set_ostream_ptr(nullptr, false); return 1; } diff --git a/pandatool/src/maya/mayaApi.cxx b/pandatool/src/maya/mayaApi.cxx index 015ce7d4c6..8ec5f9e479 100644 --- a/pandatool/src/maya/mayaApi.cxx +++ b/pandatool/src/maya/mayaApi.cxx @@ -29,7 +29,7 @@ #include // for chdir() #endif -MayaApi *MayaApi::_global_api = (MayaApi *)NULL; +MayaApi *MayaApi::_global_api = nullptr; // We need this bogus object just to force the application to link with // OpenMayaAnim.lib; otherwise, Maya will complain (when compiled on Windows) @@ -125,7 +125,7 @@ MayaApi:: // Maya code. MLibrary::cleanup(); } - _global_api = (MayaApi *)NULL; + _global_api = nullptr; } /** @@ -141,7 +141,7 @@ MayaApi:: */ PT(MayaApi) MayaApi:: open_api(string program_name, bool view_license, bool revertdir) { - if (_global_api == (MayaApi *)NULL) { + if (_global_api == nullptr) { // We need to create a new MayaApi object. if (program_name.empty()) { program_name = ExecutionEnvironment::get_binary_name(); diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index f012539b81..78484d0be3 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -113,7 +113,7 @@ get_color_def(size_t idx) const { if (_color.size() > 0) return _color[idx]; else - return (MayaShaderColorDef *)NULL; + return nullptr; } /** * Returns the overall color of the shader as a single-precision rgba value, diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index ede0bbf0d5..69aa0cd85e 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -63,7 +63,7 @@ MayaShaderColorDef() { _opposite = 0; - _color_object = (MObject *)NULL; + _color_object = nullptr; _has_texture = false; _has_flat_color = false; @@ -74,7 +74,7 @@ MayaShaderColorDef() { _interpolate = false; _uvset_name = "map1"; - _map_uvs = NULL; + _map_uvs = nullptr; } /** @@ -128,7 +128,7 @@ MayaShaderColorDef(MayaShaderColorDef ©) { */ MayaShaderColorDef:: ~MayaShaderColorDef() { - if (_color_object != (MObject *)NULL) { + if (_color_object != nullptr) { delete _color_object; } } @@ -169,7 +169,7 @@ has_projection() const { */ LTexCoordd MayaShaderColorDef:: project_uv(const LPoint3d &pos, const LPoint3d ¢roid) const { - nassertr(_map_uvs != NULL, LTexCoordd::zero()); + nassertr(_map_uvs != nullptr, LTexCoordd::zero()); return (this->*_map_uvs)(pos * _projection_matrix, centroid * _projection_matrix); } @@ -205,7 +205,7 @@ write(ostream &out) const { */ bool MayaShaderColorDef:: reset_maya_texture(const Filename &texture) { - if (_color_object != (MObject *)NULL) { + if (_color_object != nullptr) { _has_texture = set_string_attribute(*_color_object, "fileTextureName", texture.to_os_generic()); _texture_filename = texture; @@ -686,7 +686,7 @@ set_projection_type(const string &type) { maya_cat.error() << "Don't know how to handle type " << type << " projections.\n"; _projection_type = PT_off; - _map_uvs = NULL; + _map_uvs = nullptr; } } diff --git a/pandatool/src/maya/mayaShaders.cxx b/pandatool/src/maya/mayaShaders.cxx index a100ad8a4e..7aecbd3d61 100644 --- a/pandatool/src/maya/mayaShaders.cxx +++ b/pandatool/src/maya/mayaShaders.cxx @@ -55,7 +55,7 @@ find_shader_for_node(MObject node, bool legacy_shader) { // The node is not renderable. What are you thinking? maya_cat.error() << node_fn.name().asChar() << " : not a renderable object.\n"; - return (MayaShader *)NULL; + return nullptr; } // instObjGroups is a multi attribute, whatever that means. For now, we'll @@ -69,7 +69,7 @@ find_shader_for_node(MObject node, bool legacy_shader) { // No shading group defined for this object. maya_cat.error() << node_fn.name().asChar() << " : no shading group defined.\n"; - return (MayaShader *)NULL; + return nullptr; } // Now we have a number of ShadingEngines defined, one for each of these @@ -87,7 +87,7 @@ find_shader_for_node(MObject node, bool legacy_shader) { // Well, we didn't find a ShadingEngine after all. Huh. maya_cat.debug() << node_fn.name().asChar() << " : no shading engine found.\n"; - return (MayaShader *)NULL; + return nullptr; } /** @@ -175,7 +175,7 @@ get_num_shaders() const { */ MayaShader *MayaShaders:: get_shader(int n) const { - nassertr(n >= 0 && n < (int)_shaders_in_order.size(), NULL); + nassertr(n >= 0 && n < (int)_shaders_in_order.size(), nullptr); return _shaders_in_order[n]; } diff --git a/pandatool/src/maya/maya_funcs.T b/pandatool/src/maya/maya_funcs.T index 04ecfab83f..80d8803d3f 100644 --- a/pandatool/src/maya/maya_funcs.T +++ b/pandatool/src/maya/maya_funcs.T @@ -1,24 +1,20 @@ -// Filename: maya_funcs.I -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maya_funcs.T + * @author drose + * @date 2000-02-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: get_maya_attribute -// Description: A generic function to extract an attribute of some -// type from an MObject. This is used to implement -// get_bool_attribute(), etc. -//////////////////////////////////////////////////////////////////// +/** + * A generic function to extract an attribute of some type from an MObject. + * This is used to implement get_bool_attribute(), etc. + */ template bool get_maya_attribute(MObject &node, const string &attribute_name, @@ -33,12 +29,10 @@ get_maya_attribute(MObject &node, const string &attribute_name, return status; } -//////////////////////////////////////////////////////////////////// -// Function: set_maya_attribute -// Description: A generic function to set an attribute of some -// type on an MObject. This is used to implement -// set_bool_attribute(), etc. -//////////////////////////////////////////////////////////////////// +/** + * A generic function to set an attribute of some type on an MObject. This is + * used to implement set_bool_attribute(), etc. + */ template bool set_maya_attribute(MObject &node, const string &attribute_name, diff --git a/pandatool/src/mayaegg/mayaBlendDesc.cxx b/pandatool/src/mayaegg/mayaBlendDesc.cxx index c0977dcb3a..c60ecf515a 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.cxx +++ b/pandatool/src/mayaegg/mayaBlendDesc.cxx @@ -28,7 +28,7 @@ MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index) : strm << _deformer.name().asChar() << "." << _weight_index; set_name(strm.str()); - _anim = (EggSAnimData *)NULL; + _anim = nullptr; } /** @@ -65,5 +65,5 @@ get_slider() const { */ void MayaBlendDesc:: clear_egg() { - _anim = (EggSAnimData *)NULL; + _anim = nullptr; } diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index 82523d122f..6664e54aa0 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -235,7 +235,7 @@ MayaEggTex *MayaEggLoader::GetTex(EggTexture* etex) { string name = ""; string fn = ""; - if (etex != NULL) { + if (etex != nullptr) { name = etex->get_name(); fn = etex->get_fullpath().to_os_specific(); } @@ -293,7 +293,7 @@ MayaEggTex *MayaEggLoader::GetTex(EggTexture* etex) // [gjeon] to create alpha channel connection LoaderOptions options; PT(Texture) tex = TexturePool::load_texture(etex->get_fullpath(), 0, false, options); - if (((tex != NULL) && (tex->get_num_components() == 4)) + if (((tex != nullptr) && (tex->get_num_components() == 4)) || (etex->get_format() == EggTexture::F_alpha) || (etex->get_format() == EggTexture::F_luminance_alpha)) dgmod.connect(filetex.findPlug("outTransparency"),shader.findPlug("transparency")); @@ -452,7 +452,7 @@ void MayaEggJoint::AssignNames(void) MayaEggJoint *MayaEggLoader::FindJoint(EggGroup *joint) { - if (joint==(EggGroup *)NULL) { + if (joint==nullptr) { if (mayaloader_cat.is_spam()) { mayaloader_cat.spam() << "joint:" << joint->get_name() << " is null: " << endl; } @@ -1286,7 +1286,7 @@ void MayaEggLoader::CreateSkinCluster(MayaEggGeom *M) perror("skinCluster index"); return; } - skinCluster.setWeights(M->_shape_dag_path, component.object(), index, 0.0, false, NULL); + skinCluster.setWeights(M->_shape_dag_path, component.object(), index, 0.0, false, nullptr); } MFloatArray values; @@ -1302,7 +1302,7 @@ void MayaEggLoader::CreateSkinCluster(MayaEggGeom *M) values[vert->_index * joints.size() + joint->_index] = (PN_stdfloat)strength; } } - skinCluster.setWeights(M->_shape_dag_path, component.object(), influenceIndices, values, false, NULL); + skinCluster.setWeights(M->_shape_dag_path, component.object(), influenceIndices, values, false, nullptr); for (unsigned int i=0; ihas_transform()) uvtrans = etex->get_transform2d(); } else { - tex = GetTex(NULL); + tex = GetTex(nullptr); } EggPolygon::const_iterator ci; @@ -1451,7 +1451,7 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del uvtrans = etex->get_transform2d(); } } else { - tex = GetTex(NULL); + tex = GetTex(nullptr); } surface->_tex = tex; @@ -1614,7 +1614,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a if (mayaloader_cat.is_debug()) { mayaloader_cat.debug() << "root node: " << data->get_type() << endl; } - TraverseEggNode(data, NULL, ""); + TraverseEggNode(data, nullptr, ""); MStatus status; @@ -1886,15 +1886,15 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a MFnAnimCurve mfnAnimCurveSY; MFnAnimCurve mfnAnimCurveSZ; - mfnAnimCurveTX.create(node, attrTX, MFnAnimCurve::kAnimCurveTL, NULL, &status); - mfnAnimCurveTY.create(node, attrTY, MFnAnimCurve::kAnimCurveTL, NULL, &status); - mfnAnimCurveTZ.create(node, attrTZ, MFnAnimCurve::kAnimCurveTL, NULL, &status); - mfnAnimCurveRX.create(node, attrRX, MFnAnimCurve::kAnimCurveTA, NULL, &status); - mfnAnimCurveRY.create(node, attrRY, MFnAnimCurve::kAnimCurveTA, NULL, &status); - mfnAnimCurveRZ.create(node, attrRZ, MFnAnimCurve::kAnimCurveTA, NULL, &status); - mfnAnimCurveSX.create(node, attrSX, MFnAnimCurve::kAnimCurveTU, NULL, &status); - mfnAnimCurveSY.create(node, attrSY, MFnAnimCurve::kAnimCurveTU, NULL, &status); - mfnAnimCurveSZ.create(node, attrSZ, MFnAnimCurve::kAnimCurveTU, NULL, &status); + mfnAnimCurveTX.create(node, attrTX, MFnAnimCurve::kAnimCurveTL, nullptr, &status); + mfnAnimCurveTY.create(node, attrTY, MFnAnimCurve::kAnimCurveTL, nullptr, &status); + mfnAnimCurveTZ.create(node, attrTZ, MFnAnimCurve::kAnimCurveTL, nullptr, &status); + mfnAnimCurveRX.create(node, attrRX, MFnAnimCurve::kAnimCurveTA, nullptr, &status); + mfnAnimCurveRY.create(node, attrRY, MFnAnimCurve::kAnimCurveTA, nullptr, &status); + mfnAnimCurveRZ.create(node, attrRZ, MFnAnimCurve::kAnimCurveTA, nullptr, &status); + mfnAnimCurveSX.create(node, attrSX, MFnAnimCurve::kAnimCurveTU, nullptr, &status); + mfnAnimCurveSY.create(node, attrSY, MFnAnimCurve::kAnimCurveTU, nullptr, &status); + mfnAnimCurveSZ.create(node, attrSZ, MFnAnimCurve::kAnimCurveTU, nullptr, &status); MTransformationMatrix matrix( mMat ); MVector trans = matrix.translation(MSpace::kTransform, &status); @@ -1908,15 +1908,15 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a MFnAnimCurve::TangentType tangent = MFnAnimCurve::kTangentClamped; MTime time(_start_frame - 1, _timeUnit); - mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, NULL, &status); - mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, NULL, &status); - mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, NULL, &status); - mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, NULL, &status); - mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, NULL, &status); - mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, NULL, &status); - mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, NULL, &status); - mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, NULL, &status); - mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, NULL, &status); + mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, nullptr, &status); + mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, nullptr, &status); + mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, nullptr, &status); + mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, nullptr, &status); + mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, nullptr, &status); + mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, nullptr, &status); + mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, nullptr, &status); + mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, nullptr, &status); + mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, nullptr, &status); for (int frame = 0; frame < anim->_pool->get_num_rows(); frame++) { @@ -1935,15 +1935,15 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a status = matrix.getScale(scale, MSpace::kTransform); time = MTime(frame + _start_frame, _timeUnit); - mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, NULL, &status); - mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, NULL, &status); - mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, NULL, &status); - mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, NULL, &status); - mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, NULL, &status); - mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, NULL, &status); - mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, NULL, &status); - mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, NULL, &status); - mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, NULL, &status); + mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, nullptr, &status); + mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, nullptr, &status); + mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, nullptr, &status); + mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, nullptr, &status); + mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, nullptr, &status); + mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, nullptr, &status); + mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, nullptr, &status); + mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, nullptr, &status); + mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, nullptr, &status); } if (maxFrame < time) { maxFrame = time; diff --git a/pandatool/src/mayaegg/mayaNodeDesc.cxx b/pandatool/src/mayaegg/mayaNodeDesc.cxx index efef4879a8..9049bf2dc8 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.cxx +++ b/pandatool/src/mayaegg/mayaNodeDesc.cxx @@ -50,17 +50,17 @@ MayaNodeDesc(MayaNodeTree *tree, MayaNodeDesc *parent, const string &name) : _tree(tree), _parent(parent) { - _dag_path = (MDagPath *)NULL; - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _dag_path = nullptr; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; _joint_type = JT_none; _is_lod = false; _tagged = false; _joint_tagged = false; // Add ourselves to our parent. - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } } @@ -70,7 +70,7 @@ MayaNodeDesc(MayaNodeTree *tree, MayaNodeDesc *parent, const string &name) : */ MayaNodeDesc:: ~MayaNodeDesc() { - if (_dag_path != (MDagPath *)NULL) { + if (_dag_path != nullptr) { delete _dag_path; } } @@ -82,7 +82,7 @@ void MayaNodeDesc:: from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { MStatus status; - if (_dag_path == (MDagPath *)NULL) { + if (_dag_path == nullptr) { _dag_path = new MDagPath(dag_path); string name; @@ -97,7 +97,7 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { // This node is a joint, or the user specifically asked to treat it like // a joint. _joint_type = JT_joint; - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } @@ -120,7 +120,7 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { if (transform_connected) { _joint_type = JT_joint; - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } @@ -146,7 +146,7 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { */ bool MayaNodeDesc:: has_dag_path() const { - return (_dag_path != (MDagPath *)NULL); + return (_dag_path != nullptr); } /** @@ -155,7 +155,7 @@ has_dag_path() const { */ const MDagPath &MayaNodeDesc:: get_dag_path() const { - nassertr(_dag_path != (MDagPath *)NULL, *_dag_path); + nassertr(_dag_path != nullptr, *_dag_path); return *_dag_path; } @@ -174,7 +174,7 @@ get_num_blend_descs() const { */ MayaBlendDesc *MayaNodeDesc:: get_blend_desc(int n) const { - nassertr(n >= 0 && n < (int)_blend_descs.size(), NULL); + nassertr(n >= 0 && n < (int)_blend_descs.size(), nullptr); return _blend_descs[n]; } @@ -286,11 +286,11 @@ untag_recursively() { bool MayaNodeDesc:: has_object_type(string object_type) const { bool ret = false; - if ((_egg_group != (EggGroup*) NULL) + if ((_egg_group != nullptr) && _egg_group->has_object_type(object_type)) { return true; } - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { ret |= _parent->has_object_type(object_type); } return ret; @@ -301,9 +301,9 @@ has_object_type(string object_type) const { */ void MayaNodeDesc:: clear_egg() { - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -320,7 +320,7 @@ void MayaNodeDesc:: mark_joint_parent() { if (_joint_type == JT_none) { _joint_type = JT_joint_parent; - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } @@ -506,7 +506,7 @@ check_lods() { } // Now consider whether this node is an lodGroup. - if (_dag_path != (MDagPath *)NULL && + if (_dag_path != nullptr && _dag_path->hasFn(MFn::kLodGroup)) { // This node is a parent lodGroup; its children, therefore, are LOD's. MStatus status; diff --git a/pandatool/src/mayaegg/mayaNodeDesc.h b/pandatool/src/mayaegg/mayaNodeDesc.h index 1c28cb1698..bfae4300ce 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.h +++ b/pandatool/src/mayaegg/mayaNodeDesc.h @@ -40,7 +40,7 @@ class EggXfmSAnim; class MayaNodeDesc : public ReferenceCount, public Namable { public: MayaNodeDesc(MayaNodeTree *tree, - MayaNodeDesc *parent = NULL, const string &name = string()); + MayaNodeDesc *parent = nullptr, const string &name = string()); ~MayaNodeDesc(); void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter); diff --git a/pandatool/src/mayaegg/mayaNodeTree.cxx b/pandatool/src/mayaegg/mayaNodeTree.cxx index def22d13b2..32a6281725 100644 --- a/pandatool/src/mayaegg/mayaNodeTree.cxx +++ b/pandatool/src/mayaegg/mayaNodeTree.cxx @@ -41,10 +41,10 @@ MayaNodeTree(MayaToEggConverter *converter) : { _root = new MayaNodeDesc(this); _fps = 0.0; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; - _morph_node = (EggGroupNode *)NULL; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; + _morph_node = nullptr; } /** @@ -259,7 +259,7 @@ get_num_nodes() const { */ MayaNodeDesc *MayaNodeTree:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } @@ -270,10 +270,10 @@ void MayaNodeTree:: clear() { _root = new MayaNodeDesc(this); _fps = 0.0; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; - _morph_node = (EggGroupNode *)NULL; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; + _morph_node = nullptr; _nodes_by_path.clear(); _nodes.clear(); } @@ -303,13 +303,13 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, */ EggGroup *MayaNodeTree:: get_egg_group(MayaNodeDesc *node_desc) { - nassertr(_egg_root != (EggGroupNode *)NULL, NULL); + nassertr(_egg_root != nullptr, nullptr); - if (node_desc->_egg_group == (EggGroup *)NULL) { + if (node_desc->_egg_group == nullptr) { // We need to make a new group node. EggGroup *egg_group; - nassertr(node_desc->_parent != (MayaNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); egg_group = new EggGroup(node_desc->get_name()); if (node_desc->is_joint()) { if (_converter->get_animation_convert() == AC_model || @@ -318,7 +318,7 @@ get_egg_group(MayaNodeDesc *node_desc) { } } - MayaEggGroupUserData *parent_user_data = NULL; + MayaEggGroupUserData *parent_user_data = nullptr; if (node_desc->_parent == _root) { // The parent is the root. @@ -330,7 +330,7 @@ get_egg_group(MayaNodeDesc *node_desc) { parent_egg_group->add_child(egg_group); if (parent_egg_group->has_user_data()) { - DCAST_INTO_R(parent_user_data, parent_egg_group->get_user_data(), NULL); + DCAST_INTO_R(parent_user_data, parent_egg_group->get_user_data(), nullptr); } } @@ -406,7 +406,7 @@ get_egg_group(MayaNodeDesc *node_desc) { // And "vertex-color" and "double-sided" have meaning only to this // converter. MayaEggGroupUserData *user_data; - if (parent_user_data == (MayaEggGroupUserData *)NULL) { + if (parent_user_data == nullptr) { user_data = new MayaEggGroupUserData; } else { // Inherit the flags from above. @@ -443,12 +443,12 @@ get_egg_group(MayaNodeDesc *node_desc) { */ EggTable *MayaNodeTree:: get_egg_table(MayaNodeDesc *node_desc) { - nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); - nassertr(node_desc->is_joint(), NULL); + nassertr(_skeleton_node != nullptr, nullptr); + nassertr(node_desc->is_joint(), nullptr); - if (node_desc->_egg_table == (EggTable *)NULL) { + if (node_desc->_egg_table == nullptr) { // We need to make a new table node. - nassertr(node_desc->_parent != (MayaNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); EggTable *egg_table = new EggTable(node_desc->get_name()); node_desc->_anim = new EggXfmSAnim("xform", _egg_data->get_coordinate_system()); @@ -487,9 +487,9 @@ get_egg_anim(MayaNodeDesc *node_desc) { */ EggSAnimData *MayaNodeTree:: get_egg_slider(MayaBlendDesc *blend_desc) { - nassertr(_morph_node != (EggGroupNode *)NULL, NULL); + nassertr(_morph_node != nullptr, nullptr); - if (blend_desc->_anim == (EggSAnimData *)NULL) { + if (blend_desc->_anim == nullptr) { // We need to make a new anim table. EggSAnimData *egg_anim = new EggSAnimData(blend_desc->get_name()); egg_anim->set_fps(_fps); @@ -553,7 +553,7 @@ get_num_blend_descs() const { */ MayaBlendDesc *MayaNodeTree:: get_blend_desc(int n) const { - nassertr(n >= 0 && n < (int)_blend_descs.size(), NULL); + nassertr(n >= 0 && n < (int)_blend_descs.size(), nullptr); return _blend_descs[n]; } @@ -583,7 +583,7 @@ r_build_node(const string &path) { // Otherwise, we have to create it. Do this recursively, so we create each // node along the path. - MayaNodeDesc *node_desc = NULL; + MayaNodeDesc *node_desc = nullptr; // mayaegg_cat.info() << "path: " << path << endl; if (path.empty()) { @@ -610,7 +610,7 @@ r_build_node(const string &path) { if (node_desc != _root) { MayaNodeDesc *parent_node_desc = r_build_node(parent_path); - if (parent_node_desc == (MayaNodeDesc *)NULL) + if (parent_node_desc == nullptr) mayaegg_cat.info() << "empty parent: " << local_name << endl; node_desc = new MayaNodeDesc(this, parent_node_desc, local_name); _nodes.push_back(node_desc); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index d661af583b..cefe15e1cc 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -537,7 +537,7 @@ convert_maya() { bool MayaToEggConverter:: open_api(bool revert_directory) { - if (_maya == (MayaApi *)NULL || !_maya->is_valid()) { + if (_maya == nullptr || !_maya->is_valid()) { // maya to egg converter only needs a read license. only egg2maya need // write lisences. _maya = MayaApi::open_api(_program_name, true, revert_directory); @@ -653,7 +653,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, // Set the frame rate before we start asking for anim tables to be created. _tree._fps = output_frame_rate; - _tree.clear_egg(get_egg_data(), NULL, skeleton_node, morph_node); + _tree.clear_egg(get_egg_data(), nullptr, skeleton_node, morph_node); // Now we can get the animation data by walking through all of the frames, // one at a time, and getting the joint angles at each frame. @@ -675,7 +675,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, } else { // We have to write to cerr instead of mayaegg_cat to allow flushing // without writing a newline. - cerr << "." << flush; + std::cerr << "." << std::flush; } MGlobal::viewFrame(frame); @@ -758,7 +758,7 @@ convert_hierarchy(EggGroupNode *egg_root) { if (_legacy_shader) { mayaegg_cat.info() << "will disable modern Phong shader path. using legacy" << endl; } - _tree.clear_egg(get_egg_data(), egg_root, NULL, NULL); + _tree.clear_egg(get_egg_data(), egg_root, nullptr, nullptr); for (int i = 0; i < num_nodes; i++) { MayaNodeDesc *node = _tree.get_node(i); if (!process_model_node(node)) { @@ -1489,7 +1489,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, EggNurbsCurve *egg_curve = make_trim_curve(curve, name, egg_group, trim_curve_index); trim_curve_index++; - if (egg_curve != (EggNurbsCurve *)NULL) { + if (egg_curve != nullptr) { egg_loop.push_back(egg_curve); } } @@ -1509,7 +1509,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, // trim curves have been added. egg_group->add_child(egg_nurbs); - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { set_shader_attributes(*egg_nurbs, *shader); } @@ -1542,7 +1542,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, PN_stdfloat weight = weights[maya_vi * num_joints + ji]; if (weight != 0.0f) { EggGroup *joint = joints[ji]; - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { joint->ref_vertex(vert, weight); } } @@ -1581,13 +1581,13 @@ make_trim_curve(const MFnNurbsCurve &curve, const string &nurbs_name, status = curve.getCVs(cv_array, MSpace::kWorld); if (!status) { status.perror("MFnNurbsCurve::getCVs"); - return (EggNurbsCurve *)NULL; + return nullptr; } MDoubleArray knot_array; status = curve.getKnots(knot_array); if (!status) { status.perror("MFnNurbsCurve::getKnots"); - return (EggNurbsCurve *)NULL; + return nullptr; } /* @@ -1713,7 +1713,7 @@ make_nurbs_curve(const MDagPath &, const MFnNurbsCurve &curve, } } MayaShader *shader = _shaders.find_shader_for_node(curve.object(), _legacy_shader); - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { set_shader_attributes(*egg_curve, *shader); } } @@ -1838,7 +1838,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, // be two diverging paths for any Maya node with a Material (MayaShader) // on it This next bit kicks us out into mayaShader et al. to pull // textures and everything else. - MayaShader *shader = NULL; + MayaShader *shader = nullptr; int index = pi.index(); nassertv(index >= 0 && index < (int)poly_shader_indices.length()); int shader_index = poly_shader_indices[index]; @@ -1850,14 +1850,14 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, _shaders.find_shader_for_shading_engine(engine, _legacy_shader); //head out to the other classes // does this mean if we didn't find a Maya shader give it a default // value anyway? - } else if (default_shader != (MayaShader *)NULL) { + } else if (default_shader != nullptr) { shader = default_shader; } - const MayaShaderColorDef *default_color_def = NULL; + const MayaShaderColorDef *default_color_def = nullptr; // And apply the shader properties to the polygon. - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { set_shader_attributes(*egg_poly, *shader, true); default_color_def = shader->get_color_def(); } @@ -1874,7 +1874,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, // Furthermore, if _always_show_vertex_color is true, we pretend that the // "vertex-color" flag is always set. bool ignore_vertex_color = false; - if ( default_color_def != (MayaShaderColorDef *)NULL) { + if ( default_color_def != nullptr) { ignore_vertex_color = default_color_def->_has_texture && !(egg_vertex_color || _always_show_vertex_color); } @@ -1891,7 +1891,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, long i; LPoint3d centroid(0.0, 0.0, 0.0); - if (default_color_def != (MayaShaderColorDef *)NULL && default_color_def->has_projection()) { + if (default_color_def != nullptr && default_color_def->has_projection()) { // If the shader has a projection, we may need to compute the polygon's // centroid to avoid seams at the edges. for (i = 0; i < num_verts; i++) { @@ -1922,7 +1922,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, // Go thru all the texture references for this primitive and set uvs if (mayaegg_cat.is_spam()) { - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { mayaegg_cat.spam() << "shader->_color.size is " << shader->_color.size() << endl; } mayaegg_cat.spam() << "primitive->tref.size is " << egg_poly->get_num_textures() << endl; @@ -1946,7 +1946,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, bool project_uv = false; LTexCoordd uv_projection; - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { for (size_t tj = 0; tj < shader->_all_maps.size(); ++tj) { MayaShaderColorDef *def = shader->_all_maps[tj]; if (def->_uvset_name == uvset_name) { @@ -2082,7 +2082,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, PN_stdfloat weight = weights[maya_vi * num_joints + ji]; if (weight != 0.0f) { EggGroup *joint = joints[ji]; - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { joint->ref_vertex(vert, weight); } } @@ -2614,7 +2614,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, // determine if the base texture or any of the top texture need to be rgb // only - MayaShaderColorDef *color_def = NULL; + MayaShaderColorDef *color_def = nullptr; bool is_rgb = false; bool is_decal = false; bool is_interpolate = false; @@ -2644,7 +2644,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, is_decal = false; // new decal mode needs an extra dummy layers of textureStage - EggTexture *dummy_tex = (EggTexture *)NULL; + EggTexture *dummy_tex = nullptr; string dummy_uvset_name; // In Maya, a polygon is either textured or colored. The texture, if @@ -2856,7 +2856,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, } } } - if (dummy_tex != (EggTexture *)NULL) { + if (dummy_tex != nullptr) { primitive.add_texture(dummy_tex); dummy_tex->set_uv_name(dummy_uvset_name); } @@ -3052,7 +3052,7 @@ reparent_decals(EggGroupNode *egg_parent) { // First, walk through all children of this node, looking for the one decal // base, if any. - EggGroup *decal_base = (EggGroup *)NULL; + EggGroup *decal_base = nullptr; pvector decal_children; EggGroupNode::iterator ci; @@ -3061,7 +3061,7 @@ reparent_decals(EggGroupNode *egg_parent) { if (child->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, child); if (child_group->has_object_type("decalbase")) { - if (decal_base != (EggNode *)NULL) { + if (decal_base != nullptr) { mayaegg_cat.error() << "Two children of " << egg_parent->get_name() << " both have decalbase set: " << decal_base->get_name() @@ -3078,7 +3078,7 @@ reparent_decals(EggGroupNode *egg_parent) { } } - if (decal_base == (EggGroup *)NULL) { + if (decal_base == nullptr) { if (!decal_children.empty()) { mayaegg_cat.warning() << decal_children.front()->get_name() @@ -3146,7 +3146,7 @@ string_transform_type(const string &arg) { */ void MayaToEggConverter:: set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color) { - if (shader == (MayaShader *)NULL || shader->_legacy_mode) { + if (shader == nullptr || shader->_legacy_mode) { set_vertex_color_legacy(vert, pi, vert_index, shader, color); } else { set_vertex_color_modern(vert, pi, vert_index, shader, color); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index 6662184bd1..ff9d75e7b9 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -131,7 +131,7 @@ private: EggGroup *group); void make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, const MFnMesh &mesh, EggGroup *egg_group, - MayaShader *default_shader = NULL); + MayaShader *default_shader = nullptr); void make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, EggGroup *egg_group); void make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, diff --git a/pandatool/src/mayaprogs/blend_test.cxx b/pandatool/src/mayaprogs/blend_test.cxx index cf7e880731..5cbd6d413e 100644 --- a/pandatool/src/mayaprogs/blend_test.cxx +++ b/pandatool/src/mayaprogs/blend_test.cxx @@ -177,7 +177,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { exit(1); } - ofstream file(filename, ios::out | ios::trunc); + std::ofstream file(filename, ios::out | ios::trunc); if (!file) { cerr << "Couldn't open " << filename << " for output.\n"; exit(1); diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index 286d94ad67..687ec99886 100644 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -128,7 +128,7 @@ doIt(const MArgList &args) { string quoted = string("\"") + bam_filename.get_fullpath() + string("\""); nout << "pview " << pview_args << " " << quoted << "\n"; int retval = _spawnlp(_P_DETACH, "pview", - "pview", pview_args.c_str(), quoted.c_str(), NULL); + "pview", pview_args.c_str(), quoted.c_str(), nullptr); if (retval == -1) { bam_filename.unlink(); MProgressWindow::endProgress(); @@ -146,7 +146,7 @@ doIt(const MArgList &args) { // create a separate PandaFramework for each invocation, even though in // principle we could be sharing one framework for all of them. int argc = 0; - char **argv = NULL; + char **argv = nullptr; PandaFramework framework; framework.open_framework(argc, argv); framework.set_window_title("Panda Viewer"); @@ -154,7 +154,7 @@ doIt(const MArgList &args) { PT(WindowFramework) window; window = framework.open_window(); - if (window == (WindowFramework *)NULL) { + if (window == nullptr) { // Couldn't open a window. nout << "Couldn't open a window!\n"; MProgressWindow::endProgress(); @@ -281,7 +281,7 @@ convert(const NodePath &parent, bool animate) { egg_data->set_coordinate_system(CS_default); PT(PandaNode) result = load_egg_data(egg_data); - if (result == (PandaNode *)NULL) { + if (result == nullptr) { nout << "Unable to load converted egg data.\n"; return false; } diff --git a/pandatool/src/mayaprogs/mayaSavePview.cxx b/pandatool/src/mayaprogs/mayaSavePview.cxx index 60a115c14f..423c7f09da 100644 --- a/pandatool/src/mayaprogs/mayaSavePview.cxx +++ b/pandatool/src/mayaprogs/mayaSavePview.cxx @@ -73,7 +73,7 @@ doIt(const MArgList &args) { // On Windows, we use the spawn function to run pview asynchronously. MString quoted = MString("\"") + filename + MString("\""); int retval = _spawnlp(_P_DETACH, "pview", - "pview", pview_args.asChar(), quoted.asChar(), NULL); + "pview", pview_args.asChar(), quoted.asChar(), nullptr); if (retval == -1) { return MS::kFailure; } diff --git a/pandatool/src/mayaprogs/mayaToEgg.cxx b/pandatool/src/mayaprogs/mayaToEgg.cxx index 5ceb4cf1ee..8d58808a5b 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg.cxx @@ -76,7 +76,7 @@ MayaToEgg() : "Specify the fit tolerance for Maya polygon tesselation. The smaller " "the number, the more polygons will be generated. The default is " "0.01.", - &MayaToEgg::dispatch_double, NULL, &_polygon_tolerance); + &MayaToEgg::dispatch_double, nullptr, &_polygon_tolerance); add_option ("bface", "", 0, @@ -130,7 +130,7 @@ MayaToEgg() : "transforms in the egg file. The option may be one of all, model, " "dcs, or none. The default is model, which means only transforms on " "nodes that have the model flag or the dcs flag are preserved.", - &MayaToEgg::dispatch_transform_type, NULL, &_transform_type); + &MayaToEgg::dispatch_transform_type, nullptr, &_transform_type); add_option ("subroot", "name", 0, @@ -140,7 +140,7 @@ MayaToEgg() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEgg::dispatch_vector_string, NULL, &_subroots); + &MayaToEgg::dispatch_vector_string, nullptr, &_subroots); add_option ("subset", "name", 0, @@ -150,7 +150,7 @@ MayaToEgg() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEgg::dispatch_vector_string, NULL, &_subsets); + &MayaToEgg::dispatch_vector_string, nullptr, &_subsets); add_option ("exclude", "name", 0, @@ -159,7 +159,7 @@ MayaToEgg() : "name matches the parameter (which may include globbing characters " "like * or ?). This parameter may be repeated multiple times to name " "multiple roots.", - &MayaToEgg::dispatch_vector_string, NULL, &_excludes); + &MayaToEgg::dispatch_vector_string, nullptr, &_excludes); add_option ("ignore-slider", "name", 0, @@ -168,19 +168,19 @@ MayaToEgg() : "and it will not become a part of the animation. This " "parameter may including globbing characters, and it may be repeated " "as needed.", - &MayaToEgg::dispatch_vector_string, NULL, &_ignore_sliders); + &MayaToEgg::dispatch_vector_string, nullptr, &_ignore_sliders); add_option ("force-joint", "name", 0, "Specifies the name of a DAG node that maya2egg " "should treat as a joint, even if it does not appear to be a Maya joint " "and does not appear to be animated.", - &MayaToEgg::dispatch_vector_string, NULL, &_force_joints); + &MayaToEgg::dispatch_vector_string, nullptr, &_force_joints); add_option ("v", "", 0, "Increase verbosity. More v's means more verbose.", - &MayaToEgg::dispatch_count, NULL, &_verbose); + &MayaToEgg::dispatch_count, nullptr, &_verbose); add_option ("legacy-shaders", "", 0, diff --git a/pandatool/src/mayaprogs/mayaToEgg_server.cxx b/pandatool/src/mayaprogs/mayaToEgg_server.cxx index 30f88f99d0..8b97d920a4 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_server.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_server.cxx @@ -52,7 +52,7 @@ MayaToEggServer() : "Specify the fit tolerance for Maya polygon tesselation. The smaller " "the number, the more polygons will be generated. The default is " "0.01.", - &MayaToEggServer::dispatch_double, NULL, &_polygon_tolerance); + &MayaToEggServer::dispatch_double, nullptr, &_polygon_tolerance); add_option ("bface", "", 0, @@ -91,7 +91,7 @@ MayaToEggServer() : "transforms in the egg file. The option may be one of all, model, " "dcs, or none. The default is model, which means only transforms on " "nodes that have the model flag or the dcs flag are preserved.", - &MayaToEggServer::dispatch_transform_type, NULL, &_transform_type); + &MayaToEggServer::dispatch_transform_type, nullptr, &_transform_type); add_option ("subroot", "name", 0, @@ -101,7 +101,7 @@ MayaToEggServer() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEggServer::dispatch_vector_string, NULL, &_subroots); + &MayaToEggServer::dispatch_vector_string, nullptr, &_subroots); add_option ("subset", "name", 0, @@ -111,7 +111,7 @@ MayaToEggServer() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEggServer::dispatch_vector_string, NULL, &_subsets); + &MayaToEggServer::dispatch_vector_string, nullptr, &_subsets); add_option ("exclude", "name", 0, @@ -120,7 +120,7 @@ MayaToEggServer() : "name matches the parameter (which may include globbing characters " "like * or ?). This parameter may be repeated multiple times to name " "multiple roots.", - &MayaToEggServer::dispatch_vector_string, NULL, &_excludes); + &MayaToEggServer::dispatch_vector_string, nullptr, &_excludes); add_option ("ignore-slider", "name", 0, @@ -129,19 +129,19 @@ MayaToEggServer() : "and it will not become a part of the animation. This " "parameter may including globbing characters, and it may be repeated " "as needed.", - &MayaToEggServer::dispatch_vector_string, NULL, &_ignore_sliders); + &MayaToEggServer::dispatch_vector_string, nullptr, &_ignore_sliders); add_option ("force-joint", "name", 0, "Specifies the name of a DAG node that maya2egg " "should treat as a joint, even if it does not appear to be a Maya joint " "and does not appear to be animated.", - &MayaToEggServer::dispatch_vector_string, NULL, &_force_joints); + &MayaToEggServer::dispatch_vector_string, nullptr, &_force_joints); add_option ("v", "", 0, "Increase verbosity. More v's means more verbose.", - &MayaToEggServer::dispatch_count, NULL, &_verbose); + &MayaToEggServer::dispatch_count, nullptr, &_verbose); add_option ("legacy-shaders", "", 0, diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index 428e4ba128..a82411efe9 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -133,7 +133,7 @@ get_maya_location(const char *ver, string &loc) { DWORD dtype; DWORD size = 4096; char result[4096 + 1]; - res = RegQueryValueEx(hkey, "MAYA_INSTALL_LOCATION", NULL, &dtype, (LPBYTE)result, &size); + res = RegQueryValueEx(hkey, "MAYA_INSTALL_LOCATION", nullptr, &dtype, (LPBYTE)result, &size); if ((res == ERROR_SUCCESS)&&(dtype == REG_SZ)) { result[size] = 0; loc = result; @@ -222,7 +222,7 @@ main(int argc, char *argv[]) { Filename standard_maya_location; #ifdef MAYAVERSION const char *key = get_version_number(TOSTRING(MAYAVERSION)); - if (key == NULL) { + if (key == nullptr) { cerr << "Unknown Maya version: " << TOSTRING(MAYAVERSION) << "\n"; } else { string loc; @@ -386,7 +386,7 @@ main(int argc, char *argv[]) { #endif if (bin.is_directory()) { const char *path = getenv("PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string putenv_str = "PATH=" + bin.to_os_specific() + sep + path; @@ -398,7 +398,7 @@ main(int argc, char *argv[]) { // And on DYLD_LIBRARY_PATH. if (bin.is_directory()) { const char *path = getenv("DYLD_LIBRARY_PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string sep = ":"; @@ -411,7 +411,7 @@ main(int argc, char *argv[]) { Filename fw_dir = Filename(maya_location, "Frameworks"); if (fw_dir.is_directory()) { const char *path = getenv("DYLD_FALLBACK_FRAMEWORK_PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string sep = ":"; @@ -424,7 +424,7 @@ main(int argc, char *argv[]) { // Linux (or other non-Windows OS) gets it added to LD_LIBRARY_PATH. if (bin.is_directory()) { const char *path = getenv("LD_LIBRARY_PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string sep = ":"; @@ -451,8 +451,8 @@ main(int argc, char *argv[]) { GetStartupInfo(&startup_info); BOOL result = CreateProcess(os_command.c_str(), command_line, - NULL, NULL, true, 0, - NULL, NULL, + nullptr, nullptr, true, 0, + nullptr, nullptr, &startup_info, &process_info); if (result) { diff --git a/pandatool/src/mayaprogs/normal_test.cxx b/pandatool/src/mayaprogs/normal_test.cxx index e1015f2759..ca1b4638eb 100644 --- a/pandatool/src/mayaprogs/normal_test.cxx +++ b/pandatool/src/mayaprogs/normal_test.cxx @@ -179,7 +179,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { exit(1); } - ofstream file(filename, ios::out | ios::trunc); + std::ofstream file(filename, std::ios::out | std::ios::trunc); if (!file) { cerr << "Couldn't open " << filename << " for output.\n"; exit(1); diff --git a/pandatool/src/miscprogs/binToC.cxx b/pandatool/src/miscprogs/binToC.cxx index 8d1ee2dec8..44eddfb1ac 100644 --- a/pandatool/src/miscprogs/binToC.cxx +++ b/pandatool/src/miscprogs/binToC.cxx @@ -38,7 +38,7 @@ BinToC() : add_option ("n", "name", 0, "Specify the name of the table that is generated.", - &BinToC::dispatch_string, NULL, &_table_name); + &BinToC::dispatch_string, nullptr, &_table_name); add_option ("static", "", 0, @@ -66,13 +66,13 @@ BinToC() : */ void BinToC:: run() { - ifstream in; + std::ifstream in; if (!_input_filename.open_read(in)) { nout << "Unable to read " << _input_filename << ".\n"; exit(1); } - ostream &out = get_output(); + std::ostream &out = get_output(); string static_keyword; if (_static_table) { static_keyword = "static "; diff --git a/pandatool/src/objegg/eggToObjConverter.cxx b/pandatool/src/objegg/eggToObjConverter.cxx index bd359e935a..96505e7f35 100644 --- a/pandatool/src/objegg/eggToObjConverter.cxx +++ b/pandatool/src/objegg/eggToObjConverter.cxx @@ -110,14 +110,14 @@ process(const Filename &filename) { Filename obj_filename = Filename::text_filename(filename); vfs->delete_file(obj_filename); ostream *file = vfs->open_write_file(obj_filename, true, true); - if (file == (ostream *)NULL) { + if (file == nullptr) { return false; } if (egg_precision != 0) { file->precision(egg_precision); } - _current_group = NULL; + _current_group = nullptr; /* (*file) << "\n#\n" @@ -134,7 +134,7 @@ process(const Filename &filename) { write_faces(*file, _egg_data); - bool success = (file != (ostream *)NULL); + bool success = (file != nullptr); vfs->close_write_file(file); return success; @@ -171,7 +171,7 @@ collect_vertices(EggNode *egg_node) { void EggToObjConverter:: write_faces(ostream &out, EggNode *egg_node) { if (egg_node->is_of_type(EggPrimitive::get_class_type())) { - const char *prim_type = NULL; + const char *prim_type = nullptr; if (egg_node->is_of_type(EggPolygon::get_class_type())) { prim_type = "f"; } else if (egg_node->is_of_type(EggPoint::get_class_type())) { @@ -180,7 +180,7 @@ write_faces(ostream &out, EggNode *egg_node) { prim_type = "l"; } - if (prim_type != NULL) { + if (prim_type != nullptr) { write_group_reference(out, egg_node); EggPrimitive *egg_prim = DCAST(EggPrimitive, egg_node); @@ -280,7 +280,7 @@ get_group_name(string &group_name, EggGroupNode *egg_group) { // Now recurse. EggGroupNode *egg_parent = egg_group->get_parent(); - if (egg_parent != NULL) { + if (egg_parent != nullptr) { get_group_name(group_name, egg_parent); } } @@ -379,7 +379,7 @@ write_vertices(ostream &out, const string &prefix, int num_components, int index = (*ui).second; const LVecBase4d &vec = (*ui).first; nassertv(index >= 0 && index < num_vertices); - nassertv(vertices[index] == NULL); + nassertv(vertices[index] == nullptr); vertices[index] = &vec; } diff --git a/pandatool/src/objegg/eggToObjConverter.h b/pandatool/src/objegg/eggToObjConverter.h index a36fa77500..df54648a72 100644 --- a/pandatool/src/objegg/eggToObjConverter.h +++ b/pandatool/src/objegg/eggToObjConverter.h @@ -67,8 +67,6 @@ private: const UniqueVertices &unique); private: - bool _triangulate_polygons; - UniqueVertices _unique_vert3, _unique_vert4, _unique_uv2, _unique_uv3, _unique_norm; VertexMap _vmap; EggGroupNode *_current_group; diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index c6df68710c..05af8ce1a2 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -135,7 +135,7 @@ convert_to_node(const LoaderOptions &options, const Filename &filename) { delete _current_vertex_data; if (had_error()) { - return NULL; + return nullptr; } return _root_node; @@ -148,7 +148,7 @@ bool ObjToEggConverter:: process(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *strm = vfs->open_read_file(filename, true); - if (strm == NULL) { + if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; return false; @@ -270,7 +270,6 @@ process_ref_plane_res(const string &line) { } bool okflag = true; - LPoint3d pos; okflag &= string_to_double(words[1], _ref_plane_res[0]); okflag &= string_to_double(words[2], _ref_plane_res[1]); @@ -449,7 +448,7 @@ process_f(vector_string &words) { PT(EggPolygon) poly = new EggPolygon; for (size_t i = 1; i < words.size(); ++i) { EggVertex *vertex = get_face_vertex(words[i]); - if (vertex == NULL) { + if (vertex == nullptr) { return false; } poly->add_vertex(vertex); @@ -475,7 +474,7 @@ process_g(vector_string &words) { while (i > 1) { --i; EggNode *child = group->find_child(words[i]); - if (child == NULL || !child->is_of_type(EggGroup::get_class_type())) { + if (child == nullptr || !child->is_of_type(EggGroup::get_class_type())) { child = new EggGroup(words[i]); group->add_child(child); } @@ -554,7 +553,7 @@ bool ObjToEggConverter:: process_node(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *strm = vfs->open_read_file(filename, true); - if (strm == NULL) { + if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; return false; @@ -735,7 +734,7 @@ bool ObjToEggConverter:: process_g_node(vector_string &words) { _current_vertex_data->close_geom(this); delete _current_vertex_data; - _current_vertex_data = NULL; + _current_vertex_data = nullptr; NodePath np(_root_node); @@ -879,7 +878,7 @@ ObjToEggConverter::VertexData:: VertexData(PandaNode *parent, const string &name) : _parent(parent), _name(name) { - _geom_node = NULL; + _geom_node = nullptr; _v4_given = false; _vt3_given = false; @@ -1091,7 +1090,7 @@ close_geom(const ObjToEggConverter *converter) { PT(Geom) geom = new Geom(vdata); geom->add_primitive(_prim); - if (_geom_node == NULL) { + if (_geom_node == nullptr) { _geom_node = new GeomNode(_name); _parent->add_child(_geom_node); } diff --git a/pandatool/src/palettizer/destTextureImage.cxx b/pandatool/src/palettizer/destTextureImage.cxx index 757772912e..b1b3c1853b 100644 --- a/pandatool/src/palettizer/destTextureImage.cxx +++ b/pandatool/src/palettizer/destTextureImage.cxx @@ -98,7 +98,7 @@ copy_if_stale(const DestTextureImage *other, TextureImage *texture) { // Also check the timestamps. SourceTextureImage *source = texture->get_preferred_source(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->get_filename().compare_timestamps(get_filename()) > 0) { copy(texture); } diff --git a/pandatool/src/palettizer/eggFile.cxx b/pandatool/src/palettizer/eggFile.cxx index 86e7bb1a6e..1b9e20e9e8 100644 --- a/pandatool/src/palettizer/eggFile.cxx +++ b/pandatool/src/palettizer/eggFile.cxx @@ -41,9 +41,9 @@ TypeHandle EggFile::_type_handle; */ EggFile:: EggFile() { - _data = (EggData *)NULL; + _data = nullptr; _first_txa_match = false; - _default_group = (PaletteGroup *)NULL; + _default_group = nullptr; _is_surprise = true; _is_stale = true; _had_data = false; @@ -100,7 +100,7 @@ get_source_filename() const { */ void EggFile:: scan_textures() { - nassertv(_data != (EggData *)NULL); + nassertv(_data != nullptr); // Extract the set of textures referenced by this egg file. EggTextureCollection tc; @@ -338,7 +338,7 @@ build_cross_links() { for (ti = _textures.begin(); ti != _textures.end(); ++ti) { TextureReference *reference = (*ti); TextureImage *texture = reference->get_texture(); - nassertv(texture != (TextureImage *)NULL); + nassertv(texture != nullptr); texture->note_egg_file(this); // Actually, this may count the same egg file multiple times for a @@ -384,7 +384,7 @@ choose_placements() { TextureReference *reference = (*ti); TextureImage *texture = reference->get_texture(); - if (reference->get_placement() != (TexturePlacement *)NULL && + if (reference->get_placement() != nullptr && texture->get_groups().count(reference->get_placement()->get_group()) != 0) { // The egg file is already using a TexturePlacement that is suitable. // Don't bother changing it. @@ -413,7 +413,7 @@ choose_placements() { // Now get the TexturePlacement object that corresponds to the // placement of this texture into this group. TexturePlacement *placement = texture->get_placement(group); - nassertv(placement != (TexturePlacement *)NULL); + nassertv(placement != nullptr); reference->set_placement(placement); } @@ -427,7 +427,7 @@ choose_placements() { */ bool EggFile:: has_data() const { - return (_data != (EggData *)NULL); + return (_data != nullptr); } /** @@ -445,7 +445,7 @@ had_data() const { */ void EggFile:: update_egg() { - nassertv(_data != (EggData *)NULL); + nassertv(_data != nullptr); Textures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { @@ -478,7 +478,7 @@ remove_egg() { */ bool EggFile:: read_egg(bool noabs) { - nassertr(_data == (EggData *)NULL, false); + nassertr(_data == nullptr, false); nassertr(!_source_filename.empty(), false); Filename user_source_filename = @@ -551,8 +551,8 @@ read_egg(bool noabs) { */ void EggFile:: release_egg_data() { - if (_data != (EggData *)NULL) { - _data = NULL; + if (_data != nullptr) { + _data = nullptr; } Textures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { @@ -567,7 +567,7 @@ release_egg_data() { */ bool EggFile:: write_egg() { - nassertr(_data != (EggData *)NULL, false); + nassertr(_data != nullptr, false); nassertr(!_dest_filename.empty(), false); _dest_filename.make_dir(); @@ -591,7 +591,7 @@ void EggFile:: write_description(ostream &out, int indent_level) const { indent(out, indent_level) << get_name() << ": "; if (_explicitly_assigned_groups.empty()) { - if (_default_group != (PaletteGroup *)NULL) { + if (_default_group != nullptr) { out << _default_group->get_name(); } } else { @@ -654,7 +654,7 @@ remove_backstage(EggGroupNode *node) { */ void EggFile:: rescan_textures() { - nassertv(_data != (EggData *)NULL); + nassertv(_data != nullptr); // Extract the set of textures referenced by this egg file. EggTextureCollection tc; @@ -751,7 +751,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { pi += _explicitly_assigned_groups.complete_pointers(p_list + pi, manager); - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_default_group, p_list[pi], pi); } pi++; diff --git a/pandatool/src/palettizer/eggFile.h b/pandatool/src/palettizer/eggFile.h index 39f3b577df..696ec833e6 100644 --- a/pandatool/src/palettizer/eggFile.h +++ b/pandatool/src/palettizer/eggFile.h @@ -90,7 +90,6 @@ private: typedef pvector Textures; Textures _textures; - bool _noabs; bool _first_txa_match; PaletteGroups _explicitly_assigned_groups; PaletteGroup *_default_group; diff --git a/pandatool/src/palettizer/imageFile.cxx b/pandatool/src/palettizer/imageFile.cxx index 54071d4cb1..eb2409aab6 100644 --- a/pandatool/src/palettizer/imageFile.cxx +++ b/pandatool/src/palettizer/imageFile.cxx @@ -160,7 +160,7 @@ set_filename(PaletteGroup *group, const string &basename) { break; case 'g': - if (group != (PaletteGroup *)NULL) { + if (group != nullptr) { dirname += group->get_dirname(); } break; @@ -199,12 +199,12 @@ set_filename(const string &dirname, const string &basename) { // be truncated at that dot. It is therefore important that the supplied // basename always contains either an extension or a terminating dot. - if (_properties._color_type != (PNMFileType *)NULL) { + if (_properties._color_type != nullptr) { _filename.set_extension (_properties._color_type->get_suggested_extension()); } - if (_properties._alpha_type != (PNMFileType *)NULL) { + if (_properties._alpha_type != nullptr) { _alpha_filename = _filename.get_fullpath_wo_extension() + "_a."; _alpha_filename.set_extension (_properties._alpha_type->get_suggested_extension()); @@ -255,7 +255,7 @@ exists() const { if (!_filename.exists()) { return false; } - if (_properties._alpha_type != (PNMFileType *)NULL && + if (_properties._alpha_type != nullptr && _properties.uses_alpha() && !_alpha_filename.empty()) { if (!_alpha_filename.exists()) { @@ -338,7 +338,7 @@ write(const PNMImage &image) const { nassertr(!_filename.empty(), false); if (!image.has_alpha() || - _properties._alpha_type == (PNMFileType *)NULL) { + _properties._alpha_type == nullptr) { if (!_alpha_filename.empty() && _alpha_filename.exists()) { nout << "Deleting " << FilenameUnifier::make_user_filename(_alpha_filename) << "\n"; _alpha_filename.unlink(); @@ -399,7 +399,7 @@ unlink() { */ void ImageFile:: update_egg_tex(EggTexture *egg_tex) const { - nassertv(egg_tex != (EggTexture *)NULL); + nassertv(egg_tex != nullptr); egg_tex->set_filename(FilenameUnifier::make_egg_filename(_filename)); diff --git a/pandatool/src/palettizer/pal_string_utils.cxx b/pandatool/src/palettizer/pal_string_utils.cxx index 4fd04bbe3f..be747e4106 100644 --- a/pandatool/src/palettizer/pal_string_utils.cxx +++ b/pandatool/src/palettizer/pal_string_utils.cxx @@ -51,8 +51,8 @@ bool parse_image_type_request(const string &word, PNMFileType *&color_type, PNMFileType *&alpha_type) { PNMFileTypeRegistry *registry = PNMFileTypeRegistry::get_global_ptr(); - color_type = (PNMFileType *)NULL; - alpha_type = (PNMFileType *)NULL; + color_type = nullptr; + alpha_type = nullptr; string color_name = word; string alpha_name; @@ -66,7 +66,7 @@ parse_image_type_request(const string &word, PNMFileType *&color_type, if (!color_name.empty()) { color_type = registry->get_type_from_extension(color_name); - if (color_type == (PNMFileType *)NULL) { + if (color_type == nullptr) { nout << "Image file type '" << color_name << "' is unknown.\n"; return false; } @@ -74,7 +74,7 @@ parse_image_type_request(const string &word, PNMFileType *&color_type, if (!alpha_name.empty()) { alpha_type = registry->get_type_from_extension(alpha_name); - if (alpha_type == (PNMFileType *)NULL) { + if (alpha_type == nullptr) { nout << "Image file type '" << alpha_name << "' is unknown.\n"; return false; } diff --git a/pandatool/src/palettizer/paletteImage.cxx b/pandatool/src/palettizer/paletteImage.cxx index 9b664a159d..ee2ae01856 100644 --- a/pandatool/src/palettizer/paletteImage.cxx +++ b/pandatool/src/palettizer/paletteImage.cxx @@ -130,7 +130,7 @@ fillin(DatagramIterator &scan) { */ PaletteImage:: PaletteImage() { - _page = (PalettePage *)NULL; + _page = nullptr; _index = 0; _new_image = false; _got_image = false; @@ -247,7 +247,7 @@ count_coverage() const { for (pi = _placements.begin(); pi != _placements.end(); ++pi) { TexturePlacement *placement = (*pi); TextureImage *texture = placement->get_texture(); - nassertr(texture != (TextureImage *)NULL, 0.0); + nassertr(texture != nullptr, 0.0); int orig_pixels = texture->get_x_size() * @@ -564,7 +564,7 @@ update_image(bool redo_all) { if (texture->is_texture_named()) { SourceTextureImage *source = texture->get_preferred_source(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->get_filename().compare_timestamps(get_filename()) > 0) { // The source image is newer than the palette image; we need to // regenerate. @@ -581,7 +581,7 @@ update_image(bool redo_all) { if (swapTexture->is_texture_named()) { SourceTextureImage *sourceSwapTexture = swapTexture->get_preferred_source(); - if (sourceSwapTexture != (SourceTextureImage *)NULL && + if (sourceSwapTexture != nullptr && sourceSwapTexture->get_filename().compare_timestamps(get_filename()) > 0) { // The source image is newer than the palette image; we need to // regenerate. @@ -636,7 +636,7 @@ update_image(bool redo_all) { write(_image); - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { _shadow_image.write(_image); } @@ -647,7 +647,7 @@ update_image(bool redo_all) { for (si = _swappedImages.begin(); si != _swappedImages.end(); ++si) { PaletteImage *swappedImage = (*si); swappedImage->write(swappedImage->_image); - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { swappedImage->_shadow_image.write(swappedImage->_image); } swappedImage->release_image(); @@ -794,7 +794,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { // Consider the spot at x, y. TexturePlacement *overlap = find_overlap(x, y, x_size, y_size); - if (overlap == (TexturePlacement *)NULL) { + if (overlap == nullptr) { // Hooray! return true; } @@ -831,7 +831,7 @@ find_overlap(int x, int y, int x_size, int y_size) const { } } - return (TexturePlacement *)NULL; + return nullptr; } /** @@ -845,7 +845,7 @@ get_image() { } if (!_new_image) { - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { if (_shadow_image.get_filename().exists() && _shadow_image.read(_image)) { _got_image = true; return; @@ -891,7 +891,7 @@ get_swapped_image(int index) { } if (!_new_image) { - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { if (_shadow_image.get_filename().exists() && _shadow_image.read(_image)) { _got_image = true; return; @@ -959,7 +959,7 @@ release_image() { void PaletteImage:: remove_image() { unlink(); - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { _shadow_image.unlink(); } _new_image = true; @@ -1025,7 +1025,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { index++; } - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_page, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/palettePage.cxx b/pandatool/src/palettizer/palettePage.cxx index 8c04405927..adc73c660f 100644 --- a/pandatool/src/palettizer/palettePage.cxx +++ b/pandatool/src/palettizer/palettePage.cxx @@ -32,7 +32,7 @@ TypeHandle PalettePage::_type_handle; */ PalettePage:: PalettePage() { - _group = (PaletteGroup *)NULL; + _group = nullptr; } /** @@ -248,7 +248,7 @@ int PalettePage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_group, p_list[pi], pi); } pi++; diff --git a/pandatool/src/palettizer/palettizer.cxx b/pandatool/src/palettizer/palettizer.cxx index 633647cb75..3244fd396a 100644 --- a/pandatool/src/palettizer/palettizer.cxx +++ b/pandatool/src/palettizer/palettizer.cxx @@ -29,7 +29,7 @@ #include "bamWriter.h" #include "indent.h" -Palettizer *pal = (Palettizer *)NULL; +Palettizer *pal = nullptr; // This number is written out as the first number to the pi file, to indicate // the version of egg-palettize that wrote it out. This allows us to easily @@ -116,9 +116,9 @@ Palettizer() { _aggressively_clean_mapdir = true; _force_power_2 = true; _color_type = PNMFileTypeRegistry::get_global_ptr()->get_type_from_extension("png"); - _alpha_type = (PNMFileType *)NULL; - _shadow_color_type = (PNMFileType *)NULL; - _shadow_alpha_type = (PNMFileType *)NULL; + _alpha_type = nullptr; + _shadow_color_type = nullptr; + _shadow_alpha_type = nullptr; _pal_x_size = _pal_y_size = 512; _background.set(0.0, 0.0, 0.0, 0.0); _cutout_mode = EggRenderMode::AM_dual; @@ -203,19 +203,19 @@ report_pi() const { << " remap UV's for characters: " << _remap_char_uv << "\n"; cout << " alpha cutouts: " << _cutout_mode << " " << _cutout_ratio << "\n"; - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { cout << " generate image files of type: " << _color_type->get_suggested_extension(); - if (_alpha_type != (PNMFileType *)NULL) { + if (_alpha_type != nullptr) { cout << "," << _alpha_type->get_suggested_extension(); } cout << "\n"; } - if (_shadow_color_type != (PNMFileType *)NULL) { + if (_shadow_color_type != nullptr) { cout << " generate shadow palette files of type: " << _shadow_color_type->get_suggested_extension(); - if (_shadow_alpha_type != (PNMFileType *)NULL) { + if (_shadow_alpha_type != nullptr) { cout << "," << _shadow_alpha_type->get_suggested_extension(); } cout << "\n"; @@ -358,14 +358,14 @@ read_txa_file(istream &txa_file, const string &txa_filename) { } // Also reset _shadow_color_type. - _shadow_color_type = (PNMFileType *)NULL; - _shadow_alpha_type = (PNMFileType *)NULL; + _shadow_color_type = nullptr; + _shadow_alpha_type = nullptr; if (!_txa_file.read(txa_file, txa_filename)) { exit(1); } - if (_color_type == (PNMFileType *)NULL) { + if (_color_type == nullptr) { nout << "No valid output image file type available; cannot run.\n" << "Use :imagetype command in .txa file.\n"; exit(1); @@ -810,7 +810,7 @@ test_palette_group(const string &name) const { return (*gi).second; } - return (PaletteGroup *)NULL; + return nullptr; } /** @@ -981,22 +981,22 @@ int Palettizer:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_color_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_alpha_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_shadow_color_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_shadow_alpha_type, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/sourceTextureImage.cxx b/pandatool/src/palettizer/sourceTextureImage.cxx index df1afec310..aea0046ad1 100644 --- a/pandatool/src/palettizer/sourceTextureImage.cxx +++ b/pandatool/src/palettizer/sourceTextureImage.cxx @@ -28,7 +28,7 @@ TypeHandle SourceTextureImage::_type_handle; */ SourceTextureImage:: SourceTextureImage() { - _texture = (TextureImage *)NULL; + _texture = nullptr; _egg_count = 0; _read_header = false; diff --git a/pandatool/src/palettizer/textureImage.cxx b/pandatool/src/palettizer/textureImage.cxx index 54e213ed24..f33d01c408 100644 --- a/pandatool/src/palettizer/textureImage.cxx +++ b/pandatool/src/palettizer/textureImage.cxx @@ -38,7 +38,7 @@ TypeHandle TextureImage::_type_handle; */ TextureImage:: TextureImage() { - _preferred_source = (SourceTextureImage *)NULL; + _preferred_source = nullptr; _read_source_image = false; _allow_release_source_image = true; _is_surprise = true; @@ -90,7 +90,7 @@ assign_groups() { if (_explicitly_assigned_groups.empty()) { // If we have no explicit group assignments, we must consider all the egg // files. - copy(_egg_files.begin(), _egg_files.end(), back_inserter(needed_eggs)); + std::copy(_egg_files.begin(), _egg_files.end(), std::back_inserter(needed_eggs)); } else { // Otherwise, we only need to consider the egg files that don't have any @@ -203,7 +203,7 @@ get_placement(PaletteGroup *group) const { Placement::const_iterator pi; pi = _placement.find(group); if (pi == _placement.end()) { - return (TexturePlacement *)NULL; + return nullptr; } return (*pi).second; @@ -267,7 +267,7 @@ pre_txa_file() { // Get our properties from the actual image for this texture. It's possible // the .txa file will update them further. SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { _properties = source->get_properties(); } @@ -289,7 +289,7 @@ post_txa_file() { // First, get the actual size of the texture. SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { if (source->get_size()) { _size_known = true; _x_size = source->get_x_size(); @@ -358,7 +358,7 @@ post_txa_file() { _properties._anisotropic_degree = _request._anisotropic_degree; - if (_properties._color_type == (PNMFileType *)NULL) { + if (_properties._color_type == nullptr) { _properties._color_type = _request._properties._color_type; _properties._alpha_type = _request._properties._alpha_type; } @@ -530,7 +530,7 @@ get_source(const Filename &filename, const Filename &alpha_filename, // Clear out the preferred source image to force us to rederive this next // time someone asks. - _preferred_source = (SourceTextureImage *)NULL; + _preferred_source = nullptr; _read_source_image = false; return source; @@ -543,7 +543,7 @@ get_source(const Filename &filename, const Filename &alpha_filename, */ SourceTextureImage *TextureImage:: get_preferred_source() { - if (_preferred_source != (SourceTextureImage *)NULL) { + if (_preferred_source != nullptr) { return _preferred_source; } @@ -569,7 +569,7 @@ get_preferred_source() { } } - SourceTextureImage *best = (SourceTextureImage *)NULL; + SourceTextureImage *best = nullptr; int best_size = 0; for (si = _sources.begin(); si != _sources.end(); ++si) { @@ -580,7 +580,7 @@ get_preferred_source() { if (source->exists() && source->get_size()) { int source_size = source->get_x_size() * source->get_y_size(); - if (best == (SourceTextureImage *)NULL) { + if (best == nullptr) { best = source; best_size = source_size; @@ -599,14 +599,14 @@ get_preferred_source() { } } - if (best == (SourceTextureImage *)NULL && !_sources.empty()) { + if (best == nullptr && !_sources.empty()) { // If we didn't pick any that pass, it must be that all of them are // unreadable. In this case, it really doesn't matter which one we pick, // but we should at least pick one that has an egg reference, if any of // them do. if (any_referenced) { for (si = _sources.begin(); - si != _sources.end() && best == (SourceTextureImage *)NULL; + si != _sources.end() && best == nullptr; ++si) { SourceTextureImage *source = (*si).second; if (source->get_egg_count() > 0) { @@ -672,7 +672,7 @@ copy_unplaced(bool redo_all) { placement->set_dest(dest); } else { - placement->set_dest((DestTextureImage *)NULL); + placement->set_dest(nullptr); } } @@ -707,7 +707,7 @@ const PNMImage &TextureImage:: read_source_image() { if (!_read_source_image) { SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { source->read(_source_image); } _read_source_image = true; @@ -752,7 +752,7 @@ void TextureImage:: read_header() { if (!_read_source_image) { SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { source->read_header(); } } @@ -766,7 +766,7 @@ bool TextureImage:: is_newer_than(const Filename &reference_filename) { if (!_read_source_image) { SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { const Filename &source_filename = source->get_filename(); return source_filename.compare_timestamps(reference_filename) >= 0; } @@ -874,7 +874,7 @@ write_scale_info(ostream &out, int indent_level) { out << " orig "; - if (source == (SourceTextureImage *)NULL || + if (source == nullptr || !source->is_size_known()) { out << "unknown"; } else { @@ -886,7 +886,7 @@ write_scale_info(ostream &out, int indent_level) { out << " new " << get_x_size() << " " << get_y_size() << " " << get_num_channels(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->is_size_known()) { double scale = 100.0 * (((double)get_x_size() / (double)source->get_x_size()) + @@ -902,7 +902,7 @@ write_scale_info(ostream &out, int indent_level) { TexturePlacement *placement = (*pi).second; if (placement->get_omit_reason() == OR_none) { PaletteImage *image = placement->get_image(); - nassertv(image != (PaletteImage *)NULL); + nassertv(image != nullptr); indent(out, indent_level + 2) << "placed on " << FilenameUnifier::make_user_filename(image->get_filename()) @@ -914,7 +914,7 @@ write_scale_info(ostream &out, int indent_level) { } else { DestTextureImage *image = placement->get_dest(); - nassertv(image != (DestTextureImage *)NULL); + nassertv(image != nullptr); indent(out, indent_level + 2) << "copied to " << FilenameUnifier::make_user_filename(image->get_filename()); @@ -923,7 +923,7 @@ write_scale_info(ostream &out, int indent_level) { image->get_y_size() != get_y_size())) { out << " at size " << image->get_x_size() << " " << image->get_y_size(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->is_size_known()) { double scale = 100.0 * (((double)image->get_x_size() / (double)source->get_x_size()) + diff --git a/pandatool/src/palettizer/textureMemoryCounter.cxx b/pandatool/src/palettizer/textureMemoryCounter.cxx index 176461c832..3c3f78b571 100644 --- a/pandatool/src/palettizer/textureMemoryCounter.cxx +++ b/pandatool/src/palettizer/textureMemoryCounter.cxx @@ -53,11 +53,11 @@ reset() { void TextureMemoryCounter:: add_placement(TexturePlacement *placement) { TextureImage *texture = placement->get_texture(); - nassertv(texture != (TextureImage *)NULL); + nassertv(texture != nullptr); if (placement->get_omit_reason() == OR_none) { PaletteImage *image = placement->get_image(); - nassertv(image != (PaletteImage *)NULL); + nassertv(image != nullptr); add_palette(image); int bytes = count_bytes(image, placement->get_placed_x_size(), @@ -67,7 +67,7 @@ add_placement(TexturePlacement *placement) { } else { DestTextureImage *dest = placement->get_dest(); - if (dest != (DestTextureImage *)NULL) { + if (dest != nullptr) { int bytes = count_bytes(dest); add_texture(texture, bytes); diff --git a/pandatool/src/palettizer/texturePlacement.cxx b/pandatool/src/palettizer/texturePlacement.cxx index 2cbea3019c..36331ed233 100644 --- a/pandatool/src/palettizer/texturePlacement.cxx +++ b/pandatool/src/palettizer/texturePlacement.cxx @@ -34,10 +34,10 @@ TypeHandle TexturePlacement::_type_handle; */ TexturePlacement:: TexturePlacement() { - _texture = (TextureImage *)NULL; - _group = (PaletteGroup *)NULL; - _image = (PaletteImage *)NULL; - _dest = (DestTextureImage *)NULL; + _texture = nullptr; + _group = nullptr; + _image = nullptr; + _dest = nullptr; _has_uvs = false; _size_known = false; _is_filled = true; @@ -60,8 +60,8 @@ TexturePlacement(TextureImage *texture, PaletteGroup *group) : _omit_reason = OR_unknown; } - _image = (PaletteImage *)NULL; - _dest = (DestTextureImage *)NULL; + _image = nullptr; + _dest = nullptr; _has_uvs = false; _size_known = false; _is_filled = false; @@ -443,7 +443,7 @@ get_uv_area() const { */ bool TexturePlacement:: is_placed() const { - return _image != (PaletteImage *)NULL; + return _image != nullptr; } /** @@ -451,7 +451,7 @@ is_placed() const { */ PaletteImage *TexturePlacement:: get_image() const { - nassertr(is_placed(), (PaletteImage *)NULL); + nassertr(is_placed(), nullptr); return _image; } @@ -460,7 +460,7 @@ get_image() const { */ PalettePage *TexturePlacement:: get_page() const { - nassertr(is_placed(), (PalettePage *)NULL); + nassertr(is_placed(), nullptr); return _image->get_page(); } @@ -540,9 +540,9 @@ place_at(PaletteImage *image, int x, int y) { */ void TexturePlacement:: force_replace() { - if (_image != (PaletteImage *)NULL) { + if (_image != nullptr) { _image->unplace(this); - _image = (PaletteImage *)NULL; + _image = nullptr; } if (_omit_reason == OR_none) { mark_eggs_stale(); @@ -1031,22 +1031,22 @@ int TexturePlacement:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_texture, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_group, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_image, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_dest, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/texturePlacement.h b/pandatool/src/palettizer/texturePlacement.h index be4d667a24..ca69f93ea0 100644 --- a/pandatool/src/palettizer/texturePlacement.h +++ b/pandatool/src/palettizer/texturePlacement.h @@ -127,7 +127,6 @@ private: // This value is only filled in while reading from the bam file; don't use // it otherwise. int _num_references; - int _margin_override; int _num_textureSwaps; public: diff --git a/pandatool/src/palettizer/textureProperties.cxx b/pandatool/src/palettizer/textureProperties.cxx index c8db745fc8..9538b85165 100644 --- a/pandatool/src/palettizer/textureProperties.cxx +++ b/pandatool/src/palettizer/textureProperties.cxx @@ -38,8 +38,8 @@ TextureProperties() { _magfilter = EggTexture::FT_unspecified; _quality_level = EggTexture::QL_unspecified; _anisotropic_degree = 0; - _color_type = (PNMFileType *)NULL; - _alpha_type = (PNMFileType *)NULL; + _color_type = nullptr; + _alpha_type = nullptr; } /** @@ -222,7 +222,7 @@ update_properties(const TextureProperties &other) { _anisotropic_degree = other._anisotropic_degree; - if (_color_type == (PNMFileType *)NULL) { + if (_color_type == nullptr) { _color_type = other._color_type; _alpha_type = other._alpha_type; } @@ -445,7 +445,7 @@ fully_define() { break; } - if (_color_type == (PNMFileType *)NULL) { + if (_color_type == nullptr) { _color_type = pal->_color_type; _alpha_type = pal->_alpha_type; } @@ -501,7 +501,7 @@ operator < (const TextureProperties &other) const { if (_color_type != other._color_type) { return _color_type < other._color_type; } - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { if (_alpha_type != other._alpha_type) { return _alpha_type < other._alpha_type; } @@ -520,7 +520,7 @@ operator == (const TextureProperties &other) const { _quality_level == other._quality_level && _anisotropic_degree == other._anisotropic_degree && _color_type == other._color_type && - (_color_type == (PNMFileType *)NULL || + (_color_type == nullptr || _alpha_type == other._alpha_type)); } @@ -670,10 +670,10 @@ get_quality_level_string(EggTexture::QualityLevel quality_level) { */ string TextureProperties:: get_type_string(PNMFileType *color_type, PNMFileType *alpha_type) { - if (color_type == (PNMFileType *)NULL) { + if (color_type == nullptr) { return ""; } - if (alpha_type == (PNMFileType *)NULL) { + if (alpha_type == nullptr) { return "c"; } return "a"; @@ -781,12 +781,12 @@ int TextureProperties:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_color_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_alpha_type, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/textureReference.cxx b/pandatool/src/palettizer/textureReference.cxx index da6a2b626f..7bb869c336 100644 --- a/pandatool/src/palettizer/textureReference.cxx +++ b/pandatool/src/palettizer/textureReference.cxx @@ -42,12 +42,12 @@ TypeHandle TextureReference::_type_handle; */ TextureReference:: TextureReference() { - _egg_file = (EggFile *)NULL; - _egg_tex = (EggTexture *)NULL; + _egg_file = nullptr; + _egg_tex = nullptr; _tex_mat = LMatrix3d::ident_mat(); _inv_tex_mat = LMatrix3d::ident_mat(); - _source_texture = (SourceTextureImage *)NULL; - _placement = (TexturePlacement *)NULL; + _source_texture = nullptr; + _placement = nullptr; _uses_alpha = false; _any_uvs = false; _min_uv.set(0.0, 0.0); @@ -155,8 +155,8 @@ from_egg_quick(const TextureReference &other) { */ void TextureReference:: release_egg_data() { - _egg_tex = NULL; - _egg_data = NULL; + _egg_tex = nullptr; + _egg_data = nullptr; } /** @@ -192,7 +192,7 @@ get_source() const { */ TextureImage *TextureReference:: get_texture() const { - nassertr(_source_texture != (SourceTextureImage *)NULL, (TextureImage *)NULL); + nassertr(_source_texture != nullptr, nullptr); return _source_texture->get_texture(); } @@ -303,12 +303,12 @@ is_equivalent(const TextureReference &other) const { void TextureReference:: set_placement(TexturePlacement *placement) { if (_placement != placement) { - if (_placement != (TexturePlacement *)NULL) { + if (_placement != nullptr) { // Remove our reference from the old placement object. _placement->remove_egg(this); } _placement = placement; - if (_placement != (TexturePlacement *)NULL) { + if (_placement != nullptr) { // Add our reference to the new placement object. _placement->add_egg(this); } @@ -320,7 +320,7 @@ set_placement(TexturePlacement *placement) { */ void TextureReference:: clear_placement() { - set_placement((TexturePlacement *)NULL); + set_placement(nullptr); } /** @@ -338,7 +338,7 @@ get_placement() const { */ void TextureReference:: mark_egg_stale() { - if (_egg_file != (EggFile *)NULL) { + if (_egg_file != nullptr) { _egg_file->mark_stale(); } } @@ -349,12 +349,12 @@ mark_egg_stale() { */ void TextureReference:: update_egg() { - if (_egg_tex == (EggTexture *)NULL) { + if (_egg_tex == nullptr) { // Not much we can do if we don't have an actual egg file to reference. return; } - if (_placement == (TexturePlacement *)NULL) { + if (_placement == nullptr) { // Nor if we don't have an actual placement yet. This is possible if the // egg was assigned to the "null" group, and the texture hasn't been re- // assigned yet. @@ -362,7 +362,7 @@ update_egg() { } TextureImage *texture = get_texture(); - if (texture != (TextureImage *)NULL) { + if (texture != nullptr) { // Make sure the alpha mode is set according to what the texture image // wants. if (texture->has_num_channels() && @@ -406,7 +406,7 @@ update_egg() { // simply have to update the texture reference to the new texture // location. DestTextureImage *dest = _placement->get_dest(); - nassertv(dest != (DestTextureImage *)NULL); + nassertv(dest != nullptr); dest->update_egg_tex(_egg_tex); return; } @@ -415,7 +415,7 @@ update_egg() { // update the texture reference, but also adjust the UV's. In most cases, // we can do this by simply applying a texture matrix to the reference. PaletteImage *image = _placement->get_image(); - nassertv(image != (PaletteImage *)NULL); + nassertv(image != nullptr); image->update_egg_tex(_egg_tex); @@ -447,7 +447,7 @@ update_egg() { */ void TextureReference:: apply_properties_to_source() { - nassertv(_source_texture != (SourceTextureImage *)NULL); + nassertv(_source_texture != nullptr); _source_texture->update_properties(_properties); } @@ -830,17 +830,17 @@ int TextureReference:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_egg_file, p_list[pi], pi); } pi++; - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_source_texture, p_list[pi], pi); } pi++; - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_placement, p_list[pi], pi); } pi++; diff --git a/pandatool/src/palettizer/txaLine.cxx b/pandatool/src/palettizer/txaLine.cxx index 0d1c655658..51a1532610 100644 --- a/pandatool/src/palettizer/txaLine.cxx +++ b/pandatool/src/palettizer/txaLine.cxx @@ -45,8 +45,8 @@ TxaLine() { _margin = 0; _got_coverage_threshold = false; _coverage_threshold = 0.0; - _color_type = (PNMFileType *)NULL; - _alpha_type = (PNMFileType *)NULL; + _color_type = nullptr; + _alpha_type = nullptr; } /** @@ -259,7 +259,7 @@ parse(const string &line) { } else { // Maybe it's a group name. PaletteGroup *group = pal->test_palette_group(word); - if (group != (PaletteGroup *)NULL) { + if (group != nullptr) { _palette_groups.insert(group); } else { @@ -283,7 +283,7 @@ parse(const string &line) { _quality_level = ql; } else if (word.length() > 2 && word[word.length() - 2] == '_' && - strchr("uv", word[word.length() - 1]) != NULL) { + strchr("uv", word[word.length() - 1]) != nullptr) { // It must be a wrap mode for u or v. string prefix = word.substr(0, word.length() - 2); EggTexture::WrapMode wm = EggTexture::string_wrap_mode(prefix); @@ -408,7 +408,7 @@ match_texture(TextureImage *texture) const { break; case ST_scale: - if (source != (SourceTextureImage *)NULL && source->get_size()) { + if (source != nullptr && source->get_size()) { request._got_size = true; request._x_size = max(1, (int)(source->get_x_size() * _scale / 100.0)); request._y_size = max(1, (int)(source->get_y_size() * _scale / 100.0)); @@ -436,7 +436,7 @@ match_texture(TextureImage *texture) const { request._coverage_threshold = _coverage_threshold; } - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { request._properties._color_type = _color_type; request._properties._alpha_type = _alpha_type; } @@ -599,9 +599,9 @@ output(ostream &out) const { } } - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { out << " " << _color_type->get_suggested_extension(); - if (_alpha_type != (PNMFileType *)NULL) { + if (_alpha_type != nullptr) { out << "," << _alpha_type->get_suggested_extension(); } } diff --git a/pandatool/src/pfmprogs/pfmBba.cxx b/pandatool/src/pfmprogs/pfmBba.cxx index 5456efad27..30804d8fea 100644 --- a/pandatool/src/pfmprogs/pfmBba.cxx +++ b/pandatool/src/pfmprogs/pfmBba.cxx @@ -73,7 +73,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { if (!bba_filename.empty()) { bba_filename.set_text(); PT(BoundingHexahedron) bounds = file.compute_planar_bounds(LPoint2f(0.5, 0.5), pfm_bba_dist[0], pfm_bba_dist[1], false); - nassertr(bounds != (BoundingHexahedron *)NULL, false); + nassertr(bounds != nullptr, false); pofstream out; if (!bba_filename.open_write(out)) { diff --git a/pandatool/src/pfmprogs/pfmBba.h b/pandatool/src/pfmprogs/pfmBba.h index 518f5568d2..4d01ca647d 100644 --- a/pandatool/src/pfmprogs/pfmBba.h +++ b/pandatool/src/pfmprogs/pfmBba.h @@ -43,7 +43,6 @@ private: bool _got_zero_special; bool _got_output_filename; Filename _output_filename; - int _reorder_index; }; #endif diff --git a/pandatool/src/pfmprogs/pfmTrans.cxx b/pandatool/src/pfmprogs/pfmTrans.cxx index 123b098768..fdf803b601 100644 --- a/pandatool/src/pfmprogs/pfmTrans.cxx +++ b/pandatool/src/pfmprogs/pfmTrans.cxx @@ -72,7 +72,7 @@ PfmTrans() { ("rotate", "degrees", 0, "Rotates the pfm file the specified number of degrees counterclockwise, " "which must be a multiple of 90.", - &PfmTrans::dispatch_int, NULL, &_rotate); + &PfmTrans::dispatch_int, nullptr, &_rotate); add_option ("mirror_x", "", 0, @@ -231,7 +231,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { NodePath mesh = vizzer.generate_vis_mesh(PfmVizzer::MF_both); if (_got_vistex_filename) { PT(Texture) tex = TexturePool::load_texture(_vistex_filename); - if (tex == NULL) { + if (tex == nullptr) { nout << "Couldn't find " << _vistex_filename << "\n"; } else { tex->set_minfilter(SamplerState::FT_linear_mipmap_linear); diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index 86a2c17c48..e97a536127 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -57,7 +57,7 @@ operator () (const Option *a, const Option *b) const { // properly flushed before we exit, if someone calls exit(). It's probably // not necessary, but why not be phobic about it? static void flush_nout() { - nout << flush; + nout << std::flush; } static ConfigVariableInt default_terminal_width @@ -101,7 +101,7 @@ ProgramBase(const string &name) : _name(name) { add_option("h", "", 100, "Display this help page.", - &ProgramBase::handle_help_option, NULL, (void *)this); + &ProgramBase::handle_help_option, nullptr, (void *)this); // It's nice to start with a blank line. nout << "\r"; @@ -114,7 +114,7 @@ ProgramBase:: ~ProgramBase() { // Reset Notify in case any messages get sent after our destruction--our // stream is no longer valid. - Notify::ptr()->set_ostream_ptr(NULL, false); + Notify::ptr()->set_ostream_ptr(nullptr, false); } /** @@ -196,11 +196,11 @@ write_man_page(ostream &out) { // Generate a date string for inclusion into the footer. char date_str[256]; date_str[0] = 0; - time_t current_time = time(NULL); + time_t current_time = time(nullptr); if (current_time != (time_t) -1) { tm *today = localtime(¤t_time); - if (today == NULL || 0 == strftime(date_str, 256, "%d %B %Y", today)) { + if (today == nullptr || 0 == strftime(date_str, 256, "%d %B %Y", today)) { date_str[0] = 0; } } @@ -353,7 +353,7 @@ parse_command_line(int argc, char **argv) { gopt.name = (char *)opt._option.c_str(); gopt.has_arg = (opt._parm_name.empty()) ? no_argument : required_argument; - gopt.flag = (int *)NULL; + gopt.flag = nullptr; // Return an index into the _options_by_index array, offset by 256 so we // don't confuse it with '?'. @@ -379,10 +379,10 @@ parse_command_line(int argc, char **argv) { const struct option *long_opts = &long_options[0]; int flag = - getopt_long_only(argc, argv, short_options.c_str(), long_opts, NULL); + getopt_long_only(argc, argv, short_options.c_str(), long_opts, nullptr); while (flag != EOF) { string arg; - if (optarg != NULL) { + if (optarg != nullptr) { arg = optarg; } @@ -410,13 +410,13 @@ parse_command_line(int argc, char **argv) { const Option &opt = *(*ii).second; bool okflag = true; - if (opt._option_function != (OptionDispatchFunction)NULL) { + if (opt._option_function != (OptionDispatchFunction)nullptr) { okflag = (*opt._option_function)(opt._option, arg, opt._option_data); } - if (opt._option_method != (OptionDispatchMethod)NULL) { + if (opt._option_method != (OptionDispatchMethod)nullptr) { okflag = (*opt._option_method)(this, opt._option, arg, opt._option_data); } - if (opt._bool_var != (bool *)NULL) { + if (opt._bool_var != nullptr) { (*opt._bool_var) = true; } @@ -428,7 +428,7 @@ parse_command_line(int argc, char **argv) { } flag = - getopt_long_only(argc, argv, short_options.c_str(), long_opts, NULL); + getopt_long_only(argc, argv, short_options.c_str(), long_opts, nullptr); } if (!handle_args(remaining_args)) { @@ -609,14 +609,14 @@ add_option(const string &option, const string &parm_name, opt._sequence = ++_next_sequence; opt._description = description; opt._option_function = option_function; - opt._option_method = (OptionDispatchMethod)NULL; + opt._option_method = (OptionDispatchMethod)nullptr; opt._bool_var = bool_var; opt._option_data = option_data; _options_by_name[option] = opt; _sorted_options = false; - if (bool_var != (bool *)NULL) { + if (bool_var != nullptr) { (*bool_var) = false; } } @@ -644,7 +644,7 @@ add_option(const string &option, const string &parm_name, opt._index_group = index_group; opt._sequence = ++_next_sequence; opt._description = description; - opt._option_function = (OptionDispatchFunction)NULL; + opt._option_function = (OptionDispatchFunction)nullptr; opt._option_method = option_method; opt._bool_var = bool_var; opt._option_data = option_data; @@ -652,7 +652,7 @@ add_option(const string &option, const string &parm_name, _options_by_name[option] = opt; _sorted_options = false; - if (bool_var != (bool *)NULL) { + if (bool_var != nullptr) { (*bool_var) = false; } } @@ -712,7 +712,7 @@ add_path_replace_options() { "against each specified method, in the order in which they appear in " "the command line, until the file is found. If the file is not found, " "the last matching prefix is used anyway.", - &ProgramBase::dispatch_path_replace, NULL, _path_replace.p()); + &ProgramBase::dispatch_path_replace, nullptr, _path_replace.p()); add_option ("pp", "dirname", 40, @@ -721,7 +721,7 @@ add_path_replace_options() { "only for relative paths, or for paths that are made relative by a " "-pr replacement string that doesn't begin with a leading slash. " "The model-path is always implicitly searched anyway.", - &ProgramBase::dispatch_search_path, NULL, &(_path_replace->_path)); + &ProgramBase::dispatch_search_path, nullptr, &(_path_replace->_path)); } /** @@ -1194,7 +1194,7 @@ dispatch_image_type(const string &opt, const string &arg, void *var) { (*ip) = reg->get_type_from_extension(arg); - if ((*ip) == (PNMFileType *)NULL) { + if ((*ip) == nullptr) { nout << "Invalid image type for -" << opt << ": " << arg << "\n" << "The following image types are known:\n"; reg->write(nout, 2); diff --git a/pandatool/src/progbase/programBase.h b/pandatool/src/progbase/programBase.h index e6b166172c..d5d1e310a0 100644 --- a/pandatool/src/progbase/programBase.h +++ b/pandatool/src/progbase/programBase.h @@ -68,13 +68,13 @@ protected: void add_option(const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchFunction option_function, - bool *bool_var = (bool *)NULL, - void *option_data = (void *)NULL); + bool *bool_var = nullptr, + void *option_data = nullptr); void add_option(const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchMethod option_method, - bool *bool_var = (bool *)NULL, - void *option_data = (void *)NULL); + bool *bool_var = nullptr, + void *option_data = nullptr); bool redescribe_option(const string &option, const string &description); bool remove_option(const string &option); diff --git a/pandatool/src/progbase/test_prog.cxx b/pandatool/src/progbase/test_prog.cxx index 5123385cc5..289b68c8d7 100644 --- a/pandatool/src/progbase/test_prog.cxx +++ b/pandatool/src/progbase/test_prog.cxx @@ -46,13 +46,13 @@ TestProgram() { add_option ("b", "", 90, "Test option b", - &TestProgram::dispatch_count, NULL, &_count_b); + &TestProgram::dispatch_count, nullptr, &_count_b); _count_b = 0; add_option ("c", "integer_parameter", 90, "This is test option 'c'. It takes an integer parameter.", - &TestProgram::dispatch_int, NULL, &_int_c); + &TestProgram::dispatch_int, nullptr, &_int_c); _int_c = 0; } diff --git a/pandatool/src/progbase/withOutputFile.cxx b/pandatool/src/progbase/withOutputFile.cxx index 7ff8ea60d9..b88dec05d8 100644 --- a/pandatool/src/progbase/withOutputFile.cxx +++ b/pandatool/src/progbase/withOutputFile.cxx @@ -27,7 +27,7 @@ WithOutputFile(bool allow_last_param, bool allow_stdout, _allow_stdout = allow_stdout; _binary_output = binary_output; _got_output_filename = false; - _output_ptr = (ostream *)NULL; + _output_ptr = nullptr; _owns_output_ptr = false; } @@ -48,7 +48,7 @@ WithOutputFile:: */ ostream &WithOutputFile:: get_output() { - if (_output_ptr == (ostream *)NULL) { + if (_output_ptr == nullptr) { if (!_got_output_filename) { // No filename given; use standard output. if (!_allow_stdout) { @@ -108,7 +108,7 @@ close_output() { delete _output_ptr; _owns_output_ptr = false; } - _output_ptr = NULL; + _output_ptr = nullptr; _output_stream.close(); } diff --git a/pandatool/src/progbase/withOutputFile.h b/pandatool/src/progbase/withOutputFile.h index d77627ffa7..7c4c0f2af7 100644 --- a/pandatool/src/progbase/withOutputFile.h +++ b/pandatool/src/progbase/withOutputFile.h @@ -52,8 +52,8 @@ protected: Filename _output_filename; private: - ofstream _output_stream; - ostream *_output_ptr; + std::ofstream _output_stream; + std::ostream *_output_ptr; bool _owns_output_ptr; }; diff --git a/pandatool/src/progbase/wordWrapStreamBuf.cxx b/pandatool/src/progbase/wordWrapStreamBuf.cxx index 4280a3d394..f8f4dced30 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.cxx +++ b/pandatool/src/progbase/wordWrapStreamBuf.cxx @@ -17,11 +17,6 @@ #include "pnotify.h" -#ifndef HAVE_STREAMSIZE -// Some compilers--notably SGI--don't define this for us. -typedef int streamsize; -#endif - /** * */ diff --git a/pandatool/src/pstatserver/pStatClientData.cxx b/pandatool/src/pstatserver/pStatClientData.cxx index 4a3520b63f..77136b7f1d 100644 --- a/pandatool/src/pstatserver/pStatClientData.cxx +++ b/pandatool/src/pstatserver/pStatClientData.cxx @@ -55,9 +55,9 @@ is_alive() const { */ void PStatClientData:: close() { - if (_is_alive && _reader != (PStatReader *)NULL) { + if (_is_alive && _reader != nullptr) { _reader->close(); - _reader = (PStatReader *)NULL; + _reader = nullptr; _is_alive = false; } } @@ -78,7 +78,7 @@ get_num_collectors() const { bool PStatClientData:: has_collector(int index) const { return (index >= 0 && index < (int)_collectors.size() && - _collectors[index]._def != (PStatCollectorDef *)NULL); + _collectors[index]._def != nullptr); } /** @@ -144,7 +144,7 @@ set_collector_has_level(int index, int thread_index, bool flag) { // ancestors. if (flag) { PStatCollectorDef *def = _collectors[index]._def; - if (def != (PStatCollectorDef *)NULL && def->_parent_index != 0) { + if (def != nullptr && def->_parent_index != 0) { if (set_collector_has_level(def->_parent_index, thread_index, flag)) { any_changed = true; } @@ -222,7 +222,7 @@ get_thread_name(int index) const { const PStatThreadData *PStatClientData:: get_thread_data(int index) const { ((PStatClientData *)this)->define_thread(index); - nassertr(index >= 0 && index < (int)_threads.size(), NULL); + nassertr(index >= 0 && index < (int)_threads.size(), nullptr); return _threads[index]._data; } @@ -261,7 +261,7 @@ add_collector(PStatCollectorDef *def) { slot_collector(def->_index); nassertv(def->_index >= 0 && def->_index < (int)_collectors.size()); - if (_collectors[def->_index]._def != (PStatCollectorDef *)NULL) { + if (_collectors[def->_index]._def != nullptr) { // Free the old definition, if any. delete _collectors[def->_index]._def; } @@ -330,7 +330,7 @@ slot_collector(int collector_index) { while ((int)_collectors.size() <= collector_index) { Collector collector; - collector._def = (PStatCollectorDef *)NULL; + collector._def = nullptr; _collectors.push_back(collector); } } @@ -345,7 +345,7 @@ update_toplevel_collectors() { Collectors::const_iterator ci; for (ci = _collectors.begin(); ci != _collectors.end(); ++ci) { PStatCollectorDef *def = (*ci)._def; - if (def != (PStatCollectorDef *)NULL && def->_parent_index == 0) { + if (def != nullptr && def->_parent_index == 0) { _toplevel_collectors.push_back(def->_index); } } diff --git a/pandatool/src/pstatserver/pStatListener.cxx b/pandatool/src/pstatserver/pStatListener.cxx index 417ad5495d..73fe3d3b04 100644 --- a/pandatool/src/pstatserver/pStatListener.cxx +++ b/pandatool/src/pstatserver/pStatListener.cxx @@ -34,7 +34,7 @@ connection_opened(const PT(Connection) &, const NetAddress &address, const PT(Connection) &new_connection) { PStatMonitor *monitor = _manager->make_monitor(); - if (monitor == (PStatMonitor *)NULL) { + if (monitor == nullptr) { nout << "Couldn't create monitor!\n"; return; } diff --git a/pandatool/src/pstatserver/pStatReader.cxx b/pandatool/src/pstatserver/pStatReader.cxx index 7dbab59e74..c302185e0f 100644 --- a/pandatool/src/pstatserver/pStatReader.cxx +++ b/pandatool/src/pstatserver/pStatReader.cxx @@ -272,7 +272,7 @@ void PStatReader:: dequeue_frame_data() { while (!_queued_frame_data.empty()) { const FrameData &data = _queued_frame_data.front(); - nassertv(_client_data != (PStatClientData *)NULL); + nassertv(_client_data != nullptr); // Check to see if any new collectors have level data. int num_levels = data._frame_data->get_num_levels(); diff --git a/pandatool/src/pstatserver/pStatServer.cxx b/pandatool/src/pstatserver/pStatServer.cxx index 1e295ee4f9..23a6a62fda 100644 --- a/pandatool/src/pstatserver/pStatServer.cxx +++ b/pandatool/src/pstatserver/pStatServer.cxx @@ -122,7 +122,7 @@ poll() { */ void PStatServer:: main_loop(bool *interrupt_flag) { - while (interrupt_flag == (bool *)NULL || !*interrupt_flag) { + while (interrupt_flag == nullptr || !*interrupt_flag) { poll(); Thread::sleep(0.1); } diff --git a/pandatool/src/pstatserver/pStatServer.h b/pandatool/src/pstatserver/pStatServer.h index dca7ec2008..50128e4069 100644 --- a/pandatool/src/pstatserver/pStatServer.h +++ b/pandatool/src/pstatserver/pStatServer.h @@ -41,7 +41,7 @@ public: bool listen(int port = -1); void poll(); - void main_loop(bool *interrupt_flag = NULL); + void main_loop(bool *interrupt_flag = nullptr); virtual PStatMonitor *make_monitor()=0; void add_reader(Connection *connection, PStatReader *reader); diff --git a/pandatool/src/pstatserver/pStatThreadData.cxx b/pandatool/src/pstatserver/pStatThreadData.cxx index fd5e3f411b..bef18c8a24 100644 --- a/pandatool/src/pstatserver/pStatThreadData.cxx +++ b/pandatool/src/pstatserver/pStatThreadData.cxx @@ -75,7 +75,7 @@ has_frame(int frame_number) const { int rel_frame = frame_number - _first_frame_number; return (rel_frame >= 0 && rel_frame < (int)_frames.size() && - _frames[rel_frame] != (PStatFrameData *)NULL); + _frames[rel_frame] != nullptr); } /** @@ -91,21 +91,21 @@ get_frame(int frame_number) const { rel_frame = num_frames - 1; } - while (rel_frame >= 0 && _frames[rel_frame] == (PStatFrameData *)NULL) { + while (rel_frame >= 0 && _frames[rel_frame] == nullptr) { rel_frame--; } if (rel_frame < 0) { // No frame data that old. Return the oldest frame we've got. rel_frame = 0; while (rel_frame < num_frames && - _frames[rel_frame] == (PStatFrameData *)NULL) { + _frames[rel_frame] == nullptr) { rel_frame++; } } if (rel_frame >= 0 && rel_frame < num_frames) { PStatFrameData *frame = _frames[rel_frame]; - nassertr(frame != (PStatFrameData *)NULL, _null_frame); + nassertr(frame != nullptr, _null_frame); nassertr(frame->get_start() >= 0.0, _null_frame); return *frame; } @@ -154,14 +154,14 @@ int PStatThreadData:: get_frame_number_at_time(double time, int hint) const { hint -= _first_frame_number; if (hint >= 0 && hint < (int)_frames.size()) { - if (_frames[hint] != (PStatFrameData *)NULL && + if (_frames[hint] != nullptr && _frames[hint]->get_start() <= time) { // The hint might be right. Scan forward from there. int i = hint + 1; while (i < (int)_frames.size() && - (_frames[i] == (PStatFrameData *)NULL || + (_frames[i] == nullptr || _frames[i]->get_start() <= time)) { - if (_frames[i] != (PStatFrameData *)NULL) { + if (_frames[i] != nullptr) { hint = i; } ++i; @@ -175,7 +175,7 @@ get_frame_number_at_time(double time, int hint) const { int i = _frames.size() - 1; while (i >= 0) { const PStatFrameData *frame = _frames[i]; - if (frame != (PStatFrameData *)NULL && frame->get_start() <= time) { + if (frame != nullptr && frame->get_start() <= time) { break; } --i; @@ -259,17 +259,17 @@ get_history() const { */ void PStatThreadData:: record_new_frame(int frame_number, PStatFrameData *frame_data) { - nassertv(frame_data != (PStatFrameData *)NULL); + nassertv(frame_data != nullptr); nassertv(!frame_data->is_empty()); double time = frame_data->get_start(); // First, remove all the old frames that fall outside of our history window. double oldest_allowable_time = time - _history; while (!_frames.empty() && - (_frames.front() == (PStatFrameData *)NULL || + (_frames.front() == nullptr || _frames.front()->is_empty() || _frames.front()->get_start() < oldest_allowable_time)) { - if (_frames.front() != (PStatFrameData *)NULL) { + if (_frames.front() != nullptr) { delete _frames.front(); } _frames.pop_front(); @@ -281,18 +281,18 @@ record_new_frame(int frame_number, PStatFrameData *frame_data) { // get all the frames in order or even at all. if (_frames.empty()) { _first_frame_number = frame_number; - _frames.push_back(NULL); + _frames.push_back(nullptr); } else { while (_first_frame_number + (int)_frames.size() <= frame_number) { - _frames.push_back(NULL); + _frames.push_back(nullptr); } } int index = frame_number - _first_frame_number; nassertv(index >= 0 && index < (int)_frames.size()); - if (_frames[index] != (PStatFrameData *)NULL) { + if (_frames[index] != nullptr) { nout << "Got repeated frame data for frame " << frame_number << "\n"; delete _frames[index]; } @@ -314,7 +314,7 @@ compute_elapsed_frames() { } else { _now_i = _frames.size() - 1; - while (_now_i > 0 && _frames[_now_i] == (PStatFrameData *)NULL) { + while (_now_i > 0 && _frames[_now_i] == nullptr) { _now_i--; } if (_now_i < 0) { @@ -322,7 +322,7 @@ compute_elapsed_frames() { _got_elapsed_frames = false; } else { - nassertv(_frames[_now_i] != (PStatFrameData *)NULL); + nassertv(_frames[_now_i] != nullptr); double now = _frames[_now_i]->get_end(); double then = now - pstats_average_time; @@ -332,7 +332,7 @@ compute_elapsed_frames() { while (old_i >= 0) { const PStatFrameData *frame = _frames[old_i]; - if (frame != (PStatFrameData *)NULL) { + if (frame != nullptr) { if (frame->get_start() > then) { _then_i = old_i; } else { @@ -343,7 +343,7 @@ compute_elapsed_frames() { } nassertv(_then_i >= 0); - nassertv(_frames[_then_i] != (PStatFrameData *)NULL); + nassertv(_frames[_then_i] != nullptr); _got_elapsed_frames = true; _now_i += _first_frame_number; diff --git a/pandatool/src/pstatserver/pStatView.cxx b/pandatool/src/pstatserver/pStatView.cxx index b8d6aa9793..e69959a731 100644 --- a/pandatool/src/pstatserver/pStatView.cxx +++ b/pandatool/src/pstatserver/pStatView.cxx @@ -266,7 +266,7 @@ get_level(int collector) { PStatViewLevel *level = new PStatViewLevel; level->_collector = collector; - level->_parent = NULL; + level->_parent = nullptr; _levels[collector] = level; reset_level(level); @@ -518,7 +518,7 @@ reset_level(PStatViewLevel *level) { int parent_index = _client_data->get_collector_def(level->_collector)._parent_index; - if (level->_parent == (PStatViewLevel *)NULL) { + if (level->_parent == nullptr) { // This level didn't know its parent before, but now it does. PStatViewLevel *parent_level = get_level(parent_index); nassertr(parent_level != level, true); @@ -540,7 +540,7 @@ reset_level(PStatViewLevel *level) { new_parent_level->_children.push_back(level); new_parent_level->sort_children(_client_data); } else { - level->_parent = NULL; + level->_parent = nullptr; } PStatViewLevel::Children::iterator ci = diff --git a/pandatool/src/pstatserver/pStatViewLevel.cxx b/pandatool/src/pstatserver/pStatViewLevel.cxx index 04d962e833..47ed1fae98 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.cxx +++ b/pandatool/src/pstatserver/pStatViewLevel.cxx @@ -77,6 +77,6 @@ get_num_children() const { */ const PStatViewLevel *PStatViewLevel:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.cxx b/pandatool/src/ptloader/loaderFileTypePandatool.cxx index 0de02c19de..dade132585 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.cxx +++ b/pandatool/src/ptloader/loaderFileTypePandatool.cxx @@ -32,7 +32,7 @@ LoaderFileTypePandatool(SomethingToEggConverter *loader, EggToSomethingConverter *saver) : _loader(loader), _saver(saver) { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { _loader->set_merge_externals(true); } } @@ -49,7 +49,7 @@ LoaderFileTypePandatool:: */ string LoaderFileTypePandatool:: get_name() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->get_name(); } return _saver->get_name(); @@ -60,7 +60,7 @@ get_name() const { */ string LoaderFileTypePandatool:: get_extension() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->get_extension(); } return _saver->get_extension(); @@ -72,7 +72,7 @@ get_extension() const { */ string LoaderFileTypePandatool:: get_additional_extensions() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->get_additional_extensions(); } return _saver->get_additional_extensions(); @@ -84,7 +84,7 @@ get_additional_extensions() const { */ bool LoaderFileTypePandatool:: supports_compressed() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->supports_compressed(); } return _saver->supports_compressed(); @@ -97,7 +97,7 @@ supports_compressed() const { */ bool LoaderFileTypePandatool:: supports_load() const { - return (_loader != NULL); + return (_loader != nullptr); } /** @@ -107,7 +107,7 @@ supports_load() const { */ bool LoaderFileTypePandatool:: supports_save() const { - return (_saver != NULL); + return (_saver != nullptr); } /** @@ -125,11 +125,11 @@ resolve_filename(Filename &path) const { PT(PandaNode) LoaderFileTypePandatool:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { - if (_loader == NULL) { - return NULL; + if (_loader == nullptr) { + return nullptr; } - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(path); } @@ -205,7 +205,7 @@ load_file(const Filename &path, const LoaderOptions &options, bool LoaderFileTypePandatool:: save_file(const Filename &path, const LoaderOptions &options, PandaNode *node) const { - if (_saver == NULL) { + if (_saver == nullptr) { return false; } diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.h b/pandatool/src/ptloader/loaderFileTypePandatool.h index 3e38e3a8b9..721e7477c3 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.h +++ b/pandatool/src/ptloader/loaderFileTypePandatool.h @@ -29,7 +29,7 @@ class EggToSomethingConverter; class EXPCL_PTLOADER LoaderFileTypePandatool : public LoaderFileType { public: LoaderFileTypePandatool(SomethingToEggConverter *loader, - EggToSomethingConverter *saver = NULL); + EggToSomethingConverter *saver = nullptr); virtual ~LoaderFileTypePandatool(); virtual string get_name() const; diff --git a/pandatool/src/softegg/soft2Egg.c b/pandatool/src/softegg/soft2Egg.c index aaad102fb4..9e744b8655 100644 --- a/pandatool/src/softegg/soft2Egg.c +++ b/pandatool/src/softegg/soft2Egg.c @@ -192,10 +192,9 @@ class soft2egg : public EggBase bool has_morph; bool make_pose; - ofstream eggFile; - ofstream animFile; - ofstream texFile; - + std::ofstream eggFile; + std::ofstream animFile; + std::ofstream texFile; }; diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx index 5be0b79246..86d98ab7db 100644 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ b/pandatool/src/softegg/softNodeDesc.cxx @@ -29,38 +29,38 @@ SoftNodeDesc(SoftNodeDesc *parent, const string &name) : Namable(name), _parent(parent) { - _model = (SAA_Elem *)NULL; - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _model = nullptr; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; _joint_type = JT_none; // Add ourselves to our parent. - if (_parent != (SoftNodeDesc *)NULL) { + if (_parent != nullptr) { softegg_cat.spam() << "parent name " << _parent->get_name(); _parent->_children.push_back(this); } // set the _parentJoint to Null - _parentJoint = NULL; + _parentJoint = nullptr; - fullname = NULL; + fullname = nullptr; numTexLoc = 0; numTexGlb = 0; - uScale = NULL; - vScale = NULL; - uOffset = NULL; - vOffset = NULL; + uScale = nullptr; + vScale = nullptr; + uOffset = nullptr; + vOffset = nullptr; valid; uv_swap; // SAA_Boolean visible; - numTexTri = NULL; - textures = NULL; - materials = NULL; - triangles = NULL; + numTexTri = nullptr; + textures = nullptr; + materials = nullptr; + triangles = nullptr; gtype = SAA_GEOM_ORIGINAL; } @@ -140,7 +140,7 @@ force_set_parent(SoftNodeDesc *parent) { */ bool SoftNodeDesc:: has_model() const { - return (_model != (SAA_Elem *)NULL); + return (_model != nullptr); } /** @@ -149,7 +149,7 @@ has_model() const { */ SAA_Elem *SoftNodeDesc:: get_model() const { - nassertr(_model != (SAA_Elem *)NULL, _model); + nassertr(_model != nullptr, _model); return _model; } @@ -190,9 +190,9 @@ is_joint_parent() const { */ void SoftNodeDesc:: clear_egg() { - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -214,7 +214,7 @@ mark_joint_parent() { else softegg_cat.spam() << " ?parent " << get_name() << " joint type " << _joint_type; - if (_parent != (SoftNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } softegg_cat.spam() << endl; @@ -249,13 +249,13 @@ check_junk(bool parent_junk) { _joint_type = JT_junk; softegg_cat.spam() << "junk node " << get_name() << endl; } - if ( (strstr(name, "con-") != NULL) || - (strstr(name, "con_") != NULL) || - (strstr(name, "fly_") != NULL) || - (strstr(name, "fly-") != NULL) || - (strstr(name, "camRIG") != NULL) || - (strstr(name, "cam_rig") != NULL) || - (strstr(name, "bars") != NULL) ) + if ( (strstr(name, "con-") != nullptr) || + (strstr(name, "con_") != nullptr) || + (strstr(name, "fly_") != nullptr) || + (strstr(name, "fly-") != nullptr) || + (strstr(name, "camRIG") != nullptr) || + (strstr(name, "cam_rig") != nullptr) || + (strstr(name, "bars") != nullptr) ) { _joint_type = JT_junk; softegg_cat.spam() << "junk node " << get_name() << endl; @@ -286,12 +286,12 @@ is_partial(char *search_prefix) { if (!search_prefix) return false; // if name is search_prefix, return false - if (strstr(name, search_prefix) != NULL) { + if (strstr(name, search_prefix) != nullptr) { softegg_cat.debug() << "matched " << name << " "; return false; } // if name is not search_prefix, look in its parent - if (strstr(name, search_prefix) == NULL) { + if (strstr(name, search_prefix) == nullptr) { softegg_cat.debug() << "node " << name << " "; if (_parent) return _parent->is_partial(search_prefix); @@ -322,13 +322,13 @@ set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint) { // if already a joint or name has "joint" in it const char *name = get_name().c_str(); - if (is_joint() || isSkeleton || strstr(name, "joint") != NULL) { + if (is_joint() || isSkeleton || strstr(name, "joint") != nullptr) { lastJoint = this; } - if ( _parentJoint && strstr( _parentJoint->get_name().c_str(), "scale" ) != NULL ) { + if ( _parentJoint && strstr( _parentJoint->get_name().c_str(), "scale" ) != nullptr ) { // make sure _parentJoint didn't have the name "joint" in it - if (strstr(_parentJoint->get_name().c_str(), "joint") == NULL) { - _parentJoint = NULL; + if (strstr(_parentJoint->get_name().c_str(), "joint") == nullptr) { + _parentJoint = nullptr; // _parentJoint = lastJoint = NULL; softegg_cat.spam() << "scale joint flag set!\n"; } @@ -464,7 +464,7 @@ get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, b SAA_Elem *skeletonPart = _model; const char *name = get_name().c_str(); - if ( skeletonPart != NULL ) { + if ( skeletonPart != nullptr ) { PN_stdfloat i,j,k; PN_stdfloat h,p,r; PN_stdfloat x,y,z; @@ -636,7 +636,7 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { TEX_PER_MAT , &textures[i] ); // initialize the array value - texNameArray[i] = NULL; + texNameArray[i] = nullptr; // initialize the repeats uRepeat[i] = vRepeat[i] = 0; @@ -895,12 +895,12 @@ make_vertex_offsets(int numShapes) { int offset; int numCV; char tableName[_MAX_PATH]; - SAA_DVector *shapeVerts = NULL; - SAA_DVector *uniqueVerts = NULL; + SAA_DVector *shapeVerts = nullptr; + SAA_DVector *uniqueVerts = nullptr; SAA_Elem *model = get_model(); SAA_Scene *scene = &stec.scene; - EggVertexPool *vpool = NULL; + EggVertexPool *vpool = nullptr; string vpool_name = get_name() + ".verts"; EggNode *t = stec._tree.get_egg_root()->find_child(vpool_name); if (t) @@ -988,7 +988,7 @@ make_vertex_offsets(int numShapes) { // if change isn't negligible, make a morph vertex entry double total = fabs(dx)+fabs(dy)+fabs(dz); if ( total > 0.00001 ) { - if ( vpool != NULL ) { + if ( vpool != nullptr ) { // create offset LVector3d p(dx, dy, dz); EggMorphVertex *dxyz = new EggMorphVertex(tableName, p); @@ -1011,7 +1011,7 @@ make_vertex_offsets(int numShapes) { void SoftNodeDesc:: make_morph_table( PN_stdfloat time ) { int numShapes; - SAA_Elem *model = NULL; + SAA_Elem *model = nullptr; SAA_AnimInterpType type; SAA_Scene *scene = &stec.scene; @@ -1080,7 +1080,7 @@ make_linear_morph_table(int numShapes, PN_stdfloat time) { // find the morph table associated with this key shape anim = stec.find_morph_table(tableName); - if ( anim != NULL ) { + if ( anim != nullptr ) { if ( i == (int)curveVal ) { if ( curveVal - i == 0 ) { anim->add_data(1.0f ); @@ -1151,7 +1151,7 @@ make_weighted_morph_table(int numShapes, PN_stdfloat time) { // find the morph table associated with this key shape anim = stec.find_morph_table(tableName); - if ( anim != NULL ) { + if ( anim != nullptr ) { anim->add_data(curveVal); softegg_cat.spam() << "adding element " << curveVal << endl; } @@ -1183,7 +1183,7 @@ make_expression_morph_table(int numShapes, PN_stdfloat time) // populate morph table values for this frame // compose track name - track = NULL; + track = nullptr; // find how many expressions for this shape SAA_elementGetNbExpressions( scene, model, track, FALSE, &numExp ); diff --git a/pandatool/src/softegg/softNodeDesc.h b/pandatool/src/softegg/softNodeDesc.h index 8d041377c6..af2060435a 100644 --- a/pandatool/src/softegg/softNodeDesc.h +++ b/pandatool/src/softegg/softNodeDesc.h @@ -42,7 +42,7 @@ class EggXfmSAnim; */ class SoftNodeDesc : public ReferenceCount, public Namable { public: - SoftNodeDesc(SoftNodeDesc *parent=NULL, const string &name = string()); + SoftNodeDesc(SoftNodeDesc *parent=nullptr, const string &name = string()); ~SoftNodeDesc(); void set_parent(SoftNodeDesc *parent); diff --git a/pandatool/src/softegg/softNodeTree.cxx b/pandatool/src/softegg/softNodeTree.cxx index f8dda53d48..a896bce4e0 100644 --- a/pandatool/src/softegg/softNodeTree.cxx +++ b/pandatool/src/softegg/softNodeTree.cxx @@ -30,14 +30,14 @@ */ SoftNodeTree:: SoftNodeTree() { - _root = new SoftNodeDesc(NULL, "----root"); + _root = new SoftNodeDesc(nullptr, "----root"); _root->fullname = "----root"; _fps = 0.0; _use_prefix = 0; - _search_prefix = NULL; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; + _search_prefix = nullptr; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; } /** * Given an element, return a copy of the element's name WITHOUT prefix. @@ -91,7 +91,7 @@ GetFullName( SAA_Scene *scene, SAA_Elem *element ) char *SoftNodeTree:: GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { int size; - char *modelNote = NULL; + char *modelNote = nullptr; SAA_Boolean bigEndian; SAA_elementGetUserDataSize( scene, model, "MNOT", &size ); @@ -106,7 +106,7 @@ GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { // strip off newline, if present char *eol = (char *)memchr( modelNote, '\n', size ); - if ( eol != NULL) + if ( eol != nullptr) *eol = '\0'; else modelNote[size] = '\0'; @@ -130,7 +130,7 @@ GetRootName( const char *name ) { hyphen = strchr( name, '-' ); len = hyphen-name; - if ( (hyphen != NULL) && len ) { + if ( (hyphen != nullptr) && len ) { root = new char[len+1]; strncpy( root, name, len ); root[len] = '\0'; @@ -164,7 +164,7 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { if ( numModels ) { // allocate array of models models = (SAA_Elem *) new SAA_Elem[numModels]; - if ( models != NULL ) { + if ( models != nullptr ) { if ((status = SAA_sceneGetModels( &scene, numModels, models )) != SI_SUCCESS) { return false; } @@ -200,7 +200,7 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { softegg_cat.spam() << "========================================================\n"; // find _parentJoint for each node - _root->set_parentJoint(&scene, NULL); + _root->set_parentJoint(&scene, nullptr); return all_ok; } @@ -280,7 +280,7 @@ get_num_nodes() const { */ SoftNodeDesc *SoftNodeTree:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } @@ -292,7 +292,7 @@ get_node(string name) const { NodesByName::const_iterator ni = _nodes_by_name.find(name); if (ni != _nodes_by_name.end()) return (*ni).second; - return NULL; + return nullptr; } /** @@ -314,7 +314,7 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, */ EggGroup *SoftNodeTree:: get_egg_group(SoftNodeDesc *node_desc) { - nassertr(_egg_root != (EggGroupNode *)NULL, NULL); + nassertr(_egg_root != nullptr, nullptr); // lets print some relationship softegg_cat.spam() << " group " << node_desc->get_name() << "(" << node_desc->_egg_group << ")"; @@ -324,7 +324,7 @@ get_egg_group(SoftNodeDesc *node_desc) { softegg_cat.spam() << " parent " << node_desc->_parent; softegg_cat.spam() << endl; - if (node_desc->_egg_group == (EggGroup *)NULL) { + if (node_desc->_egg_group == nullptr) { // We need to make a new group node. EggGroup *egg_group; @@ -355,8 +355,8 @@ get_egg_group(SoftNodeDesc *node_desc) { */ EggTable *SoftNodeTree:: get_egg_table(SoftNodeDesc *node_desc) { - nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); - nassertr(node_desc->is_joint(), NULL); + nassertr(_skeleton_node != nullptr, nullptr); + nassertr(node_desc->is_joint(), nullptr); // lets print some relationship softegg_cat.spam() << " group " << node_desc->get_name() << "(" << node_desc->_egg_group << ")"; @@ -366,7 +366,7 @@ get_egg_table(SoftNodeDesc *node_desc) { softegg_cat.spam() << " parent " << node_desc->_parent; softegg_cat.spam() << endl; - if (node_desc->_egg_table == (EggTable *)NULL) { + if (node_desc->_egg_table == nullptr) { softegg_cat.spam() << "creating a new table\n"; // We need to make a new table node. nassertr(node_desc->_parent != // (SoftNodeDesc *)NULL, NULL); @@ -433,7 +433,7 @@ handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { // check to see if this NULL is used as a skeleton or is animated via // constraint only ( these nodes are tagged by the animator with the // keyword "joint" somewhere in the nodes name) - if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) { + if ( isSkeleton || (strstr( name, "joint" ) != nullptr) ) { // MakeJoint( &scene, lastJoint, lastAnim, model, name ); node_desc->set_joint(); softegg_cat.spam() << " animating Standard null!!!\n"; @@ -466,7 +466,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { node_name = name; - SoftNodeDesc *node_desc = r_build_node(NULL, node_name); + SoftNodeDesc *node_desc = r_build_node(nullptr, node_name); node_desc->fullname = fullname; node_desc->set_model(model); @@ -475,7 +475,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { // find out what type of node we're dealing with SAA_modelGetType( scene, node_desc->get_model(), &type ); - if (type == SAA_MJNT || isSkeleton || (strstr(node_desc->get_name().c_str(), "joint") != NULL)) + if (type == SAA_MJNT || isSkeleton || (strstr(node_desc->get_name().c_str(), "joint") != nullptr)) node_desc->set_joint(); // treat the MNILL differently, because it needs to detect and set some @@ -514,7 +514,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { // find out what type of node we're dealing with SAA_modelGetType( scene, node_child->get_model(), &type ); - if (type == SAA_MJNT || isSkeleton || (strstr(node_child->get_name().c_str(), "joint") != NULL)) + if (type == SAA_MJNT || isSkeleton || (strstr(node_child->get_name().c_str(), "joint") != nullptr)) node_child->set_joint(); // treat the MNILL differently, because it needs to detect and set some diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx index 64d5da3aed..3e0ab21ef6 100644 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ b/pandatool/src/softegg/softToEggConverter.cxx @@ -52,15 +52,15 @@ SoftToEggConverter(const string &program_name) : */ _transform_type = TT_model; - database_name = NULL; - scene_name = NULL; - model_name = NULL; - animFileName = NULL; - eggFileName = NULL; - tex_path = NULL; - eggGroupName = NULL; - tex_filename = NULL; - search_prefix = NULL; + database_name = nullptr; + scene_name = nullptr; + model_name = nullptr; + animFileName = nullptr; + eggFileName = nullptr; + tex_path = nullptr; + eggGroupName = nullptr; + tex_filename = nullptr; + search_prefix = nullptr; result = SI_SUCCESS; // skeleton = new EggGroup(); @@ -473,7 +473,7 @@ GetTextureName( SAA_Scene *scene, SAA_Elem *texture ) { strcpy(fileName, tex_path); // do some processing on the name string - char *tmpName = NULL; + char *tmpName = nullptr; tmpName = strrchr(tempName, '/'); if (tmpName) tmpName++; @@ -601,7 +601,7 @@ convert_soft(bool from_selection) { */ bool SoftToEggConverter:: open_api() { - if ((scene_name == NULL && model_name == NULL) || database_name == NULL) { + if ((scene_name == nullptr && model_name == nullptr) || database_name == nullptr) { Usage(); exit( 1 ); } @@ -637,7 +637,7 @@ open_api() { } // if no egg filename specified, make up a name - if ( eggFileName == NULL ) { + if ( eggFileName == nullptr ) { string madeName; string tempName(scene_name); string::size_type end = tempName.find(".dsc"); @@ -651,7 +651,7 @@ open_api() { strcpy(eggFileName, madeName.c_str()); // if no anim filename specified, make up a name - if ( animFileName == NULL ) { + if ( animFileName == nullptr ) { madeName.assign(tempName.substr(0,end)); madeName.insert(madeName.size(), "-chan.egg"); animFileName = new char[strlen(scene_name)+ 10]; @@ -691,7 +691,7 @@ convert_char_model() { */ EggSAnimData *SoftToEggConverter:: find_morph_table(char *name) { - EggSAnimData *anim = NULL; + EggSAnimData *anim = nullptr; MorphTable::iterator mt; for (mt = _morph_table.begin(); mt != _morph_table.end(); ++mt) { anim = (*mt); @@ -742,7 +742,7 @@ convert_char_chan() { _tree._fps = output_frame_rate / frame_inc; // _tree.clear_egg(get_egg_data(), NULL, root_node); - _tree.clear_egg(get_egg_data(), NULL, skeleton_node); + _tree.clear_egg(get_egg_data(), nullptr, skeleton_node); // Now we can get the animation data by walking through all of the frames, // one at a time, and getting the joint angles at each frame. @@ -775,7 +775,7 @@ convert_char_chan() { // if (softegg_cat.is_debug()) { softegg_cat.debug(false) softegg_cat.info() << "frame " << time << "\n"; // } else { We have to write to cerr instead of softegg_cat to allow - // flushing without writing a newline. cerr << "." << flush; } + // flushing without writing a newline. std::cerr << "." << std::flush; } // MGlobal::viewFrame(frame); for (i = 0; i < num_nodes; i++) { @@ -828,7 +828,7 @@ bool SoftToEggConverter:: convert_hierarchy(EggGroupNode *egg_root) { int num_nodes = _tree.get_num_nodes(); - _tree.clear_egg(get_egg_data(), egg_root, NULL); + _tree.clear_egg(get_egg_data(), egg_root, nullptr); softegg_cat.spam() << "num_nodes = " << num_nodes << endl; for (int i = 0; i < num_nodes; i++) { if (!process_model_node(_tree.get_node(i))) { @@ -846,9 +846,9 @@ convert_hierarchy(EggGroupNode *egg_root) { */ bool SoftToEggConverter:: process_model_node(SoftNodeDesc *node_desc) { - EggGroup *egg_group = NULL; - const char *name = NULL; - char *fullname = NULL; + EggGroup *egg_group = nullptr; + const char *name = nullptr; + char *fullname = nullptr; SAA_ModelType type; name = node_desc->get_name().c_str(); @@ -930,8 +930,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { int numShapes; SAA_Boolean valid; SAA_Boolean visible; - PN_stdfloat *uCoords = NULL; - PN_stdfloat *vCoords = NULL; + PN_stdfloat *uCoords = nullptr; + PN_stdfloat *vCoords = nullptr; string name = node_desc->get_name(); SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); @@ -984,8 +984,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { // Is this a double sided polygon? meaning check for back face flag char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); - if ( modelNoteStr != NULL ) { - if ( strstr( modelNoteStr, "bface" ) != NULL ) + if ( modelNoteStr != nullptr ) { + if ( strstr( modelNoteStr, "bface" ) != nullptr ) egg_poly->set_bface_flag(TRUE); } @@ -1018,7 +1018,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { vCoords = new PN_stdfloat[3]; // read the u & v coords into the arrays - if ( uCoords != NULL && vCoords != NULL) { + if ( uCoords != nullptr && vCoords != nullptr) { for ( i = 0; i < 3; i++ ) uCoords[i] = vCoords[i] = 0.0f; @@ -1044,7 +1044,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { } // read the u & v coords into the arrays - if ( uCoords != NULL && vCoords != NULL) { + if ( uCoords != nullptr && vCoords != nullptr) { SAA_triCtrlVertexGetGlobalUVTxtCoords( &scene, node_desc->get_model(), 3, cvertices, node_desc->numTexGlb, node_desc->textures, uCoords, vCoords ); } @@ -1132,7 +1132,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { } // Now apply the shader. - if (node_desc->textures != NULL) { + if (node_desc->textures != nullptr) { if (node_desc->numTexLoc && node_desc->numTexTri[idx]) { if (!strstr(node_desc->texNameArray[idx], "noIcon")) set_shader_attributes(node_desc, *egg_poly, idx); @@ -1164,8 +1164,8 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty int numShapes; SAA_Boolean valid; SAA_Boolean visible; - PN_stdfloat *uCoords = NULL; - PN_stdfloat *vCoords = NULL; + PN_stdfloat *uCoords = nullptr; + PN_stdfloat *vCoords = nullptr; string name = node_desc->get_name(); SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); @@ -1261,8 +1261,8 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty // Is this a double sided polygon? meaning check for back face flag char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); - if ( modelNoteStr != NULL ) { - if ( strstr( modelNoteStr, "bface" ) != NULL ) { + if ( modelNoteStr != nullptr ) { + if ( strstr( modelNoteStr, "bface" ) != nullptr ) { eggNurbs->set_bface_flag(TRUE); softegg_cat.spam() << "Set backface flag\n"; } @@ -1303,7 +1303,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty softegg_cat.spam() << numVert << " CV's\n"; // get the CV's - SAA_DVector *vertices = NULL; + SAA_DVector *vertices = nullptr; vertices = new SAA_DVector[numVert]; SAA_modelGetVertices( &scene, node_desc->get_model(), node_desc->gtype, 0, numVert, vertices ); @@ -1410,7 +1410,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty egg_group->add_child(eggNurbs); // Now apply the shader. - if (node_desc->textures != NULL) { + if (node_desc->textures != nullptr) { if (!strstr(node_desc->texNameArray[0], "noIcon")) set_shader_attributes(node_desc, *eggNurbs, 0); else @@ -1489,7 +1489,7 @@ add_knots( vector &eggKnots, double *knots, int numKnots, SAA_Boolean c int *SoftToEggConverter:: FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { int i,j; - int *vertMap = NULL; + int *vertMap = nullptr; int vpoolSize = (int)vpool->size(); PN_stdfloat closestDist; PN_stdfloat thisDist; @@ -1565,7 +1565,7 @@ make_soft_skin() { SAA_ModelType type; SAA_Elem *envelopes; SAA_Elem *model = node_desc->get_model(); - EggGroup *joint = NULL; + EggGroup *joint = nullptr; EggVertexPool *vpool; SAA_skeletonGetNbEnvelopes( &scene, model, &numEnv ); @@ -1579,7 +1579,7 @@ make_soft_skin() { softegg_cat.spam() << "numEnv = " << numEnv << endl; // allocate envelope array envelopes = new SAA_Elem[numEnv]; - if ( envelopes == NULL ) { + if ( envelopes == nullptr ) { softegg_cat.info() << "Out Of Memory" << endl; exit(1); } @@ -1615,13 +1615,13 @@ make_soft_skin() { if ( !hasEnvVertices ) continue; - SAA_SubElem *envVertices = NULL; + SAA_SubElem *envVertices = nullptr; int *numEnvVertices; int i,j,k; numEnvVertices = new int[numEnv]; - if ( numEnvVertices != NULL ) { + if ( numEnvVertices != nullptr ) { SAA_envelopeGetNbCtrlVertices( &scene, model, numEnv, envelopes, numEnvVertices ); int totalEnvVertices = 0; for( i = 0; i < numEnv; i++ ) { @@ -1633,7 +1633,7 @@ make_soft_skin() { continue; envVertices = new SAA_SubElem[totalEnvVertices]; - if ( envVertices != NULL ) { + if ( envVertices != nullptr ) { result = SAA_envelopeGetCtrlVertices( &scene, model, numEnv, envelopes, numEnvVertices, envVertices); if (result != SI_SUCCESS) { @@ -1642,13 +1642,13 @@ make_soft_skin() { } // loop through for each envelope for ( i = 0; i < numEnv; i++ ) { - PN_stdfloat *weights = NULL; + PN_stdfloat *weights = nullptr; int vertArrayOffset = 0; softegg_cat.spam() << "envelope[" << i << "]: "; weights = new PN_stdfloat[numEnvVertices[i]]; if ( weights ) { char *envName; - int *vpoolMap = NULL; + int *vpoolMap = nullptr; for ( j = 0; j < i; j++ ) vertArrayOffset += numEnvVertices[j]; softegg_cat.spam() << "envVertArray offset = " << vertArrayOffset; @@ -1697,7 +1697,7 @@ make_soft_skin() { else softegg_cat.spam() << "OTHER\n"; - int *envVtxIndices = NULL; + int *envVtxIndices = nullptr; envVtxIndices = new int[numEnvVertices[i]]; // Get the envelope vertex indices @@ -1714,7 +1714,7 @@ make_soft_skin() { SAA_modelGetNbVertices( &scene, &envelopes[i], &modelNumVert ); - SAA_DVector *modelVertices = NULL; + SAA_DVector *modelVertices = nullptr; modelVertices = new SAA_DVector[modelNumVert]; // get the model vertices @@ -1723,7 +1723,7 @@ make_soft_skin() { modelVertices ); // create array of global model coords - SAA_DVector *globalModelVertices = NULL; + SAA_DVector *globalModelVertices = nullptr; globalModelVertices = new SAA_DVector[modelNumVert]; PN_stdfloat matrix[4][4]; @@ -1748,7 +1748,7 @@ make_soft_skin() { string vpool_name = s_name + ".verts"; EggNode *t = _tree.get_egg_root()->find_child(vpool_name); if (t) - DCAST_INTO_R(vpool, t, NULL); + DCAST_INTO_R(vpool, t, nullptr); // find the mapping of the vertices that match this envelop if (vpool) { @@ -1841,8 +1841,8 @@ cleanup_soft_skin() continue; SAA_Elem *model = node_desc->get_model(); - EggGroup *joint = NULL; - EggVertexPool *vpool = NULL; + EggGroup *joint = nullptr; + EggVertexPool *vpool = nullptr; SAA_ModelType type; // find out what type of node we're dealing with @@ -1860,7 +1860,7 @@ cleanup_soft_skin() string vpool_name = node_desc->get_name() + ".verts"; EggNode *t = _tree.get_egg_root()->find_child(vpool_name); if (t) - DCAST_INTO_R(vpool, t, NULL); + DCAST_INTO_R(vpool, t, nullptr); if (!vpool) { // softegg_cat.spam() << "couldn't find vpool " << vpool_name << endl; @@ -2014,7 +2014,7 @@ reparent_decals(EggGroupNode *egg_parent) { // First, walk through all children of this node, looking for the one decal // base, if any. - EggGroup *decal_base = (EggGroup *)NULL; + EggGroup *decal_base = nullptr; pvector decal_children; EggGroupNode::iterator ci; @@ -2023,7 +2023,7 @@ reparent_decals(EggGroupNode *egg_parent) { if (child->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, child); if (child_group->has_object_type("decalbase")) { - if (decal_base != (EggNode *)NULL) { + if (decal_base != nullptr) { softegg_cat.error() << "Two children of " << egg_parent->get_name() << " both have decalbase set: " << decal_base->get_name() @@ -2040,7 +2040,7 @@ reparent_decals(EggGroupNode *egg_parent) { } } - if (decal_base == (EggGroup *)NULL) { + if (decal_base == nullptr) { if (!decal_children.empty()) { softegg_cat.warning() << decal_children.front()->get_name() diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx index 22329eb8c5..a0351b854e 100644 --- a/pandatool/src/softprogs/softCVS.cxx +++ b/pandatool/src/softprogs/softCVS.cxx @@ -57,7 +57,7 @@ SoftCVS() { ("cvs", "cvs_binary", 80, "Specify how to run the cvs program for adding newly-created files. " "The default is simply \"cvs\".", - &SoftCVS::dispatch_string, NULL, &_cvs_binary); + &SoftCVS::dispatch_string, nullptr, &_cvs_binary); } @@ -282,7 +282,7 @@ get_scenes() { Filename file(sf.get_dirname(), sf.get_filename()); file.set_text(); - ifstream in; + std::ifstream in; if (!file.open_read(in)) { nout << "Unable to read " << file << "\n"; } else { @@ -436,7 +436,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { return false; } - ifstream in; + std::ifstream in; cvs_entries.set_text(); if (!cvs_entries.open_read(in)) { nout << "Unable to read CVS directory.\n"; @@ -444,7 +444,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { } string line; - getline(in, line); + std::getline(in, line); while (!in.fail() && !in.eof()) { if (!line.empty() && line[0] == '/') { size_t slash = line.find('/', 1); @@ -461,7 +461,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { } } - getline(in, line); + std::getline(in, line); } return true; diff --git a/pandatool/src/text-stats/textStats.cxx b/pandatool/src/text-stats/textStats.cxx index cc1e2392c1..9f2929f440 100644 --- a/pandatool/src/text-stats/textStats.cxx +++ b/pandatool/src/text-stats/textStats.cxx @@ -42,20 +42,20 @@ TextStats() { ("p", "port", 0, "Specify the TCP port to listen for connections on. By default, this " "is taken from the pstats-host Config variable.", - &TextStats::dispatch_int, NULL, &_port); + &TextStats::dispatch_int, nullptr, &_port); add_option ("r", "", 0, "Show the raw frame data, in addition to boiling it down to a total " "time per collector.", - &TextStats::dispatch_none, &_show_raw_data, NULL); + &TextStats::dispatch_none, &_show_raw_data, nullptr); add_option ("o", "filename", 0, "Filename where to print. If not given then stderr is being used.", &TextStats::dispatch_string, &_got_outputFileName, &_outputFileName); - _outFile = NULL; + _outFile = nullptr; _port = pstats_port; } @@ -87,7 +87,7 @@ run() { nout << "Listening for connections.\n"; if (_got_outputFileName) { - _outFile = new ofstream(_outputFileName.c_str(), ios::out); + _outFile = new std::ofstream(_outputFileName.c_str(), std::ios::out); } else { _outFile = &(nout); } diff --git a/pandatool/src/vrml/parse_vrml.cxx b/pandatool/src/vrml/parse_vrml.cxx index dfa2167e7f..1e55b68594 100644 --- a/pandatool/src/vrml/parse_vrml.cxx +++ b/pandatool/src/vrml/parse_vrml.cxx @@ -83,9 +83,9 @@ parse_vrml(Filename filename) { filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { nout << "Cannot open " << filename << " for reading.\n"; - return NULL; + return nullptr; } VrmlScene *result = parse_vrml(*in, filename); vfs->close_read_file(in); @@ -100,10 +100,10 @@ VrmlScene * parse_vrml(istream &in, const string &filename) { if (!get_standard_nodes()) { cerr << "Internal error--unable to parse VRML.\n"; - return NULL; + return nullptr; } - VrmlScene *scene = NULL; + VrmlScene *scene = nullptr; VrmlNodeType::pushNameSpace(); vrml_init_parser(in, filename); @@ -126,7 +126,7 @@ main(int argc, char *argv[]) { } VrmlScene *scene = parse_vrml(argv[1]); - if (scene == (VrmlScene *)NULL) { + if (scene == nullptr) { exit(1); } diff --git a/pandatool/src/vrml/vrmlLexer.lxx b/pandatool/src/vrml/vrmlLexer.lxx index e8b1290615..cd913fddc1 100644 --- a/pandatool/src/vrml/vrmlLexer.lxx +++ b/pandatool/src/vrml/vrmlLexer.lxx @@ -50,7 +50,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the vrml file we're parsing. We keep it so we // can print it out for error messages. @@ -123,7 +123,7 @@ vrmlyywarning(const string &msg) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -143,7 +143,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } @@ -164,7 +164,7 @@ input_chars(char *buffer, int &result, int max_size) { } int extract_int() { - return strtol(yytext, NULL, 0); + return strtol(yytext, nullptr, 0); } double extract_float() { @@ -275,7 +275,7 @@ idRestChar ([^\x00-\x20\x22\x23\x27\x2b-\x2c\x2e\x5b-\x5d\x7b\x7d]) TO { return TO; } IS { return IS; } ROUTE { return ROUTE; } -NULL { return SFN_NULL; } +nullptr { return SFN_NULL; } eventIn { return EVENTIN; } eventOut { return EVENTOUT; } field { return FIELD; } diff --git a/pandatool/src/vrml/vrmlNode.cxx b/pandatool/src/vrml/vrmlNode.cxx index d21061cd3a..628e09fb31 100644 --- a/pandatool/src/vrml/vrmlNode.cxx +++ b/pandatool/src/vrml/vrmlNode.cxx @@ -39,7 +39,7 @@ get_value(const char *field_name) const { // That field was not defined. Get the default value. const VrmlNodeType::NameTypeRec *field = _type->hasField(field_name); - if (field != NULL) { + if (field != nullptr) { return field->dflt; } diff --git a/pandatool/src/vrml/vrmlNodeType.cxx b/pandatool/src/vrml/vrmlNodeType.cxx index bfe4faf349..923570bd81 100644 --- a/pandatool/src/vrml/vrmlNodeType.cxx +++ b/pandatool/src/vrml/vrmlNodeType.cxx @@ -98,7 +98,7 @@ output_value(ostream &out, const VrmlFieldValue &value, int type, return out << "NULL"; case SFNodeRef::T_unnamed: - nassertr(value._sfnode._p != NULL, out); + nassertr(value._sfnode._p != nullptr, out); value._sfnode._p->output(out, indent); return out; @@ -145,7 +145,7 @@ output_value(ostream &out, const VrmlFieldValue &value, int type, VrmlNodeType::VrmlNodeType(const char *nm) { - nassertv(nm != NULL); + nassertv(nm != nullptr); name = strdup(nm); } @@ -176,7 +176,7 @@ VrmlNodeType::~VrmlNodeType() void VrmlNodeType::addToNameSpace(VrmlNodeType *_type) { - if (find(_type->getName()) != NULL) { + if (find(_type->getName()) != nullptr) { cerr << "PROTO " << _type->getName() << " already defined\n"; return; } @@ -191,7 +191,7 @@ VrmlNodeType::addToNameSpace(VrmlNodeType *_type) void VrmlNodeType::pushNameSpace() { - typeList.push_front(NULL); + typeList.push_front(nullptr); } void @@ -204,7 +204,7 @@ VrmlNodeType::popNameSpace() ++i; typeList.pop_front(); - if (nodeType == NULL) { + if (nodeType == nullptr) { break; } else { @@ -224,11 +224,11 @@ VrmlNodeType::find(const char *_name) plist::iterator i; for (i = typeList.begin(); i != typeList.end(); i++) { const VrmlNodeType *nt = *i; - if (nt != NULL && strcmp(nt->getName(),_name) == 0) { + if (nt != nullptr && strcmp(nt->getName(),_name) == 0) { return nt; } } - return NULL; + return nullptr; } void @@ -268,7 +268,7 @@ VrmlNodeType::add(plist &recs, const char *name, int type, NameTypeRec *r = new NameTypeRec; r->name = strdup(name); r->type = type; - if (dflt != NULL) { + if (dflt != nullptr) { r->dflt = *dflt; } else { memset(&r->dflt, 0, sizeof(r->dflt)); @@ -305,19 +305,19 @@ VrmlNodeType::hasExposedField(const char *name) const base = has(fields, name); sprintf(tmp, "set_%s\n", name); - nassertr(strlen(tmp) < 1000, NULL); + nassertr(strlen(tmp) < 1000, nullptr); set_name = has(eventIns, tmp); sprintf(tmp, "%s_changed\n", name); - nassertr(strlen(tmp) < 1000, NULL); + nassertr(strlen(tmp) < 1000, nullptr); name_changed = has(eventOuts, tmp); - if (base == NULL || set_name == NULL || name_changed == NULL) { - return NULL; + if (base == nullptr || set_name == nullptr || name_changed == nullptr) { + return nullptr; } if (base->type != set_name->type || base->type != name_changed->type) { - return NULL; + return nullptr; } return base; @@ -331,6 +331,6 @@ VrmlNodeType::has(const plist &recs, const char *name) const if (strcmp((*i)->name, name) == 0) return (*i); } - return NULL; + return nullptr; } diff --git a/pandatool/src/vrml/vrmlNodeType.h b/pandatool/src/vrml/vrmlNodeType.h index e455cf99ca..ae259af055 100644 --- a/pandatool/src/vrml/vrmlNodeType.h +++ b/pandatool/src/vrml/vrmlNodeType.h @@ -70,13 +70,13 @@ public: // Routines for adding/getting eventIns/Outs/fields void addEventIn(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); void addEventOut(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); void addField(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); void addExposedField(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); typedef struct { char *name; diff --git a/pandatool/src/vrml/vrmlParser.cxx.prebuilt b/pandatool/src/vrml/vrmlParser.cxx.prebuilt index fb95f8075f..6eaddbf170 100644 --- a/pandatool/src/vrml/vrmlParser.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlParser.cxx.prebuilt @@ -106,7 +106,7 @@ // Currently-being-define proto. Prototypes may be nested, so a stack // is needed: -stack< VrmlNodeType*, plist > currentProtoStack; +std::stack > currentProtoStack; // This is used to keep track of which field in which type of node is being // parsed. Field are nested (nodes are contained inside MFNode/SFNode fields) @@ -117,12 +117,12 @@ typedef struct { const VrmlNodeType::NameTypeRec *typeRec; } FieldRec; -stack< FieldRec*, plist > currentField; +std::stack > currentField; // Similarly for the node entries (which contain the actual values for // the fields as they are encountered): -stack< VrmlNode*, plist > currentNode; +std::stack > currentNode; // This is used when the parser knows what kind of token it expects // to get next-- used when parsing field values (whose types are declared diff --git a/pandatool/src/vrml/vrmlParser.yxx b/pandatool/src/vrml/vrmlParser.yxx index 3404f8c3f8..d114028828 100644 --- a/pandatool/src/vrml/vrmlParser.yxx +++ b/pandatool/src/vrml/vrmlParser.yxx @@ -49,7 +49,7 @@ // Currently-being-define proto. Prototypes may be nested, so a stack // is needed: -stack< VrmlNodeType*, plist > currentProtoStack; +std::stack > currentProtoStack; // This is used to keep track of which field in which type of node is being // parsed. Field are nested (nodes are contained inside MFNode/SFNode fields) @@ -60,12 +60,12 @@ typedef struct { const VrmlNodeType::NameTypeRec *typeRec; } FieldRec; -stack< FieldRec*, plist > currentField; +std::stack > currentField; // Similarly for the node entries (which contain the actual values for // the fields as they are encountered): -stack< VrmlNode*, plist > currentNode; +std::stack > currentNode; // This is used when the parser knows what kind of token it expects // to get next-- used when parsing field values (whose types are declared @@ -73,15 +73,15 @@ stack< VrmlNode*, plist > currentNode; extern int expectToken; // This is where we store the parsed scene. -VrmlScene *parsed_scene = NULL; +VrmlScene *parsed_scene = nullptr; // Some helper routines defined below: static void beginProto(const char *); static void endProto(); -int addField(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); -int addEventIn(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); -int addEventOut(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); -int addExposedField(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); +int addField(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); +int addEventIn(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); +int addEventOut(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); +int addExposedField(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); int add(void (VrmlNodeType::*func)(const char *, int, const VrmlFieldValue *), const char *typeString, const char *name, const VrmlFieldValue *dflt); @@ -170,7 +170,7 @@ nodeDeclaration: { $$._p = $1; $$._type = SFNodeRef::T_unnamed; - $$._name = NULL; + $$._name = nullptr; } | DEF IDENTIFIER node { @@ -180,7 +180,7 @@ nodeDeclaration: } | USE IDENTIFIER { - $$._p = NULL; + $$._p = nullptr; $$._type = SFNodeRef::T_use; $$._name = $2; } @@ -314,9 +314,9 @@ fieldValue: | SFNODE nodeDeclaration { $$._sfnode = $2; } | SFNODE SFN_NULL { - $$._sfnode._p = NULL; + $$._sfnode._p = nullptr; $$._sfnode._type = SFNodeRef::T_null; - $$._sfnode._name = NULL; + $$._sfnode._name = nullptr; } | MFNODE mfnodeValue { $$._mf = $2; } | IS IDENTIFIER { free($2); } @@ -461,15 +461,15 @@ void enterNode(const char *nodeType) { const VrmlNodeType *t = VrmlNodeType::find(nodeType); - if (t == NULL) { + if (t == nullptr) { char tmp[1000]; sprintf(tmp, "Unknown node type '%s'", nodeType); vrmlyyerror(tmp); } FieldRec *fr = new FieldRec; fr->nodeType = t; - fr->fieldName = NULL; - fr->typeRec = NULL; + fr->fieldName = nullptr; + fr->typeRec = nullptr; currentField.push(fr); VrmlNode *node = new VrmlNode(t); @@ -480,11 +480,11 @@ VrmlNode * exitNode() { FieldRec *fr = currentField.top(); - nassertr(fr != NULL, NULL); + nassertr(fr != nullptr, nullptr); currentField.pop(); VrmlNode *node = currentNode.top(); - nassertr(node != NULL, NULL); + nassertr(node != nullptr, nullptr); currentNode.pop(); // cerr << "Just defined node:\n" << *node << "\n\n"; @@ -497,7 +497,7 @@ void inScript() { FieldRec *fr = currentField.top(); - if (fr->nodeType == NULL || + if (fr->nodeType == nullptr || strcmp(fr->nodeType->getName(), "Script") != 0) { vrmlyyerror("interface declaration outside of Script or prototype"); } @@ -507,11 +507,11 @@ void enterField(const char *fieldName) { FieldRec *fr = currentField.top(); - nassertv(fr != NULL); + nassertv(fr != nullptr); fr->fieldName = fieldName; - fr->typeRec = NULL; - if (fr->nodeType != NULL) { + fr->typeRec = nullptr; + if (fr->nodeType != nullptr) { // enterField is called when parsing eventIn and eventOut IS // declarations, in which case we don't need to do anything special-- // the IS IDENTIFIER will be returned from the lexer normally. @@ -521,7 +521,7 @@ enterField(const char *fieldName) const VrmlNodeType::NameTypeRec *typeRec = fr->nodeType->hasField(fieldName); - if (typeRec != NULL) { + if (typeRec != nullptr) { fr->typeRec = typeRec; // Let the lexer know what field type to expect: expect(typeRec->type); @@ -539,12 +539,12 @@ enterField(const char *fieldName) void storeField(const VrmlFieldValue &value) { FieldRec *fr = currentField.top(); - nassertv(fr != NULL); + nassertv(fr != nullptr); VrmlNode *node = currentNode.top(); - nassertv(node != NULL); + nassertv(node != nullptr); - if (fr->typeRec != NULL) { + if (fr->typeRec != nullptr) { node->_fields.push_back(VrmlNode::Field(fr->typeRec, value)); } } @@ -553,10 +553,10 @@ void exitField() { FieldRec *fr = currentField.top(); - nassertv(fr != NULL); + nassertv(fr != nullptr); - fr->fieldName = NULL; - fr->typeRec = NULL; + fr->fieldName = nullptr; + fr->typeRec = nullptr; } void diff --git a/pandatool/src/vrmlegg/indexedFaceSet.cxx b/pandatool/src/vrmlegg/indexedFaceSet.cxx index 96b5cc9194..35e03857fc 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.cxx +++ b/pandatool/src/vrmlegg/indexedFaceSet.cxx @@ -65,7 +65,7 @@ void IndexedFaceSet:: get_coord_values() { const VrmlNode *coord = _geometry->get_value("coord")._sfnode._p; - if (coord != NULL) { + if (coord != nullptr) { const MFArray *point = coord->get_value("point")._mf; MFArray::const_iterator ci; for (ci = point->begin(); ci != point->end(); ++ci) { @@ -153,7 +153,7 @@ get_vrml_uvs(const VrmlNode *texCoord_node, bool IndexedFaceSet:: get_colors() { const VrmlNode *color = _geometry->get_value("color")._sfnode._p; - if (color != NULL) { + if (color != nullptr) { // Vertex or face colors. pvector color_list; get_vrml_colors(color, _appearance._transparency, color_list); @@ -223,7 +223,7 @@ get_colors() { bool IndexedFaceSet:: get_normals() { const VrmlNode *normal = _geometry->get_value("normal")._sfnode._p; - if (normal != NULL) { + if (normal != nullptr) { // Vertex or face normals. pvector normal_list; get_vrml_normals(normal, normal_list); @@ -375,7 +375,7 @@ assign_per_vertex_normals() { bool IndexedFaceSet:: get_uvs() { const VrmlNode *texCoord = _geometry->get_value("texCoord")._sfnode._p; - if (texCoord != NULL) { + if (texCoord != nullptr) { // Vertex or face texCoords. pvector uv_list; get_vrml_uvs(texCoord, uv_list); @@ -496,7 +496,7 @@ make_polys(EggVertexPool *vpool, EggGroup *group, poly->set_color(_appearance._color); } - if (_appearance._tex != (EggTexture *)NULL) { + if (_appearance._tex != nullptr) { poly->set_texture(_appearance._tex); } @@ -535,7 +535,7 @@ make_polys(EggVertexPool *vpool, EggGroup *group, void IndexedFaceSet:: compute_normals(EggGroup *group) { const VrmlNode *normal = _geometry->get_value("normal")._sfnode._p; - if (normal == NULL) { + if (normal == nullptr) { // Compute normals. double creaseAngle = _geometry->get_value("creaseAngle")._sffloat; if (creaseAngle == 0.0) { diff --git a/pandatool/src/vrmlegg/vrmlAppearance.cxx b/pandatool/src/vrmlegg/vrmlAppearance.cxx index fff1ec48f2..06f9186c33 100644 --- a/pandatool/src/vrmlegg/vrmlAppearance.cxx +++ b/pandatool/src/vrmlegg/vrmlAppearance.cxx @@ -22,9 +22,9 @@ VRMLAppearance(const VrmlNode *appearance) { _color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_tex_transform = false; - if (appearance != NULL) { + if (appearance != nullptr) { const VrmlNode *material = appearance->get_value("material")._sfnode._p; - if (material != NULL) { + if (material != nullptr) { _has_material = true; const double *c = material->get_value("diffuseColor")._sfvec; _transparency = material->get_value("transparency")._sffloat; @@ -32,7 +32,7 @@ VRMLAppearance(const VrmlNode *appearance) { } const VrmlNode *tex_transform = appearance->get_value("textureTransform")._sfnode._p; - if (tex_transform != NULL) { + if (tex_transform != nullptr) { if (strcmp(tex_transform->_type->getName(), "TextureTransform") == 0) { _has_tex_transform = true; const double *c = tex_transform->get_value("center")._sfvec; @@ -46,7 +46,7 @@ VRMLAppearance(const VrmlNode *appearance) { } const VrmlNode *texture = appearance->get_value("texture")._sfnode._p; - if (texture != NULL) { + if (texture != nullptr) { if (strcmp(texture->_type->getName(), "ImageTexture") == 0) { MFArray *url = texture->get_value("url")._mf; if (!url->empty()) { diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx index 4083fb0847..150cf6da4c 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx @@ -88,7 +88,7 @@ convert_file(const Filename &filename) { clear_error(); VrmlScene *scene = parse_vrml(filename); - if (scene == (VrmlScene *)NULL) { + if (scene == nullptr) { return false; } @@ -127,8 +127,8 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { switch (vrml._type) { case SFNodeRef::T_def: // If this is a node definition, add it to the map. - nassertv(vrml._name != NULL); - nassertv(vrml._p != NULL); + nassertv(vrml._name != nullptr); + nassertv(vrml._p != nullptr); /* This happens too often to bother yelling about it. ni = nodes.find(vrml._name); @@ -142,7 +142,7 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { case SFNodeRef::T_use: // If it's a reference, resolve it. - nassertv(vrml._name != NULL); + nassertv(vrml._name != nullptr); ni = nodes.find(vrml._name); if (ni == nodes.end()) { cerr << "Unknown node reference: " << vrml._name << "\n"; @@ -161,7 +161,7 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { } VrmlNode *node = vrml._p; - if (node != NULL) { + if (node != nullptr) { VrmlNode::Fields::iterator fi; for (fi = node->_fields.begin(); fi != node->_fields.end(); ++fi) { if ((*fi)._type->type == SFNODE) { @@ -185,7 +185,7 @@ void VRMLToEggConverter:: vrml_node(const SFNodeRef &vrml, EggGroupNode *egg, const LMatrix4d &net_transform) { const VrmlNode *node = vrml._p; - if (node != NULL) { + if (node != nullptr) { // Now add it to the egg file at this point. if (strcmp(node->_type->getName(), "Group") == 0) { vrml_grouping_node(vrml, egg, net_transform, @@ -213,9 +213,9 @@ vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, (const VrmlNode *node, EggGroup *group, const LMatrix4d &net_transform)) { const VrmlNode *node = vrml._p; - nassertv(node != NULL); + nassertv(node != nullptr); string name; - if (vrml._name != NULL) { + if (vrml._name != nullptr) { name = vrml._name; } @@ -369,7 +369,7 @@ vrml_shape(const VrmlNode *node, EggGroup *group, const LMatrix4d &net_transform) { const VrmlNode *geometry = node->get_value("geometry")._sfnode._p; - if (geometry != NULL) { + if (geometry != nullptr) { VRMLAppearance appearance(node->get_value("appearance")._sfnode._p); if (strcmp(geometry->_type->getName(), "IndexedFaceSet") == 0) { diff --git a/pandatool/src/vrmlprogs/vrmlTrans.cxx b/pandatool/src/vrmlprogs/vrmlTrans.cxx index e03075b0e5..48ed508b93 100644 --- a/pandatool/src/vrmlprogs/vrmlTrans.cxx +++ b/pandatool/src/vrmlprogs/vrmlTrans.cxx @@ -53,7 +53,7 @@ run() { nout << "Reading " << _input_filename << "\n"; VrmlScene *scene = parse_vrml(_input_filename); - if (scene == (VrmlScene *)NULL) { + if (scene == nullptr) { nout << "Unable to read.\n"; exit(1); } diff --git a/pandatool/src/win-stats/winStats.cxx b/pandatool/src/win-stats/winStats.cxx index 5c54535210..0b22e9e0d7 100644 --- a/pandatool/src/win-stats/winStats.cxx +++ b/pandatool/src/win-stats/winStats.cxx @@ -19,7 +19,7 @@ #include static const char *toplevel_class_name = "pstats"; -static WinStatsServer *server = NULL; +static WinStatsServer *server = nullptr; /** * @@ -69,7 +69,7 @@ create_toplevel_window(HINSTANCE application) { HWND toplevel_window = CreateWindow(toplevel_class_name, window_name.c_str(), window_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, application, 0); + nullptr, nullptr, application, 0); if (!toplevel_window) { nout << "Could not create toplevel window!\n"; exit(1); @@ -79,7 +79,7 @@ create_toplevel_window(HINSTANCE application) { } int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); HWND toplevel_window = create_toplevel_window(application); ShowWindow(toplevel_window, SW_SHOWMINIMIZED); @@ -99,12 +99,12 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { } // Set up a timer to poll the pstats every so often. - SetTimer(toplevel_window, 1, 200, NULL); + SetTimer(toplevel_window, 1, 200, nullptr); // Now get lost in the Windows message loop. MSG msg; int retval; - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); while (retval != 0) { if (retval == -1) { nout << "Error processing message queue.\n"; @@ -112,7 +112,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { } TranslateMessage(&msg); DispatchMessage(&msg); - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); } return (0); @@ -123,5 +123,5 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { // doesn't squelch the stderr output. int main(int argc, char *argv[]) { - return WinMain(NULL, NULL, NULL, 0); + return WinMain(nullptr, nullptr, nullptr, 0); } diff --git a/pandatool/src/win-stats/winStatsGraph.cxx b/pandatool/src/win-stats/winStatsGraph.cxx index 393f905909..6eb19583f6 100644 --- a/pandatool/src/win-stats/winStatsGraph.cxx +++ b/pandatool/src/win-stats/winStatsGraph.cxx @@ -30,8 +30,8 @@ WinStatsGraph(WinStatsMonitor *monitor) : { _window = 0; _graph_window = 0; - _sizewe_cursor = LoadCursor(NULL, IDC_SIZEWE); - _hand_cursor = LoadCursor(NULL, IDC_HAND); + _sizewe_cursor = LoadCursor(nullptr, IDC_SIZEWE); + _hand_cursor = LoadCursor(nullptr, IDC_HAND); _bitmap = 0; _bitmap_dc = 0; @@ -59,7 +59,7 @@ WinStatsGraph(WinStatsMonitor *monitor) : */ WinStatsGraph:: ~WinStatsGraph() { - _monitor = (WinStatsMonitor *)NULL; + _monitor = nullptr; release_bitmap(); DeleteObject(_dark_pen); @@ -142,8 +142,8 @@ set_pause(bool pause) { */ void WinStatsGraph:: user_guide_bars_changed() { - InvalidateRect(_window, NULL, TRUE); - InvalidateRect(_graph_window, NULL, TRUE); + InvalidateRect(_window, nullptr, TRUE); + InvalidateRect(_graph_window, nullptr, TRUE); } /** @@ -160,8 +160,8 @@ clicked_label(int collector_index) { void WinStatsGraph:: close() { WinStatsMonitor *monitor = _monitor; - _monitor = (WinStatsMonitor *)NULL; - if (monitor != (WinStatsMonitor *)NULL) { + _monitor = nullptr; + if (monitor != nullptr) { monitor->remove_graph(this); } } @@ -228,7 +228,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_SIZE: move_label_stack(); - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); break; case WM_SIZING: @@ -286,7 +286,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { int16_t x = LOWORD(lparam); _left_margin += (x - _drag_start_x); _drag_start_x = x; - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); move_label_stack(); return 0; @@ -294,7 +294,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { int16_t x = LOWORD(lparam); _right_margin += (_drag_start_x - x); _drag_start_x = x; - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); return 0; } break; @@ -505,7 +505,7 @@ create_graph_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_graph_window_class(application); string window_title = "graph"; @@ -514,7 +514,7 @@ create_graph_window() { _graph_window = CreateWindow(_graph_window_class_name, window_title.c_str(), window_style, 0, 0, 0, 0, - _window, NULL, application, 0); + _window, nullptr, application, 0); if (!_graph_window) { nout << "Could not create graph window!\n"; exit(1); @@ -539,9 +539,9 @@ register_graph_window_class(HINSTANCE application) { wc.style = CS_DBLCLKS; wc.lpfnWndProc = (WNDPROC)static_graph_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.hbrBackground = nullptr; + wc.lpszMenuName = nullptr; wc.lpszClassName = _graph_window_class_name; // Reserve space to associate the this pointer with the window. @@ -561,7 +561,7 @@ register_graph_window_class(HINSTANCE application) { LONG WINAPI WinStatsGraph:: static_graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsGraph *self = (WinStatsGraph *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsGraph *)NULL && self->_graph_window == hwnd) { + if (self != nullptr && self->_graph_window == hwnd) { return self->graph_window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsLabel.cxx b/pandatool/src/win-stats/winStatsLabel.cxx index 3886cb8e15..5cd744c501 100644 --- a/pandatool/src/win-stats/winStatsLabel.cxx +++ b/pandatool/src/win-stats/winStatsLabel.cxx @@ -175,7 +175,7 @@ void WinStatsLabel:: set_highlight(bool highlight) { if (_highlight != highlight) { _highlight = highlight; - InvalidateRect(_window, NULL, TRUE); + InvalidateRect(_window, nullptr, TRUE); } } @@ -194,7 +194,7 @@ void WinStatsLabel:: set_mouse_within(bool mouse_within) { if (_mouse_within != mouse_within) { _mouse_within = mouse_within; - InvalidateRect(_window, NULL, TRUE); + InvalidateRect(_window, nullptr, TRUE); } } @@ -207,13 +207,13 @@ create_window(HWND parent_window) { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); _window = CreateWindow(_window_class_name, _text.c_str(), WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0, - parent_window, NULL, application, 0); + parent_window, nullptr, application, 0); if (!_window) { nout << "Could not create Label window!\n"; exit(1); @@ -238,9 +238,9 @@ register_window_class(HINSTANCE application) { wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.hbrBackground = nullptr; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -260,7 +260,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsLabel:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsLabel *self = (WinStatsLabel *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsLabel *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsLabelStack.cxx b/pandatool/src/win-stats/winStatsLabelStack.cxx index c3d8404aa2..063a7780e8 100644 --- a/pandatool/src/win-stats/winStatsLabelStack.cxx +++ b/pandatool/src/win-stats/winStatsLabelStack.cxx @@ -235,13 +235,13 @@ create_window(HWND parent_window) { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); _window = CreateWindow(_window_class_name, "label stack", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 0, 0, - parent_window, NULL, application, 0); + parent_window, nullptr, application, 0); if (!_window) { nout << "Could not create Label Stack window!\n"; exit(1); @@ -266,8 +266,8 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.lpszMenuName = NULL; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -287,7 +287,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsLabelStack:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsLabelStack *self = (WinStatsLabelStack *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsLabelStack *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsMonitor.cxx b/pandatool/src/win-stats/winStatsMonitor.cxx index bb412050df..1b2cedee37 100644 --- a/pandatool/src/win-stats/winStatsMonitor.cxx +++ b/pandatool/src/win-stats/winStatsMonitor.cxx @@ -122,7 +122,7 @@ got_bad_version(int client_major, int client_minor, } string message = str.str(); - MessageBox(NULL, message.c_str(), "Bad version", + MessageBox(nullptr, message.c_str(), "Bad version", MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); } @@ -438,7 +438,7 @@ create_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); _menu_bar = CreateMenu(); @@ -459,7 +459,7 @@ create_window() { _window = CreateWindow(_window_class_name, _window_title.c_str(), window_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, _menu_bar, application, 0); + nullptr, _menu_bar, application, 0); if (!_window) { nout << "Could not create monitor window!\n"; exit(1); @@ -497,8 +497,8 @@ setup_options_menu() { mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE; mii.fType = MFT_STRING | MFT_RADIOCHECK; - mii.hbmpChecked = NULL; - mii.hbmpUnchecked = NULL; + mii.hbmpChecked = nullptr; + mii.hbmpUnchecked = nullptr; mii.fState = MFS_UNCHECKED; mii.wID = MI_time_ms; mii.dwTypeData = "ms"; @@ -531,8 +531,8 @@ setup_speed_menu() { mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE; mii.fType = MFT_STRING | MFT_RADIOCHECK; - mii.hbmpChecked = NULL; - mii.hbmpUnchecked = NULL; + mii.hbmpChecked = nullptr; + mii.hbmpUnchecked = nullptr; mii.fState = MFS_UNCHECKED; mii.wID = MI_speed_1; mii.dwTypeData = "1"; @@ -603,9 +603,9 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -625,7 +625,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsMonitor:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsMonitor *self = (WinStatsMonitor *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsMonitor *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsPianoRoll.cxx b/pandatool/src/win-stats/winStatsPianoRoll.cxx index ef61895a6c..7c81b65fdf 100644 --- a/pandatool/src/win-stats/winStatsPianoRoll.cxx +++ b/pandatool/src/win-stats/winStatsPianoRoll.cxx @@ -171,7 +171,7 @@ draw_bar(int row, int from_x, int to_x) { */ void WinStatsPianoRoll:: end_draw() { - InvalidateRect(_graph_window, NULL, FALSE); + InvalidateRect(_graph_window, nullptr, FALSE); } /** @@ -443,7 +443,7 @@ draw_guide_bar(HDC hdc, const PStatGraph::GuideBar &bar) { SelectObject(hdc, _dark_pen); break; } - MoveToEx(hdc, x, 0, NULL); + MoveToEx(hdc, x, 0, nullptr); LineTo(hdc, x, get_ysize()); } } @@ -497,7 +497,7 @@ create_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); const PStatClientData *client_data = @@ -520,7 +520,7 @@ create_window() { CW_USEDEFAULT, CW_USEDEFAULT, win_rect.right - win_rect.left, win_rect.bottom - win_rect.top, - WinStatsGraph::_monitor->get_window(), NULL, application, 0); + WinStatsGraph::_monitor->get_window(), nullptr, application, 0); if (!_window) { nout << "Could not create PianoRoll window!\n"; exit(1); @@ -550,9 +550,9 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -572,7 +572,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsPianoRoll:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsPianoRoll *self = (WinStatsPianoRoll *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsPianoRoll *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsStripChart.cxx b/pandatool/src/win-stats/winStatsStripChart.cxx index 066673aecd..79411a03d7 100644 --- a/pandatool/src/win-stats/winStatsStripChart.cxx +++ b/pandatool/src/win-stats/winStatsStripChart.cxx @@ -246,7 +246,7 @@ copy_region(int start_x, int end_x, int dest_x) { // Also shift the brush origin over, so we still get proper dithering. _brush_origin += (dest_x - start_x); - SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, NULL); + SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, nullptr); RECT rect = { dest_x, 0, dest_x + end_x - start_x, get_ysize() @@ -596,7 +596,7 @@ move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysiz _left_margin, _top_margin - _check_box_height - 1, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); - InvalidateRect(_smooth_check_box, NULL, TRUE); + InvalidateRect(_smooth_check_box, nullptr, TRUE); } } @@ -623,7 +623,7 @@ draw_guide_bar(HDC hdc, int from_x, int to_x, SelectObject(hdc, _dark_pen); break; } - MoveToEx(hdc, from_x, y, NULL); + MoveToEx(hdc, from_x, y, nullptr); LineTo(hdc, to_x + 1, y); } } @@ -684,7 +684,7 @@ create_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); string window_title = get_title_text(); @@ -703,7 +703,7 @@ create_window() { CW_USEDEFAULT, CW_USEDEFAULT, win_rect.right - win_rect.left, win_rect.bottom - win_rect.top, - WinStatsGraph::_monitor->get_window(), NULL, application, 0); + WinStatsGraph::_monitor->get_window(), nullptr, application, 0); if (!_window) { nout << "Could not create StripChart window!\n"; exit(1); @@ -716,7 +716,7 @@ create_window() { CreateWindow("BUTTON", "", WS_CHILD | BS_AUTOCHECKBOX, 0, 0, _check_box_width, _check_box_height, - _window, NULL, application, 0); + _window, nullptr, application, 0); // Ensure that the window is on top of the stack. SetWindowPos(_window, HWND_TOP, 0, 0, 0, 0, @@ -739,9 +739,9 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -761,7 +761,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsStripChart:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsStripChart *self = (WinStatsStripChart *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsStripChart *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/xfile/xFile.cxx b/pandatool/src/xfile/xFile.cxx index 26791ed403..17fc9f1e34 100644 --- a/pandatool/src/xfile/xFile.cxx +++ b/pandatool/src/xfile/xFile.cxx @@ -69,7 +69,7 @@ read(Filename filename) { filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { xfile_cat.error() << "Cannot open " << filename << " for reading.\n"; return false; @@ -123,7 +123,7 @@ read(istream &in, const string &filename) { */ bool XFile:: write(Filename filename) const { - ofstream out; + std::ofstream out; // We actually open the file to write in binary mode, to avoid the MS-DOS // newline characters (since Windows seems to do this too). @@ -171,17 +171,17 @@ write(ostream &out) const { */ XFileTemplate *XFile:: find_template(const string &name) const { - XFileTemplate *standard = (XFileTemplate *)NULL; + XFileTemplate *standard = nullptr; const XFile *standard_templates = get_standard_templates(); if (standard_templates != this) { standard = standard_templates->find_template(name); } XFileNode *child = find_child(name); - if (child != (XFileNode *)NULL && + if (child != nullptr && child->is_of_type(XFileTemplate::get_class_type())) { XFileTemplate *xtemplate = DCAST(XFileTemplate, child); - if (standard != (XFileTemplate *)NULL && xtemplate->matches(standard)) { + if (standard != nullptr && xtemplate->matches(standard)) { // If the template matches a standard template, return the standard // instead. The assumption is that code may expect a certain naming // scheme for the data elements of the standard template, so we want to @@ -200,7 +200,7 @@ find_template(const string &name) const { */ XFileTemplate *XFile:: find_template(const WindowsGuid &guid) const { - XFileTemplate *standard = (XFileTemplate *)NULL; + XFileTemplate *standard = nullptr; const XFile *standard_templates = get_standard_templates(); if (standard_templates != this) { standard = standard_templates->find_template(guid); @@ -211,7 +211,7 @@ find_template(const WindowsGuid &guid) const { if (gi != _nodes_by_guid.end() && (*gi).second->is_of_type(XFileTemplate::get_class_type())) { XFileTemplate *xtemplate = DCAST(XFileTemplate, (*gi).second); - if (standard != (XFileTemplate *)NULL && xtemplate->matches(standard)) { + if (standard != nullptr && xtemplate->matches(standard)) { // If the template matches a standard template, return the standard // instead. The assumption is that code may expect a certain naming // scheme for the data elements of the standard template, so we want to @@ -251,12 +251,12 @@ find_standard_template(const WindowsGuid &guid) { XFileDataNodeTemplate *XFile:: find_data_object(const string &name) const { XFileNode *child = find_descendent(name); - if (child != (XFileNode *)NULL && + if (child != nullptr && child->is_of_type(XFileDataNodeTemplate::get_class_type())) { return DCAST(XFileDataNodeTemplate, child); } - return NULL; + return nullptr; } /** @@ -272,7 +272,7 @@ find_data_object(const WindowsGuid &guid) const { return DCAST(XFileDataNodeTemplate, (*gi).second); } - return NULL; + return nullptr; } /** @@ -438,7 +438,7 @@ write_header(ostream &out) const { */ const XFile *XFile:: get_standard_templates() { - if (_standard_templates == (XFile *)NULL) { + if (_standard_templates == nullptr) { // The standardTemplates.x file has been compiled into this binary. // Extract it out. diff --git a/pandatool/src/xfile/xFileArrayDef.I b/pandatool/src/xfile/xFileArrayDef.I index bb06c75fb8..f231f0c6ba 100644 --- a/pandatool/src/xfile/xFileArrayDef.I +++ b/pandatool/src/xfile/xFileArrayDef.I @@ -17,7 +17,7 @@ INLINE XFileArrayDef:: XFileArrayDef(int fixed_size) : _fixed_size(fixed_size), - _dynamic_size(NULL) + _dynamic_size(nullptr) { } @@ -37,7 +37,7 @@ XFileArrayDef(XFileDataDef *dynamic_size) : */ INLINE bool XFileArrayDef:: is_fixed_size() const { - return (_dynamic_size == (XFileDataDef *)NULL); + return (_dynamic_size == nullptr); } /** @@ -55,6 +55,6 @@ get_fixed_size() const { */ INLINE XFileDataDef *XFileArrayDef:: get_dynamic_size() const { - nassertr(!is_fixed_size(), NULL); + nassertr(!is_fixed_size(), nullptr); return _dynamic_size; } diff --git a/pandatool/src/xfile/xFileArrayDef.cxx b/pandatool/src/xfile/xFileArrayDef.cxx index 7bde81d7e0..da5abf9f51 100644 --- a/pandatool/src/xfile/xFileArrayDef.cxx +++ b/pandatool/src/xfile/xFileArrayDef.cxx @@ -29,7 +29,7 @@ get_size(const XFileNode::PrevData &prev_data) const { XFileNode::PrevData::const_iterator pi; pi = prev_data.find(_dynamic_size); nassertr_always(pi != prev_data.end(), 0); - nassertr((*pi).second != (XFileDataObject *)NULL, 0); + nassertr((*pi).second != nullptr, 0); return (*pi).second->i(); } } diff --git a/pandatool/src/xfile/xFileDataDef.cxx b/pandatool/src/xfile/xFileDataDef.cxx index 4e47187b6a..6c133347ef 100644 --- a/pandatool/src/xfile/xFileDataDef.cxx +++ b/pandatool/src/xfile/xFileDataDef.cxx @@ -175,7 +175,7 @@ repack_data(XFileDataObject *object, break; } - if (data_value != (XFileDataObject *)NULL) { + if (data_value != nullptr) { object->add_element(data_value); prev_data[this] = data_value; } @@ -219,7 +219,7 @@ fill_zero_data(XFileDataObject *object) const { break; } - if (data_value != (XFileDataObject *)NULL) { + if (data_value != nullptr) { object->add_element(data_value); } @@ -270,13 +270,13 @@ PT(XFileDataObject) XFileDataDef:: unpack_integer_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { - nassertr(index < parse_data_list._list.size(), NULL); + nassertr(index < parse_data_list._list.size(), nullptr); const XFileParseData &parse_data = parse_data_list._list[index]; PT(XFileDataObject) data_value; if ((parse_data._parse_flags & XFileParseData::PF_int) != 0) { - nassertr(sub_index < parse_data._int_list.size(), NULL); + nassertr(sub_index < parse_data._int_list.size(), nullptr); int value = parse_data._int_list[sub_index]; data_value = new XFileDataObjectInteger(this, value); @@ -301,13 +301,13 @@ PT(XFileDataObject) XFileDataDef:: unpack_double_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { - nassertr(index < parse_data_list._list.size(), NULL); + nassertr(index < parse_data_list._list.size(), nullptr); const XFileParseData &parse_data = parse_data_list._list[index]; PT(XFileDataObject) data_value; if ((parse_data._parse_flags & XFileParseData::PF_double) != 0) { - nassertr(sub_index < parse_data._double_list.size(), NULL); + nassertr(sub_index < parse_data._double_list.size(), nullptr); double value = parse_data._double_list[sub_index]; data_value = new XFileDataObjectDouble(this, value); @@ -318,7 +318,7 @@ unpack_double_value(const XFileParseDataList &parse_data_list, } } else if ((parse_data._parse_flags & XFileParseData::PF_int) != 0) { - nassertr(sub_index < parse_data._int_list.size(), NULL); + nassertr(sub_index < parse_data._int_list.size(), nullptr); int value = parse_data._int_list[sub_index]; data_value = new XFileDataObjectDouble(this, value); @@ -343,7 +343,7 @@ PT(XFileDataObject) XFileDataDef:: unpack_string_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { - nassertr(index < parse_data_list._list.size(), NULL); + nassertr(index < parse_data_list._list.size(), nullptr); const XFileParseData &parse_data = parse_data_list._list[index]; PT(XFileDataObject) data_value; @@ -373,7 +373,7 @@ unpack_template_value(const XFileParseDataList &parse_data_list, PrevData nested_prev_data(prev_data); if (!_template->repack_data(data_value, parse_data_list, nested_prev_data, index, sub_index)) { - return NULL; + return nullptr; } return data_value.p(); @@ -394,7 +394,7 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, if (array_index == (int)_array_def.size()) { if (index >= parse_data_list._list.size()) { xyyerror("Not enough data elements in structure at " + get_name()); - return NULL; + return nullptr; } data_value = (this->*unpack_method)(parse_data_list, prev_data, index, sub_index); @@ -414,7 +414,7 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, unpack_value(parse_data_list, array_index + 1, prev_data, index, sub_index, unpack_method); - if (array_element == (XFileDataObject *)NULL) { + if (array_element == nullptr) { return data_value; } data_value->add_element(array_element); @@ -456,7 +456,7 @@ zero_fill_template_value() const { PT(XFileDataObject) data_value = new XFileDataNodeTemplate(get_x_file(), get_name(), _template); if (!_template->fill_zero_data(data_value)) { - return NULL; + return nullptr; } return data_value; @@ -485,8 +485,8 @@ zero_fill_value(int array_index, for (int i = 0; i < array_size; i++) { PT(XFileDataObject) array_element = zero_fill_value(array_index + 1, zero_fill_method); - if (array_element == (XFileDataObject *)NULL) { - return NULL; + if (array_element == nullptr) { + return nullptr; } data_value->add_element(array_element); } diff --git a/pandatool/src/xfile/xFileDataDef.h b/pandatool/src/xfile/xFileDataDef.h index 7d489ceafd..93d85c2b36 100644 --- a/pandatool/src/xfile/xFileDataDef.h +++ b/pandatool/src/xfile/xFileDataDef.h @@ -46,7 +46,7 @@ public: }; INLINE XFileDataDef(XFile *x_file, const string &name, - Type type, XFileTemplate *xtemplate = NULL); + Type type, XFileTemplate *xtemplate = nullptr); virtual ~XFileDataDef(); virtual void clear(); diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.cxx b/pandatool/src/xfile/xFileDataNodeTemplate.cxx index 1e0e153438..9f09cc0583 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.cxx +++ b/pandatool/src/xfile/xFileDataNodeTemplate.cxx @@ -205,7 +205,7 @@ get_num_elements() const { */ XFileDataObject *XFileDataNodeTemplate:: get_element(int n) { - nassertr(n >= 0 && n < (int)_nested_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_elements.size(), nullptr); return _nested_elements[n]; } @@ -222,5 +222,5 @@ get_element(const string &name) { xfile_cat.warning() << "\"" << name << "\" not a member of " << _template->get_name() << "\n"; - return NULL; + return nullptr; } diff --git a/pandatool/src/xfile/xFileDataObject.I b/pandatool/src/xfile/xFileDataObject.I index ebe25becc1..e68f383e1c 100644 --- a/pandatool/src/xfile/xFileDataObject.I +++ b/pandatool/src/xfile/xFileDataObject.I @@ -258,7 +258,7 @@ size() const { INLINE const XFileDataObject &XFileDataObject:: operator [] (int n) const { const XFileDataObject *element = ((XFileDataObject *)this)->get_element(n); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } @@ -270,7 +270,7 @@ operator [] (int n) const { INLINE const XFileDataObject &XFileDataObject:: operator [] (const string &name) const { const XFileDataObject *element = ((XFileDataObject *)this)->get_element(name); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } @@ -281,7 +281,7 @@ operator [] (const string &name) const { INLINE XFileDataObject &XFileDataObject:: operator [] (int n) { XFileDataObject *element = get_element(n); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } @@ -293,7 +293,7 @@ operator [] (int n) { INLINE XFileDataObject &XFileDataObject:: operator [] (const string &name) { XFileDataObject *element = get_element(name); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } diff --git a/pandatool/src/xfile/xFileDataObject.cxx b/pandatool/src/xfile/xFileDataObject.cxx index e170b901ea..5abfa1e9ab 100644 --- a/pandatool/src/xfile/xFileDataObject.cxx +++ b/pandatool/src/xfile/xFileDataObject.cxx @@ -93,7 +93,7 @@ add_string(const string &string_value) { XFileDataObject &XFileDataObject:: add_Vector(XFile *x_file, const LVecBase3d &vector) { XFileTemplate *xtemplate = XFile::find_standard_template("Vector"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -110,7 +110,7 @@ add_Vector(XFile *x_file, const LVecBase3d &vector) { XFileDataObject &XFileDataObject:: add_MeshFace(XFile *x_file) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshFace"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -125,7 +125,7 @@ add_MeshFace(XFile *x_file) { XFileDataObject &XFileDataObject:: add_IndexedColor(XFile *x_file, int index, const LColor &color) { XFileTemplate *xtemplate = XFile::find_standard_template("IndexedColor"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -143,7 +143,7 @@ add_IndexedColor(XFile *x_file, int index, const LColor &color) { XFileDataObject &XFileDataObject:: add_Coords2d(XFile *x_file, const LVecBase2d &coords) { XFileTemplate *xtemplate = XFile::find_standard_template("Coords2d"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -288,7 +288,7 @@ get_element(int n) { xfile_cat.warning() << "Looking for [" << n << "] within data object of type " << get_type_name() << ", does not support nested objects.\n"; - return NULL; + return nullptr; } /** @@ -300,5 +300,5 @@ get_element(const string &name) { xfile_cat.warning() << "Looking for [\"" << name << "\"] within data object of type " << get_type_name() << ", does not support nested objects.\n"; - return NULL; + return nullptr; } diff --git a/pandatool/src/xfile/xFileDataObject.h b/pandatool/src/xfile/xFileDataObject.h index ac7d8001f3..6b40c5f399 100644 --- a/pandatool/src/xfile/xFileDataObject.h +++ b/pandatool/src/xfile/xFileDataObject.h @@ -29,7 +29,7 @@ class XFileDataDef; */ class XFileDataObject : virtual public ReferenceCount { public: - INLINE XFileDataObject(const XFileDataDef *data_def = NULL); + INLINE XFileDataObject(const XFileDataDef *data_def = nullptr); virtual ~XFileDataObject(); INLINE const XFileDataDef *get_data_def() const; diff --git a/pandatool/src/xfile/xFileDataObjectArray.cxx b/pandatool/src/xfile/xFileDataObjectArray.cxx index 90d9948860..10aa13d5f2 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.cxx +++ b/pandatool/src/xfile/xFileDataObjectArray.cxx @@ -98,6 +98,6 @@ get_num_elements() const { */ XFileDataObject *XFileDataObjectArray:: get_element(int n) { - nassertr(n >= 0 && n < (int)_nested_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_elements.size(), nullptr); return _nested_elements[n]; } diff --git a/pandatool/src/xfile/xFileNode.I b/pandatool/src/xfile/xFileNode.I index b23bea089d..6032a749e2 100644 --- a/pandatool/src/xfile/xFileNode.I +++ b/pandatool/src/xfile/xFileNode.I @@ -34,7 +34,7 @@ get_num_children() const { */ INLINE XFileNode *XFileNode:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -55,6 +55,6 @@ get_num_objects() const { */ INLINE XFileDataNode *XFileNode:: get_object(int n) const { - nassertr(n >= 0 && n < (int)_objects.size(), NULL); + nassertr(n >= 0 && n < (int)_objects.size(), nullptr); return _objects[n]; } diff --git a/pandatool/src/xfile/xFileNode.cxx b/pandatool/src/xfile/xFileNode.cxx index 61d9d17d8f..a67c7488d0 100644 --- a/pandatool/src/xfile/xFileNode.cxx +++ b/pandatool/src/xfile/xFileNode.cxx @@ -57,7 +57,7 @@ find_child(const string &name) const { return get_child((*ni).second); } - return NULL; + return nullptr; } /** @@ -96,19 +96,19 @@ find_child_index(const XFileNode *child) const { XFileNode *XFileNode:: find_descendent(const string &name) const { XFileNode *child = find_child(name); - if (child != (XFileNode *)NULL) { + if (child != nullptr) { return child; } Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { XFileNode *child = (*ci)->find_descendent(name); - if (child != (XFileNode *)NULL){ + if (child != nullptr){ return child; } } - return NULL; + return nullptr; } /** @@ -297,7 +297,7 @@ matches(const XFileNode *other) const { XFileDataNode *XFileNode:: add_Mesh(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("Mesh"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -312,7 +312,7 @@ add_Mesh(const string &name) { XFileDataNode *XFileNode:: add_MeshNormals(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshNormals"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -327,7 +327,7 @@ add_MeshNormals(const string &name) { XFileDataNode *XFileNode:: add_MeshVertexColors(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshVertexColors"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -342,7 +342,7 @@ add_MeshVertexColors(const string &name) { XFileDataNode *XFileNode:: add_MeshTextureCoords(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshTextureCoords"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -357,7 +357,7 @@ add_MeshTextureCoords(const string &name) { XFileDataNode *XFileNode:: add_MeshMaterialList(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshMaterialList"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -374,7 +374,7 @@ add_Material(const string &name, const LColor &face_color, double power, const LRGBColor &specular_color, const LRGBColor &emissive_color) { XFileTemplate *xtemplate = XFile::find_standard_template("Material"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -401,7 +401,7 @@ add_Material(const string &name, const LColor &face_color, XFileDataNode *XFileNode:: add_TextureFilename(const string &name, const Filename &filename) { XFileTemplate *xtemplate = XFile::find_standard_template("TextureFilename"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -418,7 +418,7 @@ add_TextureFilename(const string &name, const Filename &filename) { XFileDataNode *XFileNode:: add_Frame(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("Frame"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -434,7 +434,7 @@ XFileDataNode *XFileNode:: add_FrameTransformMatrix(const LMatrix4d &mat) { XFileTemplate *xtemplate = XFile::find_standard_template("FrameTransformMatrix"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), "", xtemplate); add_child(node); diff --git a/pandatool/src/xfile/xFileTemplate.I b/pandatool/src/xfile/xFileTemplate.I index 3d7e52ec61..d56ff28984 100644 --- a/pandatool/src/xfile/xFileTemplate.I +++ b/pandatool/src/xfile/xFileTemplate.I @@ -65,6 +65,6 @@ get_num_options() const { */ INLINE XFileTemplate *XFileTemplate:: get_option(int n) const { - nassertr(n >= 0 && n < (int)_options.size(), NULL); + nassertr(n >= 0 && n < (int)_options.size(), nullptr); return _options[n]; } diff --git a/pandatool/src/xfile/xLexer.lxx b/pandatool/src/xfile/xLexer.lxx index e3d72709b0..614679ff34 100644 --- a/pandatool/src/xfile/xLexer.lxx +++ b/pandatool/src/xfile/xLexer.lxx @@ -34,7 +34,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the x file we're parsing. We keep it so we // can print it out for error messages. @@ -115,7 +115,7 @@ xyywarning(const string &msg) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -136,7 +136,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(x_current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } diff --git a/pandatool/src/xfile/xParser.yxx b/pandatool/src/xfile/xParser.yxx index a98f39d177..0f151c70ec 100644 --- a/pandatool/src/xfile/xParser.yxx +++ b/pandatool/src/xfile/xParser.yxx @@ -30,8 +30,8 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -static XFile *x_file = (XFile *)NULL; -static XFileNode *current_node = (XFileNode *)NULL; +static XFile *x_file = nullptr; +static XFileNode *current_node = nullptr; static PT(XFileDataDef) current_data_def; //////////////////////////////////////////////////////////////////// @@ -47,8 +47,8 @@ x_init_parser(istream &in, const string &filename, XFile &file) { void x_cleanup_parser() { - x_file = (XFile *)NULL; - current_node = (XFileNode *)NULL; + x_file = nullptr; + current_node = nullptr; } %} @@ -172,7 +172,7 @@ template_reference: singleword_name optional_multiword_name TOKEN_SEMICOLON { XFileTemplate *xtemplate = x_file->find_template($1); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { current_data_def = new XFileDataDef(x_file, $2, XFileDataDef::T_template, xtemplate); @@ -237,7 +237,7 @@ array_data_type: | singleword_name multiword_name { XFileTemplate *xtemplate = x_file->find_template($1); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { current_data_def = new XFileDataDef(x_file, $2, XFileDataDef::T_template, xtemplate); @@ -263,7 +263,7 @@ dimension_size: | multiword_name { XFileNode *data_def = current_node->find_child($1); - if (data_def == (XFileNode *)NULL) { + if (data_def == nullptr) { yyerror("Unknown identifier: " + $1); } else { current_data_def->add_array_def(XFileArrayDef(DCAST(XFileDataDef, data_def))); @@ -284,7 +284,7 @@ template_option_part: singleword_name { XFileTemplate *xtemplate = x_file->find_template($1); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { DCAST(XFileTemplate, current_node)->add_option(xtemplate); @@ -293,7 +293,7 @@ template_option_part: | singleword_name class_id { XFileTemplate *xtemplate = x_file->find_template($2); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { if (xtemplate->get_name() != $1) { @@ -351,7 +351,7 @@ object: XFileTemplate *xtemplate = x_file->find_template($1); $$ = current_node; - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { XFileDataNodeTemplate *templ = @@ -438,7 +438,7 @@ data_reference: multiword_name { XFileDataNodeTemplate *data_object = x_file->find_data_object($1); - if (data_object == (XFileDataObject *)NULL) { + if (data_object == nullptr) { yyerror("Unknown data_object: " + $1); } @@ -447,7 +447,7 @@ data_reference: | multiword_name class_id { XFileDataNodeTemplate *data_object = x_file->find_data_object($2); - if (data_object == (XFileDataObject *)NULL) { + if (data_object == nullptr) { yyerror("Unknown data_object: " + $1); } else { if (data_object->get_name() != $1) { diff --git a/pandatool/src/xfileegg/xFileAnimationSet.cxx b/pandatool/src/xfileegg/xFileAnimationSet.cxx index 25e9136c94..112b61ba12 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.cxx +++ b/pandatool/src/xfileegg/xFileAnimationSet.cxx @@ -63,7 +63,7 @@ create_hierarchy(XFileToEggConverter *converter) { const FrameData &table = (*ji).second; EggXfmSAnim *anim_table = get_table(joint_name); - if (anim_table == (EggXfmSAnim *)NULL) { + if (anim_table == nullptr) { xfile_cat.warning() << "Frame " << joint_name << ", named by animation data, not defined.\n"; } else { @@ -81,7 +81,7 @@ create_hierarchy(XFileToEggConverter *converter) { for (ti = _tables.begin(); ti != _tables.end(); ++ti) { EggXfmSAnim *anim_table = (*ti).second._table; EggGroup *joint = (*ti).second._joint; - if (anim_table->empty() && joint != (EggGroup *)NULL) { + if (anim_table->empty() && joint != nullptr) { // If there's no animation data, assign the rest transform. anim_table->add_data(joint->get_transform3d()); } @@ -104,7 +104,7 @@ get_table(const string &joint_name) const { if (ti != _tables.end()) { return (*ti).second._table; } - return NULL; + return nullptr; } /** diff --git a/pandatool/src/xfileegg/xFileMesh.cxx b/pandatool/src/xfileegg/xFileMesh.cxx index 7298ef118b..9ddf66bc0e 100644 --- a/pandatool/src/xfileegg/xFileMesh.cxx +++ b/pandatool/src/xfileegg/xFileMesh.cxx @@ -33,7 +33,7 @@ XFileMesh(CoordinateSystem cs) : _cs(cs) { _has_colors = false; _has_uvs = false; _has_materials = false; - _egg_parent = NULL; + _egg_parent = nullptr; } /** @@ -257,7 +257,7 @@ set_egg_parent(EggGroupNode *egg_parent) { */ bool XFileMesh:: create_polygons(XFileToEggConverter *converter) { - nassertr(_egg_parent != (EggGroupNode *)NULL, false); + nassertr(_egg_parent != nullptr, false); EggVertexPool *vpool = new EggVertexPool(get_name()); _egg_parent->add_child(vpool); @@ -279,7 +279,7 @@ create_polygons(XFileToEggConverter *converter) { continue; } XFileVertex *vertex = _vertices[vertex_index]; - XFileNormal *normal = (XFileNormal *)NULL; + XFileNormal *normal = nullptr; if (normal_index >= 0 && normal_index < (int)_normals.size()) { normal = _normals[normal_index]; @@ -299,7 +299,7 @@ create_polygons(XFileToEggConverter *converter) { temp_vtx.set_uv(uv); } - if (normal != (XFileNormal *)NULL && normal->_has_normal) { + if (normal != nullptr && normal->_has_normal) { temp_vtx.set_normal(normal->_normal); } @@ -318,7 +318,7 @@ create_polygons(XFileToEggConverter *converter) { WeightMap::const_iterator wmi = data._weight_map.find(vertex_index); if (wmi != data._weight_map.end()) { EggGroup *joint = converter->find_joint(data._joint_name); - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { double weight = (*wmi).second; LMatrix4d mat = data._matrix_offset; mat *= joint->get_node_to_vertex(); @@ -366,7 +366,7 @@ create_polygons(XFileToEggConverter *converter) { WeightMap::const_iterator wmi = data._weight_map.find(vertex_index); if (wmi != data._weight_map.end()) { EggGroup *joint = converter->find_joint(data._joint_name); - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { double weight = (*wmi).second; joint->ref_vertex(egg_vtx, weight); } @@ -433,7 +433,7 @@ get_num_materials() const { */ XFileMaterial *XFileMesh:: get_material(int n) const { - nassertr(n >= 0 && n < (int)_materials.size(), (XFileMaterial *)NULL); + nassertr(n >= 0 && n < (int)_materials.size(), nullptr); return _materials[n]; } diff --git a/pandatool/src/xfileegg/xFileToEggConverter.cxx b/pandatool/src/xfileegg/xFileToEggConverter.cxx index 5b1c6459af..2f65643c0f 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.cxx +++ b/pandatool/src/xfileegg/xFileToEggConverter.cxx @@ -34,7 +34,7 @@ XFileToEggConverter() { _make_char = false; _frame_rate = 0.0; _x_file = new XFile(true); - _dart_node = NULL; + _dart_node = nullptr; } /** @@ -46,7 +46,7 @@ XFileToEggConverter(const XFileToEggConverter ©) : _make_char(copy._make_char) { _x_file = new XFile(true); - _dart_node = NULL; + _dart_node = nullptr; } /** @@ -226,9 +226,9 @@ find_joint(const string &joint_name) { ji = _joints.find(joint_name); if (ji != _joints.end()) { EggGroup *joint = (*ji).second; - if (joint == (EggGroup *)NULL) { + if (joint == nullptr) { // An invalid joint detected earlier. - return NULL; + return nullptr; } return joint; @@ -240,9 +240,9 @@ find_joint(const string &joint_name) { xfile_cat.warning() << "Joint name " << joint_name << " in animation data is undefined.\n"; } - _joints[joint_name] = NULL; + _joints[joint_name] = nullptr; - return NULL; + return nullptr; } /** diff --git a/pandatool/src/xfileprogs/xFileToEgg.cxx b/pandatool/src/xfileprogs/xFileToEgg.cxx index fd0c90e77a..d3734fa803 100644 --- a/pandatool/src/xfileprogs/xFileToEgg.cxx +++ b/pandatool/src/xfileprogs/xFileToEgg.cxx @@ -51,7 +51,7 @@ XFileToEgg() : "Specify the frame rate of the resulting animation. If this is " "omitted or 0, the frame rate is inferred from the file itself; but " "note that the file must contain evenly-spaced keyframes.", - &XFileToEgg::dispatch_double, NULL, &_frame_rate); + &XFileToEgg::dispatch_double, nullptr, &_frame_rate); add_option ("anim", "", 0, diff --git a/tests/display/conftest.py b/tests/display/conftest.py index 88a2b5f3c3..36d498b9a3 100644 --- a/tests/display/conftest.py +++ b/tests/display/conftest.py @@ -68,7 +68,9 @@ def gsg(graphics_pipe, graphics_engine): ) graphics_engine.open_windows() - assert buffer is not None + if buffer is None: + pytest.skip("GraphicsPipe cannot make offscreen buffers") + yield buffer.gsg if buffer is not None: diff --git a/tests/putil/test_bitmask.py b/tests/putil/test_bitmask.py new file mode 100644 index 0000000000..e87984cac1 --- /dev/null +++ b/tests/putil/test_bitmask.py @@ -0,0 +1,10 @@ +from panda3d import core + + +def test_bitmask_allon(): + assert core.BitMask16.all_on().is_all_on() + assert core.BitMask32.all_on().is_all_on() + assert core.BitMask64.all_on().is_all_on() + assert core.DoubleBitMaskNative.all_on().is_all_on() + assert core.QuadBitMaskNative.all_on().is_all_on() + assert core.BitArray.all_on().is_all_on()