Browse Source

Merge remote-tracking branch 'origin/master' into deploy-ng

Mitchell Stokes 7 years ago
parent
commit
e4cf73378c
100 changed files with 935 additions and 948 deletions
  1. 1 0
      .gitignore
  2. 51 47
      contrib/src/ai/aiBehaviors.cxx
  3. 15 15
      contrib/src/ai/aiBehaviors.h
  4. 4 1
      contrib/src/ai/aiCharacter.cxx
  5. 4 3
      contrib/src/ai/aiCharacter.h
  6. 3 3
      contrib/src/ai/aiNode.cxx
  7. 4 4
      contrib/src/ai/aiPathFinder.cxx
  8. 4 4
      contrib/src/ai/aiPathFinder.h
  9. 33 105
      contrib/src/ai/aiWorld.cxx
  10. 5 25
      contrib/src/ai/aiWorld.h
  11. 4 4
      contrib/src/ai/arrival.cxx
  12. 1 1
      contrib/src/ai/flock.h
  13. 3 3
      contrib/src/ai/meshNode.cxx
  14. 0 1
      contrib/src/ai/obstacleAvoidance.cxx
  15. 25 21
      contrib/src/ai/pathFind.cxx
  16. 4 4
      contrib/src/ai/pathFind.h
  17. 1 1
      contrib/src/ai/pathFollow.cxx
  18. 3 3
      contrib/src/ai/pathFollow.h
  19. 1 1
      contrib/src/rplight/gpuCommand.I
  20. 4 4
      contrib/src/rplight/gpuCommand.cxx
  21. 1 1
      contrib/src/rplight/gpuCommand.h
  22. 1 1
      contrib/src/rplight/gpuCommandList.h
  23. 4 2
      contrib/src/rplight/iesDataset.cxx
  24. 5 3
      contrib/src/rplight/internalLightManager.cxx
  25. 3 2
      contrib/src/rplight/pointerSlotStorage.h
  26. 2 0
      contrib/src/rplight/pssmCameraRig.cxx
  27. 3 3
      contrib/src/rplight/pssmCameraRig.h
  28. 2 2
      contrib/src/rplight/rpLight.I
  29. 2 2
      contrib/src/rplight/rpLight.h
  30. 2 0
      contrib/src/rplight/rpSpotLight.cxx
  31. 1 1
      contrib/src/rplight/shadowAtlas.I
  32. 6 6
      contrib/src/rplight/shadowAtlas.cxx
  33. 2 2
      contrib/src/rplight/shadowManager.I
  34. 5 5
      contrib/src/rplight/tagStateManager.I
  35. 3 1
      contrib/src/rplight/tagStateManager.cxx
  36. 10 10
      contrib/src/rplight/tagStateManager.h
  37. 5 2
      direct/src/dcparse/dcparse.cxx
  38. 9 7
      direct/src/dcparser/dcArrayParameter.cxx
  39. 4 4
      direct/src/dcparser/dcArrayParameter.h
  40. 9 7
      direct/src/dcparser/dcAtomicField.cxx
  41. 6 6
      direct/src/dcparser/dcAtomicField.h
  42. 1 1
      direct/src/dcparser/dcClass.I
  43. 51 47
      direct/src/dcparser/dcClass.cxx
  44. 17 17
      direct/src/dcparser/dcClass.h
  45. 4 4
      direct/src/dcparser/dcClassParameter.cxx
  46. 2 2
      direct/src/dcparser/dcClassParameter.h
  47. 6 6
      direct/src/dcparser/dcDeclaration.cxx
  48. 5 5
      direct/src/dcparser/dcDeclaration.h
  49. 4 4
      direct/src/dcparser/dcField.I
  50. 28 26
      direct/src/dcparser/dcField.cxx
  51. 14 14
      direct/src/dcparser/dcField.h
  52. 18 15
      direct/src/dcparser/dcFile.cxx
  53. 15 15
      direct/src/dcparser/dcFile.h
  54. 4 4
      direct/src/dcparser/dcKeyword.cxx
  55. 5 5
      direct/src/dcparser/dcKeyword.h
  56. 5 5
      direct/src/dcparser/dcKeywordList.cxx
  57. 4 4
      direct/src/dcparser/dcKeywordList.h
  58. 17 13
      direct/src/dcparser/dcLexer.cxx.prebuilt
  59. 21 17
      direct/src/dcparser/dcLexer.lxx
  60. 3 3
      direct/src/dcparser/dcLexerDefs.h
  61. 5 5
      direct/src/dcparser/dcMolecularField.cxx
  62. 3 3
      direct/src/dcparser/dcMolecularField.h
  63. 15 15
      direct/src/dcparser/dcNumericRange.I
  64. 4 4
      direct/src/dcparser/dcNumericRange.h
  65. 6 6
      direct/src/dcparser/dcPackData.I
  66. 1 1
      direct/src/dcparser/dcPackData.cxx
  67. 1 1
      direct/src/dcparser/dcPackData.h
  68. 59 59
      direct/src/dcparser/dcPacker.I
  69. 82 76
      direct/src/dcparser/dcPacker.cxx
  70. 21 21
      direct/src/dcparser/dcPacker.h
  71. 1 1
      direct/src/dcparser/dcPackerCatalog.I
  72. 14 12
      direct/src/dcparser/dcPackerCatalog.cxx
  73. 7 7
      direct/src/dcparser/dcPackerCatalog.h
  74. 1 1
      direct/src/dcparser/dcPackerInterface.I
  75. 17 15
      direct/src/dcparser/dcPackerInterface.cxx
  76. 8 8
      direct/src/dcparser/dcPackerInterface.h
  77. 12 9
      direct/src/dcparser/dcParameter.cxx
  78. 12 12
      direct/src/dcparser/dcParameter.h
  79. 4 0
      direct/src/dcparser/dcParser.cxx.prebuilt
  80. 61 57
      direct/src/dcparser/dcParser.yxx
  81. 4 4
      direct/src/dcparser/dcParserDefs.h
  82. 9 7
      direct/src/dcparser/dcSimpleParameter.cxx
  83. 4 4
      direct/src/dcparser/dcSimpleParameter.h
  84. 2 2
      direct/src/dcparser/dcSubatomicType.cxx
  85. 1 1
      direct/src/dcparser/dcSubatomicType.h
  86. 28 25
      direct/src/dcparser/dcSwitch.cxx
  87. 21 21
      direct/src/dcparser/dcSwitch.h
  88. 7 5
      direct/src/dcparser/dcSwitchParameter.cxx
  89. 5 5
      direct/src/dcparser/dcSwitchParameter.h
  90. 5 3
      direct/src/dcparser/dcTypedef.cxx
  91. 5 5
      direct/src/dcparser/dcTypedef.h
  92. 7 10
      direct/src/dcparser/dcbase.h
  93. 2 2
      direct/src/dcparser/dcindent.cxx
  94. 2 2
      direct/src/dcparser/dcindent.h
  95. 2 2
      direct/src/dcparser/hashGenerator.cxx
  96. 1 1
      direct/src/dcparser/hashGenerator.h
  97. 1 1
      direct/src/dcparser/primeNumberGenerator.h
  98. 5 5
      direct/src/deadrec/smoothMover.cxx
  99. 2 2
      direct/src/deadrec/smoothMover.h
  100. 9 4
      direct/src/directd/directd.cxx

+ 1 - 0
.gitignore

@@ -59,3 +59,4 @@ __pycache__/
 # Test tool cache directories
 .tox/
 .cache/
+.pytest_cache/

+ 51 - 47
contrib/src/ai/aiBehaviors.cxx

@@ -13,6 +13,10 @@
 
 #include "aiBehaviors.h"
 
+using std::cout;
+using std::endl;
+using std::string;
+
 static const float _PI = 3.14;
 
 AIBehaviors::AIBehaviors() {
@@ -21,16 +25,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 +271,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 +290,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 +324,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 +342,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 +360,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 +440,7 @@ void AIBehaviors::pause_ai(string ai_type) {
             }
 
     case 1:  {
-              if(_seek_obj != NULL) {
+              if(_seek_obj != nullptr) {
                 turn_off("seek");
               }
               break;
@@ -451,7 +455,7 @@ void AIBehaviors::pause_ai(string ai_type) {
             }
 
     case 3: {
-              if(_pursue_obj != NULL) {
+              if(_pursue_obj != nullptr) {
                 turn_off("pursue");
               }
               break;
@@ -466,7 +470,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 +478,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 +486,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 +501,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 +538,7 @@ void AIBehaviors::resume_ai(string ai_type) {
             }
 
     case 1:  {
-              if(_seek_obj != NULL) {
+              if(_seek_obj != nullptr) {
                 turn_on("seek");
               }
               break;
@@ -548,7 +552,7 @@ void AIBehaviors::resume_ai(string ai_type) {
             }
 
     case 3: {
-              if(_pursue_obj != NULL) {
+              if(_pursue_obj != nullptr) {
                 turn_on("pursue");
               }
               break;
@@ -562,42 +566,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;
               }

+ 15 - 15
contrib/src/ai/aiBehaviors.h

@@ -28,8 +28,8 @@ class PathFollow;
 class PathFind;
 class ObstacleAvoidance;
 
-typedef list<Flee, allocator<Flee> > ListFlee;
-typedef list<Evade, allocator<Evade> > ListEvade;
+typedef std::list<Flee, std::allocator<Flee> > ListFlee;
+typedef std::list<Evade, std::allocator<Evade> > ListEvade;
 
 /**
  * This class implements all the steering behaviors of the AI framework, such
@@ -113,21 +113,21 @@ public:
   ~AIBehaviors();
 
   bool is_on(_behavior_type bt);
-  bool is_on(string ai_type); // special cases for pathfollow and pathfinding
+  bool is_on(std::string ai_type); // special cases for pathfollow and pathfinding
   bool is_off(_behavior_type bt);
-  bool is_off(string ai_type); // special cases for pathfollow and pathfinding
-  void turn_on(string ai_type);
-  void turn_off(string ai_type);
+  bool is_off(std::string ai_type); // special cases for pathfollow and pathfinding
+  void turn_on(std::string ai_type);
+  void turn_off(std::string ai_type);
 
   bool is_conflict();
 
-  void accumulate_force(string force_type, LVecBase3 force);
+  void accumulate_force(std::string force_type, LVecBase3 force);
   LVecBase3 calculate_prioritized();
 
   void flock_activate();
   LVecBase3 do_flock();
 
-  int char_to_int(string ai_type);
+  int char_to_int(std::string ai_type);
 
 PUBLISHED:
   void seek(NodePath target_object, float seek_wt = 1.0);
@@ -150,21 +150,21 @@ PUBLISHED:
 
   void path_follow(float follow_wt);
   void add_to_path(LVecBase3 pos);
-  void start_follow(string type = "normal");
+  void start_follow(std::string type = "normal");
 
   // should have different function names.
   void init_path_find(const char* navmesh_filename);
-  void path_find_to(LVecBase3 pos, string type = "normal");
-  void path_find_to(NodePath target, string type = "normal");
+  void path_find_to(LVecBase3 pos, std::string type = "normal");
+  void path_find_to(NodePath target, std::string type = "normal");
   void add_static_obstacle(NodePath obstacle);
   void add_dynamic_obstacle(NodePath obstacle);
 
 
-  void remove_ai(string ai_type);
-  void pause_ai(string ai_type);
-  void resume_ai(string ai_type);
+  void remove_ai(std::string ai_type);
+  void pause_ai(std::string ai_type);
+  void resume_ai(std::string ai_type);
 
-  string behavior_status(string ai_type);
+  std::string behavior_status(std::string ai_type);
 };
 
 #endif

+ 4 - 1
contrib/src/ai/aiCharacter.cxx

@@ -13,7 +13,7 @@
 
 #include "aiCharacter.h"
 
-AICharacter::AICharacter(string model_name, NodePath model_np, double mass, double movt_force, double max_force) {
+AICharacter::AICharacter(std::string model_name, NodePath model_np, double mass, double movt_force, double max_force) {
   _name = model_name;
   _ai_char_np = model_np;
 
@@ -24,6 +24,8 @@ AICharacter::AICharacter(string model_name, NodePath model_np, double mass, doub
   _velocity = LVecBase3(0.0, 0.0, 0.0);
   _steering_force = LVecBase3(0.0, 0.0, 0.0);
 
+  _world = nullptr;
+
   _steering = new AIBehaviors();
   _steering->_ai_char = this;
 
@@ -31,6 +33,7 @@ AICharacter::AICharacter(string model_name, NodePath model_np, double mass, doub
 }
 
 AICharacter::~AICharacter() {
+  nassertv(_world == nullptr);
 }
 
 /**

+ 4 - 3
contrib/src/ai/aiCharacter.h

@@ -15,6 +15,7 @@
 #define _AICHARACTER_H
 
 #include "aiBehaviors.h"
+#include "referenceCount.h"
 
 /**
  * This class is used for creating the AI characters.  It assigns both physics
@@ -25,13 +26,13 @@
 class AIBehaviors;
 class AIWorld;
 
-class EXPCL_PANDAAI AICharacter {
+class EXPCL_PANDAAI AICharacter : public ReferenceCount {
  public:
   double _mass;
   double _max_force;
   LVecBase3 _velocity;
   LVecBase3 _steering_force;
-  string _name;
+  std::string _name;
   double _movt_force;
   unsigned int _ai_char_flock_id;
   AIWorld *_world;
@@ -62,7 +63,7 @@ PUBLISHED:
     // This function is used to enable or disable the guides for path finding.
     void set_pf_guide(bool pf_guide);
 
-    explicit AICharacter(string model_name, NodePath model_np, double mass, double movt_force, double max_force);
+    explicit AICharacter(std::string model_name, NodePath model_np, double mass, double movt_force, double max_force);
     ~AICharacter();
 };
 

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

+ 4 - 4
contrib/src/ai/aiPathFinder.cxx

@@ -74,7 +74,7 @@ void PathFinder::generate_path() {
       add_to_clist(nxt_node);
     }
   }
-  cout<<"DESTINATION NOT REACHABLE MATE!"<<endl;
+  std::cout << "DESTINATION NOT REACHABLE MATE!" << std::endl;
   _closed_list.clear();
 }
 
@@ -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;
 }

+ 4 - 4
contrib/src/ai/aiPathFinder.h

@@ -18,8 +18,8 @@
 #include "cmath.h"
 #include "lineSegs.h"
 
-typedef vector<Node *> NodeArray;
-typedef vector<NodeArray> NavMesh;
+typedef std::vector<Node *> NodeArray;
+typedef std::vector<NodeArray> NavMesh;
 
 Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size);
 
@@ -32,8 +32,8 @@ class EXPCL_PANDAAI PathFinder {
 public:
   Node *_src_node;
   Node *_dest_node;
-  vector<Node*> _open_list;
-  vector<Node*> _closed_list;
+  std::vector<Node*> _open_list;
+  std::vector<Node*> _closed_list;
 
   NavMesh _grid;
 

+ 33 - 105
contrib/src/ai/aiWorld.cxx

@@ -14,44 +14,56 @@
 #include "aiWorld.h"
 
 AIWorld::AIWorld(NodePath render) {
-  _ai_char_pool = new AICharPool();
-  _render = render;
+  _render = std::move(render);
 }
 
 AIWorld::~AIWorld() {
 }
 
 void AIWorld::add_ai_char(AICharacter *ai_char) {
-  _ai_char_pool->append(ai_char);
+  _ai_char_pool.push_back(ai_char);
   ai_char->_window_render = _render;
   ai_char->_world = this;
 }
 
-void AIWorld::remove_ai_char(string name) {
-  _ai_char_pool->del(name);
-  remove_ai_char_from_flock(name);
+void AIWorld::remove_ai_char(std::string name) {
+  AICharPool::iterator it;
+  for (it = _ai_char_pool.begin(); it != _ai_char_pool.end(); ++it) {
+    AICharacter *ai_char = *it;
+    if (ai_char->_name == name) {
+      nassertv(ai_char->_world == this);
+      ai_char->_world = nullptr;
+      _ai_char_pool.erase(it);
+      break;
+    }
+  }
+
+  remove_ai_char_from_flock(std::move(name));
 }
 
-void AIWorld::remove_ai_char_from_flock(string name) {
-  AICharPool::node *ai_pool;
-  ai_pool = _ai_char_pool->_head;
-  while((ai_pool) != NULL) {
-    for(unsigned int i = 0; i < _flock_pool.size(); ++i) {
-      if(ai_pool->_ai_char->_ai_char_flock_id == _flock_pool[i]->get_id()) {
-        for(unsigned int j = 0; j<_flock_pool[i]->_ai_char_list.size(); ++j) {
-          if(_flock_pool[i]->_ai_char_list[j]->_name == name) {
-            _flock_pool[i]->_ai_char_list.erase(_flock_pool[i]->_ai_char_list.begin() + j);
+void AIWorld::remove_ai_char_from_flock(std::string name) {
+  for (AICharacter *ai_char : _ai_char_pool) {
+    for (Flock *flock : _flock_pool) {
+      if (ai_char->_ai_char_flock_id == flock->get_id()) {
+        for (size_t j = 0; j < flock->_ai_char_list.size(); ++j) {
+          if (flock->_ai_char_list[j]->_name == name) {
+            flock->_ai_char_list.erase(flock->_ai_char_list.begin() + j);
             return;
           }
         }
       }
     }
-    ai_pool = ai_pool->_next;
   }
 }
 
+/**
+ * This function prints the names of the AI characters that have been added to
+ * the AIWorld.  Useful for debugging purposes.
+ */
 void AIWorld::print_list() {
-  _ai_char_pool->print_list();
+  for (AICharacter *ai_char : _ai_char_pool) {
+    std::cout << ai_char->_name << std::endl;
+  }
 }
 
 /**
@@ -59,12 +71,8 @@ void AIWorld::print_list() {
  * characters which have been added to the AIWorld.
  */
 void AIWorld::update() {
-  AICharPool::node *ai_pool;
-  ai_pool = _ai_char_pool->_head;
-
-  while((ai_pool)!=NULL) {
-    ai_pool->_ai_char->update();
-    ai_pool = ai_pool->_next;
+  for (AICharacter *ai_char : _ai_char_pool) {
+    ai_char->update();
   }
 }
 
@@ -91,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;
 }
 
@@ -104,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;
@@ -142,86 +150,6 @@ void AIWorld::flock_on(unsigned int flock_id) {
   }
 }
 
-AICharPool::AICharPool() {
-  _head = NULL;
-}
-
-AICharPool::~AICharPool() {
-}
-
-void AICharPool::append(AICharacter *ai_ch) {
-  node *q;
-  node *t;
-
-  if(_head == NULL) {
-    q = new node();
-    q->_ai_char = ai_ch;
-    q->_next = NULL;
-    _head = q;
-  }
-  else {
-    q = _head;
-    while( q->_next != NULL) {
-      q = q->_next;
-    }
-
-    t = new node();
-    t->_ai_char = ai_ch;
-    t->_next = NULL;
-    q->_next = t;
-  }
-}
-
-void AICharPool::del(string name) {
-  node *q;
-  node *r;
-  q = _head;
-
-  if(_head==NULL) {
-    return;
-  }
-
-  // Only one node in the linked list
-  if(q->_next == NULL) {
-    if(q->_ai_char->_name == name) {
-      _head = NULL;
-      delete q;
-    }
-    return;
-  }
-
-  r = q;
-  while( q != NULL) {
-    if( q->_ai_char->_name == name) {
-      // Special case
-      if(q == _head) {
-        _head = q->_next;
-        delete q;
-        return;
-      }
-
-      r->_next = q->_next;
-      delete q;
-      return;
-    }
-    r = q;
-    q = q->_next;
-  }
-}
-
-/**
- * This function prints the ai characters in the AICharPool.  Used for
- * debugging purposes.
- */
-void AICharPool::print_list() {
-  node* q;
-  q = _head;
-  while(q != NULL) {
-    cout<<q->_ai_char->_name<<endl;
-    q = q->_next;
-  }
-}
-
 /**
  * This function adds the nodepath as an obstacle that is needed by the
  * obstacle avoidance behavior.

+ 5 - 25
contrib/src/ai/aiWorld.h

@@ -21,27 +21,6 @@
 class AICharacter;
 class Flock;
 
-/**
- * This class implements a linked list of AI Characters allowing the user to
- * add and delete characters from the linked list.  This will be used in the
- * AIWorld class.
- */
-class EXPCL_PANDAAI AICharPool {
-    public:
-    struct node {
-      AICharacter * _ai_char;
-      node * _next;
-    } ;
-
-    node* _head;
-    AICharPool();
-    ~AICharPool();
-    void append(AICharacter *ai_ch);
-    void del(string name);
-        void print_list();
-};
-
-
 /**
  * A class that implements the virtual AI world which keeps track of the AI
  * characters active at any given time.  It contains a linked list of AI
@@ -51,20 +30,21 @@ class EXPCL_PANDAAI AICharPool {
  */
 class EXPCL_PANDAAI AIWorld {
   private:
-    AICharPool * _ai_char_pool;
+    typedef std::vector<PT(AICharacter)> AICharPool;
+    AICharPool _ai_char_pool;
     NodePath _render;
   public:
-    vector<NodePath> _obstacles;
+    std::vector<NodePath> _obstacles;
     typedef std::vector<Flock*> FlockPool;
     FlockPool _flock_pool;
-    void remove_ai_char_from_flock(string name);
+    void remove_ai_char_from_flock(std::string name);
 
 PUBLISHED:
     AIWorld(NodePath render);
     ~AIWorld();
 
     void add_ai_char(AICharacter *ai_ch);
-    void remove_ai_char(string name);
+    void remove_ai_char(std::string name);
 
     void add_flock(Flock *flock);
     void flock_off(unsigned int flock_id);

+ 4 - 4
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");
@@ -77,7 +77,7 @@ LVecBase3 Arrival::do_arrival() {
     return(desired_force);
   }
 
-  cout<<"Arrival works only with seek and pursue"<<endl;
+  std::cout << "Arrival works only with seek and pursue" << std::endl;
   return(LVecBase3(0.0, 0.0, 0.0));
 }
 

+ 1 - 1
contrib/src/ai/flock.h

@@ -40,7 +40,7 @@ public:
   unsigned int _alignment_wt;
 
   // This vector will hold all the ai characters which belong to this flock.
-  typedef std::vector<AICharacter*> AICharList;
+  typedef std::vector<PT(AICharacter)> AICharList;
   AICharList _ai_char_list;
 
 PUBLISHED:

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

+ 0 - 1
contrib/src/ai/obstacleAvoidance.cxx

@@ -36,7 +36,6 @@ obstacle_detection() {
   double distance = 0x7fff ;
   double expanded_radius = 0;
   LVecBase3 to_obstacle;
-  LVecBase3 prev_avoidance;
   for(unsigned int i = 0; i < _ai_char->_world->_obstacles.size(); ++i) {
     PT(BoundingVolume) bounds = _ai_char->_world->_obstacles[i].get_bounds();
     CPT(BoundingSphere) bsphere = bounds->as_bounding_sphere();

+ 25 - 21
contrib/src/ai/pathFind.cxx

@@ -13,6 +13,10 @@
 
 #include "pathFind.h"
 
+using std::cout;
+using std::endl;
+using std::string;
+
 PathFind::PathFind(AICharacter *ai_ch) {
   _ai_char = ai_ch;
 
@@ -23,7 +27,7 @@ PathFind::PathFind(AICharacter *ai_ch) {
   _pen->set_color(1.0, 0.0, 0.0);
   _pen->set_thickness(2.0);
 
-  _path_finder_obj = NULL;
+  _path_finder_obj = nullptr;
   _dynamic_avoid = false;
 }
 
@@ -46,7 +50,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
   string fields[10];
 
   // Open data file for reading.
-  ifstream nav_mesh_file (navmesh_filename);
+  std::ifstream nav_mesh_file (navmesh_filename);
 
   if(nav_mesh_file.is_open()) {
     // Capture the grid size from the file.
@@ -56,9 +60,9 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
 
     // Initialize the stage mesh with NULL nodes.
     for(int r = 0; r < _grid_size; ++r) {
-      _nav_mesh.push_back(vector<Node*>());
+      _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);
       }
     }
 
@@ -68,7 +72,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
     // Begin reading data from the file.
     while(!nav_mesh_file.eof()) {
       getline(nav_mesh_file, line);
-      stringstream linestream (line);
+      std::stringstream linestream (line);
 
       // Stores all the data members in the line to the array.  Data
       // structure:
@@ -111,7 +115,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
  * _nav_mesh.
  */
 void PathFind::assign_neighbor_nodes(const char* navmesh_filename){
-  ifstream nav_mesh_file (navmesh_filename);
+  std::ifstream nav_mesh_file (navmesh_filename);
 
   // Stage variables.
   int gd_x, gd_y, gd_xn, gd_yn;
@@ -125,7 +129,7 @@ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){
 
     while(!nav_mesh_file.eof()) {
       getline(nav_mesh_file, ln); // Gets main node data only. No neighbor nodes.
-      stringstream linestream (ln);
+      std::stringstream linestream (ln);
       for(int i = 0; i < 10; ++i) {
         getline(linestream, fields[i], ',');
       }
@@ -135,7 +139,7 @@ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){
         gd_y = atoi(fields[3].c_str());
         for(int i = 0; i < 8; ++i) {
           getline(nav_mesh_file, ln); // Gets neighbor node data only. No main nodes.
-          stringstream linestream_n (ln);
+          std::stringstream linestream_n (ln);
           for(int j = 0; j < 10; ++j) {
             getline(linestream_n, fields_n[j], ',');
           }
@@ -150,7 +154,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 +187,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 +211,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 +252,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 +281,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 +337,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 +345,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;

+ 4 - 4
contrib/src/ai/pathFind.h

@@ -40,9 +40,9 @@ public:
   LVecBase3 _prev_position;
   PT(GeomNode) _parent;
   LineSegs *_pen;
-  vector<int> _previous_obstacles;
+  std::vector<int> _previous_obstacles;
   bool _dynamic_avoid;
-  vector<NodePath> _dynamic_obstacle;
+  std::vector<NodePath> _dynamic_obstacle;
 
   PathFind(AICharacter *ai_ch);
   ~PathFind();
@@ -56,8 +56,8 @@ public:
   void clear_previous_obstacles();
 
   void set_path_find(const char* navmesh_filename);
-  void path_find(LVecBase3 pos, string type = "normal");
-  void path_find(NodePath target, string type = "normal");
+  void path_find(LVecBase3 pos, std::string type = "normal");
+  void path_find(NodePath target, std::string type = "normal");
   void add_obstacle_to_mesh(NodePath obstacle);
   void dynamic_avoid(NodePath obstacle);
 };

+ 1 - 1
contrib/src/ai/pathFollow.cxx

@@ -23,7 +23,7 @@ void PathFollow::add_to_path(LVecBase3 pos) {
 /**
  * This function initiates the path follow behavior.
  */
-void PathFollow::start(string type) {
+void PathFollow::start(std::string type) {
     _type = type;
   _start = true;
   if(_path.size() > 0) {

+ 3 - 3
contrib/src/ai/pathFollow.h

@@ -13,18 +13,18 @@ class EXPCL_PANDAAI PathFollow {
 public:
   AICharacter *_ai_char;
   float _follow_weight;
-  vector<LVecBase3> _path;
+  std::vector<LVecBase3> _path;
   int _curr_path_waypoint;
   bool _start;
   NodePath _dummy;
-  string _type;
+  std::string _type;
   ClockObject *_myClock;
   float _time;
 
   PathFollow(AICharacter *ai_ch, float follow_wt);
   ~PathFollow();
   void add_to_path(LVecBase3 pos);
-  void start(string type);
+  void start(std::string type);
   void do_follow();
   bool check_if_possible();
 };

+ 1 - 1
contrib/src/rplight/gpuCommand.I

@@ -74,7 +74,7 @@ inline float GPUCommand::convert_int_to_float(int v) const {
  */
 inline void GPUCommand::push_float(float v) {
   if (_current_index >= GPU_COMMAND_ENTRIES) {
-    gpucommand_cat.error() << "Out of bounds! Exceeded command size of " << GPU_COMMAND_ENTRIES << endl;
+    gpucommand_cat.error() << "Out of bounds! Exceeded command size of " << GPU_COMMAND_ENTRIES << std::endl;
     return;
   }
   _data[_current_index++] = v;

+ 4 - 4
contrib/src/rplight/gpuCommand.cxx

@@ -57,13 +57,13 @@ GPUCommand::GPUCommand(CommandType command_type) {
  *   in mind that integers might be shown in their binary float representation,
  *   depending on the setting in the GPUCommand::convert_int_to_float method.
  */
-void GPUCommand::write(ostream &out) const {
-  out << "GPUCommand(type=" << _command_type << ", size=" << _current_index << ", data = {" << endl;
+void GPUCommand::write(std::ostream &out) const {
+  out << "GPUCommand(type=" << _command_type << ", size=" << _current_index << ", data = {" << std::endl;
   for (size_t k = 0; k < GPU_COMMAND_ENTRIES; ++k) {
     out << std::setw(12) << std::fixed << std::setprecision(5) << _data[k] << " ";
-    if (k % 6 == 5 || k == GPU_COMMAND_ENTRIES - 1) out << endl;
+    if (k % 6 == 5 || k == GPU_COMMAND_ENTRIES - 1) out << std::endl;
   }
-  out << "})" << endl;
+  out << "})" << std::endl;
 }
 
 /**

+ 1 - 1
contrib/src/rplight/gpuCommand.h

@@ -73,7 +73,7 @@ PUBLISHED:
   inline static bool get_uses_integer_packing();
 
   void write_to(const PTA_uchar &dest, size_t command_index);
-  void write(ostream &out) const;
+  void write(std::ostream &out) const;
 
 private:
 

+ 1 - 1
contrib/src/rplight/gpuCommandList.h

@@ -48,7 +48,7 @@ PUBLISHED:
   MAKE_PROPERTY(num_commands, get_num_commands);
 
 protected:
-  queue<GPUCommand> _commands;
+  std::queue<GPUCommand> _commands;
 };
 
 #endif // GPUCOMMANDLIST_H

+ 4 - 2
contrib/src/rplight/iesDataset.cxx

@@ -27,7 +27,9 @@
 
 #include "iesDataset.h"
 
+#ifndef _USE_MATH_DEFINES
 #define _USE_MATH_DEFINES
+#endif
 #include <math.h>
 
 NotifyCategoryDef(iesdataset, "")
@@ -139,7 +141,7 @@ float IESDataset::get_candela_value(float vertical_angle, float horizontal_angle
         iesdataset_cat.error() << "Invalid horizontal lerp: " << lerp
                      << ", requested angle was " << horizontal_angle
                      << ", prev = " << prev_angle << ", cur = " << curr_angle
-                     << endl;
+                     << std::endl;
       }
 
       return curr_value * lerp + prev_value * (1-lerp);
@@ -190,7 +192,7 @@ float IESDataset::get_vertical_candela_value(size_t horizontal_angle_idx, float
         iesdataset_cat.error() << "ERROR: Invalid vertical lerp: " << lerp
                      << ", requested angle was " << vertical_angle
                      << ", prev = " << prev_angle << ", cur = " << curr_angle
-                     << endl;
+                     << std::endl;
       }
 
       return curr_value * lerp + prev_value * (1-lerp);

+ 5 - 3
contrib/src/rplight/internalLightManager.cxx

@@ -29,6 +29,8 @@
 
 #include <algorithm>
 
+using std::endl;
+
 NotifyCategoryDef(lightmgr, "");
 
 
@@ -133,7 +135,7 @@ void InternalLightManager::setup_shadows(RPLight* light) {
   }
 
   // Init all sources
-  for (int i = 0; i < num_sources; ++i) {
+  for (size_t i = 0; i < num_sources; ++i) {
     ShadowSource* source = light->get_shadow_source(i);
 
     // Set the source as dirty, so it gets updated in the beginning
@@ -355,7 +357,7 @@ bool InternalLightManager::compare_shadow_sources(const ShadowSource* a, const S
 void InternalLightManager::update_shadow_sources() {
 
   // Find all dirty shadow sources and make a list of them
-  vector<ShadowSource*> sources_to_update;
+  std::vector<ShadowSource*> sources_to_update;
    for (auto iter = _shadow_sources.begin(); iter != _shadow_sources.end(); ++iter) {
     ShadowSource* source = *iter;
     if (source) {
@@ -393,7 +395,7 @@ void InternalLightManager::update_shadow_sources() {
 
   // Free the regions of all sources which will get updated. We have to take into
   // account that only a limited amount of sources can get updated per frame.
-  size_t update_slots = min(sources_to_update.size(),
+  size_t update_slots = std::min(sources_to_update.size(),
                 _shadow_manager->get_num_update_slots_left());
   for(size_t i = 0; i < update_slots; ++i) {
     if (sources_to_update[i]->has_region()) {

+ 3 - 2
contrib/src/rplight/pointerSlotStorage.h

@@ -45,6 +45,7 @@ class PointerSlotStorage {};
 using std::tr1::array;
 #else
 #include <array>
+using std::array;
 #endif
 
 /**
@@ -169,7 +170,7 @@ public:
     _num_entries--;
 
     // Update maximum index
-    if (slot == _max_index) {
+    if ((int)slot == _max_index) {
       while (_max_index >= 0 && !_data[_max_index--]);
     }
   }
@@ -202,7 +203,7 @@ public:
     nassertv(slot >= 0 && slot < SIZE);
     nassertv(_data[slot] == nullptr); // Slot already taken!
     nassertv(ptr != nullptr); // nullptr passed as argument!
-    _max_index = max(_max_index, (int)slot);
+    _max_index = std::max(_max_index, (int)slot);
     _data[slot] = ptr;
     _num_entries++;
   }

+ 2 - 0
contrib/src/rplight/pssmCameraRig.cxx

@@ -27,7 +27,9 @@
 
 #include "pssmCameraRig.h"
 
+#ifndef _USE_MATH_DEFINES
 #define _USE_MATH_DEFINES
+#endif
 #include <math.h>
 #include "orthographicLens.h"
 

+ 3 - 3
contrib/src/rplight/pssmCameraRig.h

@@ -96,9 +96,9 @@ protected:
   inline LPoint3 get_interpolated_point(CoordinateOrigin origin, float depth);
   LVecBase3 get_snap_offset(const LMatrix4& mat, size_t resolution);
 
-  vector<NodePath> _cam_nodes;
-  vector<Camera*> _cameras;
-  vector<LVecBase2> _max_film_sizes;
+  std::vector<NodePath> _cam_nodes;
+  std::vector<Camera*> _cameras;
+  std::vector<LVecBase2> _max_film_sizes;
 
   // Current near and far points
   // Order: UL, UR, LL, LR (See CoordinateOrigin)

+ 2 - 2
contrib/src/rplight/rpLight.I

@@ -33,7 +33,7 @@
  *
  * @return Amount of shadow sources
  */
-inline int RPLight::get_num_shadow_sources() const {
+inline size_t RPLight::get_num_shadow_sources() const {
   return _shadow_sources.size();
 }
 
@@ -278,7 +278,7 @@ inline RPLight::LightType RPLight::get_light_type() const {
  */
 inline void RPLight::set_casts_shadows(bool flag) {
   if (has_slot()) {
-    cerr << "Light is already attached, can not call set_casts_shadows!" << endl;
+    std::cerr << "Light is already attached, can not call set_casts_shadows!" << std::endl;
     return;
   }
   _casts_shadows = flag;

+ 2 - 2
contrib/src/rplight/rpLight.h

@@ -57,7 +57,7 @@ public:
   virtual void update_shadow_sources() = 0;
   virtual void write_to_command(GPUCommand &cmd);
 
-  inline int get_num_shadow_sources() const;
+  inline size_t get_num_shadow_sources() const;
   inline ShadowSource* get_shadow_source(size_t index) const;
   inline void clear_shadow_sources();
 
@@ -122,7 +122,7 @@ protected:
   LightType _light_type;
   float _near_plane;
 
-  vector<ShadowSource*> _shadow_sources;
+  std::vector<ShadowSource*> _shadow_sources;
 };
 
 #include "rpLight.I"

+ 2 - 0
contrib/src/rplight/rpSpotLight.cxx

@@ -27,7 +27,9 @@
 
 #include "rpSpotLight.h"
 
+#ifndef _USE_MATH_DEFINES
 #define _USE_MATH_DEFINES
+#endif
 #include <math.h>
 
 

+ 1 - 1
contrib/src/rplight/shadowAtlas.I

@@ -118,7 +118,7 @@ inline int ShadowAtlas::get_required_tiles(size_t resolution) const {
 
   if (resolution % _tile_size != 0) {
     shadowatlas_cat.error() << "Resolution " << resolution << " is not a multiple "
-                << "of the shadow atlas tile size (" << _tile_size << ")!" << endl;
+                << "of the shadow atlas tile size (" << _tile_size << ")!" << std::endl;
     return 1;
   }
   return resolution / _tile_size;

+ 6 - 6
contrib/src/rplight/shadowAtlas.cxx

@@ -131,13 +131,13 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h
 
   // Check for empty region
   if (tile_width < 1 || tile_height < 1) {
-    shadowatlas_cat.error() << "Called find_and_reserve_region with null-region!" << endl;
+    shadowatlas_cat.error() << "Called find_and_reserve_region with null-region!" << std::endl;
     return LVecBase4i(-1);
   }
 
   // Check for region bigger than the shadow atlas
   if (tile_width > _num_tiles || tile_height > _num_tiles) {
-    shadowatlas_cat.error() << "Requested region exceeds shadow atlas size!" << endl;
+    shadowatlas_cat.error() << "Requested region exceeds shadow atlas size!" << std::endl;
     return LVecBase4i(-1);
   }
 
@@ -155,7 +155,7 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h
   // When we reached this part, we couldn't find a free region, so the atlas
   // seems to be full.
   shadowatlas_cat.error() << "Failed to find a free region of size " << tile_width
-              << " x " << tile_height << "!"  << endl;
+              << " x " << tile_height << "!"  << std::endl;
   return LVecBase4i(-1);
 }
 
@@ -173,12 +173,12 @@ LVecBase4i ShadowAtlas::find_and_reserve_region(size_t tile_width, size_t tile_h
 void ShadowAtlas::free_region(const LVecBase4i& region) {
   // Out of bounds check, can't hurt
   nassertv(region.get_x() >= 0 && region.get_y() >= 0);
-  nassertv(region.get_x() + region.get_z() <= _num_tiles && region.get_y() + region.get_w() <= _num_tiles);
+  nassertv(region.get_x() + region.get_z() <= (int)_num_tiles && region.get_y() + region.get_w() <= (int)_num_tiles);
 
   _num_used_tiles -= region.get_z() * region.get_w();
 
-  for (size_t x = 0; x < region.get_z(); ++x) {
-    for (size_t y = 0; y < region.get_w(); ++y) {
+  for (int x = 0; x < region.get_z(); ++x) {
+    for (int y = 0; y < region.get_w(); ++y) {
       // Could do an assert here, that the tile should have been used (=true) before
       set_tile(region.get_x() + x, region.get_y() + y, false);
     }

+ 2 - 2
contrib/src/rplight/shadowManager.I

@@ -52,7 +52,7 @@ inline void ShadowManager::set_max_updates(size_t max_updates) {
   nassertv(max_updates >= 0);
   nassertv(_atlas == nullptr);  // ShadowManager was already initialized
   if (max_updates == 0) {
-    shadowmanager_cat.warning() << "max_updates set to 0, no shadows will be updated." << endl;
+    shadowmanager_cat.warning() << "max_updates set to 0, no shadows will be updated." << std::endl;
   }
   _max_updates = max_updates;
 }
@@ -170,7 +170,7 @@ inline bool ShadowManager::add_update(const ShadowSource* source) {
 
   if (_queued_updates.size() >= _max_updates) {
     if (shadowmanager_cat.is_debug()) {
-      shadowmanager_cat.debug() << "cannot update source, out of update slots" << endl;
+      shadowmanager_cat.debug() << "cannot update source, out of update slots" << std::endl;
     }
     return false;
   }

+ 5 - 5
contrib/src/rplight/tagStateManager.I

@@ -35,7 +35,7 @@
  * @param source Camera which will be used to render shadows
  */
 inline void TagStateManager::
-register_camera(const string& name, Camera* source) {
+register_camera(const std::string& name, Camera* source) {
   ContainerList::iterator entry = _containers.find(name);
   nassertv(entry != _containers.end());
   register_camera(entry->second, source);
@@ -49,7 +49,7 @@ register_camera(const string& name, Camera* source) {
  * @param source Camera to unregister
  */
 inline void TagStateManager::
-unregister_camera(const string& name, Camera* source) {
+unregister_camera(const std::string& name, Camera* source) {
   ContainerList::iterator entry = _containers.find(name);
   nassertv(entry != _containers.end());
   unregister_camera(entry->second, source);
@@ -67,8 +67,8 @@ unregister_camera(const string& name, Camera* source) {
  * @param sort Determines the sort with which the shader will be applied.
  */
 inline void TagStateManager::
-apply_state(const string& state, NodePath np, Shader* shader,
-            const string &name, int sort) {
+apply_state(const std::string& state, NodePath np, Shader* shader,
+            const std::string &name, int sort) {
   ContainerList::iterator entry = _containers.find(state);
   nassertv(entry != _containers.end());
   apply_state(entry->second, np, shader, name, sort);
@@ -83,7 +83,7 @@ apply_state(const string& state, NodePath np, Shader* shader,
  * @return Bit mask of the render pass
  */
 inline BitMask32 TagStateManager::
-get_mask(const string &container_name) {
+get_mask(const std::string &container_name) {
   if (container_name == "gbuffer") {
     return BitMask32::bit(1);
   }

+ 3 - 1
contrib/src/rplight/tagStateManager.cxx

@@ -27,6 +27,8 @@
 
 #include "tagStateManager.h"
 
+using std::endl;
+
 
 NotifyCategoryDef(tagstatemgr, "");
 
@@ -77,7 +79,7 @@ TagStateManager::
  */
 void TagStateManager::
 apply_state(StateContainer& container, NodePath np, Shader* shader,
-            const string &name, int sort) {
+            const std::string &name, int sort) {
   if (tagstatemgr_cat.is_spam()) {
     tagstatemgr_cat.spam() << "Constructing new state " << name
                  << " with shader " << shader << endl;

+ 10 - 10
contrib/src/rplight/tagStateManager.h

@@ -52,36 +52,36 @@ PUBLISHED:
   TagStateManager(NodePath main_cam_node);
   ~TagStateManager();
 
-  inline void apply_state(const string& state, NodePath np, Shader* shader, const string &name, int sort);
+  inline void apply_state(const std::string& state, NodePath np, Shader* shader, const std::string &name, int sort);
   void cleanup_states();
 
-  inline void register_camera(const string& state, Camera* source);
-  inline void unregister_camera(const string& state, Camera* source);
-  inline BitMask32 get_mask(const string &container_name);
+  inline void register_camera(const std::string& state, Camera* source);
+  inline void unregister_camera(const std::string& state, Camera* source);
+  inline BitMask32 get_mask(const std::string &container_name);
 
 private:
-  typedef vector<Camera*> CameraList;
-  typedef pmap<string, CPT(RenderState)> TagStateList;
+  typedef std::vector<Camera*> CameraList;
+  typedef pmap<std::string, CPT(RenderState)> TagStateList;
 
   struct StateContainer {
     CameraList cameras;
     TagStateList tag_states;
-    string tag_name;
+    std::string tag_name;
     BitMask32 mask;
     bool write_color;
 
     StateContainer() {};
-    StateContainer(const string &tag_name, size_t mask, bool write_color)
+    StateContainer(const std::string &tag_name, size_t mask, bool write_color)
       : tag_name(tag_name), mask(BitMask32::bit(mask)), write_color(write_color) {};
   };
 
   void apply_state(StateContainer& container, NodePath np, Shader* shader,
-                   const string& name, int sort);
+                   const std::string& name, int sort);
   void cleanup_container_states(StateContainer& container);
   void register_camera(StateContainer &container, Camera* source);
   void unregister_camera(StateContainer &container, Camera* source);
 
-  typedef pmap<string, StateContainer> ContainerList;
+  typedef pmap<std::string, StateContainer> ContainerList;
   ContainerList _containers;
 
   NodePath _main_cam_node;

+ 5 - 2
direct/src/dcparse/dcparse.cxx

@@ -19,6 +19,9 @@
 #include "indent.h"
 #include "panda_getopt.h"
 
+using std::cerr;
+using std::cout;
+
 void
 usage() {
   cerr <<
@@ -103,8 +106,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 << "()";
       }

+ 9 - 7
direct/src/dcparser/dcArrayParameter.cxx

@@ -16,6 +16,8 @@
 #include "dcClassParameter.h"
 #include "hashGenerator.h"
 
+using std::string;
+
 /**
  *
  */
@@ -58,7 +60,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 +150,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);
   }
@@ -201,13 +203,13 @@ validate_num_nested_fields(int num_nested_fields) const {
  * identifier.
  */
 void DCArrayParameter::
-output_instance(ostream &out, bool brief, const string &prename,
+output_instance(std::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 {
-    ostringstream strm;
+    std::ostringstream strm;
 
     strm << "[";
     _array_size_range.output(strm);
@@ -236,7 +238,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 +308,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/dcArrayParameter.h

@@ -46,14 +46,14 @@ public:
   virtual DCPackerInterface *get_nested_field(int n) const;
   virtual bool validate_num_nested_fields(int num_nested_fields) const;
 
-  virtual void output_instance(ostream &out, bool brief, const string &prename,
-                               const string &name, const string &postname) const;
+  virtual void output_instance(std::ostream &out, bool brief, const std::string &prename,
+                               const std::string &name, const std::string &postname) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
-  virtual void pack_string(DCPackData &pack_data, const string &value,
+  virtual void pack_string(DCPackData &pack_data, const std::string &value,
                            bool &pack_error, bool &range_error) const;
   virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
   virtual void unpack_string(const char *data, size_t length, size_t &p,
-                             string &value, bool &pack_error, bool &range_error) const;
+                             std::string &value, bool &pack_error, bool &range_error) const;
 
 protected:
   virtual bool do_check_match(const DCPackerInterface *other) const;

+ 9 - 7
direct/src/dcparser/dcAtomicField.cxx

@@ -19,6 +19,8 @@
 
 #include <math.h>
 
+using std::string;
+
 /**
  *
  */
@@ -73,7 +75,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 +129,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 +145,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();
 }
 
@@ -151,7 +153,7 @@ get_element_divisor(int n) const {
  *
  */
 void DCAtomicField::
-output(ostream &out, bool brief) const {
+output(std::ostream &out, bool brief) const {
   out << _name << "(";
 
   if (!_elements.empty()) {
@@ -174,7 +176,7 @@ output(ostream &out, bool brief) const {
  * stream.
  */
 void DCAtomicField::
-write(ostream &out, bool brief, int indent_level) const {
+write(std::ostream &out, bool brief, int indent_level) const {
   indent(out, indent_level);
   output(out, brief);
   out << ";";
@@ -207,7 +209,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];
 }
 
@@ -270,7 +272,7 @@ do_check_match_atomic_field(const DCAtomicField *other) const {
  *
  */
 void DCAtomicField::
-output_element(ostream &out, bool brief, DCParameter *element) const {
+output_element(std::ostream &out, bool brief, DCParameter *element) const {
   element->output(out, brief);
 
   if (!brief && element->has_default_value()) {

+ 6 - 6
direct/src/dcparser/dcAtomicField.h

@@ -29,7 +29,7 @@
  */
 class DCAtomicField : public DCField {
 public:
-  DCAtomicField(const string &name, DCClass *dclass, bool bogus_field);
+  DCAtomicField(const std::string &name, DCClass *dclass, bool bogus_field);
   virtual ~DCAtomicField();
 
 PUBLISHED:
@@ -40,17 +40,17 @@ PUBLISHED:
   DCParameter *get_element(int n) const;
 
   // These five methods are deprecated and will be removed soon.
-  string get_element_default(int n) const;
+  std::string get_element_default(int n) const;
   bool has_element_default(int n) const;
-  string get_element_name(int n) const;
+  std::string get_element_name(int n) const;
   DCSubatomicType get_element_type(int n) const;
   int get_element_divisor(int n) const;
 
 public:
   void add_element(DCParameter *element);
 
-  virtual void output(ostream &out, bool brief) const;
-  virtual void write(ostream &out, bool brief, int indent_level) const;
+  virtual void output(std::ostream &out, bool brief) const;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
 
   virtual DCPackerInterface *get_nested_field(int n) const;
@@ -60,7 +60,7 @@ protected:
   virtual bool do_check_match_atomic_field(const DCAtomicField *other) const;
 
 private:
-  void output_element(ostream &out, bool brief, DCParameter *element) const;
+  void output_element(std::ostream &out, bool brief, DCParameter *element) const;
 
   typedef pvector<DCParameter *> Elements;
   Elements _elements;

+ 1 - 1
direct/src/dcparser/dcClass.I

@@ -22,7 +22,7 @@ get_dc_file() const {
 /**
  * Returns the name of this class.
  */
-INLINE const string &DCClass::
+INLINE const std::string &DCClass::
 get_name() const {
   return _name;
 }

+ 51 - 47
direct/src/dcparser/dcClass.cxx

@@ -25,6 +25,10 @@
 #include "py_panda.h"
 #endif
 
+using std::ostream;
+using std::ostringstream;
+using std::string;
+
 #ifdef WITHIN_PANDA
 #include "pStatTimer.h"
 
@@ -80,11 +84,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 +97,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 +141,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 +151,7 @@ get_parent(int n) const {
  */
 bool DCClass::
 has_constructor() const {
-  return (_constructor != (DCField *)NULL);
+  return (_constructor != nullptr);
 }
 
 /**
@@ -177,13 +181,13 @@ DCField *DCClass::
 get_field(int n) const {
   #ifndef NDEBUG //[
   if (n < 0 || n >= (int)_fields.size()) {
-    cerr << *this << " "
+    std::cerr << *this << " "
          << "n:" << n << " _fields.size():"
-         << (int)_fields.size() << endl;
+         << (int)_fields.size() << std::endl;
     // __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 +209,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 +236,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 +244,7 @@ get_field_by_index(int index_number) const {
   }
 
   // Nobody knew what this field is.
-  return (DCField *)NULL;
+  return nullptr;
 }
 
 /**
@@ -250,7 +254,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 +287,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 +353,7 @@ output(ostream &out) const {
  */
 bool DCClass::
 has_class_def() const {
-  return (_class_def != NULL);
+  return (_class_def != nullptr);
 }
 #endif  // HAVE_PYTHON
 
@@ -373,7 +377,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 +394,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 +418,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 +445,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 +482,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 +517,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 +550,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 +589,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 +649,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 +672,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 +681,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 +690,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,16 +744,16 @@ 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";
+    std::cerr << "Error when calling " << getter_name << "\n";
     return false;
   }
 
@@ -789,7 +793,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 +814,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 +836,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 +875,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 +901,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 +960,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 +984,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 +1046,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 +1102,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 +1138,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 +1251,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 +1282,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);

+ 17 - 17
direct/src/dcparser/dcClass.h

@@ -43,7 +43,7 @@ class DCParameter;
  */
 class DCClass : public DCDeclaration {
 public:
-  DCClass(DCFile *dc_file, const string &name,
+  DCClass(DCFile *dc_file, const std::string &name,
           bool is_struct, bool bogus_class);
   ~DCClass();
 
@@ -53,7 +53,7 @@ PUBLISHED:
 
   INLINE DCFile *get_dc_file() const;
 
-  INLINE const string &get_name() const;
+  INLINE const std::string &get_name() const;
   INLINE int get_number() const;
 
   int get_num_parents() const;
@@ -65,7 +65,7 @@ PUBLISHED:
   int get_num_fields() const;
   DCField *get_field(int n) const;
 
-  DCField *get_field_by_name(const string &name) const;
+  DCField *get_field_by_name(const std::string &name) const;
   DCField *get_field_by_index(int index_number) const;
 
   int get_num_inherited_fields() const;
@@ -78,7 +78,7 @@ PUBLISHED:
   INLINE void start_generate();
   INLINE void stop_generate();
 
-  virtual void output(ostream &out) const;
+  virtual void output(std::ostream &out) const;
 
 #ifdef HAVE_PYTHON
   bool has_class_def() const;
@@ -94,9 +94,9 @@ PUBLISHED:
   void receive_update_all_required(PyObject *distobj, DatagramIterator &di) const;
   void receive_update_other(PyObject *distobj, DatagramIterator &di) const;
 
-  void direct_update(PyObject *distobj, const string &field_name,
-                     const string &value_blob);
-  void direct_update(PyObject *distobj, const string &field_name,
+  void direct_update(PyObject *distobj, const std::string &field_name,
+                     const std::string &value_blob);
+  void direct_update(PyObject *distobj, const std::string &field_name,
                      const Datagram &datagram);
   bool pack_required_field(Datagram &datagram, PyObject *distobj,
                            const DCField *field) const;
@@ -105,11 +105,11 @@ PUBLISHED:
 
 
 
-  Datagram client_format_update(const string &field_name,
+  Datagram client_format_update(const std::string &field_name,
                                 DOID_TYPE do_id, PyObject *args) const;
-  Datagram ai_format_update(const string &field_name, DOID_TYPE do_id,
+  Datagram ai_format_update(const std::string &field_name, DOID_TYPE do_id,
                             CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const;
-  Datagram ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id,
+  Datagram ai_format_update_msg_type(const std::string &field_name, DOID_TYPE do_id,
                             CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const;
   Datagram ai_format_generate(PyObject *distobj, DOID_TYPE do_id, ZONEID_TYPE parent_id, ZONEID_TYPE zone_id,
                               CHANNEL_TYPE district_channel_id, CHANNEL_TYPE from_channel_id,
@@ -120,10 +120,10 @@ PUBLISHED:
 #endif
 
 public:
-  virtual void output(ostream &out, bool brief) const;
-  virtual void write(ostream &out, bool brief, int indent_level) const;
-  void output_instance(ostream &out, bool brief, const string &prename,
-                       const string &name, const string &postname) const;
+  virtual void output(std::ostream &out, bool brief) const;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const;
+  void output_instance(std::ostream &out, bool brief, const std::string &prename,
+                       const std::string &name, const std::string &postname) const;
   void generate_hash(HashGenerator &hashgen) const;
   void clear_inherited_fields();
   void rebuild_inherited_fields();
@@ -133,7 +133,7 @@ public:
   void set_number(int number);
 
 private:
-  void shadow_inherited_field(const string &name);
+  void shadow_inherited_field(const std::string &name);
 
 #ifdef WITHIN_PANDA
   PStatCollector _class_update_pcollector;
@@ -144,7 +144,7 @@ private:
 
   DCFile *_dc_file;
 
-  string _name;
+  std::string _name;
   bool _is_struct;
   bool _bogus_class;
   int _number;
@@ -157,7 +157,7 @@ private:
   typedef pvector<DCField *> Fields;
   Fields _fields, _inherited_fields;
 
-  typedef pmap<string, DCField *> FieldsByName;
+  typedef pmap<std::string, DCField *> FieldsByName;
   FieldsByName _fields_by_name;
 
   typedef pmap<int, DCField *> FieldsByIndex;

+ 4 - 4
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];
 }
 
@@ -128,9 +128,9 @@ get_nested_field(int n) const {
  * identifier.
  */
 void DCClassParameter::
-output_instance(ostream &out, bool brief, const string &prename,
-                const string &name, const string &postname) const {
-  if (get_typedef() != (DCTypedef *)NULL) {
+output_instance(std::ostream &out, bool brief, const std::string &prename,
+                const std::string &name, const std::string &postname) const {
+  if (get_typedef() != nullptr) {
     output_typedef_name(out, brief, prename, name, postname);
 
   } else {

+ 2 - 2
direct/src/dcparser/dcClassParameter.h

@@ -39,8 +39,8 @@ PUBLISHED:
 public:
   virtual DCPackerInterface *get_nested_field(int n) const;
 
-  virtual void output_instance(ostream &out, bool brief, const string &prename,
-                               const string &name, const string &postname) const;
+  virtual void output_instance(std::ostream &out, bool brief, const std::string &prename,
+                               const std::string &name, const std::string &postname) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
 
 protected:

+ 6 - 6
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,14 +50,14 @@ as_switch() {
  */
 const DCSwitch *DCDeclaration::
 as_switch() const {
-  return (DCSwitch *)NULL;
+  return nullptr;
 }
 
 /**
  * Write a string representation of this instance to <out>.
  */
 void DCDeclaration::
-output(ostream &out) const {
+output(std::ostream &out) const {
   output(out, true);
 }
 
@@ -65,6 +65,6 @@ output(ostream &out) const {
  * Write a string representation of this instance to <out>.
  */
 void DCDeclaration::
-write(ostream &out, int indent_level) const {
+write(std::ostream &out, int indent_level) const {
   write(out, false, indent_level);
 }

+ 5 - 5
direct/src/dcparser/dcDeclaration.h

@@ -36,15 +36,15 @@ PUBLISHED:
   virtual DCSwitch *as_switch();
   virtual const DCSwitch *as_switch() const;
 
-  virtual void output(ostream &out) const;
-  void write(ostream &out, int indent_level) const;
+  virtual void output(std::ostream &out) const;
+  void write(std::ostream &out, int indent_level) const;
 
 public:
-  virtual void output(ostream &out, bool brief) const=0;
-  virtual void write(ostream &out, bool brief, int indent_level) const=0;
+  virtual void output(std::ostream &out, bool brief) const=0;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const=0;
 };
 
-INLINE ostream &operator << (ostream &out, const DCDeclaration &decl) {
+INLINE std::ostream &operator << (std::ostream &out, const DCDeclaration &decl) {
   decl.output(out);
   return out;
 }

+ 4 - 4
direct/src/dcparser/dcField.I

@@ -42,7 +42,7 @@ has_default_value() const {
  * explicitly set (e.g.  has_default_value() returns true), returns that
  * value; otherwise, returns an implicit default for the field.
  */
-INLINE const string &DCField::
+INLINE const std::string &DCField::
 get_default_value() const {
   if (_default_value_stale) {
     ((DCField *)this)->refresh_default_value();
@@ -138,7 +138,7 @@ is_airecv() const {
  * Write a string representation of this instance to <out>.
  */
 INLINE void DCField::
-output(ostream &out) const {
+output(std::ostream &out) const {
   output(out, true);
 }
 
@@ -146,7 +146,7 @@ output(ostream &out) const {
  * Write a string representation of this instance to <out>.
  */
 INLINE void DCField::
-write(ostream &out, int indent_level) const {
+write(std::ostream &out, int indent_level) const {
   write(out, false, indent_level);
 }
 
@@ -172,7 +172,7 @@ set_class(DCClass *dclass) {
  * Establishes a default value for this field.
  */
 INLINE void DCField::
-set_default_value(const string &default_value) {
+set_default_value(const std::string &default_value) {
   _default_value = default_value;
   _has_default_value = true;
   _default_value_stale = false;

+ 28 - 26
direct/src/dcparser/dcField.cxx

@@ -26,12 +26,14 @@
 #include "pStatTimer.h"
 #endif
 
+using std::string;
+
 /**
  *
  */
 DCField::
 DCField() :
-  _dclass(NULL)
+  _dclass(nullptr)
 #ifdef WITHIN_PANDA
   ,
   _field_update_pcollector("DCField")
@@ -108,7 +110,7 @@ as_field() const {
  */
 DCAtomicField *DCField::
 as_atomic_field() {
-  return (DCAtomicField *)NULL;
+  return nullptr;
 }
 
 /**
@@ -117,7 +119,7 @@ as_atomic_field() {
  */
 const DCAtomicField *DCField::
 as_atomic_field() const {
-  return (DCAtomicField *)NULL;
+  return nullptr;
 }
 
 /**
@@ -126,7 +128,7 @@ as_atomic_field() const {
  */
 DCMolecularField *DCField::
 as_molecular_field() {
-  return (DCMolecularField *)NULL;
+  return nullptr;
 }
 
 /**
@@ -135,7 +137,7 @@ as_molecular_field() {
  */
 const DCMolecularField *DCField::
 as_molecular_field() const {
-  return (DCMolecularField *)NULL;
+  return nullptr;
 }
 
 /**
@@ -143,7 +145,7 @@ as_molecular_field() const {
  */
 DCParameter *DCField::
 as_parameter() {
-  return (DCParameter *)NULL;
+  return nullptr;
 }
 
 /**
@@ -151,7 +153,7 @@ as_parameter() {
  */
 const DCParameter *DCField::
 as_parameter() const {
-  return (DCParameter *)NULL;
+  return nullptr;
 }
 
 /**
@@ -232,10 +234,10 @@ pack_args(DCPacker &packer, PyObject *sequence) const {
   }
 
   if (!Notify::ptr()->has_assert_failed()) {
-    ostringstream strm;
+    std::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 +253,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 +289,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();
@@ -303,7 +305,7 @@ unpack_args(DCPacker &packer) const {
   }
 
   if (!Notify::ptr()->has_assert_failed()) {
-    ostringstream strm;
+    std::ostringstream strm;
     PyObject *exc_type = PyExc_Exception;
 
     if (packer.had_pack_error()) {
@@ -315,7 +317,7 @@ unpack_args(DCPacker &packer) const {
       dg.dump_hex(strm);
       size_t error_byte = packer.get_num_unpacked_bytes() - start_byte;
       strm << "Error detected on byte " << error_byte
-           << " (" << hex << error_byte << dec << " hex)";
+           << " (" << std::hex << error_byte << std::dec << " hex)";
 
       exc_type = PyExc_RuntimeError;
     } else {
@@ -329,7 +331,7 @@ unpack_args(DCPacker &packer) const {
   }
 
   Py_XDECREF(object);
-  return NULL;
+  return nullptr;
 }
 #endif  // HAVE_PYTHON
 
@@ -340,10 +342,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 +364,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 +501,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 +512,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 +528,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 +538,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
@@ -562,7 +564,7 @@ refresh_default_value() {
   packer.begin_pack(this);
   packer.pack_default_value();
   if (!packer.end_pack()) {
-    cerr << "Error while packing default value for " << get_name() << "\n";
+    std::cerr << "Error while packing default value for " << get_name() << "\n";
   } else {
     _default_value.assign(packer.get_data(), packer.get_length());
   }

+ 14 - 14
direct/src/dcparser/dcField.h

@@ -37,7 +37,7 @@ class HashGenerator;
 class DCField : public DCPackerInterface, public DCKeywordList {
 public:
   DCField();
-  DCField(const string &name, DCClass *dclass);
+  DCField(const std::string &name, DCClass *dclass);
   virtual ~DCField();
 
 PUBLISHED:
@@ -53,13 +53,13 @@ PUBLISHED:
   virtual DCParameter *as_parameter();
   virtual const DCParameter *as_parameter() const;
 
-  string format_data(const string &packed_data, bool show_field_names = true);
-  string parse_string(const string &formatted_string);
+  std::string format_data(const std::string &packed_data, bool show_field_names = true);
+  std::string parse_string(const std::string &formatted_string);
 
-  bool validate_ranges(const string &packed_data) const;
+  bool validate_ranges(const std::string &packed_data) const;
 
   INLINE bool has_default_value() const;
-  INLINE const string &get_default_value() const;
+  INLINE const std::string &get_default_value() const;
 
   INLINE bool is_bogus_field() const;
 
@@ -73,8 +73,8 @@ PUBLISHED:
   INLINE bool is_ownrecv() const;
   INLINE bool is_airecv() const;
 
-  INLINE void output(ostream &out) const;
-  INLINE void write(ostream &out, int indent_level) const;
+  INLINE void output(std::ostream &out) const;
+  INLINE void write(std::ostream &out, int indent_level) const;
 
 #ifdef HAVE_PYTHON
   bool pack_args(DCPacker &packer, PyObject *sequence) const;
@@ -90,18 +90,18 @@ PUBLISHED:
 #endif
 
 public:
-  virtual void output(ostream &out, bool brief) const=0;
-  virtual void write(ostream &out, bool brief, int indent_level) const=0;
+  virtual void output(std::ostream &out, bool brief) const=0;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const=0;
   virtual void generate_hash(HashGenerator &hashgen) const;
   virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
-  virtual void set_name(const string &name);
+  virtual void set_name(const std::string &name);
 
   INLINE void set_number(int number);
   INLINE void set_class(DCClass *dclass);
-  INLINE void set_default_value(const string &default_value);
+  INLINE void set_default_value(const std::string &default_value);
 
 #ifdef HAVE_PYTHON
-  static string get_pystr(PyObject *value);
+  static std::string get_pystr(PyObject *value);
 #endif
 
 protected:
@@ -115,14 +115,14 @@ protected:
   bool _bogus_field;
 
 private:
-  string _default_value;
+  std::string _default_value;
 
 #ifdef WITHIN_PANDA
   PStatCollector _field_update_pcollector;
 #endif
 };
 
-INLINE ostream &operator << (ostream &out, const DCField &field) {
+INLINE std::ostream &operator << (std::ostream &out, const DCField &field) {
   field.output(out);
   return out;
 }

+ 18 - 15
direct/src/dcparser/dcFile.cxx

@@ -28,6 +28,9 @@
 #include "configVariableList.h"
 #endif
 
+using std::cerr;
+using std::string;
+
 
 /**
  *
@@ -122,8 +125,8 @@ read(Filename filename) {
 #ifdef WITHIN_PANDA
   filename.set_text();
   VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
-  istream *in = vfs->open_read_file(filename, true);
-  if (in == (istream *)NULL) {
+  std::istream *in = vfs->open_read_file(filename, true);
+  if (in == nullptr) {
     cerr << "Cannot open " << filename << " for reading.\n";
     return false;
   }
@@ -163,7 +166,7 @@ read(Filename filename) {
  * (in which case the file might have been partially read).
  */
 bool DCFile::
-read(istream &in, const string &filename) {
+read(std::istream &in, const string &filename) {
   cerr << "DCFile::read of " << filename << "\n";
   dc_init_parser(in, filename, *this);
   dcyyparse();
@@ -203,7 +206,7 @@ write(Filename filename, bool brief) const {
  * Returns true if the description is successfully written, false otherwise.
  */
 bool DCFile::
-write(ostream &out, bool brief) const {
+write(std::ostream &out, bool brief) const {
   if (!_imports.empty()) {
     Imports::const_iterator ii;
     for (ii = _imports.begin(); ii != _imports.end(); ++ii) {
@@ -247,7 +250,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 +266,7 @@ get_class_by_name(const string &name) const {
     return (*ni).second->as_class();
   }
 
-  return (DCClass *)NULL;
+  return nullptr;
 }
 
 /**
@@ -278,7 +281,7 @@ get_switch_by_name(const string &name) const {
     return (*ni).second->as_switch();
   }
 
-  return (DCSwitch *)NULL;
+  return nullptr;
 }
 
 /**
@@ -291,13 +294,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 +355,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 +371,7 @@ get_typedef_by_name(const string &name) const {
     return (*ni).second;
   }
 
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -394,9 +397,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 +615,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);

+ 15 - 15
direct/src/dcparser/dcFile.h

@@ -41,32 +41,32 @@ PUBLISHED:
 #endif
 
   bool read(Filename filename);
-  bool read(istream &in, const string &filename = string());
+  bool read(std::istream &in, const std::string &filename = std::string());
 
   bool write(Filename filename, bool brief) const;
-  bool write(ostream &out, bool brief) const;
+  bool write(std::ostream &out, bool brief) const;
 
   int get_num_classes() const;
   DCClass *get_class(int n) const;
-  DCClass *get_class_by_name(const string &name) const;
-  DCSwitch *get_switch_by_name(const string &name) const;
+  DCClass *get_class_by_name(const std::string &name) const;
+  DCSwitch *get_switch_by_name(const std::string &name) const;
 
   DCField *get_field_by_index(int index_number) const;
 
   INLINE bool all_objects_valid() const;
 
   int get_num_import_modules() const;
-  string get_import_module(int n) const;
+  std::string get_import_module(int n) const;
   int get_num_import_symbols(int n) const;
-  string get_import_symbol(int n, int i) const;
+  std::string get_import_symbol(int n, int i) const;
 
   int get_num_typedefs() const;
   DCTypedef *get_typedef(int n) const;
-  DCTypedef *get_typedef_by_name(const string &name) const;
+  DCTypedef *get_typedef_by_name(const std::string &name) const;
 
   int get_num_keywords() const;
   const DCKeyword *get_keyword(int n) const;
-  const DCKeyword *get_keyword_by_name(const string &name) const;
+  const DCKeyword *get_keyword_by_name(const std::string &name) const;
 
   unsigned long get_hash() const;
 
@@ -74,10 +74,10 @@ public:
   void generate_hash(HashGenerator &hashgen) const;
   bool add_class(DCClass *dclass);
   bool add_switch(DCSwitch *dswitch);
-  void add_import_module(const string &import_module);
-  void add_import_symbol(const string &import_symbol);
+  void add_import_module(const std::string &import_module);
+  void add_import_symbol(const std::string &import_symbol);
   bool add_typedef(DCTypedef *dtypedef);
-  bool add_keyword(const string &name);
+  bool add_keyword(const std::string &name);
   void add_thing_to_delete(DCDeclaration *decl);
 
   void set_new_index_number(DCField *field);
@@ -91,13 +91,13 @@ private:
   typedef pvector<DCClass *> Classes;
   Classes _classes;
 
-  typedef pmap<string, DCDeclaration *> ThingsByName;
+  typedef pmap<std::string, DCDeclaration *> ThingsByName;
   ThingsByName _things_by_name;
 
-  typedef pvector<string> ImportSymbols;
+  typedef pvector<std::string> ImportSymbols;
   class Import {
   public:
-    string _module;
+    std::string _module;
     ImportSymbols _symbols;
   };
 
@@ -107,7 +107,7 @@ private:
   typedef pvector<DCTypedef *> Typedefs;
   Typedefs _typedefs;
 
-  typedef pmap<string, DCTypedef *> TypedefsByName;
+  typedef pmap<std::string, DCTypedef *> TypedefsByName;
   TypedefsByName _typedefs_by_name;
 
   DCKeywordList _keywords;

+ 4 - 4
direct/src/dcparser/dcKeyword.cxx

@@ -19,7 +19,7 @@
  *
  */
 DCKeyword::
-DCKeyword(const string &name, int historical_flag) :
+DCKeyword(const std::string &name, int historical_flag) :
   _name(name),
   _historical_flag(historical_flag)
 {
@@ -35,7 +35,7 @@ DCKeyword::
 /**
  * Returns the name of this keyword.
  */
-const string &DCKeyword::
+const std::string &DCKeyword::
 get_name() const {
   return _name;
 }
@@ -64,7 +64,7 @@ clear_historical_flag() {
  * Write a string representation of this instance to <out>.
  */
 void DCKeyword::
-output(ostream &out, bool brief) const {
+output(std::ostream &out, bool brief) const {
   out << "keyword " << _name;
 }
 
@@ -72,7 +72,7 @@ output(ostream &out, bool brief) const {
  *
  */
 void DCKeyword::
-write(ostream &out, bool, int indent_level) const {
+write(std::ostream &out, bool, int indent_level) const {
   indent(out, indent_level)
     << "keyword " << _name << ";\n";
 }

+ 5 - 5
direct/src/dcparser/dcKeyword.h

@@ -27,22 +27,22 @@ class HashGenerator;
  */
 class DCKeyword : public DCDeclaration {
 public:
-  DCKeyword(const string &name, int historical_flag = ~0);
+  DCKeyword(const std::string &name, int historical_flag = ~0);
   virtual ~DCKeyword();
 
 PUBLISHED:
-  const string &get_name() const;
+  const std::string &get_name() const;
 
 public:
   int get_historical_flag() const;
   void clear_historical_flag();
 
-  virtual void output(ostream &out, bool brief) const;
-  virtual void write(ostream &out, bool brief, int indent_level) const;
+  virtual void output(std::ostream &out, bool brief) const;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const;
   void generate_hash(HashGenerator &hashgen) const;
 
 private:
-  const string _name;
+  const std::string _name;
 
   // This flag is only kept for historical reasons, so we can preserve the
   // file's hash code if no new flags are in use.

+ 5 - 5
direct/src/dcparser/dcKeywordList.cxx

@@ -57,7 +57,7 @@ DCKeywordList::
  * Returns true if this list includes the indicated keyword, false otherwise.
  */
 bool DCKeywordList::
-has_keyword(const string &name) const {
+has_keyword(const std::string &name) const {
   return (_keywords_by_name.find(name) != _keywords_by_name.end());
 }
 
@@ -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];
 }
 
@@ -92,14 +92,14 @@ get_keyword(int n) const {
  * is no keyword in the list with that name.
  */
 const DCKeyword *DCKeywordList::
-get_keyword_by_name(const string &name) const {
+get_keyword_by_name(const std::string &name) const {
   KeywordsByName::const_iterator ni;
   ni = _keywords_by_name.find(name);
   if (ni != _keywords_by_name.end()) {
     return (*ni).second;
   }
 
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -148,7 +148,7 @@ clear_keywords() {
  *
  */
 void DCKeywordList::
-output_keywords(ostream &out) const {
+output_keywords(std::ostream &out) const {
   Keywords::const_iterator ki;
   for (ki = _keywords.begin(); ki != _keywords.end(); ++ki) {
     out << " " << (*ki)->get_name();

+ 4 - 4
direct/src/dcparser/dcKeywordList.h

@@ -31,11 +31,11 @@ public:
   ~DCKeywordList();
 
 PUBLISHED:
-  bool has_keyword(const string &name) const;
+  bool has_keyword(const std::string &name) const;
   bool has_keyword(const DCKeyword *keyword) const;
   int get_num_keywords() const;
   const DCKeyword *get_keyword(int n) const;
-  const DCKeyword *get_keyword_by_name(const string &name) const;
+  const DCKeyword *get_keyword_by_name(const std::string &name) const;
 
   bool compare_keywords(const DCKeywordList &other) const;
 
@@ -45,14 +45,14 @@ public:
   bool add_keyword(const DCKeyword *keyword);
   void clear_keywords();
 
-  void output_keywords(ostream &out) const;
+  void output_keywords(std::ostream &out) const;
   void generate_hash(HashGenerator &hashgen) const;
 
 private:
   typedef pvector<const DCKeyword *> Keywords;
   Keywords _keywords;
 
-  typedef pmap<string, const DCKeyword *> KeywordsByName;
+  typedef pmap<std::string, const DCKeyword *> KeywordsByName;
   KeywordsByName _keywords_by_name;
 
   int _flags;

+ 17 - 13
direct/src/dcparser/dcLexer.cxx.prebuilt

@@ -610,11 +610,11 @@ 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 std::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.
-static string dc_filename;
+static std::string dc_filename;
 
 // This is the initial token state returned by the lexer.  It allows
 // the yacc grammar to start from initial points.
@@ -626,7 +626,7 @@ static int initial_token;
 ////////////////////////////////////////////////////////////////////
 
 void
-dc_init_lexer(istream &in, const string &filename) {
+dc_init_lexer(std::istream &in, const std::string &filename) {
   input_p = &in;
   dc_filename = filename;
   line_number = 0;
@@ -671,7 +671,9 @@ dcyywrap(void) {
 }
 
 void
-dcyyerror(const string &msg) {
+dcyyerror(const std::string &msg) {
+  using std::cerr;
+
   cerr << "\nError";
   if (!dc_filename.empty()) {
     cerr << " in " << dc_filename;
@@ -686,7 +688,9 @@ dcyyerror(const string &msg) {
 }
 
 void
-dcyywarning(const string &msg) {
+dcyywarning(const std::string &msg) {
+  using std::cerr;
+
   cerr << "\nWarning";
   if (!dc_filename.empty()) {
     cerr << " in " << dc_filename;
@@ -740,7 +744,7 @@ input_chars(char *buffer, int &result, int max_size) {
 // Define this macro carefully, since different flex versions call it
 // with a different type for result.
 #define YY_INPUT(buffer, result, max_size) { \
-  int int_result; \
+  int int_result = 0; \
   input_chars((buffer), int_result, (max_size)); \
   (result) = int_result; \
 }
@@ -762,9 +766,9 @@ read_char(int &line, int &col) {
 
 // scan_quoted_string reads a string delimited by quotation marks and
 // returns it.
-static string
+static std::string
 scan_quoted_string(char quote_mark) {
-  string result;
+  std::string result;
 
   // We don't touch the current line number and column number during
   // scanning, so that if we detect an error while scanning the string
@@ -884,9 +888,9 @@ scan_quoted_string(char quote_mark) {
 
 // scan_hex_string reads a string of hexadecimal digits delimited by
 // angle brackets and returns the representative string.
-static string
+static std::string
 scan_hex_string() {
-  string result;
+  std::string result;
 
   // We don't touch the current line number and column number during
   // scanning, so that if we detect an error while scanning the string
@@ -916,7 +920,7 @@ scan_hex_string() {
       line_number = line;
       col_number = col;
       dcyyerror("Invalid hex digit.");
-      return string();
+      return std::string();
     }
 
     odd = !odd;
@@ -930,10 +934,10 @@ scan_hex_string() {
 
   if (c == EOF) {
     dcyyerror("This hex string is unterminated.");
-    return string();
+    return std::string();
   } else if (odd) {
     dcyyerror("Odd number of hex digits.");
-    return string();
+    return std::string();
   }
 
   line_number = line;

+ 21 - 17
direct/src/dcparser/dcLexer.lxx

@@ -35,11 +35,11 @@ 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 std::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.
-static string dc_filename;
+static std::string dc_filename;
 
 // This is the initial token state returned by the lexer.  It allows
 // the yacc grammar to start from initial points.
@@ -51,7 +51,7 @@ static int initial_token;
 ////////////////////////////////////////////////////////////////////
 
 void
-dc_init_lexer(istream &in, const string &filename) {
+dc_init_lexer(std::istream &in, const std::string &filename) {
   input_p = &in;
   dc_filename = filename;
   line_number = 0;
@@ -96,7 +96,9 @@ dcyywrap(void) {
 }
 
 void
-dcyyerror(const string &msg) {
+dcyyerror(const std::string &msg) {
+  using std::cerr;
+
   cerr << "\nError";
   if (!dc_filename.empty()) {
     cerr << " in " << dc_filename;
@@ -111,7 +113,9 @@ dcyyerror(const string &msg) {
 }
 
 void
-dcyywarning(const string &msg) {
+dcyywarning(const std::string &msg) {
+  using std::cerr;
+
   cerr << "\nWarning";
   if (!dc_filename.empty()) {
     cerr << " in " << dc_filename;
@@ -129,7 +133,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 +154,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';
       }
     }
@@ -165,7 +169,7 @@ input_chars(char *buffer, int &result, int max_size) {
 // Define this macro carefully, since different flex versions call it
 // with a different type for result.
 #define YY_INPUT(buffer, result, max_size) { \
-  int int_result; \
+  int int_result = 0; \
   input_chars((buffer), int_result, (max_size)); \
   (result) = int_result; \
 }
@@ -187,9 +191,9 @@ read_char(int &line, int &col) {
 
 // scan_quoted_string reads a string delimited by quotation marks and
 // returns it.
-static string
+static std::string
 scan_quoted_string(char quote_mark) {
-  string result;
+  std::string result;
 
   // We don't touch the current line number and column number during
   // scanning, so that if we detect an error while scanning the string
@@ -309,9 +313,9 @@ scan_quoted_string(char quote_mark) {
 
 // scan_hex_string reads a string of hexadecimal digits delimited by
 // angle brackets and returns the representative string.
-static string
+static std::string
 scan_hex_string() {
-  string result;
+  std::string result;
 
   // We don't touch the current line number and column number during
   // scanning, so that if we detect an error while scanning the string
@@ -341,7 +345,7 @@ scan_hex_string() {
       line_number = line;
       col_number = col;
       dcyyerror("Invalid hex digit.");
-      return string();
+      return std::string();
     }
 
     odd = !odd;
@@ -355,10 +359,10 @@ scan_hex_string() {
 
   if (c == EOF) {
     dcyyerror("This hex string is unterminated.");
-    return string();
+    return std::string();
   } else if (odd) {
     dcyyerror("Odd number of hex digits.");
-    return string();
+    return std::string();
   }
 
   line_number = line;
@@ -733,9 +737,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;
     }

+ 3 - 3
direct/src/dcparser/dcLexerDefs.h

@@ -16,14 +16,14 @@
 
 #include "dcbase.h"
 
-void dc_init_lexer(istream &in, const string &filename);
+void dc_init_lexer(std::istream &in, const std::string &filename);
 void dc_start_parameter_value();
 void dc_start_parameter_description();
 int dc_error_count();
 int dc_warning_count();
 
-void dcyyerror(const string &msg);
-void dcyywarning(const string &msg);
+void dcyyerror(const std::string &msg);
+void dcyywarning(const std::string &msg);
 
 int dcyylex();
 

+ 5 - 5
direct/src/dcparser/dcMolecularField.cxx

@@ -22,7 +22,7 @@
  *
  */
 DCMolecularField::
-DCMolecularField(const string &name, DCClass *dclass) : DCField(name, dclass) {
+DCMolecularField(const std::string &name, DCClass *dclass) : DCField(name, dclass) {
   _got_keywords = false;
 }
 
@@ -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];
 }
 
@@ -109,7 +109,7 @@ add_atomic(DCAtomicField *atomic) {
  *
  */
 void DCMolecularField::
-output(ostream &out, bool brief) const {
+output(std::ostream &out, bool brief) const {
   out << _name;
 
   if (!_fields.empty()) {
@@ -130,7 +130,7 @@ output(ostream &out, bool brief) const {
  * stream.
  */
 void DCMolecularField::
-write(ostream &out, bool brief, int indent_level) const {
+write(std::ostream &out, bool brief, int indent_level) const {
   indent(out, indent_level);
   output(out, brief);
   if (!brief) {
@@ -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];
 }
 

+ 3 - 3
direct/src/dcparser/dcMolecularField.h

@@ -27,7 +27,7 @@ class DCParameter;
  */
 class DCMolecularField : public DCField {
 public:
-  DCMolecularField(const string &name, DCClass *dclass);
+  DCMolecularField(const std::string &name, DCClass *dclass);
 
 PUBLISHED:
   virtual DCMolecularField *as_molecular_field();
@@ -39,8 +39,8 @@ PUBLISHED:
 public:
   void add_atomic(DCAtomicField *atomic);
 
-  virtual void output(ostream &out, bool brief) const;
-  virtual void write(ostream &out, bool brief, int indent_level) const;
+  virtual void output(std::ostream &out, bool brief) const;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
 
   virtual DCPackerInterface *get_nested_field(int n) const;

+ 15 - 15
direct/src/dcparser/dcNumericRange.I

@@ -58,7 +58,7 @@ is_in_range(Number num) const {
     return true;
   }
 
-  TYPENAME Ranges::const_iterator ri;
+  typename Ranges::const_iterator ri;
   for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) {
     if (num >= (*ri)._min && num <= (*ri)._max) {
       return true;
@@ -96,7 +96,7 @@ has_one_value() const {
  * by the numeric range.
  */
 template <class NUM>
-INLINE TYPENAME DCNumericRange<NUM>::Number DCNumericRange<NUM>::
+INLINE typename DCNumericRange<NUM>::Number DCNumericRange<NUM>::
 get_one_value() const {
   nassertr(has_one_value(), 0);
   return _ranges[0]._min;
@@ -110,7 +110,7 @@ void DCNumericRange<NUM>::
 generate_hash(HashGenerator &hashgen) const {
   if (!_ranges.empty()) {
     hashgen.add_int(_ranges.size());
-    TYPENAME Ranges::const_iterator ri;
+    typename Ranges::const_iterator ri;
     for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) {
       // We don't account for the fractional part of floating-point ranges
       // here.  Shouldn't be a real issue.
@@ -125,9 +125,9 @@ generate_hash(HashGenerator &hashgen) const {
  */
 template <class NUM>
 void DCNumericRange<NUM>::
-output(ostream &out, Number divisor) const {
+output(std::ostream &out, Number divisor) const {
   if (!_ranges.empty()) {
-    TYPENAME Ranges::const_iterator ri;
+    typename Ranges::const_iterator ri;
     ri = _ranges.begin();
     output_minmax(out, divisor, *ri);
     ++ri;
@@ -145,13 +145,13 @@ output(ostream &out, Number divisor) const {
  */
 template <class NUM>
 void DCNumericRange<NUM>::
-output_char(ostream &out, Number divisor) const {
+output_char(std::ostream &out, Number divisor) const {
   if (divisor != 1) {
     output(out, divisor);
 
   } else {
     if (!_ranges.empty()) {
-      TYPENAME Ranges::const_iterator ri;
+      typename Ranges::const_iterator ri;
       ri = _ranges.begin();
       output_minmax_char(out, *ri);
       ++ri;
@@ -187,7 +187,7 @@ add_range(Number min, Number max) {
     return false;
   }
 
-  TYPENAME Ranges::const_iterator ri;
+  typename Ranges::const_iterator ri;
   for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) {
     if ((min >= (*ri)._min && min <= (*ri)._max) ||
         (max >= (*ri)._min && max <= (*ri)._max) ||
@@ -227,7 +227,7 @@ get_num_ranges() const {
  * Returns the minimum value defined by the nth component.
  */
 template <class NUM>
-INLINE TYPENAME DCNumericRange<NUM>::Number DCNumericRange<NUM>::
+INLINE typename DCNumericRange<NUM>::Number DCNumericRange<NUM>::
 get_min(int n) const {
   nassertr(n >= 0 && n < (int)_ranges.size(), 0);
   return _ranges[n]._min;
@@ -237,7 +237,7 @@ get_min(int n) const {
  * Returns the maximum value defined by the nth component.
  */
 template <class NUM>
-INLINE TYPENAME DCNumericRange<NUM>::Number DCNumericRange<NUM>::
+INLINE typename DCNumericRange<NUM>::Number DCNumericRange<NUM>::
 get_max(int n) const {
   nassertr(n >= 0 && n < (int)_ranges.size(), 0);
   return _ranges[n]._max;
@@ -248,7 +248,7 @@ get_max(int n) const {
  */
 template <class NUM>
 INLINE void DCNumericRange<NUM>::
-output_minmax(ostream &out, Number divisor, const MinMax &range) const {
+output_minmax(std::ostream &out, Number divisor, const MinMax &range) const {
   if (divisor == 1) {
     if (range._min == range._max) {
       out << range._min;
@@ -271,12 +271,12 @@ output_minmax(ostream &out, Number divisor, const MinMax &range) const {
  */
 template <class NUM>
 INLINE void DCNumericRange<NUM>::
-output_minmax_char(ostream &out, const MinMax &range) const {
+output_minmax_char(std::ostream &out, const MinMax &range) const {
   if (range._min == range._max) {
-    DCPacker::enquote_string(out, '\'', string(1, range._min));
+    DCPacker::enquote_string(out, '\'', std::string(1, range._min));
   } else {
-    DCPacker::enquote_string(out, '\'', string(1, range._min));
+    DCPacker::enquote_string(out, '\'', std::string(1, range._min));
     out << "-";
-    DCPacker::enquote_string(out, '\'', string(1, range._max));
+    DCPacker::enquote_string(out, '\'', std::string(1, range._max));
   }
 }

+ 4 - 4
direct/src/dcparser/dcNumericRange.h

@@ -40,8 +40,8 @@ public:
 
   void generate_hash(HashGenerator &hashgen) const;
 
-  void output(ostream &out, Number divisor = 1) const;
-  void output_char(ostream &out, Number divisor = 1) const;
+  void output(std::ostream &out, Number divisor = 1) const;
+  void output_char(std::ostream &out, Number divisor = 1) const;
 
 public:
   INLINE void clear();
@@ -60,8 +60,8 @@ private:
     Number _min;
     Number _max;
   };
-  INLINE void output_minmax(ostream &out, Number divisor, const MinMax &range) const;
-  INLINE void output_minmax_char(ostream &out, const MinMax &range) const;
+  INLINE void output_minmax(std::ostream &out, Number divisor, const MinMax &range) const;
+  INLINE void output_minmax_char(std::ostream &out, const MinMax &range) const;
 
   typedef pvector<MinMax> Ranges;
   Ranges _ranges;

+ 6 - 6
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,16 +82,16 @@ 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;
 }
 
 /**
  * Returns the data buffer as a string.  Also see get_data().
  */
-INLINE string DCPackData::
+INLINE std::string DCPackData::
 get_string() const {
-  return string(_buffer, _used_length);
+  return std::string(_buffer, _used_length);
 }
 
 /**
@@ -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;

+ 1 - 1
direct/src/dcparser/dcPackData.h

@@ -34,7 +34,7 @@ public:
   INLINE char *get_rewrite_pointer(size_t position, size_t size);
 
 PUBLISHED:
-  INLINE string get_string() const;
+  INLINE std::string get_string() const;
   INLINE size_t get_length() const;
 public:
   INLINE const char *get_data() const;

+ 59 - 59
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();
@@ -123,10 +123,10 @@ get_pack_type() const {
  * Returns the name of the current field, if it has a name, or the empty
  * string if the field does not have a name or there is no current field.
  */
-INLINE string DCPacker::
+INLINE std::string DCPacker::
 get_current_field_name() const {
-  if (_current_field == NULL) {
-    return string();
+  if (_current_field == nullptr) {
+    return std::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);
@@ -206,9 +206,9 @@ pack_uint64(uint64_t value) {
  * Packs the indicated numeric or string value into the stream.
  */
 INLINE void DCPacker::
-pack_string(const string &value) {
+pack_string(const std::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);
@@ -221,9 +221,9 @@ pack_string(const string &value) {
  * packed field element, or a whole group of field elements at once.
  */
 INLINE void DCPacker::
-pack_literal_value(const string &value) {
+pack_literal_value(const std::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 {
@@ -329,11 +329,11 @@ unpack_uint64() {
 /**
  * Unpacks the current numeric or string value from the stream.
  */
-INLINE string DCPacker::
+INLINE std::string DCPacker::
 unpack_string() {
-  string value;
+  std::string value;
   nassertr(_mode == M_unpack, value);
-  if (_current_field == NULL) {
+  if (_current_field == nullptr) {
     _pack_error = true;
 
   } else {
@@ -349,12 +349,12 @@ unpack_string() {
  * Returns the literal string that represents the packed value of the current
  * field, and advances the field pointer.
  */
-INLINE string DCPacker::
+INLINE std::string DCPacker::
 unpack_literal_value() {
   size_t start = _unpack_p;
   unpack_skip();
-  nassertr(_unpack_p >= start, string());
-  return string(_unpack_data + start, _unpack_p - start);
+  nassertr(_unpack_p >= start, std::string());
+  return std::string(_unpack_data + start, _unpack_p - start);
 }
 
 /**
@@ -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 {
@@ -441,9 +441,9 @@ unpack_uint64(uint64_t &value) {
  * Unpacks the current numeric or string value from the stream.
  */
 INLINE void DCPacker::
-unpack_string(string &value) {
+unpack_string(std::string &value) {
   nassertv(_mode == M_unpack);
-  if (_current_field == NULL) {
+  if (_current_field == nullptr) {
     _pack_error = true;
 
   } else {
@@ -458,7 +458,7 @@ unpack_string(string &value) {
  * field, and advances the field pointer.
  */
 INLINE void DCPacker::
-unpack_literal_value(string &value) {
+unpack_literal_value(std::string &value) {
   size_t start = _unpack_p;
   unpack_skip();
   nassertv(_unpack_p >= start);
@@ -536,7 +536,7 @@ get_length() const {
 /**
  * Returns the packed data buffer as a string.  Also see get_data().
  */
-INLINE string DCPacker::
+INLINE std::string DCPacker::
 get_string() const {
   return _pack_data.get_string();
 }
@@ -556,16 +556,16 @@ get_unpack_length() const {
  * unpacking; it is separate from the pack data returned by get_string(),
  * which is filled during packing.  Also see get_unpack_data().
  */
-INLINE string DCPacker::
+INLINE std::string DCPacker::
 get_unpack_string() const {
-  return string(_unpack_data, _unpack_length);
+  return std::string(_unpack_data, _unpack_length);
 }
 
 /**
  * Copies the packed data into the indicated string.  Also see get_data().
  */
 INLINE void DCPacker::
-get_string(string &data) const {
+get_string(std::string &data) const {
   data.assign(_pack_data.get_data(), _pack_data.get_length());
 }
 
@@ -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);
 }
 
@@ -722,7 +722,7 @@ raw_pack_float64(double value) {
  * Packs the data into the buffer between packing sessions.
  */
 INLINE void DCPacker::
-raw_pack_string(const string &value) {
+raw_pack_string(const std::string &value) {
   nassertv(_mode == M_idle);
   DCPackerInterface::do_pack_uint16(_pack_data.get_write_pointer(2), value.length());
   _pack_data.append_data(value.data(), value.length());
@@ -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;
@@ -863,9 +863,9 @@ raw_unpack_float64() {
 /**
  * Unpacks the data from the buffer between unpacking sessions.
  */
-INLINE string DCPacker::
+INLINE std::string DCPacker::
 raw_unpack_string() {
-  string value;
+  std::string value;
   raw_unpack_string(value);
   return value;
 }
@@ -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;
@@ -958,8 +958,8 @@ raw_unpack_float64(double &value) {
  * Unpacks the data from the buffer between unpacking sessions.
  */
 INLINE void DCPacker::
-raw_unpack_string(string &value) {
-  nassertv(_mode == M_idle && _unpack_data != NULL);
+raw_unpack_string(std::string &value) {
+  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;

+ 82 - 76
direct/src/dcparser/dcPacker.cxx

@@ -23,7 +23,13 @@
 #include "py_panda.h"
 #endif
 
-DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = NULL;
+using std::istream;
+using std::istringstream;
+using std::ostream;
+using std::ostringstream;
+using std::string;
+
+DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = nullptr;
 int DCPacker::StackElement::_num_ever_allocated = 0;
 
 /**
@@ -32,15 +38,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 +79,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 +100,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 +152,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 +160,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 +181,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 +212,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 +226,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 +268,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 +298,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 +330,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 +340,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 +363,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 +476,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 +493,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 +503,7 @@ pop() {
     _pack_error = true;
   }
 
-  if (_stack == NULL) {
+  if (_stack == nullptr) {
     // Unbalanced pop().
     _pack_error = true;
 
@@ -528,7 +534,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 +551,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 +577,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 +603,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 +745,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 +777,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,11 +788,11 @@ 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 {
-          cerr << "Unable to extract item " << i << " from sequence.\n";
+          std::cerr << "Unable to extract item " << i << " from sequence.\n";
         }
       }
       pop();
@@ -812,7 +818,7 @@ pack_object(PyObject *object) {
  */
 PyObject *DCPacker::
 unpack_object() {
-  PyObject *object = NULL;
+  PyObject *object = nullptr;
 
   DCPackType pack_type = get_pack_type();
 
@@ -896,14 +902,14 @@ 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) {
-            cerr << "Unable to construct object of class "
+          if (object == nullptr) {
+            std::cerr << "Unable to construct object of class "
                  << dclass->get_name() << "\n";
           } else {
             break;
@@ -939,7 +945,7 @@ unpack_object() {
     break;
   }
 
-  nassertr(object != (PyObject *)NULL, NULL);
+  nassertr(object != nullptr, nullptr);
   return object;
 }
 #endif  // HAVE_PYTHON
@@ -995,10 +1001,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 +1141,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 +1153,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 +1179,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 +1200,7 @@ clear() {
  */
 void DCPacker::
 clear_stack() {
-  while (_stack != (StackElement *)NULL) {
+  while (_stack != nullptr) {
     StackElement *next = _stack->_next;
     delete _stack;
     _stack = next;
@@ -1212,7 +1218,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 +1233,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 +1293,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 +1313,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 +1321,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 +1330,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 +1359,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();

+ 21 - 21
direct/src/dcparser/dcPacker.h

@@ -41,7 +41,7 @@ PUBLISHED:
   void begin_pack(const DCPackerInterface *root);
   bool end_pack();
 
-  void set_unpack_data(const string &data);
+  void set_unpack_data(const std::string &data);
 public:
   void set_unpack_data(const char *unpack_data, size_t unpack_length,
                        bool owns_unpack_data);
@@ -53,7 +53,7 @@ PUBLISHED:
   void begin_repack(const DCPackerInterface *root);
   bool end_repack();
 
-  bool seek(const string &field_name);
+  bool seek(const std::string &field_name);
   bool seek(int seek_index);
 
   INLINE bool has_nested_fields() const;
@@ -64,7 +64,7 @@ PUBLISHED:
   INLINE const DCPackerInterface *get_current_field() const;
   INLINE const DCSwitchParameter *get_last_switch() const;
   INLINE DCPackType get_pack_type() const;
-  INLINE string get_current_field_name() const;
+  INLINE std::string get_current_field_name() const;
 
   void push();
   void pop();
@@ -74,8 +74,8 @@ PUBLISHED:
   INLINE void pack_uint(unsigned int value);
   INLINE void pack_int64(int64_t value);
   INLINE void pack_uint64(uint64_t value);
-  INLINE void pack_string(const string &value);
-  INLINE void pack_literal_value(const string &value);
+  INLINE void pack_string(const std::string &value);
+  INLINE void pack_literal_value(const std::string &value);
   void pack_default_value();
 
   INLINE double unpack_double();
@@ -83,8 +83,8 @@ PUBLISHED:
   INLINE unsigned int unpack_uint();
   INLINE int64_t unpack_int64();
   INLINE uint64_t unpack_uint64();
-  INLINE string unpack_string();
-  INLINE string unpack_literal_value();
+  INLINE std::string unpack_string();
+  INLINE std::string unpack_literal_value();
   void unpack_validate();
   void unpack_skip();
 
@@ -96,8 +96,8 @@ public:
   INLINE void unpack_uint(unsigned int &value);
   INLINE void unpack_int64(int64_t &value);
   INLINE void unpack_uint64(uint64_t &value);
-  INLINE void unpack_string(string &value);
-  INLINE void unpack_literal_value(string &value);
+  INLINE void unpack_string(std::string &value);
+  INLINE void unpack_literal_value(std::string &value);
 
 PUBLISHED:
 
@@ -106,10 +106,10 @@ PUBLISHED:
   PyObject *unpack_object();
 #endif
 
-  bool parse_and_pack(const string &formatted_object);
-  bool parse_and_pack(istream &in);
-  string unpack_and_format(bool show_field_names = true);
-  void unpack_and_format(ostream &out, bool show_field_names = true);
+  bool parse_and_pack(const std::string &formatted_object);
+  bool parse_and_pack(std::istream &in);
+  std::string unpack_and_format(bool show_field_names = true);
+  void unpack_and_format(std::ostream &out, bool show_field_names = true);
 
   INLINE bool had_parse_error() const;
   INLINE bool had_pack_error() const;
@@ -118,11 +118,11 @@ PUBLISHED:
   INLINE size_t get_num_unpacked_bytes() const;
 
   INLINE size_t get_length() const;
-  INLINE string get_string() const;
+  INLINE std::string get_string() const;
   INLINE size_t get_unpack_length() const;
-  INLINE string get_unpack_string() const;
+  INLINE std::string get_unpack_string() const;
 public:
-  INLINE void get_string(string &data) const;
+  INLINE void get_string(std::string &data) const;
   INLINE const char *get_data() const;
   INLINE char *take_data();
 
@@ -147,7 +147,7 @@ PUBLISHED:
   INLINE void raw_pack_uint32(unsigned int value);
   INLINE void raw_pack_uint64(uint64_t value);
   INLINE void raw_pack_float64(double value);
-  INLINE void raw_pack_string(const string &value);
+  INLINE void raw_pack_string(const std::string &value);
 
 // this is a hack to allw me to get in and out of 32bit Mode Faster need to
 // agree with channel_type in dcbase.h
@@ -164,7 +164,7 @@ PUBLISHED:
   INLINE unsigned int raw_unpack_uint32();
   INLINE uint64_t raw_unpack_uint64();
   INLINE double raw_unpack_float64();
-  INLINE string raw_unpack_string();
+  INLINE std::string raw_unpack_string();
 
 public:
   INLINE void raw_unpack_int8(int &value);
@@ -176,11 +176,11 @@ public:
   INLINE void raw_unpack_uint32(unsigned int &value);
   INLINE void raw_unpack_uint64(uint64_t &value);
   INLINE void raw_unpack_float64(double &value);
-  INLINE void raw_unpack_string(string &value);
+  INLINE void raw_unpack_string(std::string &value);
 
 public:
-  static void enquote_string(ostream &out, char quote_mark, const string &str);
-  static void output_hex_string(ostream &out, const string &str);
+  static void enquote_string(std::ostream &out, char quote_mark, const std::string &str);
+  static void output_hex_string(std::ostream &out, const std::string &str);
 
 private:
   INLINE void advance();

+ 1 - 1
direct/src/dcparser/dcPackerCatalog.I

@@ -52,7 +52,7 @@ get_entry(int n) const {
  * get_entry().
  */
 int DCPackerCatalog::LiveCatalog::
-find_entry_by_name(const string &name) const {
+find_entry_by_name(const std::string &name) const {
   return _catalog->find_entry_by_name(name);
 }
 

+ 14 - 12
direct/src/dcparser/dcPackerCatalog.cxx

@@ -16,12 +16,14 @@
 #include "dcPacker.h"
 #include "dcSwitchParameter.h"
 
+using std::string;
+
 /**
  * The catalog is created only by DCPackerInterface::get_catalog().
  */
 DCPackerCatalog::
 DCPackerCatalog(const DCPackerInterface *root) : _root(root) {
-  _live_catalog = NULL;
+  _live_catalog = nullptr;
 }
 
 /**
@@ -34,7 +36,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 +44,7 @@ DCPackerCatalog(const DCPackerCatalog &copy) :
  */
 DCPackerCatalog::
 ~DCPackerCatalog() {
-  if (_live_catalog != (LiveCatalog *)NULL) {
+  if (_live_catalog != nullptr) {
     delete _live_catalog;
   }
 
@@ -92,7 +94,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 +113,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 +190,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 +199,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 +213,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 +257,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 +319,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);
     }
   }

+ 7 - 7
direct/src/dcparser/dcPackerCatalog.h

@@ -37,7 +37,7 @@ public:
   // and its relationship to its parent.
   class Entry {
   public:
-    string _name;
+    std::string _name;
     const DCPackerInterface *_field;
     const DCPackerInterface *_parent;
     int _field_index;
@@ -58,7 +58,7 @@ public:
 
     INLINE int get_num_entries() const;
     INLINE const Entry &get_entry(int n) const;
-    INLINE int find_entry_by_name(const string &name) const;
+    INLINE int find_entry_by_name(const std::string &name) const;
     INLINE int find_entry_by_field(const DCPackerInterface *field) const;
 
   private:
@@ -71,17 +71,17 @@ public:
 
   INLINE int get_num_entries() const;
   INLINE const Entry &get_entry(int n) const;
-  int find_entry_by_name(const string &name) const;
+  int find_entry_by_name(const std::string &name) const;
   int find_entry_by_field(const DCPackerInterface *field) const;
 
   const LiveCatalog *get_live_catalog(const char *data, size_t length) const;
   void release_live_catalog(const LiveCatalog *live_catalog) const;
 
 private:
-  void add_entry(const string &name, const DCPackerInterface *field,
+  void add_entry(const std::string &name, const DCPackerInterface *field,
                  const DCPackerInterface *parent, int field_index);
 
-  void r_fill_catalog(const string &name_prefix, const DCPackerInterface *field,
+  void r_fill_catalog(const std::string &name_prefix, const DCPackerInterface *field,
                       const DCPackerInterface *parent, int field_index);
   void r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer,
                            const DCSwitchParameter *&last_switch) const;
@@ -96,7 +96,7 @@ private:
   typedef pvector<Entry> Entries;
   Entries _entries;
 
-  typedef pmap<string, int> EntriesByName;
+  typedef pmap<std::string, int> EntriesByName;
   EntriesByName _entries_by_name;
 
   typedef pmap<const DCPackerInterface *, int> EntriesByField;
@@ -105,7 +105,7 @@ private:
   typedef pmap<const DCPackerInterface *, DCPackerCatalog *> SwitchCatalogs;
   SwitchCatalogs _switch_catalogs;
 
-  typedef pmap<const DCSwitchParameter *, string> SwitchPrefixes;
+  typedef pmap<const DCSwitchParameter *, std::string> SwitchPrefixes;
   SwitchPrefixes _switch_prefixes;
 
   friend class DCPackerInterface;

+ 1 - 1
direct/src/dcparser/dcPackerInterface.I

@@ -14,7 +14,7 @@
 /**
  * Returns the name of this field, or empty string if the field is unnamed.
  */
-INLINE const string &DCPackerInterface::
+INLINE const std::string &DCPackerInterface::
 get_name() const {
   return _name;
 }

+ 17 - 15
direct/src/dcparser/dcPackerInterface.cxx

@@ -17,6 +17,8 @@
 #include "dcParserDefs.h"
 #include "dcLexerDefs.h"
 
+using std::string;
+
 /**
  *
  */
@@ -32,7 +34,7 @@ DCPackerInterface(const string &name) :
   _has_nested_fields = false;
   _num_nested_fields = -1;
   _pack_type = PT_invalid;
-  _catalog = NULL;
+  _catalog = nullptr;
 }
 
 /**
@@ -50,7 +52,7 @@ DCPackerInterface(const DCPackerInterface &copy) :
   _num_nested_fields(copy._num_nested_fields),
   _pack_type(copy._pack_type)
 {
-  _catalog = NULL;
+  _catalog = nullptr;
 }
 
 /**
@@ -58,7 +60,7 @@ DCPackerInterface(const DCPackerInterface &copy) :
  */
 DCPackerInterface::
 ~DCPackerInterface() {
-  if (_catalog != (DCPackerCatalog *)NULL) {
+  if (_catalog != nullptr) {
     delete _catalog;
   }
 }
@@ -83,7 +85,7 @@ find_seek_index(const string &name) const {
  */
 DCField *DCPackerInterface::
 as_field() {
-  return (DCField *)NULL;
+  return nullptr;
 }
 
 /**
@@ -91,7 +93,7 @@ as_field() {
  */
 const DCField *DCPackerInterface::
 as_field() const {
-  return (DCField *)NULL;
+  return nullptr;
 }
 
 /**
@@ -99,7 +101,7 @@ as_field() const {
  */
 DCSwitchParameter *DCPackerInterface::
 as_switch_parameter() {
-  return (DCSwitchParameter *)NULL;
+  return nullptr;
 }
 
 /**
@@ -107,7 +109,7 @@ as_switch_parameter() {
  */
 const DCSwitchParameter *DCPackerInterface::
 as_switch_parameter() const {
-  return (DCSwitchParameter *)NULL;
+  return nullptr;
 }
 
 /**
@@ -115,7 +117,7 @@ as_switch_parameter() const {
  */
 DCClassParameter *DCPackerInterface::
 as_class_parameter() {
-  return (DCClassParameter *)NULL;
+  return nullptr;
 }
 
 /**
@@ -123,7 +125,7 @@ as_class_parameter() {
  */
 const DCClassParameter *DCPackerInterface::
 as_class_parameter() const {
-  return (DCClassParameter *)NULL;
+  return nullptr;
 }
 
 /**
@@ -139,13 +141,13 @@ bool DCPackerInterface::
 check_match(const string &description, DCFile *dcfile) const {
   bool match = false;
 
-  istringstream strm(description);
+  std::istringstream strm(description);
   dc_init_parser_parameter_description(strm, "check_match", dcfile);
   dcyyparse();
   dc_cleanup_parser();
 
   DCField *field = dc_get_parameter_description();
-  if (field != NULL) {
+  if (field != nullptr) {
     match = check_match(field);
     delete field;
   }
@@ -184,7 +186,7 @@ calc_num_nested_fields(size_t) const {
  */
 DCPackerInterface *DCPackerInterface::
 get_nested_field(int) const {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -367,7 +369,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 +434,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);
 }

+ 8 - 8
direct/src/dcparser/dcPackerInterface.h

@@ -66,13 +66,13 @@ END_PUBLISH
  */
 class DCPackerInterface {
 public:
-  DCPackerInterface(const string &name = string());
+  DCPackerInterface(const std::string &name = std::string());
   DCPackerInterface(const DCPackerInterface &copy);
   virtual ~DCPackerInterface();
 
 PUBLISHED:
-  INLINE const string &get_name() const;
-  int find_seek_index(const string &name) const;
+  INLINE const std::string &get_name() const;
+  int find_seek_index(const std::string &name) const;
 
   virtual DCField *as_field();
   virtual const DCField *as_field() const;
@@ -82,10 +82,10 @@ 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 std::string &description, DCFile *dcfile = nullptr) const;
 
 public:
-  virtual void set_name(const string &name);
+  virtual void set_name(const std::string &name);
   INLINE bool has_fixed_byte_size() const;
   INLINE size_t get_fixed_byte_size() const;
   INLINE bool has_fixed_structure() const;
@@ -111,7 +111,7 @@ public:
                           bool &pack_error, bool &range_error) const;
   virtual void pack_uint64(DCPackData &pack_data, uint64_t value,
                            bool &pack_error, bool &range_error) const;
-  virtual void pack_string(DCPackData &pack_data, const string &value,
+  virtual void pack_string(DCPackData &pack_data, const std::string &value,
                            bool &pack_error, bool &range_error) const;
   virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
 
@@ -126,7 +126,7 @@ public:
   virtual void unpack_uint64(const char *data, size_t length, size_t &p,
                              uint64_t &value, bool &pack_error, bool &range_error) const;
   virtual void unpack_string(const char *data, size_t length, size_t &p,
-                             string &value, bool &pack_error, bool &range_error) const;
+                             std::string &value, bool &pack_error, bool &range_error) const;
   virtual bool unpack_validate(const char *data, size_t length, size_t &p,
                                bool &pack_error, bool &range_error) const;
   virtual bool unpack_skip(const char *data, size_t length, size_t &p,
@@ -184,7 +184,7 @@ private:
   void make_catalog();
 
 protected:
-  string _name;
+  std::string _name;
   bool _has_fixed_byte_size;
   size_t _fixed_byte_size;
   bool _has_fixed_structure;

+ 12 - 9
direct/src/dcparser/dcParameter.cxx

@@ -17,12 +17,15 @@
 #include "dcindent.h"
 #include "dcTypedef.h"
 
+using std::ostream;
+using std::string;
+
 /**
  *
  */
 DCParameter::
 DCParameter() {
-  _typedef = NULL;
+  _typedef = nullptr;
   _has_fixed_byte_size = false;
   _has_fixed_structure = false;
   _num_nested_fields = -1;
@@ -66,7 +69,7 @@ as_parameter() const {
  */
 DCSimpleParameter *DCParameter::
 as_simple_parameter() {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -74,7 +77,7 @@ as_simple_parameter() {
  */
 const DCSimpleParameter *DCParameter::
 as_simple_parameter() const {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -82,7 +85,7 @@ as_simple_parameter() const {
  */
 DCClassParameter *DCParameter::
 as_class_parameter() {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -90,7 +93,7 @@ as_class_parameter() {
  */
 const DCClassParameter *DCParameter::
 as_class_parameter() const {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -98,7 +101,7 @@ as_class_parameter() const {
  */
 DCSwitchParameter *DCParameter::
 as_switch_parameter() {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -106,7 +109,7 @@ as_switch_parameter() {
  */
 const DCSwitchParameter *DCParameter::
 as_switch_parameter() const {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -114,7 +117,7 @@ as_switch_parameter() const {
  */
 DCArrayParameter *DCParameter::
 as_array_parameter() {
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -122,7 +125,7 @@ as_array_parameter() {
  */
 const DCArrayParameter *DCParameter::
 as_array_parameter() const {
-  return NULL;
+  return nullptr;
 }
 
 /**

+ 12 - 12
direct/src/dcparser/dcParameter.h

@@ -60,18 +60,18 @@ public:
   void set_typedef(const DCTypedef *dtypedef);
   virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size);
 
-  virtual void output(ostream &out, bool brief) const;
-  virtual void write(ostream &out, bool brief, int indent_level) const;
-  virtual void output_instance(ostream &out, bool brief, const string &prename,
-                               const string &name, const string &postname) const=0;
-  virtual void write_instance(ostream &out, bool brief, int indent_level,
-                              const string &prename, const string &name,
-                              const string &postname) const;
-  void output_typedef_name(ostream &out, bool brief, const string &prename,
-                           const string &name, const string &postname) const;
-  void write_typedef_name(ostream &out, bool brief, int indent_level,
-                          const string &prename, const string &name,
-                          const string &postname) const;
+  virtual void output(std::ostream &out, bool brief) const;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const;
+  virtual void output_instance(std::ostream &out, bool brief, const std::string &prename,
+                               const std::string &name, const std::string &postname) const=0;
+  virtual void write_instance(std::ostream &out, bool brief, int indent_level,
+                              const std::string &prename, const std::string &name,
+                              const std::string &postname) const;
+  void output_typedef_name(std::ostream &out, bool brief, const std::string &prename,
+                           const std::string &name, const std::string &postname) const;
+  void write_typedef_name(std::ostream &out, bool brief, int indent_level,
+                          const std::string &prename, const std::string &name,
+                          const std::string &postname) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
 
 private:

+ 4 - 0
direct/src/dcparser/dcParser.cxx.prebuilt

@@ -101,6 +101,10 @@
 #define YYINITDEPTH 1000
 #define YYMAXDEPTH 1000
 
+using std::istream;
+using std::ostringstream;
+using std::string;
+
 DCFile *dc_file = (DCFile *)NULL;
 static DCClass *current_class = (DCClass *)NULL;
 static DCSwitch *current_switch = (DCSwitch *)NULL;

+ 61 - 57
direct/src/dcparser/dcParser.yxx

@@ -29,18 +29,22 @@
 #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;
+using std::istream;
+using std::ostringstream;
+using std::string;
+
+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 +59,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 +70,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 +81,7 @@ dc_get_parameter_description() {
 
 void
 dc_cleanup_parser() {
-  dc_file = (DCFile *)NULL;
+  dc_file = nullptr;
 }
 
 %}
@@ -181,7 +185,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 +253,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 +308,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 +336,7 @@ dclass_derivation:
 dclass_base_list:
         dclass_name
 {
-  if ($1 != (DCClass *)NULL) {
+  if ($1 != nullptr) {
     current_class->add_parent($1);
   }
 }
@@ -342,7 +346,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 +358,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 +371,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 +383,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 +412,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 +440,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 +457,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 +487,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 +515,7 @@ nonempty_parameter_list:
 atomic_element:
         parameter_with_default
 {
-  if ($1 != (DCParameter *)NULL) {
+  if ($1 != nullptr) {
     current_atomic->add_element($1);
   }
 }
@@ -538,14 +542,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 +572,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 +640,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 +649,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 +665,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 +680,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 +713,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 +729,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 +844,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 +861,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 +876,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 +1188,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 +1204,7 @@ atomic_name:
 
   } else {
     $$ = field->as_atomic_field();
-    if ($$ == (DCAtomicField *)NULL) {
+    if ($$ == nullptr) {
       yyerror("Not an atomic field: " + $1);
     }
   }
@@ -1210,13 +1214,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 +1262,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());
     }

+ 4 - 4
direct/src/dcparser/dcParserDefs.h

@@ -26,10 +26,10 @@ class DCParameter;
 class DCKeyword;
 class DCPacker;
 
-void dc_init_parser(istream &in, const string &filename, DCFile &file);
-void dc_init_parser_parameter_value(istream &in, const string &filename,
+void dc_init_parser(std::istream &in, const std::string &filename, DCFile &file);
+void dc_init_parser_parameter_value(std::istream &in, const std::string &filename,
                                     DCPacker &packer);
-void dc_init_parser_parameter_description(istream &in, const string &filename,
+void dc_init_parser_parameter_description(std::istream &in, const std::string &filename,
                                           DCFile *file);
 DCField *dc_get_parameter_description();
 void dc_cleanup_parser();
@@ -60,7 +60,7 @@ public:
     DCParameter *parameter;
     const DCKeyword *keyword;
   } u;
-  string str;
+  std::string str;
 };
 
 // The yacc-generated code expects to use the symbol 'YYSTYPE' to refer to the

+ 9 - 7
direct/src/dcparser/dcSimpleParameter.cxx

@@ -20,8 +20,10 @@
 #include "hashGenerator.h"
 #include <math.h>
 
+using std::string;
+
 DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map;
-DCClassParameter *DCSimpleParameter::_uint32uint8_type = NULL;
+DCClassParameter *DCSimpleParameter::_uint32uint8_type = nullptr;
 
 /**
  *
@@ -186,7 +188,7 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) :
     _nested_field = create_uint32uint8_type();
 
   } else {
-    _nested_field = NULL;
+    _nested_field = nullptr;
   }
 }
 
@@ -2171,9 +2173,9 @@ unpack_skip(const char *data, size_t length, size_t &p,
  * identifier.
  */
 void DCSimpleParameter::
-output_instance(ostream &out, bool brief, const string &prename,
+output_instance(std::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 +2344,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 +2376,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);

+ 4 - 4
direct/src/dcparser/dcSimpleParameter.h

@@ -60,7 +60,7 @@ public:
                           bool &pack_error, bool &range_error) const;
   virtual void pack_uint64(DCPackData &pack_data, uint64_t value,
                            bool &pack_error, bool &range_error) const;
-  virtual void pack_string(DCPackData &pack_data, const string &value,
+  virtual void pack_string(DCPackData &pack_data, const std::string &value,
                            bool &pack_error, bool &range_error) const;
   virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
 
@@ -75,14 +75,14 @@ public:
   virtual void unpack_uint64(const char *data, size_t length, size_t &p,
                              uint64_t &value, bool &pack_error, bool &range_error) const;
   virtual void unpack_string(const char *data, size_t length, size_t &p,
-                             string &value, bool &pack_error, bool &range_error) const;
+                             std::string &value, bool &pack_error, bool &range_error) const;
   virtual bool unpack_validate(const char *data, size_t length, size_t &p,
                                bool &pack_error, bool &range_error) const;
   virtual bool unpack_skip(const char *data, size_t length, size_t &p,
                            bool &pack_error) const;
 
-  virtual void output_instance(ostream &out, bool brief, const string &prename,
-                               const string &name, const string &postname) const;
+  virtual void output_instance(std::ostream &out, bool brief, const std::string &prename,
+                               const std::string &name, const std::string &postname) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
 
 protected:

+ 2 - 2
direct/src/dcparser/dcSubatomicType.cxx

@@ -13,8 +13,8 @@
 
 #include "dcSubatomicType.h"
 
-ostream &
-operator << (ostream &out, DCSubatomicType type) {
+std::ostream &
+operator << (std::ostream &out, DCSubatomicType type) {
   switch (type) {
   case ST_int8:
     return out << "int8";

+ 1 - 1
direct/src/dcparser/dcSubatomicType.h

@@ -60,6 +60,6 @@ enum DCSubatomicType {
 };
 END_PUBLISH
 
-ostream &operator << (ostream &out, DCSubatomicType type);
+std::ostream &operator << (std::ostream &out, DCSubatomicType type);
 
 #endif

+ 28 - 25
direct/src/dcparser/dcSwitch.cxx

@@ -18,6 +18,9 @@
 #include "dcindent.h"
 #include "dcPacker.h"
 
+using std::ostream;
+using std::string;
+
 /**
  * The key_parameter must be recently allocated via new; it will be deleted
  * via delete when the switch destructs.
@@ -27,7 +30,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 +39,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 +124,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 +160,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 +171,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 +180,7 @@ get_field_by_name(int case_index, const string &name) const {
     return (*ni).second;
   }
 
-  return NULL;
+  return nullptr;
 }
 
 /**
@@ -226,7 +229,7 @@ add_invalid_case() {
  */
 bool DCSwitch::
 add_default() {
-  if (_default_case != (SwitchFields *)NULL) {
+  if (_default_case != nullptr) {
     add_invalid_case();
     return false;
   }
@@ -286,12 +289,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 +329,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 +375,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 +388,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 +431,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 +449,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 +469,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 +531,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 +590,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];
 }
 

+ 21 - 21
direct/src/dcparser/dcSwitch.h

@@ -29,29 +29,29 @@ class DCField;
  */
 class DCSwitch : public DCDeclaration {
 public:
-  DCSwitch(const string &name, DCField *key_parameter);
+  DCSwitch(const std::string &name, DCField *key_parameter);
   virtual ~DCSwitch();
 
 PUBLISHED:
   virtual DCSwitch *as_switch();
   virtual const DCSwitch *as_switch() const;
 
-  const string &get_name() const;
+  const std::string &get_name() const;
   DCField *get_key_parameter() const;
 
   int get_num_cases() const;
-  int get_case_by_value(const string &case_value) const;
+  int get_case_by_value(const std::string &case_value) const;
   DCPackerInterface *get_case(int n) const;
   DCPackerInterface *get_default_case() const;
 
-  string get_value(int case_index) const;
+  std::string get_value(int case_index) const;
   int get_num_fields(int case_index) const;
   DCField *get_field(int case_index, int n) const;
-  DCField *get_field_by_name(int case_index, const string &name) const;
+  DCField *get_field_by_name(int case_index, const std::string &name) const;
 
 public:
   bool is_field_valid() const;
-  int add_case(const string &value);
+  int add_case(const std::string &value);
   void add_invalid_case();
   bool add_default();
   bool add_field(DCField *field);
@@ -59,13 +59,13 @@ public:
 
   const DCPackerInterface *apply_switch(const char *value_data, size_t length) const;
 
-  virtual void output(ostream &out, bool brief) const;
-  virtual void write(ostream &out, bool brief, int indent_level) const;
-  void output_instance(ostream &out, bool brief, const string &prename,
-                       const string &name, const string &postname) const;
-  void write_instance(ostream &out, bool brief, int indent_level,
-                      const string &prename, const string &name,
-                      const string &postname) const;
+  virtual void output(std::ostream &out, bool brief) const;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const;
+  void output_instance(std::ostream &out, bool brief, const std::string &prename,
+                       const std::string &name, const std::string &postname) const;
+  void write_instance(std::ostream &out, bool brief, int indent_level,
+                      const std::string &prename, const std::string &name,
+                      const std::string &postname) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
   virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
 
@@ -73,19 +73,19 @@ public:
 
 public:
   typedef pvector<DCField *> Fields;
-  typedef pmap<string, DCField *> FieldsByName;
+  typedef pmap<std::string, DCField *> FieldsByName;
 
   class SwitchFields : public DCPackerInterface {
   public:
-    SwitchFields(const string &name);
+    SwitchFields(const std::string &name);
     ~SwitchFields();
     virtual DCPackerInterface *get_nested_field(int n) const;
 
     bool add_field(DCField *field);
     bool do_check_match_switch_case(const SwitchFields *other) const;
 
-    void output(ostream &out, bool brief) const;
-    void write(ostream &out, bool brief, int indent_level) const;
+    void output(std::ostream &out, bool brief) const;
+    void write(std::ostream &out, bool brief, int indent_level) const;
 
   protected:
     virtual bool do_check_match(const DCPackerInterface *other) const;
@@ -98,13 +98,13 @@ public:
 
   class SwitchCase {
   public:
-    SwitchCase(const string &value, SwitchFields *fields);
+    SwitchCase(const std::string &value, SwitchFields *fields);
     ~SwitchCase();
 
     bool do_check_match_switch_case(const SwitchCase *other) const;
 
   public:
-    string _value;
+    std::string _value;
     SwitchFields *_fields;
   };
 
@@ -112,7 +112,7 @@ private:
   SwitchFields *start_new_case();
 
 private:
-  string _name;
+  std::string _name;
   DCField *_key_parameter;
 
   typedef pvector<SwitchCase *> Cases;
@@ -137,7 +137,7 @@ private:
   bool _fields_added;
 
   // This map indexes into the _cases vector, above.
-  typedef pmap<string, int> CasesByValue;
+  typedef pmap<std::string, int> CasesByValue;
   CasesByValue _cases_by_value;
 };
 

+ 7 - 5
direct/src/dcparser/dcSwitchParameter.cxx

@@ -15,6 +15,8 @@
 #include "dcSwitch.h"
 #include "hashGenerator.h"
 
+using std::string;
+
 /**
  *
  */
@@ -66,7 +68,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;
@@ -153,9 +155,9 @@ apply_switch(const char *value_data, size_t length) const {
  * identifier.
  */
 void DCSwitchParameter::
-output_instance(ostream &out, bool brief, const string &prename,
+output_instance(std::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 {
@@ -168,10 +170,10 @@ output_instance(ostream &out, bool brief, const string &prename,
  * identifier.
  */
 void DCSwitchParameter::
-write_instance(ostream &out, bool brief, int indent_level,
+write_instance(std::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 {

+ 5 - 5
direct/src/dcparser/dcSwitchParameter.h

@@ -41,11 +41,11 @@ public:
 
   const DCPackerInterface *apply_switch(const char *value_data, size_t length) const;
 
-  virtual void output_instance(ostream &out, bool brief, const string &prename,
-                               const string &name, const string &postname) const;
-  virtual void write_instance(ostream &out, bool brief, int indent_level,
-                              const string &prename, const string &name,
-                              const string &postname) const;
+  virtual void output_instance(std::ostream &out, bool brief, const std::string &prename,
+                               const std::string &name, const std::string &postname) const;
+  virtual void write_instance(std::ostream &out, bool brief, int indent_level,
+                              const std::string &prename, const std::string &name,
+                              const std::string &postname) const;
   virtual void generate_hash(HashGenerator &hashgen) const;
   virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const;
 

+ 5 - 3
direct/src/dcparser/dcTypedef.cxx

@@ -16,6 +16,8 @@
 #include "dcSimpleParameter.h"
 #include "dcindent.h"
 
+using std::string;
+
 /**
  * The DCTypedef object becomes the owner of the supplied parameter pointer
  * and will delete it upon destruction.
@@ -72,7 +74,7 @@ get_name() const {
  */
 string DCTypedef::
 get_description() const {
-  ostringstream strm;
+  std::ostringstream strm;
   _parameter->output(strm, true);
   return strm.str();
 }
@@ -122,7 +124,7 @@ set_number(int number) {
  * Write a string representation of this instance to <out>.
  */
 void DCTypedef::
-output(ostream &out, bool brief) const {
+output(std::ostream &out, bool brief) const {
   out << "typedef ";
   _parameter->output(out, false);
 }
@@ -131,7 +133,7 @@ output(ostream &out, bool brief) const {
  *
  */
 void DCTypedef::
-write(ostream &out, bool brief, int indent_level) const {
+write(std::ostream &out, bool brief, int indent_level) const {
   indent(out, indent_level)
     << "typedef ";
 

+ 5 - 5
direct/src/dcparser/dcTypedef.h

@@ -26,13 +26,13 @@ class DCParameter;
 class DCTypedef : public DCDeclaration {
 public:
   DCTypedef(DCParameter *parameter, bool implicit = false);
-  DCTypedef(const string &name);
+  DCTypedef(const std::string &name);
   virtual ~DCTypedef();
 
 PUBLISHED:
   int get_number() const;
-  const string &get_name() const;
-  string get_description() const;
+  const std::string &get_name() const;
+  std::string get_description() const;
 
   bool is_bogus_typedef() const;
   bool is_implicit_typedef() const;
@@ -41,8 +41,8 @@ public:
   DCParameter *make_new_parameter() const;
 
   void set_number(int number);
-  virtual void output(ostream &out, bool brief) const;
-  virtual void write(ostream &out, bool brief, int indent_level) const;
+  virtual void output(std::ostream &out, bool brief) const;
+  virtual void write(std::ostream &out, bool brief, int indent_level) const;
 
 private:
   DCParameter *_parameter;

+ 7 - 10
direct/src/dcparser/dcbase.h

@@ -60,10 +60,7 @@
 #include <unistd.h>
 #endif
 
-using namespace std;
-
 #define INLINE inline
-#define TYPENAME typename
 
 // These symbols are used within the Panda environment for exporting classes
 // and functions to the scripting language.  They're largely meaningless if
@@ -82,7 +79,7 @@ using namespace std;
 
 // Panda defines a special Filename class.  We'll use an ordinary string
 // instead.
-typedef string Filename;
+typedef std::string Filename;
 
 // Panda defines WORDS_BIGENDIAN on a bigendian machine; otherwise, the
 // machine is assumed to be littleendian.  Outside of Panda, you're
@@ -92,15 +89,15 @@ typedef string Filename;
 #include <vector>
 #include <map>
 #include <set>
-#define pvector vector
-#define pmap map
-#define pset set
+#define pvector std::vector
+#define pmap std::map
+#define pset std::set
 
 #include <stdint.h>
 
-typedef ifstream pifstream;
-typedef ofstream pofstream;
-typedef fstream pfstream;
+typedef std::ifstream pifstream;
+typedef std::ofstream pofstream;
+typedef std::fstream pfstream;
 
 #endif  // WITHIN_PANDA
 

+ 2 - 2
direct/src/dcparser/dcindent.cxx

@@ -18,8 +18,8 @@
 /**
  *
  */
-ostream &
-indent(ostream &out, int indent_level) {
+std::ostream &
+indent(std::ostream &out, int indent_level) {
   for (int i = 0; i < indent_level; i++) {
     out << ' ';
   }

+ 2 - 2
direct/src/dcparser/dcindent.h

@@ -29,8 +29,8 @@
  * stream itself.  Useful for indenting a series of lines of text by a given
  * amount.
  */
-ostream &
-indent(ostream &out, int indent_level);
+std::ostream &
+indent(std::ostream &out, int indent_level);
 
 #endif  // WITHIN_PANDA
 

+ 2 - 2
direct/src/dcparser/hashGenerator.cxx

@@ -48,9 +48,9 @@ add_int(int num) {
  * Adds a string to the hash, by breaking it down into a sequence of integers.
  */
 void HashGenerator::
-add_string(const string &str) {
+add_string(const std::string &str) {
   add_int(str.length());
-  string::const_iterator si;
+  std::string::const_iterator si;
   for (si = str.begin(); si != str.end(); ++si) {
     add_int(*si);
   }

+ 1 - 1
direct/src/dcparser/hashGenerator.h

@@ -25,7 +25,7 @@ public:
   HashGenerator();
 
   void add_int(int num);
-  void add_string(const string &str);
+  void add_string(const std::string &str);
 
   unsigned long get_hash() const;
 

+ 1 - 1
direct/src/dcparser/primeNumberGenerator.h

@@ -22,7 +22,7 @@
 #include "vector_int.h"
 
 #else
-typedef vector<int> vector_int;
+typedef std::vector<int> vector_int;
 #endif
 
 /**

+ 5 - 5
direct/src/deadrec/smoothMover.cxx

@@ -95,7 +95,7 @@ mark_position() {
       LVector3 pos_delta = _sample._pos - _smooth_pos;
       LVecBase3 hpr_delta = _sample._hpr - _smooth_hpr;
       double age = timestamp - _smooth_timestamp;
-      age = min(age, _max_position_age);
+      age = std::min(age, _max_position_age);
 
       set_smooth_pos(_sample._pos, _sample._hpr, timestamp);
       if (age != 0.0) {
@@ -272,13 +272,13 @@ compute_smooth_position(double timestamp) {
 
   // Find the newest of the points before the indicated time.  Assume that
   // this will be no older than _last_point_before.
-  i = max(0, _last_point_before);
+  i = std::max(0, _last_point_before);
   while (i < num_points && _points[i]._timestamp < timestamp) {
     point_before = i;
     timestamp_before = _points[i]._timestamp;
     ++i;
   }
-  point_way_before = max(point_before - 1, -1);
+  point_way_before = std::max(point_before - 1, -1);
 
   // Now the next point is presumably the oldest point after the indicated
   // time.
@@ -527,7 +527,7 @@ get_latest_position() {
  *
  */
 void SmoothMover::
-output(ostream &out) const {
+output(std::ostream &out) const {
   out << "SmoothMover, " << _points.size() << " sample points.";
 }
 
@@ -535,7 +535,7 @@ output(ostream &out) const {
  *
  */
 void SmoothMover::
-write(ostream &out) const {
+write(std::ostream &out) const {
   out << "SmoothMover, " << _points.size() << " sample points:\n";
   int num_points = _points.size();
   for (int i = 0; i < num_points; i++) {

+ 2 - 2
direct/src/deadrec/smoothMover.h

@@ -137,8 +137,8 @@ PUBLISHED:
   INLINE void set_default_to_standing_still(bool flag);
   INLINE bool get_default_to_standing_still();
 
-  void output(ostream &out) const;
-  void write(ostream &out) const;
+  void output(std::ostream &out) const;
+  void write(std::ostream &out) const;
 
 private:
   void set_smooth_pos(const LPoint3 &pos, const LVecBase3 &hpr,

+ 9 - 4
direct/src/directd/directd.cxx

@@ -34,6 +34,11 @@
   #error Buildsystem error: BUILDING_DIRECT_DIRECTD not defined
 #endif
 
+using std::cerr;
+using std::cout;
+using std::endl;
+using std::string;
+
 namespace {
   // ...This section is part of the old stuff from the original
   // implementation.  The new stuff that uses job objects doesn't need this
@@ -83,7 +88,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 +120,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;
@@ -148,7 +153,7 @@ DirectD::~DirectD() {
 int
 DirectD::client_ready(const string& server_host, int port,
     const string& cmd) {
-  stringstream ss;
+  std::stringstream ss;
   ss<<"!"<<cmd;
   send_one_message(server_host, port, ss.str());
   return 0;
@@ -228,7 +233,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

Some files were not shown because too many files changed in this diff