add pack_required_field(datagram, ...)

This commit is contained in:
David Rose 2004-08-24 00:19:02 +00:00
parent 50974f8189
commit 215d97d75f
4 changed files with 33 additions and 4 deletions

View File

@ -459,6 +459,34 @@ direct_update(PyObject *distobj, const string &field_name,
}
#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
////////////////////////////////////////////////////////////////////
// Function: DCClass::pack_required_field

View File

@ -74,6 +74,8 @@ PUBLISHED:
const string &value_blob);
void direct_update(PyObject *distobj, const string &field_name,
const Datagram &datagram);
bool pack_required_field(Datagram &datagram, PyObject *distobj,
const DCField *field) const;
bool pack_required_field(DCPacker &packer, PyObject *distobj,
const DCField *field) const;

View File

@ -482,9 +482,8 @@ receive_update(DCPacker &packer, PyObject *distobj) const {
PyObject *result = PyObject_CallObject(func, args);
Py_XDECREF(result);
Py_DECREF(func);
Py_DECREF(args);
}
Py_DECREF(args);
}
}
#endif // HAVE_PYTHON

View File

@ -1033,7 +1033,7 @@ enquote_string(ostream &out, char quote_mark, const string &str) {
} else if (!isprint(*pi)) {
char buffer[10];
sprintf(buffer, "%02x", (unsigned int)(*pi));
sprintf(buffer, "%02x", (unsigned char)(*pi));
out << "\\x" << buffer;
} else {
@ -1055,7 +1055,7 @@ output_hex_string(ostream &out, const string &str) {
pi != str.end();
++pi) {
char buffer[10];
sprintf(buffer, "%02x", (unsigned int)(*pi));
sprintf(buffer, "%02x", (unsigned char)(*pi));
out << buffer;
}
out << '>';