Преглед изворни кода

general: Replace NULL (and 0 as pointer) with C++11 nullptr

Exceptions to this replacement are:
- .c files
- Headers included by a .c file
- stb_image.h
- dr_flac.h
- Strings
- Comments
Sam Edwards пре 7 година
родитељ
комит
e2b4353800
100 измењених фајлова са 1899 додато и 1899 уклоњено
  1. 47 47
      contrib/src/ai/aiBehaviors.cxx
  2. 3 3
      contrib/src/ai/aiNode.cxx
  3. 3 3
      contrib/src/ai/aiPathFinder.cxx
  4. 2 2
      contrib/src/ai/aiWorld.cxx
  5. 3 3
      contrib/src/ai/arrival.cxx
  6. 3 3
      contrib/src/ai/meshNode.cxx
  7. 15 15
      contrib/src/ai/pathFind.cxx
  8. 2 2
      direct/src/dcparse/dcparse.cxx
  9. 5 5
      direct/src/dcparser/dcArrayParameter.cxx
  10. 4 4
      direct/src/dcparser/dcAtomicField.cxx
  11. 44 44
      direct/src/dcparser/dcClass.cxx
  12. 2 2
      direct/src/dcparser/dcClassParameter.cxx
  13. 4 4
      direct/src/dcparser/dcDeclaration.cxx
  14. 22 22
      direct/src/dcparser/dcField.cxx
  15. 12 12
      direct/src/dcparser/dcFile.cxx
  16. 2 2
      direct/src/dcparser/dcKeywordList.cxx
  17. 5 5
      direct/src/dcparser/dcLexer.lxx
  18. 2 2
      direct/src/dcparser/dcMolecularField.cxx
  19. 4 4
      direct/src/dcparser/dcPackData.I
  20. 1 1
      direct/src/dcparser/dcPackData.cxx
  21. 40 40
      direct/src/dcparser/dcPacker.I
  22. 74 74
      direct/src/dcparser/dcPacker.cxx
  23. 12 12
      direct/src/dcparser/dcPackerCatalog.cxx
  24. 14 14
      direct/src/dcparser/dcPackerInterface.cxx
  25. 1 1
      direct/src/dcparser/dcPackerInterface.h
  26. 9 9
      direct/src/dcparser/dcParameter.cxx
  27. 57 57
      direct/src/dcparser/dcParser.yxx
  28. 6 6
      direct/src/dcparser/dcSimpleParameter.cxx
  29. 25 25
      direct/src/dcparser/dcSwitch.cxx
  30. 3 3
      direct/src/dcparser/dcSwitchParameter.cxx
  31. 3 3
      direct/src/directd/directd.cxx
  32. 39 39
      direct/src/distributed/cConnectionRepository.cxx
  33. 6 6
      direct/src/distributed/cDistributedSmoothNodeBase.cxx
  34. 11 11
      direct/src/interval/cIntervalManager.cxx
  35. 5 5
      direct/src/interval/cLerpNodePathInterval.cxx
  36. 2 2
      direct/src/interval/cMetaInterval.I
  37. 2 2
      direct/src/interval/cMetaInterval.cxx
  38. 7 7
      direct/src/motiontrail/cMotionTrail.cxx
  39. 19 19
      direct/src/plugin/binaryXml.cxx
  40. 13 13
      direct/src/plugin/fileSpec.cxx
  41. 14 14
      direct/src/plugin/find_root_dir.cxx
  42. 4 4
      direct/src/plugin/handleStreamBuf.cxx
  43. 89 89
      direct/src/plugin/load_plugin.cxx
  44. 4 4
      direct/src/plugin/mkdir_complete.cxx
  45. 15 15
      direct/src/plugin/p3dAuthSession.cxx
  46. 1 1
      direct/src/plugin/p3dCInstance.cxx
  47. 48 48
      direct/src/plugin/p3dCert.cxx
  48. 37 37
      direct/src/plugin/p3dCert_wx.cxx
  49. 4 4
      direct/src/plugin/p3dConcreteSequence.cxx
  50. 5 5
      direct/src/plugin/p3dConcreteStruct.cxx
  51. 3 3
      direct/src/plugin/p3dConditionVar.cxx
  52. 3 3
      direct/src/plugin/p3dDownload.cxx
  53. 3 3
      direct/src/plugin/p3dFileParams.cxx
  54. 1 1
      direct/src/plugin/p3dHost.I
  55. 47 47
      direct/src/plugin/p3dHost.cxx
  56. 4 4
      direct/src/plugin/p3dInstance.I
  57. 170 170
      direct/src/plugin/p3dInstance.cxx
  58. 41 41
      direct/src/plugin/p3dInstanceManager.cxx
  59. 27 27
      direct/src/plugin/p3dMainObject.cxx
  60. 8 8
      direct/src/plugin/p3dMultifileReader.cxx
  61. 14 14
      direct/src/plugin/p3dObject.cxx
  62. 5 5
      direct/src/plugin/p3dOsxSplashWindow.I
  63. 39 39
      direct/src/plugin/p3dOsxSplashWindow.cxx
  64. 58 58
      direct/src/plugin/p3dPackage.cxx
  65. 24 24
      direct/src/plugin/p3dPatchFinder.cxx
  66. 9 9
      direct/src/plugin/p3dPythonMain.cxx
  67. 21 21
      direct/src/plugin/p3dPythonObject.cxx
  68. 123 123
      direct/src/plugin/p3dPythonRun.cxx
  69. 51 51
      direct/src/plugin/p3dSession.cxx
  70. 3 3
      direct/src/plugin/p3dSplashWindow.cxx
  71. 1 1
      direct/src/plugin/p3dWinSplashWindow.I
  72. 46 46
      direct/src/plugin/p3dWinSplashWindow.cxx
  73. 26 26
      direct/src/plugin/p3dX11SplashWindow.cxx
  74. 5 5
      direct/src/plugin/p3d_lock.h
  75. 33 33
      direct/src/plugin/p3d_plugin.cxx
  76. 1 1
      direct/src/plugin/p3d_plugin.h
  77. 1 1
      direct/src/plugin/p3d_plugin_common.h
  78. 1 1
      direct/src/plugin/run_p3dpython.cxx
  79. 3 3
      direct/src/plugin/wstring_encode.cxx
  80. 1 1
      direct/src/plugin/xml_helpers.cxx
  81. 4 4
      direct/src/plugin_activex/PPDownloadRequest.h
  82. 2 2
      direct/src/plugin_npapi/npruntime.h
  83. 10 10
      direct/src/plugin_npapi/ppBrowserObject.cxx
  84. 1 1
      direct/src/plugin_npapi/ppInstance.I
  85. 125 125
      direct/src/plugin_npapi/ppInstance.cxx
  86. 1 1
      direct/src/plugin_npapi/ppPandaObject.I
  87. 17 17
      direct/src/plugin_npapi/ppPandaObject.cxx
  88. 6 6
      direct/src/plugin_npapi/ppToplevelObject.cxx
  89. 17 17
      direct/src/plugin_npapi/startup.cxx
  90. 2 2
      direct/src/plugin_standalone/p3dEmbed.cxx
  91. 21 21
      direct/src/plugin_standalone/panda3d.cxx
  92. 25 25
      direct/src/plugin_standalone/panda3dBase.cxx
  93. 2 2
      direct/src/plugin_standalone/panda3dMac.cxx
  94. 10 10
      dtool/src/cppparser/cppArrayType.cxx
  95. 116 116
      dtool/src/cppparser/cppBison.yxx
  96. 5 5
      dtool/src/cppparser/cppClassTemplateParameter.cxx
  97. 1 1
      dtool/src/cppparser/cppClassTemplateParameter.h
  98. 4 4
      dtool/src/cppparser/cppClosureType.cxx
  99. 1 1
      dtool/src/cppparser/cppClosureType.h
  100. 3 3
      dtool/src/cppparser/cppConstType.cxx

+ 47 - 47
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;
               }

+ 3 - 3
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() {

+ 3 - 3
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;
 }

+ 2 - 2
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;

+ 3 - 3
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");

+ 3 - 3
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() {

+ 15 - 15
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;
 }
 
@@ -58,7 +58,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
     for(int r = 0; r < _grid_size; ++r) {
       _nav_mesh.push_back(std::vector<Node*>());
       for(int c = 0; c < _grid_size; ++c) {
-        _nav_mesh[r].push_back(NULL);
+        _nav_mesh[r].push_back(nullptr);
       }
     }
 
@@ -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!"<<endl;
@@ -183,7 +183,7 @@ void PathFind::set_path_find(const char* navmesh_filename) {
 
   if(_path_finder_obj) {
     delete _path_finder_obj;
-    _path_finder_obj = NULL;
+    _path_finder_obj = nullptr;
   }
 
   _path_finder_obj = new PathFinder(_nav_mesh);
@@ -207,17 +207,17 @@ void PathFind::path_find(LVecBase3 pos, 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"<<endl;
   }
 
   Node* dst = find_in_mesh(_nav_mesh, pos, _grid_size);
 
-  if(dst == NULL) {
+  if(dst == nullptr) {
     cout<<"couldnt find destination"<<endl;
   }
 
-  if(src != NULL && dst != NULL) {
+  if(src != nullptr && dst != nullptr) {
     _path_finder_obj->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"<<endl;
   }
 
   Node* dst = find_in_mesh(_nav_mesh, _prev_position, _grid_size);
 
-  if(dst == NULL) {
+  if(dst == nullptr) {
     cout<<"couldnt find destination"<<endl;
   }
 
-  if(src != NULL && dst != NULL) {
+  if(src != nullptr && dst != nullptr) {
     _path_finder_obj->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;

+ 2 - 2
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 << "()";
       }

+ 5 - 5
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;
   }

+ 4 - 4
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];
 }
 

+ 44 - 44
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);

+ 2 - 2
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 {

+ 4 - 4
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;
 }
 
 /**

+ 22 - 22
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

+ 12 - 12
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);

+ 2 - 2
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;
 }
 
 /**

+ 5 - 5
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;
     }

+ 2 - 2
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];
 }
 

+ 4 - 4
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;
 

+ 1 - 1
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;

+ 40 - 40
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;

+ 74 - 74
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();

+ 12 - 12
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 &copy) :
   _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 &copy) :
  */
 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);
     }
   }

+ 14 - 14
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 &copy) :
   _num_nested_fields(copy._num_nested_fields),
   _pack_type(copy._pack_type)
 {
-  _catalog = NULL;
+  _catalog = nullptr;
 }
 
 /**
@@ -58,7 +58,7 @@ DCPackerInterface(const DCPackerInterface &copy) :
  */
 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);
 }

+ 1 - 1
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);

+ 9 - 9
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;
 }
 
 /**

+ 57 - 57
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());
     }

+ 6 - 6
direct/src/dcparser/dcSimpleParameter.cxx

@@ -21,7 +21,7 @@
 #include <math.h>
 
 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);

+ 25 - 25
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];
 }
 

+ 3 - 3
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 {

+ 3 - 3
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

+ 39 - 39
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);
@@ -915,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));
@@ -952,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);
@@ -969,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);
@@ -985,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";
 
@@ -993,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 {

+ 6 - 6
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 {

+ 11 - 11
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;
   }

+ 5 - 5
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 {

+ 2 - 2
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;
 }
 

+ 2 - 2
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);

+ 7 - 7
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;
   }
 }

+ 19 - 19
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
 

+ 13 - 13
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 &copy) :
   _got_hash(copy._got_hash)
 {
   memcpy(_hash, copy._hash, hash_size);
-  _actual_file = NULL;
+  _actual_file = nullptr;
 }
 
 /**
@@ -76,7 +76,7 @@ operator = (const FileSpec &copy) {
  */
 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;

+ 14 - 14
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 <config> 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);
 

+ 4 - 4
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();

+ 89 - 89
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 ||
-
-      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_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_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) {
+  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 == 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 == 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 == 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_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_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_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_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 = 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 = 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 = 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;
 }

+ 4 - 4
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

+ 15 - 15
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(),

+ 1 - 1
direct/src/plugin/p3dCInstance.cxx

@@ -19,7 +19,7 @@
  */
 P3DCInstance::
 P3DCInstance(TiXmlElement *xinstance) :
-  _func(NULL)
+  _func(nullptr)
 {
   xinstance->Attribute("instance_id", &_instance_id);
 }

+ 48 - 48
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);

+ 37 - 37
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);

+ 4 - 4
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.

+ 5 - 5
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;

+ 3 - 3
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;

+ 3 - 3
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 &copy) :
 
   _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() << ": ";

+ 3 - 3
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);

+ 1 - 1
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);
 }
 
 /**

+ 47 - 47
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;

+ 4 - 4
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;
   }
 }

Разлика између датотеке није приказан због своје велике величине
+ 170 - 170
direct/src/plugin/p3dInstance.cxx


+ 41 - 41
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<string>::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<string> &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;
     }

+ 27 - 27
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") {

+ 8 - 8
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();

+ 14 - 14
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);

+ 5 - 5
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;
 }
 
 /**

+ 39 - 39
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;
   }
 }
 

+ 58 - 58
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 <package>\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 {

+ 24 - 24
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);

+ 9 - 9
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";
   }

+ 21 - 21
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);
   }

+ 123 - 123
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 <value> 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;
         }

+ 51 - 51
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;

+ 3 - 3
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();
 }

+ 1 - 1
direct/src/plugin/p3dWinSplashWindow.I

@@ -17,7 +17,7 @@
 inline P3DWinSplashWindow::WinImageData::
 WinImageData() {
   _filename_changed = false;
-  _bitmap = NULL;
+  _bitmap = nullptr;
 }
 
 /**

+ 46 - 46
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;
   }
 }
 

+ 26 - 26
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;
 

+ 5 - 5
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

+ 33 - 33
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);
   }
 

+ 1 - 1
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

+ 1 - 1
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);

+ 1 - 1
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;
 }

+ 3 - 3
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(),

+ 1 - 1
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;
   }
 

+ 4 - 4
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 )
     {
     }

+ 2 - 2
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)                                        \

+ 10 - 10
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();

+ 1 - 1
direct/src/plugin_npapi/ppInstance.I

@@ -27,5 +27,5 @@ get_window() const {
   if (_got_window) {
     return &_window;
   }
-  return NULL;
+  return nullptr;
 }

+ 125 - 125
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<string> &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);
 

+ 1 - 1
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;

+ 17 - 17
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;

+ 6 - 6
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;
   }

+ 17 - 17
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;

+ 2 - 2
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;

+ 21 - 21
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);
 

+ 25 - 25
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;
 }

+ 2 - 2
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.

+ 10 - 10
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;
   }
 

+ 116 - 116
dtool/src/cppparser/cppBison.yxx

@@ -36,15 +36,15 @@
 // 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 CPPType *current_type = nullptr;
+static CPPExpression *current_expr = nullptr;
 static int publish_nest_level = 0;
 static CPPVisibility publish_previous;
 static YYLTYPE publish_loc;
@@ -118,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();
 
@@ -142,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();
 
@@ -159,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;
   }
 }
@@ -652,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);
@@ -688,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);
@@ -890,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(),
@@ -1070,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));
@@ -1079,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);
@@ -1087,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);
@@ -1144,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);
@@ -1269,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);
@@ -1287,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);
@@ -1301,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();
   }
 
@@ -1322,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);
@@ -1332,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");
@@ -1360,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;
   }
 }
         ;
@@ -1626,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);
 }
         ;
@@ -1645,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
 {
@@ -1657,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);
 }
@@ -1706,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);
 }
         ;
 
@@ -1733,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);
@@ -1748,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());
@@ -1832,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;
@@ -1849,7 +1849,7 @@ instance_identifier_and_maybe_trailing_return_type:
 maybe_trailing_return_type:
         empty
 {
-  $$ = NULL;
+  $$ = nullptr;
 }
         | POINTSAT predefined_type empty_instance_identifier
 {
@@ -1866,7 +1866,7 @@ maybe_trailing_return_type:
 maybe_comma_identifier:
         empty
 {
-  $$ = NULL;
+  $$ = nullptr;
 }
         | ',' IDENTIFIER
 {
@@ -1956,7 +1956,7 @@ formal_parameters:
 template_parameter_maybe_initialize:
         empty
 {
-  $$ = (CPPExpression *)NULL;
+  $$ = nullptr;
 }
         | '=' no_angle_bracket_const_expr
 {
@@ -1967,7 +1967,7 @@ template_parameter_maybe_initialize:
 maybe_initialize:
         empty
 {
-  $$ = (CPPExpression *)NULL;
+  $$ = nullptr;
 }
         | '=' const_expr
 {
@@ -1978,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 ';'
 {
@@ -2001,11 +2001,11 @@ maybe_initialize_or_constructor_body:
 maybe_initialize_or_function_body:
         ';'
 {
-  $$ = (CPPExpression *)NULL;
+  $$ = nullptr;
 }
         | '{' code '}'
 {
-  $$ = (CPPExpression *)NULL;
+  $$ = nullptr;
 }
         | '=' const_expr ';'
 {
@@ -2021,7 +2021,7 @@ maybe_initialize_or_function_body:
 }
         | '=' '{' structure_init '}'
 {
-  $$ = (CPPExpression *)NULL;
+  $$ = nullptr;
 }
         ;
 
@@ -2106,7 +2106,7 @@ formal_parameter:
 not_paren_formal_parameter_identifier:
         empty
 {
-  $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL);
+  $$ = new CPPInstanceIdentifier(nullptr);
 }
         | name_no_final
 {
@@ -2152,7 +2152,7 @@ not_paren_formal_parameter_identifier:
 formal_parameter_identifier:
         empty
 {
-  $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL);
+  $$ = new CPPInstanceIdentifier(nullptr);
 }
         | name_no_final
 {
@@ -2209,7 +2209,7 @@ formal_parameter_identifier:
 parameter_pack_identifier:
         ELLIPSIS
 {
-  $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL);
+  $$ = new CPPInstanceIdentifier(nullptr);
   $$->_packed = true;
 }
         | ELLIPSIS name
@@ -2268,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
@@ -2320,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
@@ -2369,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);
 }
@@ -2404,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
 {
@@ -2428,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;
@@ -2444,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;
@@ -2460,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);
@@ -2473,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 {
@@ -2490,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);
 }
         ;
 
@@ -2505,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
 {
@@ -2529,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;
@@ -2545,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;
@@ -2563,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;
@@ -2579,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);
@@ -2592,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 {
@@ -2613,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
 {
@@ -2625,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;
@@ -2641,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;
@@ -2657,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);
@@ -2666,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 {
@@ -2727,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);
 
@@ -2750,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(),
@@ -2838,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
 {
@@ -2878,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);
 };
 
@@ -2891,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);
 }
         ;
@@ -2935,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);
@@ -2957,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);
@@ -3165,7 +3165,7 @@ element:
 optional_const_expr:
         empty
 {
-  $$ = (CPPExpression *)NULL;
+  $$ = nullptr;
 }
         | const_expr
 {
@@ -3176,7 +3176,7 @@ optional_const_expr:
 optional_const_expr_comma:
         empty
 {
-  $$ = (CPPExpression *)NULL;
+  $$ = nullptr;
 }
         | const_expr_comma
 {
@@ -3227,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();
@@ -3392,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 ')'
@@ -3491,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();
@@ -3835,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();
@@ -4123,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;

+ 5 - 5
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;
   }
 

+ 1 - 1
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,

+ 4 - 4
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);
   }

+ 1 - 1
dtool/src/cppparser/cppClosureType.h

@@ -44,7 +44,7 @@ public:
 
   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;
 

+ 3 - 3
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;
 }

Неке датотеке нису приказане због велике количине промена