Merge branch 'master' into input-overhaul

This commit is contained in:
rdb
2018-06-08 15:23:47 +02:00
3519 changed files with 34583 additions and 38269 deletions

View File

@@ -43,24 +43,26 @@ Building Panda3D
Windows
-------
We currently build using the Microsoft Visual C++ 2010 compiler. You do not
need Microsoft Visual Studio to build Panda3D, though - the relevant compilers
are included as part of the Windows 7.1 SDK.
We currently build using the Microsoft Visual C++ 2015 compiler. You will
also need to install the [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk),
and if you intend to target Windows XP, you will also need the
[Windows 7.1 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=8279).
You will also need to have the third-party dependency libraries available for
the build scripts to use. These are available from one of these two URLs,
depending on whether you are on a 32-bit or 64-bit system:
https://www.panda3d.org/download/panda3d-1.9.4/panda3d-1.9.4-tools-win32.zip
https://www.panda3d.org/download/panda3d-1.9.4/panda3d-1.9.4-tools-win64.zip
depending on whether you are on a 32-bit or 64-bit system, or you can
[click here](https://github.com/rdb/panda3d-thirdparty) for instructions on
building them from source.
(It is also possible to build using MSVC 2015 and 2017, which requires a
different set of thirdparty libraries, but that is not described here.)
http://rdb.name/thirdparty-vc14-x64.7z
http://rdb.name/thirdparty-vc14.7z
After acquiring these dependencies, you may simply build Panda3D from the
command prompt using the following command:
command prompt using the following command. (Add the `--windows-sdk=10`
option if you don't need to support Windows XP.)
```bash
makepanda\makepanda.bat --everything --installer --no-eigen
makepanda\makepanda.bat --everything --installer --no-eigen --threads=2
```
When the build succeeds, it will produce an .exe file that you can use to

View File

@@ -21,16 +21,16 @@ AIBehaviors::AIBehaviors() {
_previous_conflict = false;
_conflict = false;
_seek_obj = NULL;
_flee_obj = NULL;
_pursue_obj = NULL;
_evade_obj = NULL;
_arrival_obj = NULL;
_wander_obj = NULL;
_flock_group = NULL;
_path_follow_obj = NULL;
_path_find_obj = NULL;
_obstacle_avoidance_obj = NULL;
_seek_obj = nullptr;
_flee_obj = nullptr;
_pursue_obj = nullptr;
_evade_obj = nullptr;
_arrival_obj = nullptr;
_wander_obj = nullptr;
_flock_group = nullptr;
_path_follow_obj = nullptr;
_path_find_obj = nullptr;
_obstacle_avoidance_obj = nullptr;
turn_off("seek");
turn_off("flee");
@@ -267,7 +267,7 @@ LVecBase3 AIBehaviors::calculate_prioritized() {
accumulate_force("obstacle_avoidance", force);
}
if(_path_follow_obj!=NULL) {
if(_path_follow_obj!=nullptr) {
if(_path_follow_obj->_start) {
_path_follow_obj->do_follow();
}
@@ -286,13 +286,13 @@ LVecBase3 AIBehaviors::calculate_prioritized() {
}
if(is_on(_arrival)) {
if(_seek_obj != NULL) {
if(_seek_obj != nullptr) {
LVecBase3 dirn = _steering_force;
dirn.normalize();
_steering_force = ((_steering_force.length() - _arrival_force.length()) * dirn);
}
if(_pursue_obj != NULL) {
if(_pursue_obj != nullptr) {
LVecBase3 dirn = _steering_force;
dirn.normalize();
_steering_force = ((_steering_force.length() - _arrival_force.length()) * _arrival_obj->_arrival_direction);
@@ -320,10 +320,10 @@ void AIBehaviors::remove_ai(string ai_type) {
}
case 1: {
if(_seek_obj != NULL) {
if(_seek_obj != nullptr) {
turn_off("seek");
delete _seek_obj;
_seek_obj = NULL;
_seek_obj = nullptr;
}
break;
}
@@ -338,10 +338,10 @@ void AIBehaviors::remove_ai(string ai_type) {
}
case 3: {
if(_pursue_obj != NULL) {
if(_pursue_obj != nullptr) {
turn_off("pursue");
delete _pursue_obj;
_pursue_obj = NULL;
_pursue_obj = nullptr;
}
break;
}
@@ -356,59 +356,59 @@ void AIBehaviors::remove_ai(string ai_type) {
}
case 5: {
if(_arrival_obj != NULL) {
if(_arrival_obj != nullptr) {
turn_off("arrival");
turn_off("arrival_activate");
delete _arrival_obj;
_arrival_obj = NULL;
_arrival_obj = nullptr;
}
break;
}
case 6: {
if(_flock_group != NULL) {
if(_flock_group != nullptr) {
turn_off("flock");
turn_off("flock_activate");
_flock_group = NULL;
_flock_group = nullptr;
}
break;
}
case 7: {
if(_wander_obj != NULL) {
if(_wander_obj != nullptr) {
turn_off("wander");
delete _wander_obj;
_wander_obj = NULL;
_wander_obj = nullptr;
}
break;
}
case 8: {
if(_obstacle_avoidance_obj !=NULL) {
if(_obstacle_avoidance_obj !=nullptr) {
turn_off("obstacle_avoidance");
delete _obstacle_avoidance_obj;
_obstacle_avoidance_obj = NULL;
_obstacle_avoidance_obj = nullptr;
}
break;
}
case 9: {
if(_pursue_obj != NULL && _path_follow_obj != NULL) {
if(_pursue_obj != nullptr && _path_follow_obj != nullptr) {
turn_off("pursue");
delete _pursue_obj;
_pursue_obj = NULL;
_pursue_obj = nullptr;
delete _path_follow_obj;
_path_follow_obj = NULL;
_path_follow_obj = nullptr;
}
break;
}
case 16: {
if(_pursue_obj != NULL && _path_follow_obj != NULL) {
if(_pursue_obj != nullptr && _path_follow_obj != nullptr) {
turn_off("pursue");
delete _pursue_obj;
_pursue_obj = NULL;
_pursue_obj = nullptr;
delete _path_follow_obj;
_path_follow_obj = NULL;
_path_follow_obj = nullptr;
}
break;
}
@@ -436,7 +436,7 @@ void AIBehaviors::pause_ai(string ai_type) {
}
case 1: {
if(_seek_obj != NULL) {
if(_seek_obj != nullptr) {
turn_off("seek");
}
break;
@@ -451,7 +451,7 @@ void AIBehaviors::pause_ai(string ai_type) {
}
case 3: {
if(_pursue_obj != NULL) {
if(_pursue_obj != nullptr) {
turn_off("pursue");
}
break;
@@ -466,7 +466,7 @@ void AIBehaviors::pause_ai(string ai_type) {
}
case 5: {
if(_arrival_obj != NULL) {
if(_arrival_obj != nullptr) {
turn_off("arrival");
turn_off("arrival_activate");
}
@@ -474,7 +474,7 @@ void AIBehaviors::pause_ai(string ai_type) {
}
case 6: {
if(_flock_group != NULL) {
if(_flock_group != nullptr) {
turn_off("flock");
turn_off("flock_activate");
}
@@ -482,14 +482,14 @@ void AIBehaviors::pause_ai(string ai_type) {
}
case 7: {
if(_wander_obj != NULL) {
if(_wander_obj != nullptr) {
turn_off("wander");
}
break;
}
case 8: {
if(_obstacle_avoidance_obj != NULL) {
if(_obstacle_avoidance_obj != nullptr) {
turn_off("obstacle_avoidance");
turn_off("obstacle_avoidance_activate");
}
@@ -497,14 +497,14 @@ void AIBehaviors::pause_ai(string ai_type) {
}
case 9: {
if(_pursue_obj != NULL && _path_follow_obj != NULL) {
if(_pursue_obj != nullptr && _path_follow_obj != nullptr) {
turn_off("pursue");
_path_follow_obj->_start = false;
}
break;
}
case 16: {
if(_pursue_obj != NULL && _path_follow_obj != NULL) {
if(_pursue_obj != nullptr && _path_follow_obj != nullptr) {
turn_off("pursue");
_path_follow_obj->_start = false;
}
@@ -534,7 +534,7 @@ void AIBehaviors::resume_ai(string ai_type) {
}
case 1: {
if(_seek_obj != NULL) {
if(_seek_obj != nullptr) {
turn_on("seek");
}
break;
@@ -548,7 +548,7 @@ void AIBehaviors::resume_ai(string ai_type) {
}
case 3: {
if(_pursue_obj != NULL) {
if(_pursue_obj != nullptr) {
turn_on("pursue");
}
break;
@@ -562,42 +562,42 @@ void AIBehaviors::resume_ai(string ai_type) {
}
case 5: {
if(_arrival_obj != NULL) {
if(_arrival_obj != nullptr) {
turn_on("arrival");
}
break;
}
case 6: {
if(_flock_group != NULL) {
if(_flock_group != nullptr) {
turn_on("flock");
}
break;
}
case 7: {
if(_wander_obj != NULL) {
if(_wander_obj != nullptr) {
turn_on("wander");
}
break;
}
case 8: {
if(_obstacle_avoidance_obj != NULL) {
if(_obstacle_avoidance_obj != nullptr) {
turn_on("obstacle_avoidance");
}
break;
}
case 9: {
if(_pursue_obj != NULL && _path_follow_obj != NULL) {
if(_pursue_obj != nullptr && _path_follow_obj != nullptr) {
turn_on("pursue");
_path_follow_obj->_start = true;
}
break;
}
case 16: {
if(_pursue_obj != NULL && _path_follow_obj != NULL) {
if(_pursue_obj != nullptr && _path_follow_obj != nullptr) {
turn_off("pursue");
_path_follow_obj->_start = false;
}

View File

@@ -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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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;

View File

@@ -14,44 +14,56 @@
#include "aiWorld.h"
AIWorld::AIWorld(NodePath render) {
_ai_char_pool = new AICharPool();
_render = render;
_render = 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);
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(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);
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) {
cout << ai_char->_name << 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.

View File

@@ -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);

View File

@@ -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");

View File

@@ -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:

View File

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

View File

@@ -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();

View File

@@ -23,7 +23,7 @@ PathFind::PathFind(AICharacter *ai_ch) {
_pen->set_color(1.0, 0.0, 0.0);
_pen->set_thickness(2.0);
_path_finder_obj = NULL;
_path_finder_obj = nullptr;
_dynamic_avoid = false;
}
@@ -46,7 +46,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
string fields[10];
// Open data file for reading.
ifstream nav_mesh_file (navmesh_filename);
std::ifstream nav_mesh_file (navmesh_filename);
if(nav_mesh_file.is_open()) {
// Capture the grid size from the file.
@@ -56,9 +56,9 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
// Initialize the stage mesh with NULL nodes.
for(int r = 0; r < _grid_size; ++r) {
_nav_mesh.push_back(vector<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);
}
}
@@ -111,7 +111,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) {
* _nav_mesh.
*/
void PathFind::assign_neighbor_nodes(const char* navmesh_filename){
ifstream nav_mesh_file (navmesh_filename);
std::ifstream nav_mesh_file (navmesh_filename);
// Stage variables.
int gd_x, gd_y, gd_xn, gd_yn;
@@ -150,7 +150,7 @@ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){
}
else if(fields_n[0] == "1" && fields_n[1] == "1") {
// NULL neighbor.
_nav_mesh[gd_y][gd_x]->_neighbours[i] = NULL;
_nav_mesh[gd_y][gd_x]->_neighbours[i] = nullptr;
}
else {
cout<<"Warning: Corrupt data!"<<endl;
@@ -183,7 +183,7 @@ void PathFind::set_path_find(const char* navmesh_filename) {
if(_path_finder_obj) {
delete _path_finder_obj;
_path_finder_obj = NULL;
_path_finder_obj = nullptr;
}
_path_finder_obj = new PathFinder(_nav_mesh);
@@ -207,17 +207,17 @@ void PathFind::path_find(LVecBase3 pos, string type) {
Node* src = find_in_mesh(_nav_mesh, _ai_char->_ai_char_np.get_pos(_ai_char->_window_render), _grid_size);
if(src == NULL) {
if(src == nullptr) {
cout<<"couldnt find source"<<endl;
}
Node* dst = find_in_mesh(_nav_mesh, pos, _grid_size);
if(dst == NULL) {
if(dst == nullptr) {
cout<<"couldnt find destination"<<endl;
}
if(src != NULL && dst != NULL) {
if(src != nullptr && dst != nullptr) {
_path_finder_obj->find_path(src, dst);
trace_path(src);
}
@@ -248,22 +248,22 @@ void PathFind::path_find(NodePath target, string type) {
Node* src = find_in_mesh(_nav_mesh, _ai_char->_ai_char_np.get_pos(_ai_char->_window_render), _grid_size);
if(src == NULL) {
if(src == nullptr) {
cout<<"couldnt find source"<<endl;
}
Node* dst = find_in_mesh(_nav_mesh, _prev_position, _grid_size);
if(dst == NULL) {
if(dst == nullptr) {
cout<<"couldnt find destination"<<endl;
}
if(src != NULL && dst != NULL) {
if(src != nullptr && dst != nullptr) {
_path_finder_obj->find_path(src, dst);
trace_path(src);
}
if(_ai_char->_steering->_path_follow_obj!=NULL) {
if(_ai_char->_steering->_path_follow_obj!=nullptr) {
if(!_ai_char->_steering->_path_follow_obj->_start) {
_ai_char->_steering->start_follow("pathfind");
}
@@ -277,12 +277,12 @@ void PathFind::clear_path() {
// Initialize to zero
for(int i = 0; i < _grid_size; ++i) {
for(int j = 0; j < _grid_size; ++j) {
if(_nav_mesh[i][j] != NULL) {
if(_nav_mesh[i][j] != nullptr) {
_nav_mesh[i][j]->_status = _nav_mesh[i][j]->neutral;
_nav_mesh[i][j]->_cost = 0;
_nav_mesh[i][j]->_heuristic = 0;
_nav_mesh[i][j]->_score = 0;
_nav_mesh[i][j]->_prv_node = NULL;
_nav_mesh[i][j]->_prv_node = nullptr;
}
}
}
@@ -333,7 +333,7 @@ void PathFind::add_obstacle_to_mesh(NodePath obstacle) {
Node* temp = find_in_mesh(_nav_mesh, obstacle.get_pos(), _grid_size);
if(temp != NULL) {
if(temp != nullptr) {
float left = temp->_position.get_x() - np_sphere->get_radius();
float right = temp->_position.get_x() + np_sphere->get_radius();
float top = temp->_position.get_y() + np_sphere->get_radius();
@@ -341,7 +341,7 @@ void PathFind::add_obstacle_to_mesh(NodePath obstacle) {
for(int i = 0; i < _grid_size; ++i) {
for(int j = 0; j < _grid_size; ++j) {
if(_nav_mesh[i][j] != NULL && _nav_mesh[i][j]->_type == true) {
if(_nav_mesh[i][j] != nullptr && _nav_mesh[i][j]->_type == true) {
if(_nav_mesh[i][j]->_position.get_x() >= left && _nav_mesh[i][j]->_position.get_x() <= right &&
_nav_mesh[i][j]->_position.get_y() >= down && _nav_mesh[i][j]->_position.get_y() <= top) {
_nav_mesh[i][j]->_type = false;

View File

@@ -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);
};

View File

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

0
contrib/src/panda3dtoolsgui/build_exe.bat Executable file → Normal file
View File

View File

@@ -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;

View File

@@ -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:

View File

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

View File

@@ -45,6 +45,7 @@ class PointerSlotStorage {};
using std::tr1::array;
#else
#include <array>
using std::array;
#endif
/**
@@ -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++;
}

View File

@@ -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)

View File

@@ -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;

View File

@@ -122,7 +122,7 @@ protected:
LightType _light_type;
float _near_plane;
vector<ShadowSource*> _shadow_sources;
std::vector<ShadowSource*> _shadow_sources;
};
#include "rpLight.I"

View File

@@ -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;

View File

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

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -488,7 +488,7 @@ class FileSaver:
out_file.write (i2+ "alight = AmbientLight(\'"+ light.getName() +"\')\n")
out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n")
out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n")
out_file.write (i2+ "self."+light.getName()+"= render.attachNewNode(alight.upcastToPandaNode())\n")
out_file.write (i2+ "self."+light.getName()+"= render.attachNewNode(alight)\n")
out_file.write (i2+ "self."+light.getName()+".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n")
out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n")
out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n")
@@ -503,7 +503,7 @@ class FileSaver:
#out_file.write (i2+ "alight.setPoint(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n")
out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n")
out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n")
out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n")
out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight)\n")
out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n")
out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n")
out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n")
@@ -521,7 +521,7 @@ class FileSaver:
out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n")
out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n")
out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n")
out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n")
out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight)\n")
out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n")
out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n")
out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n")
@@ -539,7 +539,7 @@ class FileSaver:
out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n")
out_file.write (i2+ "alight.setExponent(" +str(light.getExponent()) +")\n")
out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n")
out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToLensNode())\n")
out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight)\n")
out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n")
out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n")
out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n")

View File

@@ -63,13 +63,8 @@ class seLight(NodePath):
self.lence = lence
self.active = True
if isinstance(light, Spotlight):
node = light.upcastToLensNode()
else:
node = light.upcastToPandaNode()
# Attach node to self
self.LightNode=parent.attachNewNode(node)
self.LightNode=parent.attachNewNode(light)
self.LightNode.setTag("Metadata",tag)
if(self.type=='spot'):
self.LightNode.setHpr(self.orientation)
@@ -418,8 +413,6 @@ class seLightManager(NodePath):
#################################################################
type = lower(light.getType().getName())
light.upcastToNamable()
specularColor = VBase4(1)
position = Point3(0,0,0)
orientation = Vec3(1,0,0)

View File

@@ -103,8 +103,8 @@ write_complete_field_list(const DCFile &file) {
cout << field->get_class()->get_name() << "::";
}
cout << field->get_name();
if (field->as_atomic_field() != (DCAtomicField *)NULL ||
field->as_molecular_field() != (DCMolecularField *)NULL) {
if (field->as_atomic_field() != nullptr ||
field->as_molecular_field() != nullptr) {
// It's a "method".
cout << "()";
}

View File

@@ -58,7 +58,7 @@ DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size) :
_pack_type = PT_array;
DCSimpleParameter *simple_type = _element_type->as_simple_parameter();
if (simple_type != (DCSimpleParameter *)NULL) {
if (simple_type != nullptr) {
if (simple_type->get_type() == ST_char) {
// We make a special case for char[] arrays: these we format as a
// string. (It will still accept an array of ints packed into it.) We
@@ -148,7 +148,7 @@ get_array_size() const {
*/
DCParameter *DCArrayParameter::
append_array_specification(const DCUnsignedIntRange &size) {
if (get_typedef() != (DCTypedef *)NULL) {
if (get_typedef() != nullptr) {
// If this was a typedef, wrap it directly.
return new DCArrayParameter(this, size);
}
@@ -203,7 +203,7 @@ validate_num_nested_fields(int num_nested_fields) const {
void DCArrayParameter::
output_instance(ostream &out, bool brief, const string &prename,
const string &name, const string &postname) const {
if (get_typedef() != (DCTypedef *)NULL) {
if (get_typedef() != nullptr) {
output_typedef_name(out, brief, prename, name, postname);
} else {
@@ -236,7 +236,7 @@ pack_string(DCPackData &pack_data, const string &value,
bool &pack_error, bool &range_error) const {
// We can only pack a string if the array element type is char or int8.
DCSimpleParameter *simple_type = _element_type->as_simple_parameter();
if (simple_type == (DCSimpleParameter *)NULL) {
if (simple_type == nullptr) {
pack_error = true;
return;
}
@@ -306,7 +306,7 @@ unpack_string(const char *data, size_t length, size_t &p, string &value,
bool &pack_error, bool &range_error) const {
// We can only unpack a string if the array element type is char or int8.
DCSimpleParameter *simple_type = _element_type->as_simple_parameter();
if (simple_type == (DCSimpleParameter *)NULL) {
if (simple_type == nullptr) {
pack_error = true;
return;
}

View File

@@ -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;

View File

@@ -73,7 +73,7 @@ get_num_elements() const {
*/
DCParameter *DCAtomicField::
get_element(int n) const {
nassertr(n >= 0 && n < (int)_elements.size(), NULL);
nassertr(n >= 0 && n < (int)_elements.size(), nullptr);
return _elements[n];
}
@@ -127,7 +127,7 @@ DCSubatomicType DCAtomicField::
get_element_type(int n) const {
nassertr(n >= 0 && n < (int)_elements.size(), ST_invalid);
DCSimpleParameter *simple_parameter = _elements[n]->as_simple_parameter();
nassertr(simple_parameter != (DCSimpleParameter *)NULL, ST_invalid);
nassertr(simple_parameter != nullptr, ST_invalid);
return simple_parameter->get_type();
}
@@ -143,7 +143,7 @@ int DCAtomicField::
get_element_divisor(int n) const {
nassertr(n >= 0 && n < (int)_elements.size(), 1);
DCSimpleParameter *simple_parameter = _elements[n]->as_simple_parameter();
nassertr(simple_parameter != (DCSimpleParameter *)NULL, 1);
nassertr(simple_parameter != nullptr, 1);
return simple_parameter->get_divisor();
}
@@ -207,7 +207,7 @@ generate_hash(HashGenerator &hashgen) const {
*/
DCPackerInterface *DCAtomicField::
get_nested_field(int n) const {
nassertr(n >= 0 && n < (int)_elements.size(), NULL);
nassertr(n >= 0 && n < (int)_elements.size(), nullptr);
return _elements[n];
}

View File

@@ -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;

View File

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

View File

@@ -80,11 +80,11 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) :
_bogus_class(bogus_class)
{
_number = -1;
_constructor = NULL;
_constructor = nullptr;
#ifdef HAVE_PYTHON
_class_def = NULL;
_owner_class_def = NULL;
_class_def = nullptr;
_owner_class_def = nullptr;
#endif
}
@@ -93,7 +93,7 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) :
*/
DCClass::
~DCClass() {
if (_constructor != (DCField *)NULL) {
if (_constructor != nullptr) {
delete _constructor;
}
@@ -137,7 +137,7 @@ get_num_parents() const {
*/
DCClass *DCClass::
get_parent(int n) const {
nassertr(n >= 0 && n < (int)_parents.size(), NULL);
nassertr(n >= 0 && n < (int)_parents.size(), nullptr);
return _parents[n];
}
@@ -147,7 +147,7 @@ get_parent(int n) const {
*/
bool DCClass::
has_constructor() const {
return (_constructor != (DCField *)NULL);
return (_constructor != nullptr);
}
/**
@@ -183,7 +183,7 @@ get_field(int n) const {
// __asm { int 3 }
}
#endif //]
nassertr_always(n >= 0 && n < (int)_fields.size(), NULL);
nassertr_always(n >= 0 && n < (int)_fields.size(), nullptr);
return _fields[n];
}
@@ -205,13 +205,13 @@ get_field_by_name(const string &name) const {
Parents::const_iterator pi;
for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
DCField *result = (*pi)->get_field_by_name(name);
if (result != (DCField *)NULL) {
if (result != nullptr) {
return result;
}
}
// Nobody knew what this field is.
return (DCField *)NULL;
return nullptr;
}
/**
@@ -232,7 +232,7 @@ get_field_by_index(int index_number) const {
Parents::const_iterator pi;
for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
DCField *result = (*pi)->get_field_by_index(index_number);
if (result != (DCField *)NULL) {
if (result != nullptr) {
// Cache this result for future lookups.
((DCClass *)this)->_fields_by_index[index_number] = result;
return result;
@@ -240,7 +240,7 @@ get_field_by_index(int index_number) const {
}
// Nobody knew what this field is.
return (DCField *)NULL;
return nullptr;
}
/**
@@ -250,7 +250,7 @@ get_field_by_index(int index_number) const {
int DCClass::
get_num_inherited_fields() const {
if (dc_multiple_inheritance && dc_virtual_inheritance &&
_dc_file != (DCFile *)NULL) {
_dc_file != nullptr) {
_dc_file->check_inherited_fields();
if (_inherited_fields.empty()) {
((DCClass *)this)->rebuild_inherited_fields();
@@ -283,12 +283,12 @@ get_num_inherited_fields() const {
DCField *DCClass::
get_inherited_field(int n) const {
if (dc_multiple_inheritance && dc_virtual_inheritance &&
_dc_file != (DCFile *)NULL) {
_dc_file != nullptr) {
_dc_file->check_inherited_fields();
if (_inherited_fields.empty()) {
((DCClass *)this)->rebuild_inherited_fields();
}
nassertr(n >= 0 && n < (int)_inherited_fields.size(), NULL);
nassertr(n >= 0 && n < (int)_inherited_fields.size(), nullptr);
return _inherited_fields[n];
} else {
@@ -349,7 +349,7 @@ output(ostream &out) const {
*/
bool DCClass::
has_class_def() const {
return (_class_def != NULL);
return (_class_def != nullptr);
}
#endif // HAVE_PYTHON
@@ -373,7 +373,7 @@ set_class_def(PyObject *class_def) {
*/
PyObject *DCClass::
get_class_def() const {
if (_class_def == NULL) {
if (_class_def == nullptr) {
Py_INCREF(Py_None);
return Py_None;
}
@@ -390,7 +390,7 @@ get_class_def() const {
*/
bool DCClass::
has_owner_class_def() const {
return (_owner_class_def != NULL);
return (_owner_class_def != nullptr);
}
#endif // HAVE_PYTHON
@@ -414,7 +414,7 @@ set_owner_class_def(PyObject *owner_class_def) {
*/
PyObject *DCClass::
get_owner_class_def() const {
if (_owner_class_def == NULL) {
if (_owner_class_def == nullptr) {
Py_INCREF(Py_None);
return Py_None;
}
@@ -441,7 +441,7 @@ receive_update(PyObject *distobj, DatagramIterator &di) const {
int field_id = packer.raw_unpack_uint16();
DCField *field = get_field_by_index(field_id);
if (field == (DCField *)NULL) {
if (field == nullptr) {
ostringstream strm;
strm
<< "Received update for field " << field_id << ", not in class "
@@ -478,7 +478,7 @@ receive_update_broadcast_required(PyObject *distobj, DatagramIterator &di) const
int num_fields = get_num_inherited_fields();
for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) {
DCField *field = get_inherited_field(i);
if (field->as_molecular_field() == (DCMolecularField *)NULL &&
if (field->as_molecular_field() == nullptr &&
field->is_required() && field->is_broadcast()) {
packer.begin_unpack(field);
field->receive_update(packer, distobj);
@@ -513,16 +513,10 @@ 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 &&
field->is_required()) {
if (field->as_molecular_field() == nullptr &&
field->is_required() && (field->is_ownrecv() || field->is_broadcast())) {
packer.begin_unpack(field);
if (field->is_ownrecv()) {
field->receive_update(packer, distobj);
} else {
// It's not an ownrecv field; skip over it. It's difficult to filter
// this on the server, ask Roger for the reason.
packer.unpack_skip();
}
field->receive_update(packer, distobj);
if (!packer.end_unpack()) {
break;
}
@@ -552,7 +546,7 @@ receive_update_all_required(PyObject *distobj, DatagramIterator &di) const {
int num_fields = get_num_inherited_fields();
for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) {
DCField *field = get_inherited_field(i);
if (field->as_molecular_field() == (DCMolecularField *)NULL &&
if (field->as_molecular_field() == nullptr &&
field->is_required()) {
packer.begin_unpack(field);
field->receive_update(packer, distobj);
@@ -591,7 +585,7 @@ void DCClass::
direct_update(PyObject *distobj, const string &field_name,
const string &value_blob) {
DCField *field = get_field_by_name(field_name);
nassertv_always(field != NULL);
nassertv_always(field != nullptr);
DCPacker packer;
packer.set_unpack_data(value_blob);
@@ -651,7 +645,7 @@ bool DCClass::
pack_required_field(DCPacker &packer, PyObject *distobj,
const DCField *field) const {
const DCParameter *parameter = field->as_parameter();
if (parameter != (DCParameter *)NULL) {
if (parameter != nullptr) {
// This is the easy case: to pack a parameter, we just look on the class
// object for the data element.
string field_name = field->get_name();
@@ -674,7 +668,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj,
}
PyObject *result =
PyObject_GetAttrString(distobj, (char *)field_name.c_str());
nassertr(result != (PyObject *)NULL, false);
nassertr(result != nullptr, false);
// Now pack the value into the datagram.
bool pack_ok = parameter->pack_args(packer, result);
@@ -683,7 +677,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj,
return pack_ok;
}
if (field->as_molecular_field() != (DCMolecularField *)NULL) {
if (field->as_molecular_field() != nullptr) {
ostringstream strm;
strm << "Cannot pack molecular field " << field->get_name()
<< " for generate";
@@ -692,7 +686,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj,
}
const DCAtomicField *atom = field->as_atomic_field();
nassertr(atom != (DCAtomicField *)NULL, false);
nassertr(atom != nullptr, false);
// We need to get the initial value of this field. There isn't a good,
// robust way to get this; presently, we just mangle the "setFoo()" name of
@@ -746,13 +740,13 @@ pack_required_field(DCPacker &packer, PyObject *distobj,
}
PyObject *func =
PyObject_GetAttrString(distobj, (char *)getter_name.c_str());
nassertr(func != (PyObject *)NULL, false);
nassertr(func != nullptr, false);
PyObject *empty_args = PyTuple_New(0);
PyObject *result = PyObject_CallObject(func, empty_args);
Py_DECREF(empty_args);
Py_DECREF(func);
if (result == (PyObject *)NULL) {
if (result == nullptr) {
// We don't set this as an exception, since presumably the Python method
// itself has already triggered a Python exception.
cerr << "Error when calling " << getter_name << "\n";
@@ -795,7 +789,7 @@ Datagram DCClass::
client_format_update(const string &field_name, DOID_TYPE do_id,
PyObject *args) const {
DCField *field = get_field_by_name(field_name);
if (field == (DCField *)NULL) {
if (field == nullptr) {
ostringstream strm;
strm << "No field named " << field_name << " in class " << get_name()
<< "\n";
@@ -816,7 +810,7 @@ Datagram DCClass::
ai_format_update(const string &field_name, DOID_TYPE do_id,
CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const {
DCField *field = get_field_by_name(field_name);
if (field == (DCField *)NULL) {
if (field == nullptr) {
ostringstream strm;
strm << "No field named " << field_name << " in class " << get_name()
<< "\n";
@@ -838,7 +832,7 @@ Datagram DCClass::
ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id,
CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const {
DCField *field = get_field_by_name(field_name);
if (field == (DCField *)NULL) {
if (field == nullptr) {
ostringstream strm;
strm << "No field named " << field_name << " in class " << get_name()
<< "\n";
@@ -877,7 +871,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id,
int num_fields = get_num_inherited_fields();
for (int i = 0; i < num_fields; ++i) {
DCField *field = get_inherited_field(i);
if (field->is_required() && field->as_molecular_field() == NULL) {
if (field->is_required() && field->as_molecular_field() == nullptr) {
packer.begin_pack(field);
if (!pack_required_field(packer, distobj, field)) {
return Datagram();
@@ -903,7 +897,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id,
Py_XDECREF(py_field_name);
DCField *field = get_field_by_name(field_name);
if (field == (DCField *)NULL) {
if (field == nullptr) {
ostringstream strm;
strm << "No field named " << field_name << " in class " << get_name()
<< "\n";
@@ -946,25 +940,23 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
bool has_optional_fields = (PyObject_IsTrue(optional_fields) != 0);
if (has_optional_fields) {
packer.raw_pack_uint16(STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER);
packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER);
} else {
packer.raw_pack_uint16(STATESERVER_OBJECT_GENERATE_WITH_REQUIRED);
packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED);
}
packer.raw_pack_uint32(do_id);
// Parent is a bit overloaded; this parent is not about inheritance, this
// one is about the visibility container parent, i.e. the zone parent:
if (parent_id) {
packer.raw_pack_uint32(parent_id);
}
packer.raw_pack_uint32(parent_id);
packer.raw_pack_uint32(zone_id);
packer.raw_pack_uint16(_number);
packer.raw_pack_uint32(do_id);
// Specify all of the required fields.
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();
@@ -988,7 +980,7 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
Py_XDECREF(py_field_name);
DCField *field = get_field_by_name(field_name);
if (field == (DCField *)NULL) {
if (field == nullptr) {
ostringstream strm;
strm << "No field named " << field_name << " in class " << get_name()
<< "\n";
@@ -1009,77 +1001,6 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
return Datagram(packer.get_data(), packer.get_length());
}
#endif // HAVE_PYTHON
#ifdef HAVE_PYTHON
/**
* Generates a datagram containing the message necessary to create a new
* database distributed object from the AI.
*
* First Pass is to only include required values (with Defaults).
*/
Datagram DCClass::
ai_database_generate_context(
unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
CHANNEL_TYPE owner_channel,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const
{
DCPacker packer;
packer.raw_pack_uint8(1);
packer.RAW_PACK_CHANNEL(database_server_id);
packer.RAW_PACK_CHANNEL(from_channel_id);
// packer.raw_pack_uint8('A');
packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT);
packer.raw_pack_uint32(parent_id);
packer.raw_pack_uint32(zone_id);
packer.RAW_PACK_CHANNEL(owner_channel);
packer.raw_pack_uint16(_number); // DCD class ID
packer.raw_pack_uint32(context_id);
// Specify all of the required fields.
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) {
packer.begin_pack(field);
packer.pack_default_value();
packer.end_pack();
}
}
return Datagram(packer.get_data(), packer.get_length());
}
#endif // HAVE_PYTHON
#ifdef HAVE_PYTHON
Datagram DCClass::
ai_database_generate_context_old(
unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const
{
DCPacker packer;
packer.raw_pack_uint8(1);
packer.RAW_PACK_CHANNEL(database_server_id);
packer.RAW_PACK_CHANNEL(from_channel_id);
// packer.raw_pack_uint8('A');
packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT);
packer.raw_pack_uint32(parent_id);
packer.raw_pack_uint32(zone_id);
packer.raw_pack_uint16(_number); // DCD class ID
packer.raw_pack_uint32(context_id);
// Specify all of the required fields.
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) {
packer.begin_pack(field);
packer.pack_default_value();
packer.end_pack();
}
}
return Datagram(packer.get_data(), packer.get_length());
}
#endif // HAVE_PYTHON
/**
* Write a string representation of this instance to <out>.
@@ -1121,7 +1042,7 @@ write(ostream &out, bool brief, int indent_level) const {
}
out << "\n";
if (_constructor != (DCField *)NULL) {
if (_constructor != nullptr) {
_constructor->write(out, brief, indent_level + 2);
}
@@ -1177,7 +1098,7 @@ output_instance(ostream &out, bool brief, const string &prename,
out << " {";
if (_constructor != (DCField *)NULL) {
if (_constructor != nullptr) {
_constructor->output(out, brief);
out << "; ";
}
@@ -1213,7 +1134,7 @@ generate_hash(HashGenerator &hashgen) const {
hashgen.add_int((*pi)->get_number());
}
if (_constructor != (DCField *)NULL) {
if (_constructor != nullptr) {
_constructor->generate_hash(hashgen);
}
@@ -1326,20 +1247,20 @@ shadow_inherited_field(const string &name) {
*/
bool DCClass::
add_field(DCField *field) {
nassertr(field->get_class() == this || field->get_class() == NULL, false);
nassertr(field->get_class() == this || field->get_class() == nullptr, false);
field->set_class(this);
if (_dc_file != (DCFile *)NULL) {
if (_dc_file != nullptr) {
_dc_file->mark_inherited_fields_stale();
}
if (!field->get_name().empty()) {
if (field->get_name() == _name) {
// This field is a constructor.
if (_constructor != (DCField *)NULL) {
if (_constructor != nullptr) {
// We already have a constructor.
return false;
}
if (field->as_atomic_field() == (DCAtomicField *)NULL) {
if (field->as_atomic_field() == nullptr) {
// The constructor must be an atomic field.
return false;
}
@@ -1357,7 +1278,7 @@ add_field(DCField *field) {
}
}
if (_dc_file != (DCFile *)NULL &&
if (_dc_file != nullptr &&
((dc_virtual_inheritance && dc_sort_inheritance_by_file) || !is_struct())) {
if (dc_multiple_inheritance) {
_dc_file->set_new_index_number(field);

View File

@@ -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,
@@ -117,18 +117,13 @@ PUBLISHED:
Datagram client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id,
ZONEID_TYPE zone_id, PyObject *optional_fields) const;
Datagram ai_database_generate_context(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE owner_channel,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const;
Datagram ai_database_generate_context_old(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id,
CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const;
#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();
@@ -138,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;
@@ -149,7 +144,7 @@ private:
DCFile *_dc_file;
string _name;
std::string _name;
bool _is_struct;
bool _bogus_class;
int _number;
@@ -162,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;

View File

@@ -119,7 +119,7 @@ get_class() const {
*/
DCPackerInterface *DCClassParameter::
get_nested_field(int n) const {
nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL);
nassertr(n >= 0 && n < (int)_nested_fields.size(), nullptr);
return _nested_fields[n];
}
@@ -130,7 +130,7 @@ get_nested_field(int n) const {
void DCClassParameter::
output_instance(ostream &out, bool brief, const string &prename,
const string &name, const string &postname) const {
if (get_typedef() != (DCTypedef *)NULL) {
if (get_typedef() != nullptr) {
output_typedef_name(out, brief, prename, name, postname);
} else {

View File

@@ -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:

View File

@@ -26,7 +26,7 @@ DCDeclaration::
*/
DCClass *DCDeclaration::
as_class() {
return (DCClass *)NULL;
return nullptr;
}
/**
@@ -34,7 +34,7 @@ as_class() {
*/
const DCClass *DCDeclaration::
as_class() const {
return (DCClass *)NULL;
return nullptr;
}
/**
@@ -42,7 +42,7 @@ as_class() const {
*/
DCSwitch *DCDeclaration::
as_switch() {
return (DCSwitch *)NULL;
return nullptr;
}
/**
@@ -50,7 +50,7 @@ as_switch() {
*/
const DCSwitch *DCDeclaration::
as_switch() const {
return (DCSwitch *)NULL;
return nullptr;
}
/**

View File

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

View File

@@ -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;

View File

@@ -31,7 +31,7 @@
*/
DCField::
DCField() :
_dclass(NULL)
_dclass(nullptr)
#ifdef WITHIN_PANDA
,
_field_update_pcollector("DCField")
@@ -108,7 +108,7 @@ as_field() const {
*/
DCAtomicField *DCField::
as_atomic_field() {
return (DCAtomicField *)NULL;
return nullptr;
}
/**
@@ -117,7 +117,7 @@ as_atomic_field() {
*/
const DCAtomicField *DCField::
as_atomic_field() const {
return (DCAtomicField *)NULL;
return nullptr;
}
/**
@@ -126,7 +126,7 @@ as_atomic_field() const {
*/
DCMolecularField *DCField::
as_molecular_field() {
return (DCMolecularField *)NULL;
return nullptr;
}
/**
@@ -135,7 +135,7 @@ as_molecular_field() {
*/
const DCMolecularField *DCField::
as_molecular_field() const {
return (DCMolecularField *)NULL;
return nullptr;
}
/**
@@ -143,7 +143,7 @@ as_molecular_field() const {
*/
DCParameter *DCField::
as_parameter() {
return (DCParameter *)NULL;
return nullptr;
}
/**
@@ -151,7 +151,7 @@ as_parameter() {
*/
const DCParameter *DCField::
as_parameter() const {
return (DCParameter *)NULL;
return nullptr;
}
/**
@@ -235,7 +235,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const {
ostringstream strm;
PyObject *exc_type = PyExc_Exception;
if (as_parameter() != (DCParameter *)NULL) {
if (as_parameter() != nullptr) {
// If it's a parameter-type field, the value may or may not be a
// sequence.
if (packer.had_pack_error()) {
@@ -251,7 +251,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const {
} else {
// If it's a molecular or atomic field, the value should be a sequence.
PyObject *tuple = PySequence_Tuple(sequence);
if (tuple == (PyObject *)NULL) {
if (tuple == nullptr) {
strm << "Value for " << get_name() << " not a sequence: " \
<< get_pystr(sequence);
exc_type = PyExc_TypeError;
@@ -287,8 +287,8 @@ pack_args(DCPacker &packer, PyObject *sequence) const {
*/
PyObject *DCField::
unpack_args(DCPacker &packer) const {
nassertr(!packer.had_error(), NULL);
nassertr(packer.get_current_field() == this, NULL);
nassertr(!packer.had_error(), nullptr);
nassertr(packer.get_current_field() == this, nullptr);
size_t start_byte = packer.get_num_unpacked_bytes();
PyObject *object = packer.unpack_object();
@@ -329,7 +329,7 @@ unpack_args(DCPacker &packer) const {
}
Py_XDECREF(object);
return NULL;
return nullptr;
}
#endif // HAVE_PYTHON
@@ -340,10 +340,10 @@ unpack_args(DCPacker &packer) const {
*/
void DCField::
receive_update(DCPacker &packer, PyObject *distobj) const {
if (as_parameter() != (DCParameter *)NULL) {
if (as_parameter() != nullptr) {
// If it's a parameter-type field, just store a new value on the object.
PyObject *value = unpack_args(packer);
if (value != (PyObject *)NULL) {
if (value != nullptr) {
PyObject_SetAttrString(distobj, (char *)_name.c_str(), value);
}
Py_DECREF(value);
@@ -362,9 +362,9 @@ receive_update(DCPacker &packer, PyObject *distobj) const {
// method.
PyObject *args = unpack_args(packer);
if (args != (PyObject *)NULL) {
if (args != nullptr) {
PyObject *func = PyObject_GetAttrString(distobj, (char *)_name.c_str());
nassertv(func != (PyObject *)NULL);
nassertv(func != nullptr);
PyObject *result;
{
@@ -391,7 +391,7 @@ Datagram DCField::
client_format_update(DOID_TYPE do_id, PyObject *args) const {
DCPacker packer;
packer.raw_pack_uint16(CLIENT_OBJECT_UPDATE_FIELD);
packer.raw_pack_uint16(CLIENT_OBJECT_SET_FIELD);
packer.raw_pack_uint32(do_id);
packer.raw_pack_uint16(_number);
@@ -417,7 +417,7 @@ ai_format_update(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyOb
packer.raw_pack_uint8(1);
packer.RAW_PACK_CHANNEL(to_id);
packer.RAW_PACK_CHANNEL(from_id);
packer.raw_pack_uint16(STATESERVER_OBJECT_UPDATE_FIELD);
packer.raw_pack_uint16(STATESERVER_OBJECT_SET_FIELD);
packer.raw_pack_uint32(do_id);
packer.raw_pack_uint16(_number);
@@ -499,7 +499,7 @@ pack_default_value(DCPackData &pack_data, bool &) const {
void DCField::
set_name(const string &name) {
DCPackerInterface::set_name(name);
if (_dclass != (DCClass *)NULL) {
if (_dclass != nullptr) {
_dclass->_dc_file->mark_inherited_fields_stale();
}
}
@@ -510,12 +510,12 @@ set_name(const string &name) {
*/
string DCField::
get_pystr(PyObject *value) {
if (value == NULL) {
if (value == nullptr) {
return "(null)";
}
PyObject *str = PyObject_Str(value);
if (str != NULL) {
if (str != nullptr) {
#if PY_MAJOR_VERSION >= 3
string result = PyUnicode_AsUTF8(str);
#else
@@ -526,7 +526,7 @@ get_pystr(PyObject *value) {
}
PyObject *repr = PyObject_Repr(value);
if (repr != NULL) {
if (repr != nullptr) {
#if PY_MAJOR_VERSION >= 3
string result = PyUnicode_AsUTF8(repr);
#else
@@ -536,9 +536,9 @@ get_pystr(PyObject *value) {
return result;
}
if (value->ob_type != NULL) {
if (value->ob_type != nullptr) {
PyObject *typestr = PyObject_Str((PyObject *)(value->ob_type));
if (typestr != NULL) {
if (typestr != nullptr) {
#if PY_MAJOR_VERSION >= 3
string result = PyUnicode_AsUTF8(typestr);
#else

View File

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

View File

@@ -123,7 +123,7 @@ read(Filename filename) {
filename.set_text();
VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
istream *in = vfs->open_read_file(filename, true);
if (in == (istream *)NULL) {
if (in == nullptr) {
cerr << "Cannot open " << filename << " for reading.\n";
return false;
}
@@ -247,7 +247,7 @@ get_num_classes() const {
*/
DCClass *DCFile::
get_class(int n) const {
nassertr(n >= 0 && n < (int)_classes.size(), NULL);
nassertr(n >= 0 && n < (int)_classes.size(), nullptr);
return _classes[n];
}
@@ -263,7 +263,7 @@ get_class_by_name(const string &name) const {
return (*ni).second->as_class();
}
return (DCClass *)NULL;
return nullptr;
}
/**
@@ -278,7 +278,7 @@ get_switch_by_name(const string &name) const {
return (*ni).second->as_switch();
}
return (DCSwitch *)NULL;
return nullptr;
}
/**
@@ -291,13 +291,13 @@ get_switch_by_name(const string &name) const {
*/
DCField *DCFile::
get_field_by_index(int index_number) const {
nassertr(dc_multiple_inheritance, NULL);
nassertr(dc_multiple_inheritance, nullptr);
if (index_number >= 0 && index_number < (int)_fields_by_index.size()) {
return _fields_by_index[index_number];
}
return NULL;
return nullptr;
}
/**
@@ -352,7 +352,7 @@ get_num_typedefs() const {
*/
DCTypedef *DCFile::
get_typedef(int n) const {
nassertr(n >= 0 && n < (int)_typedefs.size(), NULL);
nassertr(n >= 0 && n < (int)_typedefs.size(), nullptr);
return _typedefs[n];
}
@@ -368,7 +368,7 @@ get_typedef_by_name(const string &name) const {
return (*ni).second;
}
return NULL;
return nullptr;
}
/**
@@ -394,9 +394,9 @@ get_keyword(int n) const {
const DCKeyword *DCFile::
get_keyword_by_name(const string &name) const {
const DCKeyword *keyword = _keywords.get_keyword_by_name(name);
if (keyword == (const DCKeyword *)NULL) {
if (keyword == nullptr) {
keyword = _default_keywords.get_keyword_by_name(name);
if (keyword != (const DCKeyword *)NULL) {
if (keyword != nullptr) {
// One of the historical default keywords was used, but wasn't defined.
// Define it implicitly right now.
((DCFile *)this)->_keywords.add_keyword(keyword);
@@ -612,11 +612,11 @@ setup_default_keywords() {
{ "clrecv", 0x0040 },
{ "ownsend", 0x0080 },
{ "airecv", 0x0100 },
{ NULL, 0 }
{ nullptr, 0 }
};
_default_keywords.clear_keywords();
for (int i = 0; default_keywords[i].name != NULL; ++i) {
for (int i = 0; default_keywords[i].name != nullptr; ++i) {
DCKeyword *keyword =
new DCKeyword(default_keywords[i].name,
default_keywords[i].flag);

View File

@@ -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;

View File

@@ -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.

View File

@@ -83,7 +83,7 @@ get_num_keywords() const {
*/
const DCKeyword *DCKeywordList::
get_keyword(int n) const {
nassertr(n >= 0 && n < (int)_keywords.size(), NULL);
nassertr(n >= 0 && n < (int)_keywords.size(), nullptr);
return _keywords[n];
}
@@ -99,7 +99,7 @@ get_keyword_by_name(const string &name) const {
return (*ni).second;
}
return NULL;
return nullptr;
}
/**

View File

@@ -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;

View File

@@ -35,7 +35,7 @@ static int error_count = 0;
static int warning_count = 0;
// This is the pointer to the current input stream.
static istream *input_p = NULL;
static istream *input_p = nullptr;
// This is the name of the dc file we're parsing. We keep it so we
// can print it out for error messages.
@@ -129,7 +129,7 @@ dcyywarning(const string &msg) {
// stdio FILE pointer. This is flex-specific.
static void
input_chars(char *buffer, int &result, int max_size) {
nassertv(input_p != NULL);
nassertv(input_p != nullptr);
if (*input_p) {
input_p->read(buffer, max_size);
result = input_p->gcount();
@@ -150,7 +150,7 @@ input_chars(char *buffer, int &result, int max_size) {
// Truncate it at the newline.
char *end = strchr(current_line, '\n');
if (end != NULL) {
if (end != nullptr) {
*end = '\0';
}
}
@@ -733,9 +733,9 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
accept();
dcyylval.str = dcyytext;
if (dc_file != (DCFile *)NULL) {
if (dc_file != nullptr) {
const DCKeyword *keyword = dc_file->get_keyword_by_name(dcyylval.str);
if (keyword != (DCKeyword *)NULL) {
if (keyword != nullptr) {
dcyylval.u.keyword = keyword;
return KEYWORD;
}

View File

@@ -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();

View File

@@ -59,7 +59,7 @@ get_num_atomics() const {
*/
DCAtomicField *DCMolecularField::
get_atomic(int n) const {
nassertr(n >= 0 && n < (int)_fields.size(), NULL);
nassertr(n >= 0 && n < (int)_fields.size(), nullptr);
return _fields[n];
}
@@ -161,7 +161,7 @@ generate_hash(HashGenerator &hashgen) const {
*/
DCPackerInterface *DCMolecularField::
get_nested_field(int n) const {
nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL);
nassertr(n >= 0 && n < (int)_nested_fields.size(), nullptr);
return _nested_fields[n];
}

View File

@@ -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;

View File

@@ -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));
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -23,7 +23,7 @@
#include "py_panda.h"
#endif
DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = NULL;
DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = nullptr;
int DCPacker::StackElement::_num_ever_allocated = 0;
/**
@@ -32,15 +32,15 @@ int DCPacker::StackElement::_num_ever_allocated = 0;
DCPacker::
DCPacker() {
_mode = M_idle;
_unpack_data = NULL;
_unpack_data = nullptr;
_unpack_length = 0;
_owns_unpack_data = false;
_unpack_p = 0;
_live_catalog = NULL;
_live_catalog = nullptr;
_parse_error = false;
_pack_error = false;
_range_error = false;
_stack = NULL;
_stack = nullptr;
clear();
}
@@ -73,11 +73,11 @@ begin_pack(const DCPackerInterface *root) {
_range_error = false;
_root = root;
_catalog = NULL;
_live_catalog = NULL;
_catalog = nullptr;
_live_catalog = nullptr;
_current_field = root;
_current_parent = NULL;
_current_parent = nullptr;
_current_field_index = 0;
_num_nested_fields = 0;
}
@@ -94,7 +94,7 @@ end_pack() {
_mode = M_idle;
if (_stack != NULL || _current_field != NULL || _current_parent != NULL) {
if (_stack != nullptr || _current_field != nullptr || _current_parent != nullptr) {
_pack_error = true;
}
@@ -146,7 +146,7 @@ set_unpack_data(const char *unpack_data, size_t unpack_length,
void DCPacker::
begin_unpack(const DCPackerInterface *root) {
nassertv(_mode == M_idle);
nassertv(_unpack_data != NULL);
nassertv(_unpack_data != nullptr);
_mode = M_unpack;
_parse_error = false;
@@ -154,11 +154,11 @@ begin_unpack(const DCPackerInterface *root) {
_range_error = false;
_root = root;
_catalog = NULL;
_live_catalog = NULL;
_catalog = nullptr;
_live_catalog = nullptr;
_current_field = root;
_current_parent = NULL;
_current_parent = nullptr;
_current_field_index = 0;
_num_nested_fields = 0;
}
@@ -175,13 +175,13 @@ end_unpack() {
_mode = M_idle;
if (_stack != NULL || _current_field != NULL || _current_parent != NULL) {
if (_stack != nullptr || _current_field != nullptr || _current_parent != nullptr) {
// This happens if we have not unpacked all of the fields. However, this
// is not an error if we have called seek() during the unpack session (in
// which case the _catalog will be non-NULL). On the other hand, if the
// catalog is still NULL, then we have never called seek() and it is an
// error not to unpack all values.
if (_catalog == (DCPackerCatalog *)NULL) {
if (_catalog == nullptr) {
_pack_error = true;
}
}
@@ -206,7 +206,7 @@ end_unpack() {
void DCPacker::
begin_repack(const DCPackerInterface *root) {
nassertv(_mode == M_idle);
nassertv(_unpack_data != NULL);
nassertv(_unpack_data != nullptr);
nassertv(_unpack_p == 0);
_mode = M_repack;
@@ -220,14 +220,14 @@ begin_repack(const DCPackerInterface *root) {
_root = root;
_catalog = _root->get_catalog();
_live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length);
if (_live_catalog == NULL) {
if (_live_catalog == nullptr) {
_pack_error = true;
}
// We don't begin at the first field in repack mode. Instead, you must
// explicitly call seek().
_current_field = NULL;
_current_parent = NULL;
_current_field = nullptr;
_current_parent = nullptr;
_current_field_index = 0;
_num_nested_fields = 0;
}
@@ -262,12 +262,12 @@ end_repack() {
*/
bool DCPacker::
seek(const string &field_name) {
if (_catalog == (DCPackerCatalog *)NULL) {
if (_catalog == nullptr) {
_catalog = _root->get_catalog();
_live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length);
}
nassertr(_catalog != (DCPackerCatalog *)NULL, false);
if (_live_catalog == NULL) {
nassertr(_catalog != nullptr, false);
if (_live_catalog == nullptr) {
_pack_error = true;
return false;
}
@@ -292,12 +292,12 @@ seek(const string &field_name) {
*/
bool DCPacker::
seek(int seek_index) {
if (_catalog == (DCPackerCatalog *)NULL) {
if (_catalog == nullptr) {
_catalog = _root->get_catalog();
_live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length);
}
nassertr(_catalog != (DCPackerCatalog *)NULL, false);
if (_live_catalog == NULL) {
nassertr(_catalog != nullptr, false);
if (_live_catalog == nullptr) {
_pack_error = true;
return false;
}
@@ -324,9 +324,9 @@ seek(int seek_index) {
return true;
} else if (_mode == M_repack) {
nassertr(_catalog != (DCPackerCatalog *)NULL, false);
nassertr(_catalog != nullptr, false);
if (_stack != NULL || _current_field != NULL) {
if (_stack != nullptr || _current_field != nullptr) {
// It is an error to reseek while the stack is nonempty--that means we
// haven't finished packing the current field.
_pack_error = true;
@@ -334,7 +334,7 @@ seek(int seek_index) {
}
const DCPackerCatalog::Entry &entry = _live_catalog->get_entry(seek_index);
if (entry._parent->as_switch_parameter() != (DCSwitchParameter *)NULL) {
if (entry._parent->as_switch_parameter() != nullptr) {
// If the parent is a DCSwitch, that can only mean that the seeked field
// is a switch parameter. We can't support seeking to a switch
// parameter and modifying it directly--what would happen to all of the
@@ -357,7 +357,7 @@ seek(int seek_index) {
_catalog->release_live_catalog(_live_catalog);
_live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length);
if (_live_catalog == NULL) {
if (_live_catalog == nullptr) {
_pack_error = true;
return false;
}
@@ -470,7 +470,7 @@ push() {
if (_num_nested_fields >= 0 &&
_current_field_index >= _num_nested_fields) {
_current_field = NULL;
_current_field = nullptr;
} else {
_current_field = _current_parent->get_nested_field(_current_field_index);
@@ -487,7 +487,7 @@ push() {
*/
void DCPacker::
pop() {
if (_current_field != NULL && _num_nested_fields >= 0) {
if (_current_field != nullptr && _num_nested_fields >= 0) {
// Oops, didn't pack or unpack enough values.
_pack_error = true;
@@ -497,7 +497,7 @@ pop() {
_pack_error = true;
}
if (_stack == NULL) {
if (_stack == nullptr) {
// Unbalanced pop().
_pack_error = true;
@@ -528,7 +528,7 @@ pop() {
_current_field_index = _stack->_current_field_index;
_push_marker = _stack->_push_marker;
_pop_marker = _stack->_pop_marker;
_num_nested_fields = (_current_parent == NULL) ? 0 : _current_parent->get_num_nested_fields();
_num_nested_fields = (_current_parent == nullptr) ? 0 : _current_parent->get_num_nested_fields();
StackElement *next = _stack->_next;
delete _stack;
@@ -545,7 +545,7 @@ pop() {
void DCPacker::
pack_default_value() {
nassertv(_mode == M_pack || _mode == M_repack);
if (_current_field == NULL) {
if (_current_field == nullptr) {
_pack_error = true;
} else {
if (_current_field->pack_default_value(_pack_data, _pack_error)) {
@@ -571,7 +571,7 @@ pack_default_value() {
void DCPacker::
unpack_validate() {
nassertv(_mode == M_unpack);
if (_current_field == NULL) {
if (_current_field == nullptr) {
_pack_error = true;
} else {
@@ -597,7 +597,7 @@ unpack_validate() {
void DCPacker::
unpack_skip() {
nassertv(_mode == M_unpack);
if (_current_field == NULL) {
if (_current_field == nullptr) {
_pack_error = true;
} else {
@@ -739,11 +739,11 @@ pack_object(PyObject *object) {
(PyObject_HasAttrString(object, "__len__") != 0);
bool is_instance = false;
const DCClass *dclass = NULL;
const DCClass *dclass = nullptr;
const DCPackerInterface *current_field = get_current_field();
if (current_field != (DCPackerInterface *)NULL) {
if (current_field != nullptr) {
const DCClassParameter *class_param = get_current_field()->as_class_parameter();
if (class_param != (DCClassParameter *)NULL) {
if (class_param != nullptr) {
dclass = class_param->get_class();
if (dclass->has_class_def()) {
@@ -771,7 +771,7 @@ pack_object(PyObject *object) {
// (3) Otherwise, it is considered to be a class object.
if (dclass != (DCClass *)NULL && (is_instance || !is_sequence)) {
if (dclass != nullptr && (is_instance || !is_sequence)) {
// The supplied object is either an instance of the expected class
// object, or it is not a sequence--this is case (1) or (3).
pack_class_object(dclass, object);
@@ -782,7 +782,7 @@ pack_object(PyObject *object) {
int size = PySequence_Size(object);
for (int i = 0; i < size; ++i) {
PyObject *element = PySequence_GetItem(object, i);
if (element != (PyObject *)NULL) {
if (element != nullptr) {
pack_object(element);
Py_DECREF(element);
} else {
@@ -812,7 +812,7 @@ pack_object(PyObject *object) {
*/
PyObject *DCPacker::
unpack_object() {
PyObject *object = NULL;
PyObject *object = nullptr;
DCPackType pack_type = get_pack_type();
@@ -896,13 +896,13 @@ unpack_object() {
case PT_class:
{
const DCClassParameter *class_param = get_current_field()->as_class_parameter();
if (class_param != (DCClassParameter *)NULL) {
if (class_param != nullptr) {
const DCClass *dclass = class_param->get_class();
if (dclass->has_class_def()) {
// If we know what kind of class object this is and it has a valid
// constructor, create the class object instead of just a tuple.
object = unpack_class_object(dclass);
if (object == (PyObject *)NULL) {
if (object == nullptr) {
cerr << "Unable to construct object of class "
<< dclass->get_name() << "\n";
} else {
@@ -939,7 +939,7 @@ unpack_object() {
break;
}
nassertr(object != (PyObject *)NULL, NULL);
nassertr(object != nullptr, nullptr);
return object;
}
#endif // HAVE_PYTHON
@@ -995,10 +995,10 @@ unpack_and_format(ostream &out, bool show_field_names) {
DCPackType pack_type = get_pack_type();
if (show_field_names && !get_current_field_name().empty()) {
nassertv(_current_field != (DCPackerInterface *)NULL);
nassertv(_current_field != nullptr);
const DCField *field = _current_field->as_field();
if (field != (DCField *)NULL &&
field->as_parameter() != (DCParameter *)NULL) {
if (field != nullptr &&
field->as_parameter() != nullptr) {
out << field->get_name() << " = ";
}
}
@@ -1135,7 +1135,7 @@ void DCPacker::
handle_switch(const DCSwitchParameter *switch_parameter) {
// First, get the value from the key. This is either found in the unpack or
// the pack data, depending on what mode we're in.
const DCPackerInterface *new_parent = NULL;
const DCPackerInterface *new_parent = nullptr;
if (_mode == M_pack || _mode == M_repack) {
const char *data = _pack_data.get_data();
@@ -1147,7 +1147,7 @@ handle_switch(const DCSwitchParameter *switch_parameter) {
(_unpack_data + _push_marker, _unpack_p - _push_marker);
}
if (new_parent == (DCPackerInterface *)NULL) {
if (new_parent == nullptr) {
// This means an invalid value was packed for the key.
_range_error = true;
return;
@@ -1173,20 +1173,20 @@ handle_switch(const DCSwitchParameter *switch_parameter) {
void DCPacker::
clear() {
clear_stack();
_current_field = NULL;
_current_parent = NULL;
_current_field = nullptr;
_current_parent = nullptr;
_current_field_index = 0;
_num_nested_fields = 0;
_push_marker = 0;
_pop_marker = 0;
_last_switch = NULL;
_last_switch = nullptr;
if (_live_catalog != (DCPackerCatalog::LiveCatalog *)NULL) {
if (_live_catalog != nullptr) {
_catalog->release_live_catalog(_live_catalog);
_live_catalog = NULL;
_live_catalog = nullptr;
}
_catalog = NULL;
_root = NULL;
_catalog = nullptr;
_root = nullptr;
}
/**
@@ -1194,7 +1194,7 @@ clear() {
*/
void DCPacker::
clear_stack() {
while (_stack != (StackElement *)NULL) {
while (_stack != nullptr) {
StackElement *next = _stack->_next;
delete _stack;
_stack = next;
@@ -1212,7 +1212,7 @@ pack_class_object(const DCClass *dclass, PyObject *object) {
push();
while (more_nested_fields() && !_pack_error) {
const DCField *field = get_current_field()->as_field();
nassertv(field != (DCField *)NULL);
nassertv(field != nullptr);
get_class_element(dclass, object, field);
}
pop();
@@ -1227,36 +1227,36 @@ pack_class_object(const DCClass *dclass, PyObject *object) {
PyObject *DCPacker::
unpack_class_object(const DCClass *dclass) {
PyObject *class_def = dclass->get_class_def();
nassertr(class_def != (PyObject *)NULL, NULL);
nassertr(class_def != nullptr, nullptr);
PyObject *object = NULL;
PyObject *object = nullptr;
if (!dclass->has_constructor()) {
// If the class uses a default constructor, go ahead and create the Python
// object for it now.
object = PyObject_CallObject(class_def, NULL);
if (object == (PyObject *)NULL) {
return NULL;
object = PyObject_CallObject(class_def, nullptr);
if (object == nullptr) {
return nullptr;
}
}
push();
if (object == (PyObject *)NULL && more_nested_fields()) {
if (object == nullptr && more_nested_fields()) {
// The first nested field will be the constructor.
const DCField *field = get_current_field()->as_field();
nassertr(field != (DCField *)NULL, object);
nassertr(field != nullptr, object);
nassertr(field == dclass->get_constructor(), object);
set_class_element(class_def, object, field);
// By now, the object should have been constructed.
if (object == (PyObject *)NULL) {
return NULL;
if (object == nullptr) {
return nullptr;
}
}
while (more_nested_fields()) {
const DCField *field = get_current_field()->as_field();
nassertr(field != (DCField *)NULL, object);
nassertr(field != nullptr, object);
set_class_element(class_def, object, field);
}
@@ -1287,8 +1287,8 @@ set_class_element(PyObject *class_def, PyObject *&object,
push();
while (more_nested_fields()) {
const DCField *field = get_current_field()->as_field();
nassertv(field != (DCField *)NULL);
nassertv(object != (PyObject *)NULL);
nassertv(field != nullptr);
nassertv(object != nullptr);
set_class_element(class_def, object, field);
}
pop();
@@ -1307,7 +1307,7 @@ set_class_element(PyObject *class_def, PyObject *&object,
PyObject *element = unpack_object();
if (pack_type == PT_field) {
if (object == (PyObject *)NULL) {
if (object == nullptr) {
// If the object hasn't been constructed yet, assume this is the
// constructor.
object = PyObject_CallObject(class_def, element);
@@ -1315,7 +1315,7 @@ set_class_element(PyObject *class_def, PyObject *&object,
} else {
if (PyObject_HasAttrString(object, (char *)field_name.c_str())) {
PyObject *func = PyObject_GetAttrString(object, (char *)field_name.c_str());
if (func != (PyObject *)NULL) {
if (func != nullptr) {
PyObject *result = PyObject_CallObject(func, element);
Py_XDECREF(result);
Py_DECREF(func);
@@ -1324,7 +1324,7 @@ set_class_element(PyObject *class_def, PyObject *&object,
}
} else {
nassertv(object != (PyObject *)NULL);
nassertv(object != nullptr);
PyObject_SetAttrString(object, (char *)field_name.c_str(), element);
}
@@ -1353,7 +1353,7 @@ get_class_element(const DCClass *dclass, PyObject *object,
push();
while (more_nested_fields() && !_pack_error) {
const DCField *field = get_current_field()->as_field();
nassertv(field != (DCField *)NULL);
nassertv(field != nullptr);
get_class_element(dclass, object, field);
}
pop();

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -21,7 +21,7 @@
*/
DCPackerCatalog::
DCPackerCatalog(const DCPackerInterface *root) : _root(root) {
_live_catalog = NULL;
_live_catalog = nullptr;
}
/**
@@ -34,7 +34,7 @@ DCPackerCatalog(const DCPackerCatalog &copy) :
_entries_by_name(copy._entries_by_name),
_entries_by_field(copy._entries_by_field)
{
_live_catalog = NULL;
_live_catalog = nullptr;
}
/**
@@ -42,7 +42,7 @@ DCPackerCatalog(const DCPackerCatalog &copy) :
*/
DCPackerCatalog::
~DCPackerCatalog() {
if (_live_catalog != (LiveCatalog *)NULL) {
if (_live_catalog != nullptr) {
delete _live_catalog;
}
@@ -92,7 +92,7 @@ find_entry_by_field(const DCPackerInterface *field) const {
*/
const DCPackerCatalog::LiveCatalog *DCPackerCatalog::
get_live_catalog(const char *data, size_t length) const {
if (_live_catalog != (LiveCatalog *)NULL) {
if (_live_catalog != nullptr) {
// Return the previously-allocated live catalog; it will be the same as
// this one since it's based on a fixed-length field.
return _live_catalog;
@@ -111,13 +111,13 @@ get_live_catalog(const char *data, size_t length) const {
DCPacker packer;
packer.set_unpack_data(data, length, false);
packer.begin_unpack(_root);
const DCSwitchParameter *last_switch = NULL;
const DCSwitchParameter *last_switch = nullptr;
r_fill_live_catalog(live_catalog, packer, last_switch);
bool okflag = packer.end_unpack();
if (!okflag) {
delete live_catalog;
return NULL;
return nullptr;
}
if (_root->has_fixed_structure()) {
@@ -188,7 +188,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field,
const DCPackerInterface *parent, int field_index) {
string next_name_prefix = name_prefix;
if (parent != (const DCPackerInterface *)NULL && !field->get_name().empty()) {
if (parent != nullptr && !field->get_name().empty()) {
// Record this entry in the catalog.
next_name_prefix += field->get_name();
add_entry(next_name_prefix, field, parent, field_index);
@@ -197,7 +197,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field,
}
const DCSwitchParameter *switch_parameter = field->as_switch_parameter();
if (switch_parameter != (DCSwitchParameter *)NULL) {
if (switch_parameter != nullptr) {
// If we come upon a DCSwitch while building the catalog, save the
// name_prefix at this point so we'll have it again when we later
// encounter the switch while unpacking a live record (and so we can
@@ -211,7 +211,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field,
// It's ok if num_nested is -1.
for (int i = 0; i < num_nested; i++) {
DCPackerInterface *nested = field->get_nested_field(i);
if (nested != (DCPackerInterface *)NULL) {
if (nested != nullptr) {
r_fill_catalog(next_name_prefix, nested, field, i);
}
}
@@ -255,10 +255,10 @@ r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer,
last_switch = packer.get_last_switch();
const DCPackerInterface *switch_case = packer.get_current_parent();
nassertv(switch_case != (DCPackerInterface *)NULL);
nassertv(switch_case != nullptr);
const DCPackerCatalog *switch_catalog =
live_catalog->_catalog->update_switch_fields(last_switch, switch_case);
nassertv(switch_catalog != (DCPackerCatalog *)NULL);
nassertv(switch_catalog != nullptr);
live_catalog->_catalog = switch_catalog;
// And we also have to expand the live catalog to hold the new entries.
@@ -317,7 +317,7 @@ update_switch_fields(const DCSwitchParameter *switch_parameter,
int num_nested = switch_case->get_num_nested_fields();
for (int i = 1; i < num_nested; i++) {
DCPackerInterface *nested = switch_case->get_nested_field(i);
if (nested != (DCPackerInterface *)NULL) {
if (nested != nullptr) {
switch_catalog->r_fill_catalog(name_prefix, nested, switch_case, i);
}
}

View File

@@ -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;

View File

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

View File

@@ -32,7 +32,7 @@ DCPackerInterface(const string &name) :
_has_nested_fields = false;
_num_nested_fields = -1;
_pack_type = PT_invalid;
_catalog = NULL;
_catalog = nullptr;
}
/**
@@ -50,7 +50,7 @@ DCPackerInterface(const DCPackerInterface &copy) :
_num_nested_fields(copy._num_nested_fields),
_pack_type(copy._pack_type)
{
_catalog = NULL;
_catalog = nullptr;
}
/**
@@ -58,7 +58,7 @@ DCPackerInterface(const DCPackerInterface &copy) :
*/
DCPackerInterface::
~DCPackerInterface() {
if (_catalog != (DCPackerCatalog *)NULL) {
if (_catalog != nullptr) {
delete _catalog;
}
}
@@ -83,7 +83,7 @@ find_seek_index(const string &name) const {
*/
DCField *DCPackerInterface::
as_field() {
return (DCField *)NULL;
return nullptr;
}
/**
@@ -91,7 +91,7 @@ as_field() {
*/
const DCField *DCPackerInterface::
as_field() const {
return (DCField *)NULL;
return nullptr;
}
/**
@@ -99,7 +99,7 @@ as_field() const {
*/
DCSwitchParameter *DCPackerInterface::
as_switch_parameter() {
return (DCSwitchParameter *)NULL;
return nullptr;
}
/**
@@ -107,7 +107,7 @@ as_switch_parameter() {
*/
const DCSwitchParameter *DCPackerInterface::
as_switch_parameter() const {
return (DCSwitchParameter *)NULL;
return nullptr;
}
/**
@@ -115,7 +115,7 @@ as_switch_parameter() const {
*/
DCClassParameter *DCPackerInterface::
as_class_parameter() {
return (DCClassParameter *)NULL;
return nullptr;
}
/**
@@ -123,7 +123,7 @@ as_class_parameter() {
*/
const DCClassParameter *DCPackerInterface::
as_class_parameter() const {
return (DCClassParameter *)NULL;
return nullptr;
}
/**
@@ -145,7 +145,7 @@ check_match(const string &description, DCFile *dcfile) const {
dc_cleanup_parser();
DCField *field = dc_get_parameter_description();
if (field != NULL) {
if (field != nullptr) {
match = check_match(field);
delete field;
}
@@ -184,7 +184,7 @@ calc_num_nested_fields(size_t) const {
*/
DCPackerInterface *DCPackerInterface::
get_nested_field(int) const {
return NULL;
return nullptr;
}
/**
@@ -367,7 +367,7 @@ unpack_skip(const char *data, size_t length, size_t &p,
*/
const DCPackerCatalog *DCPackerInterface::
get_catalog() const {
if (_catalog == (DCPackerCatalog *)NULL) {
if (_catalog == nullptr) {
((DCPackerInterface *)this)->make_catalog();
}
return _catalog;
@@ -432,8 +432,8 @@ do_check_match_molecular_field(const DCMolecularField *) const {
*/
void DCPackerInterface::
make_catalog() {
nassertv(_catalog == (DCPackerCatalog *)NULL);
nassertv(_catalog == nullptr);
_catalog = new DCPackerCatalog(this);
_catalog->r_fill_catalog("", this, NULL, 0);
_catalog->r_fill_catalog("", this, nullptr, 0);
}

View File

@@ -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;

View File

@@ -22,7 +22,7 @@
*/
DCParameter::
DCParameter() {
_typedef = NULL;
_typedef = nullptr;
_has_fixed_byte_size = false;
_has_fixed_structure = false;
_num_nested_fields = -1;
@@ -66,7 +66,7 @@ as_parameter() const {
*/
DCSimpleParameter *DCParameter::
as_simple_parameter() {
return NULL;
return nullptr;
}
/**
@@ -74,7 +74,7 @@ as_simple_parameter() {
*/
const DCSimpleParameter *DCParameter::
as_simple_parameter() const {
return NULL;
return nullptr;
}
/**
@@ -82,7 +82,7 @@ as_simple_parameter() const {
*/
DCClassParameter *DCParameter::
as_class_parameter() {
return NULL;
return nullptr;
}
/**
@@ -90,7 +90,7 @@ as_class_parameter() {
*/
const DCClassParameter *DCParameter::
as_class_parameter() const {
return NULL;
return nullptr;
}
/**
@@ -98,7 +98,7 @@ as_class_parameter() const {
*/
DCSwitchParameter *DCParameter::
as_switch_parameter() {
return NULL;
return nullptr;
}
/**
@@ -106,7 +106,7 @@ as_switch_parameter() {
*/
const DCSwitchParameter *DCParameter::
as_switch_parameter() const {
return NULL;
return nullptr;
}
/**
@@ -114,7 +114,7 @@ as_switch_parameter() const {
*/
DCArrayParameter *DCParameter::
as_array_parameter() {
return NULL;
return nullptr;
}
/**
@@ -122,7 +122,7 @@ as_array_parameter() {
*/
const DCArrayParameter *DCParameter::
as_array_parameter() const {
return NULL;
return nullptr;
}
/**

View File

@@ -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:

View File

@@ -29,18 +29,18 @@
#define YYINITDEPTH 1000
#define YYMAXDEPTH 1000
DCFile *dc_file = (DCFile *)NULL;
static DCClass *current_class = (DCClass *)NULL;
static DCSwitch *current_switch = (DCSwitch *)NULL;
static DCAtomicField *current_atomic = (DCAtomicField *)NULL;
static DCMolecularField *current_molecular = (DCMolecularField *)NULL;
static DCParameter *current_parameter = (DCParameter *)NULL;
DCFile *dc_file = nullptr;
static DCClass *current_class = nullptr;
static DCSwitch *current_switch = nullptr;
static DCAtomicField *current_atomic = nullptr;
static DCMolecularField *current_molecular = nullptr;
static DCParameter *current_parameter = nullptr;
static DCKeywordList current_keyword_list;
static DCPacker default_packer;
static DCPacker *current_packer;
static DCDoubleRange double_range;
static DCUnsignedIntRange uint_range;
static DCField *parameter_description = (DCField *)NULL;
static DCField *parameter_description = nullptr;
////////////////////////////////////////////////////////////////////
// Defining the interface to the parser.
@@ -55,7 +55,7 @@ dc_init_parser(istream &in, const string &filename, DCFile &file) {
void
dc_init_parser_parameter_value(istream &in, const string &filename,
DCPacker &packer) {
dc_file = NULL;
dc_file = nullptr;
current_packer = &packer;
dc_init_lexer(in, filename);
dc_start_parameter_value();
@@ -66,7 +66,7 @@ dc_init_parser_parameter_description(istream &in, const string &filename,
DCFile *file) {
dc_file = file;
dc_init_lexer(in, filename);
parameter_description = NULL;
parameter_description = nullptr;
dc_start_parameter_description();
}
@@ -77,7 +77,7 @@ dc_get_parameter_description() {
void
dc_cleanup_parser() {
dc_file = (DCFile *)NULL;
dc_file = nullptr;
}
%}
@@ -181,7 +181,7 @@ dc:
{
if (!dc_file->add_class($2)) {
DCClass *old_class = dc_file->get_class_by_name($2->get_name());
if (old_class != (DCClass *)NULL && old_class->is_bogus_class()) {
if (old_class != nullptr && old_class->is_bogus_class()) {
yyerror("Base class defined after its first reference: " + $2->get_name());
} else {
yyerror("Duplicate class name: " + $2->get_name());
@@ -249,7 +249,7 @@ import_symbol_list:
typedef_decl:
KW_TYPEDEF parameter_with_default
{
if ($2 != (DCParameter *)NULL) {
if ($2 != nullptr) {
DCTypedef *dtypedef = new DCTypedef($2);
if (!dc_file->add_typedef(dtypedef)) {
@@ -304,13 +304,13 @@ dclass:
dclass_name:
IDENTIFIER
{
if (dc_file == (DCFile *)NULL) {
if (dc_file == nullptr) {
yyerror("No DCFile available, so no class names are predefined.");
$$ = NULL;
$$ = nullptr;
} else {
DCClass *dclass = dc_file->get_class_by_name($1);
if (dclass == (DCClass *)NULL) {
if (dclass == nullptr) {
// Create a bogus class as a forward reference.
dclass = new DCClass(dc_file, $1, false, true);
dc_file->add_class(dclass);
@@ -332,7 +332,7 @@ dclass_derivation:
dclass_base_list:
dclass_name
{
if ($1 != (DCClass *)NULL) {
if ($1 != nullptr) {
current_class->add_parent($1);
}
}
@@ -342,7 +342,7 @@ dclass_base_list:
yyerror("Multiple inheritance is not supported without \"dc-multiple-inheritance 1\" in your Config.prc file.");
} else {
if ($3 != (DCClass *)NULL) {
if ($3 != nullptr) {
current_class->add_parent($3);
}
}
@@ -354,7 +354,7 @@ dclass_fields:
| dclass_fields ';'
| dclass_fields dclass_field ';'
{
if ($2 == (DCField *)NULL) {
if ($2 == nullptr) {
// Pass this error up.
} else if (!current_class->add_field($2)) {
yyerror("Duplicate field name: " + $2->get_name());
@@ -367,7 +367,7 @@ dclass_fields:
dclass_field:
atomic_field keyword_list
{
if ($1 != (DCField *)NULL) {
if ($1 != nullptr) {
if ($1->get_name().empty()) {
yyerror("Field name required.");
}
@@ -379,14 +379,14 @@ dclass_field:
| unnamed_parameter_with_default keyword_list
{
yyerror("Unnamed parameters are not allowed on a dclass");
if ($1 != (DCField *)NULL) {
if ($1 != nullptr) {
$1->copy_keywords(current_keyword_list);
}
$$ = $1;
}
| named_parameter_with_default keyword_list
{
if ($1 != (DCField *)NULL) {
if ($1 != nullptr) {
$1->copy_keywords(current_keyword_list);
}
$$ = $1;
@@ -408,13 +408,13 @@ struct:
struct_name:
IDENTIFIER
{
if (dc_file == (DCFile *)NULL) {
if (dc_file == nullptr) {
yyerror("No DCFile available, so no struct names are predefined.");
$$ = NULL;
$$ = nullptr;
} else {
DCClass *dstruct = dc_file->get_class_by_name($1);
if (dstruct == (DCClass *)NULL) {
if (dstruct == nullptr) {
// Create a bogus class as a forward reference.
dstruct = new DCClass(dc_file, $1, false, true);
dc_file->add_class(dstruct);
@@ -436,13 +436,13 @@ struct_derivation:
struct_base_list:
struct_name
{
if ($1 != (DCClass *)NULL) {
if ($1 != nullptr) {
current_class->add_parent($1);
}
}
| struct_base_list ',' struct_name
{
if ($3 != (DCClass *)NULL) {
if ($3 != nullptr) {
current_class->add_parent($3);
}
}
@@ -453,7 +453,7 @@ struct_fields:
| struct_fields ';'
| struct_fields struct_field ';'
{
if ($2 == (DCField *)NULL) {
if ($2 == nullptr) {
// Pass this error up.
} else if (!current_class->add_field($2)) {
yyerror("Duplicate field name: " + $2->get_name());
@@ -483,7 +483,7 @@ struct_field:
atomic_field:
optional_name '('
{
if (current_class == (DCClass *)NULL) {
if (current_class == nullptr) {
yyerror("Cannot define a method outside of a struct or class.");
DCClass *temp_class = new DCClass(dc_file, "temp", false, false); // memory leak.
current_atomic = new DCAtomicField($1, temp_class, false);
@@ -511,7 +511,7 @@ nonempty_parameter_list:
atomic_element:
parameter_with_default
{
if ($1 != (DCParameter *)NULL) {
if ($1 != nullptr) {
current_atomic->add_element($1);
}
}
@@ -538,14 +538,14 @@ named_parameter_with_default:
{
current_packer = &default_packer;
current_packer->clear_data();
if ($1 != (DCField *)NULL) {
if ($1 != nullptr) {
current_packer->begin_pack($1);
}
}
parameter_value
{
bool is_valid = false;
if ($1 != (DCField *)NULL) {
if ($1 != nullptr) {
is_valid = $1->is_valid();
}
if (current_packer->end_pack()) {
@@ -568,14 +568,14 @@ unnamed_parameter_with_default:
{
current_packer = &default_packer;
current_packer->clear_data();
if ($1 != (DCField *)NULL) {
if ($1 != nullptr) {
current_packer->begin_pack($1);
}
}
parameter_value
{
bool is_valid = false;
if ($1 != (DCField *)NULL) {
if ($1 != nullptr) {
is_valid = $1->is_valid();
}
if (current_packer->end_pack()) {
@@ -636,7 +636,7 @@ simple_type_name:
| simple_type_name '(' double_range ')'
{
DCSimpleParameter *simple_param = $1->as_simple_parameter();
nassertr(simple_param != (DCSimpleParameter *)NULL, 0);
nassertr(simple_param != nullptr, 0);
if (!simple_param->set_range(double_range)) {
yyerror("Inappropriate range for type");
}
@@ -645,7 +645,7 @@ simple_type_name:
| simple_type_name '/' small_unsigned_integer
{
DCSimpleParameter *simple_param = $1->as_simple_parameter();
nassertr(simple_param != (DCSimpleParameter *)NULL, 0);
nassertr(simple_param != nullptr, 0);
if (!simple_param->is_numeric_type()) {
yyerror("A divisor is only valid on a numeric type.");
@@ -661,7 +661,7 @@ simple_type_name:
| simple_type_name '%' number
{
DCSimpleParameter *simple_param = $1->as_simple_parameter();
nassertr(simple_param != (DCSimpleParameter *)NULL, 0);
nassertr(simple_param != nullptr, 0);
if (!simple_param->is_numeric_type()) {
yyerror("A divisor is only valid on a numeric type.");
@@ -676,22 +676,22 @@ type_name:
simple_type_name
| IDENTIFIER
{
if (dc_file == (DCFile *)NULL) {
if (dc_file == nullptr) {
yyerror("Invalid type.");
$$ = NULL;
$$ = nullptr;
} else {
DCTypedef *dtypedef = dc_file->get_typedef_by_name($1);
if (dtypedef == (DCTypedef *)NULL) {
if (dtypedef == nullptr) {
// Maybe it's a class name.
DCClass *dclass = dc_file->get_class_by_name($1);
if (dclass != (DCClass *)NULL) {
if (dclass != nullptr) {
// Create an implicit typedef for this.
dtypedef = new DCTypedef(new DCClassParameter(dclass), true);
} else {
// Maybe it's a switch name.
DCSwitch *dswitch = dc_file->get_switch_by_name($1);
if (dswitch != (DCSwitch *)NULL) {
if (dswitch != nullptr) {
// This also gets an implicit typedef.
dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true);
} else {
@@ -709,10 +709,10 @@ type_name:
| struct
{
// This is an inline struct definition.
if ($1 == (DCClass *)NULL) {
$$ = NULL;
if ($1 == nullptr) {
$$ = nullptr;
} else {
if (dc_file != (DCFile *)NULL) {
if (dc_file != nullptr) {
dc_file->add_thing_to_delete($1);
} else {
// This is a memory leak--this happens when we put an anonymous
@@ -725,10 +725,10 @@ type_name:
| switch
{
// This is an inline switch definition.
if ($1 == (DCSwitch *)NULL) {
$$ = NULL;
if ($1 == nullptr) {
$$ = nullptr;
} else {
if (dc_file != (DCFile *)NULL) {
if (dc_file != nullptr) {
dc_file->add_thing_to_delete($1);
} else {
// This is a memory leak--this happens when we put an anonymous
@@ -840,8 +840,8 @@ type_definition:
type_name
| type_definition '[' uint_range ']'
{
if ($1 == (DCParameter *)NULL) {
$$ = NULL;
if ($1 == nullptr) {
$$ = nullptr;
} else {
$$ = $1->append_array_specification(uint_range);
}
@@ -857,7 +857,7 @@ parameter_definition:
| parameter_definition '/' small_unsigned_integer
{
DCSimpleParameter *simple_param = $1->as_simple_parameter();
if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) {
if (simple_param == nullptr || simple_param->get_typedef() != nullptr) {
yyerror("A divisor is only allowed on a primitive type.");
} else if (!simple_param->is_numeric_type()) {
@@ -872,7 +872,7 @@ parameter_definition:
| parameter_definition '%' number
{
DCSimpleParameter *simple_param = $1->as_simple_parameter();
if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) {
if (simple_param == nullptr || simple_param->get_typedef() != nullptr) {
yyerror("A modulus is only allowed on a primitive type.");
} else if (!simple_param->is_numeric_type()) {
@@ -1184,8 +1184,8 @@ atomic_name:
IDENTIFIER
{
DCField *field = current_class->get_field_by_name($1);
$$ = (DCAtomicField *)NULL;
if (field == (DCField *)NULL) {
$$ = nullptr;
if (field == nullptr) {
// Maybe the field is unknown because the class is partially
// bogus. In that case, allow it for now; create a bogus field as
// a placeholder.
@@ -1200,7 +1200,7 @@ atomic_name:
} else {
$$ = field->as_atomic_field();
if ($$ == (DCAtomicField *)NULL) {
if ($$ == nullptr) {
yyerror("Not an atomic field: " + $1);
}
}
@@ -1210,13 +1210,13 @@ atomic_name:
molecular_atom_list:
atomic_name
{
if ($1 != (DCAtomicField *)NULL) {
if ($1 != nullptr) {
current_molecular->add_atomic($1);
}
}
| molecular_atom_list ',' atomic_name
{
if ($3 != (DCAtomicField *)NULL) {
if ($3 != nullptr) {
current_molecular->add_atomic($3);
if (!$3->is_bogus_field() && !current_molecular->compare_keywords(*$3)) {
yyerror("Mismatched keywords in molecule between " +
@@ -1258,7 +1258,7 @@ switch_fields:
{
if (!current_switch->is_field_valid()) {
yyerror("case declaration required before first element");
} else if ($2 != (DCField *)NULL) {
} else if ($2 != nullptr) {
if (!current_switch->add_field($2)) {
yyerror("Duplicate field name: " + $2->get_name());
}

View File

@@ -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

View File

@@ -21,7 +21,7 @@
#include <math.h>
DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map;
DCClassParameter *DCSimpleParameter::_uint32uint8_type = NULL;
DCClassParameter *DCSimpleParameter::_uint32uint8_type = nullptr;
/**
*
@@ -186,7 +186,7 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) :
_nested_field = create_uint32uint8_type();
} else {
_nested_field = NULL;
_nested_field = nullptr;
}
}
@@ -2173,7 +2173,7 @@ unpack_skip(const char *data, size_t length, size_t &p,
void DCSimpleParameter::
output_instance(ostream &out, bool brief, const string &prename,
const string &name, const string &postname) const {
if (get_typedef() != (DCTypedef *)NULL) {
if (get_typedef() != nullptr) {
output_typedef_name(out, brief, prename, name, postname);
} else {
@@ -2238,6 +2238,8 @@ output_instance(ostream &out, bool brief, const string &prename,
}
break;
case ST_blob:
case ST_blob32:
case ST_string:
if (!_uint_range.is_empty()) {
out << "(";
@@ -2340,7 +2342,7 @@ do_check_match_array_parameter(const DCArrayParameter *other) const {
// We cannot match a fixed-size array.
return false;
}
if (_nested_field == NULL) {
if (_nested_field == nullptr) {
// Only an array-style simple parameter can match a DCArrayParameter.
return false;
}
@@ -2372,8 +2374,8 @@ create_nested_field(DCSubatomicType type, unsigned int divisor) {
*/
DCPackerInterface *DCSimpleParameter::
create_uint32uint8_type() {
if (_uint32uint8_type == NULL) {
DCClass *dclass = new DCClass(NULL, "", true, false);
if (_uint32uint8_type == nullptr) {
DCClass *dclass = new DCClass(nullptr, "", true, false);
dclass->add_field(new DCSimpleParameter(ST_uint32));
dclass->add_field(new DCSimpleParameter(ST_uint8));
_uint32uint8_type = new DCClassParameter(dclass);

View File

@@ -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:

View File

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

View File

@@ -27,7 +27,7 @@ DCSwitch(const string &name, DCField *key_parameter) :
_name(name),
_key_parameter(key_parameter)
{
_default_case = NULL;
_default_case = nullptr;
_fields_added = false;
}
@@ -36,7 +36,7 @@ DCSwitch(const string &name, DCField *key_parameter) :
*/
DCSwitch::
~DCSwitch() {
nassertv(_key_parameter != (DCField *)NULL);
nassertv(_key_parameter != nullptr);
delete _key_parameter;
Cases::iterator ci;
@@ -121,7 +121,7 @@ get_case_by_value(const string &case_value) const {
*/
DCPackerInterface *DCSwitch::
get_case(int n) const {
nassertr(n >= 0 && n < (int)_cases.size(), NULL);
nassertr(n >= 0 && n < (int)_cases.size(), nullptr);
return _cases[n]->_fields;
}
@@ -157,8 +157,8 @@ get_num_fields(int case_index) const {
*/
DCField *DCSwitch::
get_field(int case_index, int n) const {
nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL);
nassertr(n >= 0 && n < (int)_cases[case_index]->_fields->_fields.size(), NULL);
nassertr(case_index >= 0 && case_index < (int)_cases.size(), nullptr);
nassertr(n >= 0 && n < (int)_cases[case_index]->_fields->_fields.size(), nullptr);
return _cases[case_index]->_fields->_fields[n];
}
@@ -168,7 +168,7 @@ get_field(int case_index, int n) const {
*/
DCField *DCSwitch::
get_field_by_name(int case_index, const string &name) const {
nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL);
nassertr(case_index >= 0 && case_index < (int)_cases.size(), nullptr);
const FieldsByName &fields_by_name = _cases[case_index]->_fields->_fields_by_name;
FieldsByName::const_iterator ni;
@@ -177,7 +177,7 @@ get_field_by_name(int case_index, const string &name) const {
return (*ni).second;
}
return NULL;
return nullptr;
}
/**
@@ -226,7 +226,7 @@ add_invalid_case() {
*/
bool DCSwitch::
add_default() {
if (_default_case != (SwitchFields *)NULL) {
if (_default_case != nullptr) {
add_invalid_case();
return false;
}
@@ -286,12 +286,12 @@ apply_switch(const char *value_data, size_t length) const {
}
// Unexpected value--use the default.
if (_default_case != (SwitchFields *)NULL) {
if (_default_case != nullptr) {
return _default_case;
}
// No default.
return NULL;
return nullptr;
}
/**
@@ -326,26 +326,26 @@ output_instance(ostream &out, bool brief, const string &prename,
_key_parameter->output(out, brief);
out << ") {";
const SwitchFields *last_fields = NULL;
const SwitchFields *last_fields = nullptr;
Cases::const_iterator ci;
for (ci = _cases.begin(); ci != _cases.end(); ++ci) {
const SwitchCase *dcase = (*ci);
if (dcase->_fields != last_fields && last_fields != (SwitchFields *)NULL) {
if (dcase->_fields != last_fields && last_fields != nullptr) {
last_fields->output(out, brief);
}
last_fields = dcase->_fields;
out << "case " << _key_parameter->format_data(dcase->_value, false) << ": ";
}
if (_default_case != (SwitchFields *)NULL) {
if (_default_case != last_fields && last_fields != (SwitchFields *)NULL) {
if (_default_case != nullptr) {
if (_default_case != last_fields && last_fields != nullptr) {
last_fields->output(out, brief);
}
last_fields = _default_case;
out << "default: ";
}
if (last_fields != (SwitchFields *)NULL) {
if (last_fields != nullptr) {
last_fields->output(out, brief);
}
@@ -372,12 +372,12 @@ write_instance(ostream &out, bool brief, int indent_level,
_key_parameter->output(out, brief);
out << ") {\n";
const SwitchFields *last_fields = NULL;
const SwitchFields *last_fields = nullptr;
Cases::const_iterator ci;
for (ci = _cases.begin(); ci != _cases.end(); ++ci) {
const SwitchCase *dcase = (*ci);
if (dcase->_fields != last_fields && last_fields != (SwitchFields *)NULL) {
if (dcase->_fields != last_fields && last_fields != nullptr) {
last_fields->write(out, brief, indent_level + 2);
}
last_fields = dcase->_fields;
@@ -385,15 +385,15 @@ write_instance(ostream &out, bool brief, int indent_level,
<< "case " << _key_parameter->format_data(dcase->_value, false) << ":\n";
}
if (_default_case != (SwitchFields *)NULL) {
if (_default_case != last_fields && last_fields != (SwitchFields *)NULL) {
if (_default_case != nullptr) {
if (_default_case != last_fields && last_fields != nullptr) {
last_fields->write(out, brief, indent_level + 2);
}
last_fields = _default_case;
indent(out, indent_level)
<< "default:\n";
}
if (last_fields != (SwitchFields *)NULL) {
if (last_fields != nullptr) {
last_fields->write(out, brief, indent_level + 2);
}
@@ -428,7 +428,7 @@ generate_hash(HashGenerator &hashgen) const {
}
}
if (_default_case != (SwitchFields *)NULL) {
if (_default_case != nullptr) {
const SwitchFields *fields = _default_case;
hashgen.add_int(fields->_fields.size());
Fields::const_iterator fi;
@@ -446,7 +446,7 @@ generate_hash(HashGenerator &hashgen) const {
*/
bool DCSwitch::
pack_default_value(DCPackData &pack_data, bool &pack_error) const {
SwitchFields *fields = NULL;
SwitchFields *fields = nullptr;
DCPacker packer;
packer.begin_pack(_key_parameter);
if (!_cases.empty()) {
@@ -466,7 +466,7 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const {
pack_error = true;
}
if (fields == (SwitchFields *)NULL) {
if (fields == nullptr) {
pack_error = true;
} else {
@@ -528,7 +528,7 @@ do_check_match_switch(const DCSwitch *other) const {
*/
DCSwitch::SwitchFields *DCSwitch::
start_new_case() {
SwitchFields *fields = NULL;
SwitchFields *fields = nullptr;
if (_current_fields.empty() || _fields_added) {
// If we have recently encountered a break (which removes all of the
@@ -587,7 +587,7 @@ DCSwitch::SwitchFields::
*/
DCPackerInterface *DCSwitch::SwitchFields::
get_nested_field(int n) const {
nassertr(n >= 0 && n < (int)_fields.size(), NULL);
nassertr(n >= 0 && n < (int)_fields.size(), nullptr);
return _fields[n];
}

View File

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

View File

@@ -66,7 +66,7 @@ DCSwitchParameter(const DCSwitch *dswitch) :
// Also consider the default case, if there is one.
const DCSwitch::SwitchFields *fields =
(DCSwitch::SwitchFields *)_dswitch->get_default_case();
if (fields != (DCSwitch::SwitchFields *)NULL) {
if (fields != nullptr) {
if (!fields->has_fixed_byte_size() ||
fields->get_fixed_byte_size() != _fixed_byte_size) {
_has_fixed_byte_size = false;
@@ -155,7 +155,7 @@ apply_switch(const char *value_data, size_t length) const {
void DCSwitchParameter::
output_instance(ostream &out, bool brief, const string &prename,
const string &name, const string &postname) const {
if (get_typedef() != (DCTypedef *)NULL) {
if (get_typedef() != nullptr) {
output_typedef_name(out, brief, prename, name, postname);
} else {
@@ -171,7 +171,7 @@ void DCSwitchParameter::
write_instance(ostream &out, bool brief, int indent_level,
const string &prename, const string &name,
const string &postname) const {
if (get_typedef() != (DCTypedef *)NULL) {
if (get_typedef() != nullptr) {
write_typedef_name(out, brief, indent_level, prename, name, postname);
} else {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
@@ -80,15 +77,9 @@ using namespace std;
#define nassertv(condition) assert(condition)
#define nassertv_always(condition) assert(condition)
// Panda defines these export symbols for building DLL's. Outside of Panda,
// we assume we're not putting this code in a DLL, so we define them to
// nothing.
#define EXPCL_DIRECT
#define EXPTP_DIRECT
// 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
@@ -98,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

View File

@@ -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

View File

@@ -17,16 +17,13 @@
// This file defines the server message types used within this module. It
// duplicates some symbols defined in MsgTypes.py and AIMsgTypes.py.
#define CLIENT_OBJECT_UPDATE_FIELD 24
#define CLIENT_CREATE_OBJECT_REQUIRED 34
#define CLIENT_CREATE_OBJECT_REQUIRED_OTHER 35
#define CLIENT_OBJECT_SET_FIELD 120
#define CLIENT_ENTER_OBJECT_REQUIRED 142
#define CLIENT_ENTER_OBJECT_REQUIRED_OTHER 143
#define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED 2001
#define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER 2003
#define STATESERVER_OBJECT_UPDATE_FIELD 2004
#define STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT 2050
#define STATESERVER_OBJECT_CREATE_WITH_REQUIR_OTHER_CONTEXT 2051
#define STATESERVER_BOUNCE_MESSAGE 2086
#define STATESERVER_CREATE_OBJECT_WITH_REQUIRED 2000
#define STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER 2001
#define STATESERVER_OBJECT_SET_FIELD 2020
#define CLIENT_OBJECT_GENERATE_CMU 9002

View File

@@ -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;

View File

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

View File

@@ -15,6 +15,10 @@
#include "dconfig.h"
#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DEADREC)
#error Buildsystem error: BUILDING_DIRECT_DEADREC not defined
#endif
Configure(config_deadrec);
NotifyCategoryDef(deadrec, "");

View File

@@ -18,10 +18,10 @@
#include "notifyCategoryProxy.h"
#include "configVariableBool.h"
NotifyCategoryDecl(deadrec, EXPCL_DIRECT, EXPTP_DIRECT);
NotifyCategoryDecl(deadrec, EXPCL_DIRECT_DEADREC, EXPTP_DIRECT_DEADREC);
extern ConfigVariableBool accept_clock_skew;
extern EXPCL_DIRECT void init_libdeadrec();
extern EXPCL_DIRECT_DEADREC void init_libdeadrec();
#endif

View File

@@ -38,7 +38,7 @@ static const int max_timestamp_delays = 10;
* update. The assumption is that all SmoothMovers in the world will be
* operating in the same mode together.
*/
class EXPCL_DIRECT SmoothMover {
class EXPCL_DIRECT_DEADREC SmoothMover {
PUBLISHED:
SmoothMover();
~SmoothMover();
@@ -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,

View File

@@ -16,12 +16,62 @@
/* See dtoolsymbols.h for a rant on the purpose of this file. */
/* BUILDING_DIRECT is just a buildsystem shortcut for all of these: */
#ifdef BUILDING_DIRECT
#define EXPCL_DIRECT EXPORT_CLASS
#define EXPTP_DIRECT EXPORT_TEMPL
#define BUILDING_DIRECT_DEADREC
#define BUILDING_DIRECT_DIRECTD
#define BUILDING_DIRECT_INTERVAL
#define BUILDING_DIRECT_MOTIONTRAIL
#define BUILDING_DIRECT_SHOWBASE
#define BUILDING_DIRECT_DISTRIBUTED
#endif
#ifdef BUILDING_DIRECT_DEADREC
#define EXPCL_DIRECT_DEADREC EXPORT_CLASS
#define EXPTP_DIRECT_DEADREC EXPORT_TEMPL
#else
#define EXPCL_DIRECT IMPORT_CLASS
#define EXPTP_DIRECT IMPORT_TEMPL
#define EXPCL_DIRECT_DEADREC IMPORT_CLASS
#define EXPTP_DIRECT_DEADREC IMPORT_TEMPL
#endif
#ifdef BUILDING_DIRECT_DIRECTD
#define EXPCL_DIRECT_DIRECTD EXPORT_CLASS
#define EXPTP_DIRECT_DIRECTD EXPORT_TEMPL
#else
#define EXPCL_DIRECT_DIRECTD IMPORT_CLASS
#define EXPTP_DIRECT_DIRECTD IMPORT_TEMPL
#endif
#ifdef BUILDING_DIRECT_INTERVAL
#define EXPCL_DIRECT_INTERVAL EXPORT_CLASS
#define EXPTP_DIRECT_INTERVAL EXPORT_TEMPL
#else
#define EXPCL_DIRECT_INTERVAL IMPORT_CLASS
#define EXPTP_DIRECT_INTERVAL IMPORT_TEMPL
#endif
#ifdef BUILDING_DIRECT_MOTIONTRAIL
#define EXPCL_DIRECT_MOTIONTRAIL EXPORT_CLASS
#define EXPTP_DIRECT_MOTIONTRAIL EXPORT_TEMPL
#else
#define EXPCL_DIRECT_MOTIONTRAIL IMPORT_CLASS
#define EXPTP_DIRECT_MOTIONTRAIL IMPORT_TEMPL
#endif
#ifdef BUILDING_DIRECT_SHOWBASE
#define EXPCL_DIRECT_SHOWBASE EXPORT_CLASS
#define EXPTP_DIRECT_SHOWBASE EXPORT_TEMPL
#else
#define EXPCL_DIRECT_SHOWBASE IMPORT_CLASS
#define EXPTP_DIRECT_SHOWBASE IMPORT_TEMPL
#endif
#ifdef BUILDING_DIRECT_DISTRIBUTED
#define EXPCL_DIRECT_DISTRIBUTED EXPORT_CLASS
#define EXPTP_DIRECT_DISTRIBUTED EXPORT_TEMPL
#else
#define EXPCL_DIRECT_DISTRIBUTED IMPORT_CLASS
#define EXPTP_DIRECT_DISTRIBUTED IMPORT_TEMPL
#endif
#endif

View File

@@ -30,6 +30,10 @@
#include "pset.h"
#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DIRECTD)
#error Buildsystem error: BUILDING_DIRECT_DIRECTD not defined
#endif
namespace {
// ...This section is part of the old stuff from the original
// implementation. The new stuff that uses job objects doesn't need this
@@ -79,7 +83,7 @@ namespace {
// If we can't open the process with PROCESS_TERMINATE rights, then we
// give up immediately.
hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, dwPID);
if(hProc == NULL) {
if(hProc == nullptr) {
return TA_FAILED;
}
@@ -111,7 +115,7 @@ namespace {
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
if (CreateProcess(NULL, (char*)cmd.c_str(),
if (CreateProcess(nullptr, (char*)cmd.c_str(),
0, 0, 1, NORMAL_PRIORITY_CLASS,
0, 0, &si, &pi)) {
pid=pi.dwProcessId;
@@ -224,7 +228,7 @@ DirectD::start_app(const string& cmd) {
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
if (CreateProcess(NULL, (char*)cmd.c_str(),
if (CreateProcess(nullptr, (char*)cmd.c_str(),
0, 0, 1, NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED,
0, 0, &si, &pi)) {
// The process must be created with CREATE_SUSPENDED to give us a chance

View File

@@ -52,7 +52,7 @@ typedef int HANDLE;
* presented in order chronologically by their intended usage. The first
* group will probably provide everthing needed for DirectD.
*/
class EXPCL_DIRECT DirectD {
class EXPCL_DIRECT_DIRECTD DirectD {
PUBLISHED:
DirectD();
~DirectD();
@@ -73,7 +73,7 @@ PUBLISHED:
* one command, you should use connect_to(), send_command(), and
* disconnect_from().
*/
int client_ready(const string& server_host, int port, const string& cmd);
int client_ready(const std::string& server_host, int port, const std::string& cmd);
/**
* Tell the server to do the command cmd. cmd is one of the following:
@@ -85,7 +85,7 @@ PUBLISHED:
* client_ready(), it prefixes "!" for you. A new connection will be created
* and closed.
*/
int tell_server(const string& server_host, int port, const string& cmd);
int tell_server(const std::string& server_host, int port, const std::string& cmd);
/**
* Call this function from the client after calling <count> client_ready()
@@ -102,7 +102,7 @@ PUBLISHED:
* Call this function from the server when import ShowbaseGlobal is nearly
* finished.
*/
int server_ready(const string& client_host, int port);
int server_ready(const std::string& client_host, int port);
/**
* Call connect_to from client for each server. returns the port number of
@@ -110,28 +110,28 @@ PUBLISHED:
* second argument). The return value can be used for the port arguemnt in
* disconnect_from().
*/
int connect_to(const string& server_host, int port);
int connect_to(const std::string& server_host, int port);
/**
* This is the counterpart to connect_to(). Pass the same server_host as for
* connect_to(), but pass the return value from connect_to() for the port, not
* the port passed to connect_to().
*/
void disconnect_from(const string& server_host, int port);
void disconnect_from(const std::string& server_host, int port);
/**
* Send the same command string to all current connections.
*/
void send_command(const string& cmd);
void send_command(const std::string& cmd);
protected:
void start_app(const string& cmd);
void start_app(const std::string& cmd);
void kill_app(int index);
void kill_all();
virtual void handle_command(const string& cmd);
virtual void handle_command(const std::string& cmd);
void handle_datagram(NetDatagram& datagram);
void send_one_message(const string& host_name,
int port, const string& message);
void send_one_message(const std::string& host_name,
int port, const std::string& message);
QueuedConnectionManager _cm;
QueuedConnectionReader _reader;

View File

@@ -24,7 +24,7 @@ DirectDClient::cli_command(const string& cmd) {
cerr<<"command "<<cmd<<endl;
if (cmd[0]==':') {
// ...connect to host.
cerr<<"Local command "<<flush;
cerr<<"Local command "<<std::flush;
string code;
cin >> code;
string host;
@@ -49,7 +49,7 @@ DirectDClient::run_client(const string& host, int port) {
connect_to(host, port);
while (!cin.fail() && _connections.size()!=0) {
cout << "directd send: " << flush;
cout << "directd send: " << std::flush;
string d;
cin >> d;
cli_command(d);

View File

@@ -21,8 +21,8 @@ public:
DirectDClient();
~DirectDClient();
void run_client(const string& host, int port);
void run_client(const std::string& host, int port);
protected:
void cli_command(const string& cmd);
void cli_command(const std::string& cmd);
};

View File

@@ -29,6 +29,6 @@ public:
void run_server(int port);
protected:
void read_command(string& cmd);
virtual void handle_command(const string& cmd);
void read_command(std::string& cmd);
virtual void handle_command(const std::string& cmd);
};

View File

@@ -623,8 +623,8 @@ class SelectionRay(SelectionQueue):
def pickBitMask(self, bitMask = BitMask32.allOff(),
targetNodePath = None,
skipFlags = SKIP_ALL):
if parentNodePath is None:
parentNodePath = render
if targetNodePath is None:
targetNodePath = render
self.collideWithBitMask(bitMask)
self.pick(targetNodePath)
# Determine collision entry

View File

@@ -2,6 +2,8 @@ from direct.distributed.CachedDOData import CachedDOData
from panda3d.core import ConfigVariableInt
__all__ = ["CRDataCache"]
class CRDataCache:
# Stores cached data for DistributedObjects between instantiations on the client

View File

@@ -175,7 +175,7 @@ class ClientRepositoryBase(ConnectionRepository):
"generate" messages when they are replayed().
"""
if msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER:
if msgType == CLIENT_ENTER_OBJECT_REQUIRED_OTHER:
# It's a generate message.
doId = extra
if doId in self.deferredDoIds:
@@ -263,7 +263,7 @@ class ClientRepositoryBase(ConnectionRepository):
distObj.setLocation(parentId, zoneId)
distObj.updateRequiredFields(dclass, di)
# updateRequiredFields calls announceGenerate
print("New DO:%s, dclass:%s"%(doId, dclass.getName()))
self.notify.debug("New DO:%s, dclass:%s" % (doId, dclass.getName()))
return distObj
def generateWithRequiredOtherFields(self, dclass, doId, di,
@@ -381,7 +381,7 @@ class ClientRepositoryBase(ConnectionRepository):
# The object had been deferred. Great; we don't even have
# to generate it now.
del self.deferredDoIds[doId]
i = self.deferredGenerates.index((CLIENT_CREATE_OBJECT_REQUIRED_OTHER, doId))
i = self.deferredGenerates.index((CLIENT_ENTER_OBJECT_REQUIRED_OTHER, doId))
del self.deferredGenerates[i]
if len(self.deferredGenerates) == 0:
taskMgr.remove('deferredGenerate')

View File

@@ -7,9 +7,10 @@ from direct.distributed.DoCollectionManager import DoCollectionManager
from direct.showbase import GarbageReport
from .PyDatagramIterator import PyDatagramIterator
import types
import inspect
import gc
__all__ = ["ConnectionRepository", "GCTrigger"]
class ConnectionRepository(
DoInterestManager, DoCollectionManager, CConnectionRepository):
@@ -326,13 +327,13 @@ class ConnectionRepository(
if classDef is None:
self.notify.debug("No class definition for %s." % (className))
else:
if type(classDef) == types.ModuleType:
if inspect.ismodule(classDef):
if not hasattr(classDef, className):
self.notify.warning("Module %s does not define class %s." % (className, className))
continue
classDef = getattr(classDef, className)
if type(classDef) != types.ClassType and type(classDef) != types.TypeType:
if not inspect.isclass(classDef):
self.notify.error("Symbol %s is not a class name." % (className))
else:
dclass.setClassDef(classDef)
@@ -387,7 +388,7 @@ class ConnectionRepository(
if classDef is None:
self.notify.error("No class definition for %s." % className)
else:
if type(classDef) == types.ModuleType:
if inspect.ismodule(classDef):
if not hasattr(classDef, className):
self.notify.error("Module %s does not define class %s." % (className, className))
classDef = getattr(classDef, className)

View File

@@ -15,6 +15,8 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
self.DistributedNode_initialized = 1
self.gotStringParentToken = 0
DistributedObject.DistributedObject.__init__(self, cr)
if not self.this:
NodePath.__init__(self, "DistributedNode")
# initialize gridParent
self.gridParent = None

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