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