mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
add pack_required_field(datagram, ...)
This commit is contained in:
parent
50974f8189
commit
215d97d75f
@ -459,6 +459,34 @@ direct_update(PyObject *distobj, const string &field_name,
|
|||||||
}
|
}
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DCClass::pack_required_field
|
||||||
|
// Access: Published
|
||||||
|
// Description: Looks up the current value of the indicated field by
|
||||||
|
// calling the appropriate get*() function, then packs
|
||||||
|
// that value into the datagram. This field is
|
||||||
|
// presumably either a required field or a specified
|
||||||
|
// optional field, and we are building up a datagram for
|
||||||
|
// the generate-with-required message.
|
||||||
|
//
|
||||||
|
// Returns true on success, false on failure.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool DCClass::
|
||||||
|
pack_required_field(Datagram &datagram, PyObject *distobj,
|
||||||
|
const DCField *field) const {
|
||||||
|
DCPacker packer;
|
||||||
|
packer.begin_pack(field);
|
||||||
|
if (!pack_required_field(packer, distobj, field)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!packer.end_pack()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
datagram.append_data(packer.get_data(), packer.get_length());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCClass::pack_required_field
|
// Function: DCClass::pack_required_field
|
||||||
|
@ -74,6 +74,8 @@ PUBLISHED:
|
|||||||
const string &value_blob);
|
const string &value_blob);
|
||||||
void direct_update(PyObject *distobj, const string &field_name,
|
void direct_update(PyObject *distobj, const string &field_name,
|
||||||
const Datagram &datagram);
|
const Datagram &datagram);
|
||||||
|
bool pack_required_field(Datagram &datagram, PyObject *distobj,
|
||||||
|
const DCField *field) const;
|
||||||
bool pack_required_field(DCPacker &packer, PyObject *distobj,
|
bool pack_required_field(DCPacker &packer, PyObject *distobj,
|
||||||
const DCField *field) const;
|
const DCField *field) const;
|
||||||
|
|
||||||
|
@ -482,9 +482,8 @@ receive_update(DCPacker &packer, PyObject *distobj) const {
|
|||||||
PyObject *result = PyObject_CallObject(func, args);
|
PyObject *result = PyObject_CallObject(func, args);
|
||||||
Py_XDECREF(result);
|
Py_XDECREF(result);
|
||||||
Py_DECREF(func);
|
Py_DECREF(func);
|
||||||
|
Py_DECREF(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_DECREF(args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
@ -1033,7 +1033,7 @@ enquote_string(ostream &out, char quote_mark, const string &str) {
|
|||||||
|
|
||||||
} else if (!isprint(*pi)) {
|
} else if (!isprint(*pi)) {
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
sprintf(buffer, "%02x", (unsigned int)(*pi));
|
sprintf(buffer, "%02x", (unsigned char)(*pi));
|
||||||
out << "\\x" << buffer;
|
out << "\\x" << buffer;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1055,7 +1055,7 @@ output_hex_string(ostream &out, const string &str) {
|
|||||||
pi != str.end();
|
pi != str.end();
|
||||||
++pi) {
|
++pi) {
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
sprintf(buffer, "%02x", (unsigned int)(*pi));
|
sprintf(buffer, "%02x", (unsigned char)(*pi));
|
||||||
out << buffer;
|
out << buffer;
|
||||||
}
|
}
|
||||||
out << '>';
|
out << '>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user