Bläddra i källkod

rework Datagram to use pta_uchar instead of string

David Rose 24 år sedan
förälder
incheckning
a23afdddab

+ 32 - 32
panda/src/express/Sources.pp

@@ -18,6 +18,7 @@
      datagramGenerator.h datagramInputFile.I datagramInputFile.h \
      datagramIterator.I datagramIterator.h datagramOutputFile.I \
      datagramOutputFile.h datagramSink.I datagramSink.h \
+     error_utils.h \
      get_config_path.h hashGeneratorBase.I hashGeneratorBase.h \
      hashVal.I hashVal.h indent.I indent.h littleEndian.h \
      memoryInfo.I memoryInfo.h \
@@ -26,57 +27,56 @@
      memoryUsagePointers.I memoryUsagePointers.h \
      multifile.I multifile.h namable.I \
      namable.h nativeNumericData.I nativeNumericData.h \
-     numeric_types.h pointerTo.I pointerTo.h referenceCount.I \
-     profileTimer.I profileTimer.h referenceCount.h \
+     numeric_types.h pointerTo.I pointerTo.h \
+     pointerToArray.I pointerToArray.h \
+     profileTimer.I profileTimer.h \
+     pta_uchar.h referenceCount.I referenceCount.h \
      reversedNumericData.I reversedNumericData.h tokenBoard.I \
      tokenBoard.h trueClock.I trueClock.h typeHandle.I \
      typeHandle.h typedObject.I typedObject.h \
      typedReferenceCount.I typedReferenceCount.h typedef.h \
-     error_utils.h 
+     vector_uchar.h
     
   #define INCLUDED_SOURCES  \
      buffer.cxx checksumHashGenerator.cxx clockObject.cxx \
      config_express.cxx datagram.cxx datagramGenerator.cxx \
      datagramInputFile.cxx datagramIterator.cxx \
-     datagramOutputFile.cxx datagramSink.cxx get_config_path.cxx \
+     datagramOutputFile.cxx datagramSink.cxx error_utils.cxx \
+     get_config_path.cxx \
      hashGeneratorBase.cxx hashVal.cxx indent.cxx \
      memoryInfo.cxx memoryUsage.cxx memoryUsagePointerCounts.cxx \
      memoryUsagePointers.cxx multifile.cxx namable.cxx \
-     nativeNumericData.cxx profileTimer.cxx referenceCount.cxx \
+     nativeNumericData.cxx profileTimer.cxx \
+     pta_uchar.cxx referenceCount.cxx \
      reversedNumericData.cxx trueClock.cxx typeHandle.cxx \
-     typedObject.cxx typedReferenceCount.cxx error_utils.cxx
+     typedObject.cxx typedReferenceCount.cxx \
+     vector_uchar.cxx
 
   #define IF_CRYPTO_SOURCES                         \
     crypto_utils.cxx crypto_utils.h \
     patchfile.I patchfile.cxx patchfile.h
 
   #define INSTALL_HEADERS                       \
-    bigEndian.h buffer.I buffer.h \
-    checksumHashGenerator.I checksumHashGenerator.h \
-    circBuffer.I        \
-    circBuffer.h clockObject.I clockObject.h config_express.h       \
-    datagram.I datagram.h datagramInputFile.I datagramInputFile.h   \
-    datagramIterator.I datagramIterator.h \
-    datagramOutputFile.I datagramOutputFile.h   \
-    datagramSink.I datagramSink.h datagramGenerator.I           \
-    datagramGenerator.h get_config_path.h               \
-    hashGeneratorBase.I hashGeneratorBase.h \
-    hashVal.I hashVal.h \
-    indent.I indent.h littleEndian.h                    \
-    memoryInfo.I memoryInfo.h \
-    memoryUsage.I memoryUsage.h \
-    memoryUsagePointerCounts.I memoryUsagePointerCounts.h \
-    memoryUsagePointers.I memoryUsagePointers.h multifile.I multifile.h \
-    nativeNumericData.I nativeNumericData.h \
-    numeric_types.h \
-    pointerTo.I pointerTo.h referenceCount.I referenceCount.h       \
-    profileTimer.I profileTimer.h   \
-    reversedNumericData.I reversedNumericData.h \
-    tokenBoard.h trueClock.I trueClock.h typeHandle.I typeHandle.h  \
-    typedObject.h typedObject.I \
-    typedReferenceCount.I typedReferenceCount.h typedef.h       \
-    namable.I namable.h tokenBoard.I patchfile.h patchfile.I        \
-    error_utils.h
+    bigEndian.h buffer.I buffer.h checksumHashGenerator.I  \
+    checksumHashGenerator.h circBuffer.I circBuffer.h clockObject.I \
+    clockObject.h config_express.h datagram.I datagram.h \
+    datagramGenerator.I datagramGenerator.h datagramInputFile.I \
+    datagramInputFile.h datagramIterator.I datagramIterator.h \
+    datagramOutputFile.I datagramOutputFile.h datagramSink.I \
+    datagramSink.h error_utils.h get_config_path.h hashGeneratorBase.I \
+    hashGeneratorBase.h hashVal.I hashVal.h indent.I indent.h \
+    littleEndian.h memoryInfo.I memoryInfo.h memoryUsage.I \
+    memoryUsage.h memoryUsagePointerCounts.I \
+    memoryUsagePointerCounts.h memoryUsagePointers.I \
+    memoryUsagePointers.h multifile.I multifile.h namable.I namable.h \
+    nativeNumericData.I nativeNumericData.h numeric_types.h \
+    patchfile.I patchfile.h pointerTo.I pointerTo.h \
+    pointerToArray.I pointerToArray.h profileTimer.I \
+    profileTimer.h pta_uchar.h referenceCount.I referenceCount.h \
+    reversedNumericData.I reversedNumericData.h tokenBoard.I \
+    tokenBoard.h trueClock.I trueClock.h typeHandle.I typeHandle.h \
+    typedObject.I typedObject.h typedReferenceCount.I \
+    typedReferenceCount.h typedef.h vector_uchar.h
 
   #define IGATESCAN all
 

+ 55 - 60
panda/src/express/datagram.I

@@ -31,7 +31,8 @@ Datagram() {
 //  Description: Constructs a datagram from an existing block of data.
 ////////////////////////////////////////////////////////////////////
 INLINE Datagram::
-Datagram(const void *data, size_t size) : _message((const char *)data, size) {
+Datagram(const void *data, size_t size) {
+  append_data(data, size);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -40,7 +41,8 @@ Datagram(const void *data, size_t size) : _message((const char *)data, size) {
 //  Description: Constructs a datagram from an existing block of data.
 ////////////////////////////////////////////////////////////////////
 INLINE Datagram::
-Datagram(const string &data) : _message(data) {
+Datagram(const string &data) {
+  append_data(data);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -50,7 +52,7 @@ Datagram(const string &data) : _message(data) {
 ////////////////////////////////////////////////////////////////////
 INLINE Datagram::
 Datagram(const Datagram &copy) :
-  _message(copy._message)
+  _data(copy._data)
 {
 }
 
@@ -61,7 +63,7 @@ Datagram(const Datagram &copy) :
 ////////////////////////////////////////////////////////////////////
 INLINE void Datagram::
 operator = (const Datagram &copy) {
-  _message = copy._message;
+  _data = copy._data;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -81,7 +83,7 @@ add_bool(bool b) {
 ////////////////////////////////////////////////////////////////////
 INLINE void Datagram::
 add_int8(PN_int8 value) {
-  _message += (char)value;
+  append_data(&value, 1);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -91,7 +93,7 @@ add_int8(PN_int8 value) {
 ////////////////////////////////////////////////////////////////////
 INLINE void Datagram::
 add_uint8(PN_uint8 value) {
-  _message += (char)value;
+  append_data(&value, 1);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -102,7 +104,7 @@ add_uint8(PN_uint8 value) {
 INLINE void Datagram::
 add_int16(PN_int16 value) {
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -113,7 +115,7 @@ add_int16(PN_int16 value) {
 INLINE void Datagram::
 add_int32(PN_int32 value) {
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -124,7 +126,7 @@ add_int32(PN_int32 value) {
 INLINE void Datagram::
 add_int64(PN_int64 value) {
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -135,7 +137,7 @@ add_int64(PN_int64 value) {
 INLINE void Datagram::
 add_uint16(PN_uint16 value) {
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -146,7 +148,7 @@ add_uint16(PN_uint16 value) {
 INLINE void Datagram::
 add_uint32(PN_uint32 value) {
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -157,7 +159,7 @@ add_uint32(PN_uint32 value) {
 INLINE void Datagram::
 add_uint64(PN_uint64 value) {
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -175,7 +177,7 @@ add_float32(float value) {
   // is different, we will have to convert.
   nassertv(sizeof(value) == 4);
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -186,7 +188,7 @@ add_float32(float value) {
 INLINE void Datagram::
 add_float64(PN_float64 value) {
   LittleEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -198,7 +200,7 @@ add_float64(PN_float64 value) {
 INLINE void Datagram::
 add_be_int16(PN_int16 value) {
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -210,7 +212,7 @@ add_be_int16(PN_int16 value) {
 INLINE void Datagram::
 add_be_int32(PN_int32 value) {
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -222,7 +224,7 @@ add_be_int32(PN_int32 value) {
 INLINE void Datagram::
 add_be_int64(PN_int64 value) {
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -234,7 +236,7 @@ add_be_int64(PN_int64 value) {
 INLINE void Datagram::
 add_be_uint16(PN_uint16 value) {
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -246,7 +248,7 @@ add_be_uint16(PN_uint16 value) {
 INLINE void Datagram::
 add_be_uint32(PN_uint32 value) {
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -258,7 +260,7 @@ add_be_uint32(PN_uint32 value) {
 INLINE void Datagram::
 add_be_uint64(PN_uint64 value) {
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -276,7 +278,7 @@ add_be_float32(float value) {
   // is different, we will have to convert.
   nassertv(sizeof(value) == 4);
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -288,7 +290,7 @@ add_be_float32(float value) {
 INLINE void Datagram::
 add_be_float64(PN_float64 value) {
   BigEndian s(&value, sizeof(value));
-  s.append_to(_message, sizeof(value));
+  append_data(s.get_data(), sizeof(value));
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -306,7 +308,7 @@ add_string(const string &str) {
   add_uint16(str.length());
 
   // Add the string
-  _message += str;
+  append_data(str);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -320,10 +322,10 @@ add_z_string(string str) {
   // We must not have any nested null characters in the string.
   size_t null_pos = str.find('\0');
   // Add the string (sans the null character).
-  _message += str.substr(0, null_pos);
+  append_data(str.substr(0, null_pos));
 
   // And the null character.
-  _message += '\0';
+  add_uint8('\0');
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -338,38 +340,14 @@ add_z_string(string str) {
 INLINE void Datagram::
 add_fixed_string(const string &str, size_t size) {
   if (str.length() < size) {
-    _message += str;
-    _message += string(size - str.length(), '\0');
+    append_data(str);
+    pad_bytes(size - str.length());
 
   } else { // str.length() >= size
-    _message += str.substr(0, size);
+    append_data(str.substr(0, size));
   }
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: Datagram::pad_bytes
-//       Access: Public
-//  Description: Adds the indicated number of zero bytes to the
-//               datagram.
-////////////////////////////////////////////////////////////////////
-INLINE void Datagram::
-pad_bytes(size_t size) {
-  nassertv((int)size >= 0);
-  _message += string(size, '\0');
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: Datagram::append_data
-//       Access: Public
-//  Description: Appends some more raw data to the end of the
-//               datagram.
-////////////////////////////////////////////////////////////////////
-INLINE void Datagram::
-append_data(const void *data, size_t size) {
-  nassertv((int)size >= 0);
-  _message += string((const char *)data, size);
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: Datagram::append_data
 //       Access: Public
@@ -378,7 +356,7 @@ append_data(const void *data, size_t size) {
 ////////////////////////////////////////////////////////////////////
 INLINE void Datagram::
 append_data(const string &data) {
-  _message += data;
+  append_data(data.data(), data.length());
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -386,9 +364,9 @@ append_data(const string &data) {
 //       Access: Public
 //  Description: Returns the datagram's data as a string.
 ////////////////////////////////////////////////////////////////////
-INLINE const string &Datagram::
+INLINE string Datagram::
 get_message() const {
-  return _message;
+  return string((const char *)_data.p(), _data.size());
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -399,7 +377,7 @@ get_message() const {
 ////////////////////////////////////////////////////////////////////
 INLINE const void *Datagram::
 get_data() const {
-  return _message.data();
+  return _data.p();
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -409,7 +387,7 @@ get_data() const {
 ////////////////////////////////////////////////////////////////////
 INLINE size_t Datagram::
 get_length() const {
-  return _message.length();
+  return _data.size();
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -419,7 +397,13 @@ get_length() const {
 ////////////////////////////////////////////////////////////////////
 INLINE bool Datagram::
 operator == (const Datagram &other) const {
-  return _message == other._message;
+  if (_data == other._data) {
+    return true;
+  }
+  if (_data != (uchar *)NULL && other._data != (uchar *)NULL) {
+    return _data.v() == other._data.v();
+  }
+  return false;
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -429,7 +413,7 @@ operator == (const Datagram &other) const {
 ////////////////////////////////////////////////////////////////////
 INLINE bool Datagram::
 operator != (const Datagram &other) const {
-  return _message != other._message;
+  return !operator == (other);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -439,5 +423,16 @@ operator != (const Datagram &other) const {
 ////////////////////////////////////////////////////////////////////
 INLINE bool Datagram::
 operator < (const Datagram &other) const {
-  return _message < other._message;
+  if (_data == other._data) {
+    // Same pointers.
+    return false;
+  }
+
+  if (_data != (uchar *)NULL && other._data != (uchar *)NULL) {
+    // Different pointers, neither NULL.
+    return _data.v() < other._data.v();
+  }
+
+  // One of the pointers is NULL, but not the other one.
+  return _data.size() < other._data.size();
 }

+ 78 - 7
panda/src/express/datagram.cxx

@@ -43,7 +43,7 @@ Datagram::
 ////////////////////////////////////////////////////////////////////
 void Datagram::
 clear() {
-  _message = string();
+  _data.clear();
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -54,25 +54,27 @@ clear() {
 ////////////////////////////////////////////////////////////////////
 void Datagram::
 dump_hex(ostream &out) const {
-  for (size_t line = 0; line < _message.length(); line += 16) {
+  const char *message = (const char *)get_data();
+  size_t num_bytes = get_length();
+  for (size_t line = 0; line < num_bytes; line += 16) {
     char hex[12];
     sprintf(hex, "%04x ", line);
     out << hex;
 
     size_t p;
     for (p = line; p < line + 16; p++) {
-      if (p < _message.length()) {
+      if (p < num_bytes) {
         char hex[12];
-        sprintf(hex, " %02x", ((unsigned int)_message[p]) & 0xff);
+        sprintf(hex, " %02x", ((unsigned int)message[p]) & 0xff);
         out << hex;
       } else {
         out << "   ";
       }
     }
     out << "  ";
-    for (p = line; p < line + 16 && p < _message.length(); p++) {
-      if (isgraph(_message[p]) || _message[p] == ' ') {
-        out << (char)_message[p];
+    for (p = line; p < line + 16 && p < num_bytes; p++) {
+      if (isgraph(message[p]) || message[p] == ' ') {
+        out << (char)message[p];
       } else {
         out << ".";
       }
@@ -81,3 +83,72 @@ dump_hex(ostream &out) const {
   }
 }
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: Datagram::pad_bytes
+//       Access: Public
+//  Description: Adds the indicated number of zero bytes to the
+//               datagram.
+////////////////////////////////////////////////////////////////////
+void Datagram::
+pad_bytes(size_t size) {
+  nassertv((int)size >= 0);
+
+  if (_data == (uchar *)NULL) {
+    // Create a new array.
+    _data = PTA_uchar(0);
+
+  } else if (_data.get_ref_count() == 1) {
+    // Copy on write.
+    PTA_uchar new_data(0);
+    new_data.v() = _data.v();
+    _data = new_data;
+  }
+
+  // Now append the data.
+
+  // It is very important that we *don't* do this reserve() operation.
+  // See the further comments in append_data(), below.
+  //  _data.reserve(_data.size() + size);
+
+  while (size > 0) {
+    _data.push_back('\0');
+    size--;
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: Datagram::append_data
+//       Access: Public
+//  Description: Appends some more raw data to the end of the
+//               datagram.
+////////////////////////////////////////////////////////////////////
+void Datagram::
+append_data(const void *data, size_t size) {
+  nassertv((int)size >= 0);
+
+  if (_data == (uchar *)NULL) {
+    // Create a new array.
+    _data = PTA_uchar(0);
+
+  } else if (_data.get_ref_count() != 1) {
+    // Copy on write.
+    PTA_uchar new_data(0);
+    new_data.v() = _data.v();
+    _data = new_data;
+  }
+
+  // Now append the data.
+
+  // It is very important that we *don't* do this reserve() operation.
+  // This actually slows it down on Windows, which takes the reserve()
+  // request as a fixed size the array should be set to (!) instead of
+  // as a minimum size to guarantee.  This forces the array to
+  // reallocate itself with *every* call to append_data!
+  //  _data.reserve(_data.size() + size);
+
+  const uchar *source = (const uchar *)data;
+  for (size_t i = 0; i < size; i++) {
+    _data.v().push_back(source[i]);
+  }
+}

+ 6 - 7
panda/src/express/datagram.h

@@ -19,14 +19,13 @@
 #ifndef DATAGRAM_H
 #define DATAGRAM_H
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 #include "numeric_types.h"
 #include "typedObject.h"
 #include "littleEndian.h"
 #include "bigEndian.h"
-
-#include <string>
+#include "pta_uchar.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : Datagram
@@ -86,11 +85,11 @@ PUBLISHED:
   INLINE void add_z_string(string str);
   INLINE void add_fixed_string(const string &str, size_t size);
 
-  INLINE void pad_bytes(size_t size);
-  INLINE void append_data(const void *data, size_t size);
+  void pad_bytes(size_t size);
+  void append_data(const void *data, size_t size);
   INLINE void append_data(const string &data);
 
-  INLINE const string &get_message() const;
+  INLINE string get_message() const;
   INLINE const void *get_data() const;
   INLINE size_t get_length() const;
 
@@ -99,7 +98,7 @@ PUBLISHED:
   INLINE bool operator < (const Datagram &other) const;
 
 private:
-  string _message;
+  PTA_uchar _data;
 
 
 public:

+ 24 - 19
panda/src/express/datagramIterator.I

@@ -97,7 +97,8 @@ get_int8() {
   nassertr(_datagram != (const Datagram *)NULL &&
            _current_index < _datagram->get_length(), 0);
 
-  PN_int8 tempvar = (PN_int8)_datagram->get_message()[_current_index];
+  const char *ptr = (const char *)_datagram->get_data();
+  PN_int8 tempvar = (PN_int8)ptr[_current_index];
   _current_index++;
 
   return tempvar;
@@ -113,7 +114,8 @@ get_uint8() {
   nassertr(_datagram != (const Datagram *)NULL &&
            _current_index < _datagram->get_length(), 0);
 
-  PN_uint8 tempvar = (PN_uint8)_datagram->get_message()[_current_index];
+  const char *ptr = (const char *)_datagram->get_data();
+  PN_uint8 tempvar = (PN_uint8)ptr[_current_index];
   _current_index++;
 
   return tempvar;
@@ -130,7 +132,7 @@ get_int16() {
            _current_index < _datagram->get_length(), 0);
 
   PN_int16 tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -148,7 +150,7 @@ get_int32() {
            _current_index < _datagram->get_length(), 0);
 
   PN_int32 tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -166,7 +168,7 @@ get_int64() {
            _current_index < _datagram->get_length(), 0);
 
   PN_int64 tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -184,7 +186,7 @@ get_uint16() {
            _current_index < _datagram->get_length(), 0);
 
   PN_uint16 tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -202,7 +204,7 @@ get_uint32() {
            _current_index < _datagram->get_length(), 0);
 
   PN_uint32 tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -220,7 +222,7 @@ get_uint64() {
            _current_index < _datagram->get_length(), 0);
 
   PN_uint64 tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -245,7 +247,7 @@ get_float32() {
            _current_index < _datagram->get_length(), 0.0);
 
   float tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -263,7 +265,7 @@ get_float64() {
            _current_index < _datagram->get_length(), 0.0);
 
   PN_float64 tempvar;
-  LittleEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  LittleEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -281,7 +283,7 @@ get_be_int16() {
            _current_index < _datagram->get_length(), 0);
 
   PN_int16 tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -299,7 +301,7 @@ get_be_int32() {
            _current_index < _datagram->get_length(), 0);
 
   PN_int32 tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -317,7 +319,7 @@ get_be_int64() {
            _current_index < _datagram->get_length(), 0);
 
   PN_int64 tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -335,7 +337,7 @@ get_be_uint16() {
            _current_index < _datagram->get_length(), 0);
 
   PN_uint16 tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -353,7 +355,7 @@ get_be_uint32() {
            _current_index < _datagram->get_length(), 0);
 
   PN_uint32 tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -371,7 +373,7 @@ get_be_uint64() {
            _current_index < _datagram->get_length(), 0);
 
   PN_uint64 tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -396,7 +398,7 @@ get_be_float32() {
            _current_index < _datagram->get_length(), 0.0);
 
   float tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -414,7 +416,7 @@ get_be_float64() {
            _current_index < _datagram->get_length(), 0.0);
 
   PN_float64 tempvar;
-  BigEndian s(_datagram->get_message(), _current_index, sizeof(tempvar));
+  BigEndian s(_datagram->get_data(), _current_index, sizeof(tempvar));
   s.store_value(&tempvar, sizeof(tempvar));
   _current_index += sizeof(tempvar);
 
@@ -444,7 +446,10 @@ INLINE string DatagramIterator::
 get_remaining_bytes() const {
   nassertr(_datagram != (const Datagram *)NULL &&
            _current_index <= _datagram->get_length(), "");
-  return _datagram->get_message().substr(_current_index);
+
+  const char *ptr = (const char *)_datagram->get_data();
+  int remaining_size = _datagram->get_length() - _current_index;
+  return string(ptr + _current_index, remaining_size);
 }
 
 ////////////////////////////////////////////////////////////////////

+ 18 - 15
panda/src/express/datagramIterator.cxx

@@ -18,7 +18,7 @@
 
 
 #include "datagramIterator.h"
-#include <notify.h>
+#include "notify.h"
 
 ////////////////////////////////////////////////////////////////////
 //     Function: DatagramIterator::get_string
@@ -33,13 +33,12 @@ get_string() {
   nassertr(_datagram != (const Datagram *)NULL &&
            _current_index + s_len <= _datagram->get_length(), "");
 
-  string s =
-    _datagram->get_message().substr(_current_index, s_len);
+  const char *ptr = (const char *)_datagram->get_data();
+  int last_index = _current_index;
 
-  nassertr(s.length() == s_len, "");
   _current_index += s_len;
 
-  return s;
+  return string(ptr + last_index, s_len);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -53,17 +52,17 @@ get_z_string() {
   nassertr(_datagram != (const Datagram *)NULL, "");
 
   // First, determine the length of the string.
-  const string &message = _datagram->get_message();
+  const char *ptr = (const char *)_datagram->get_data();
+  size_t length = _datagram->get_length();
   size_t p = _current_index;
-  while (p < message.length() && message[p] != '\0') {
+  while (p < length && ptr[p] != '\0') {
   }
-  nassertr(p < message.length(), "");  // no NULL character?
+  nassertr(p < length, "");  // no NULL character?
 
-  string s =
-    _datagram->get_message().substr(_current_index, p - _current_index);
+  int last_index = _current_index;
   _current_index = p + 1;
 
-  return s;
+  return string(ptr + last_index, p - last_index);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -78,8 +77,9 @@ get_fixed_string(size_t size) {
   nassertr(_datagram != (const Datagram *)NULL &&
            _current_index + size <= _datagram->get_length(), "");
 
-  string s =
-    _datagram->get_message().substr(_current_index, size);
+  const char *ptr = (const char *)_datagram->get_data();
+  string s(ptr + _current_index, size);
+
   _current_index += size;
 
   size_t zero_byte = s.find('\0');
@@ -97,9 +97,12 @@ extract_bytes(size_t size) {
   nassertr((int)size >= 0, "");
   nassertr(_datagram != (const Datagram *)NULL &&
            _current_index + size <= _datagram->get_length(), "");
-  int start = _current_index;
+
+  const char *ptr = (const char *)_datagram->get_data();
+  int last_index = _current_index;
 
   _current_index += size;
-  return _datagram->get_message().substr(start, size);
+
+  return string(ptr + last_index, size);
 }
 

+ 2 - 0
panda/src/express/express_composite2.cxx

@@ -3,10 +3,12 @@
 #include "namable.cxx"
 #include "nativeNumericData.cxx"
 #include "profileTimer.cxx"
+#include "pta_uchar.cxx"
 #include "referenceCount.cxx"
 #include "reversedNumericData.cxx"
 #include "trueClock.cxx"
 #include "typeHandle.cxx"
 #include "typedObject.cxx"
 #include "typedReferenceCount.cxx"
+#include "vector_uchar.cxx"
 

+ 14 - 14
panda/src/express/nativeNumericData.I

@@ -32,19 +32,19 @@ NativeNumericData(const void *data, size_t) :
 ////////////////////////////////////////////////////////////////////
 //     Function: NativeNumericData::Constructor
 //       Access: Public
-//  Description: This constructor accepts a string containing a packed
-//               numeric value, the offset within the string at which
-//               the numeric value starts, and the size of the numeric
-//               value.
+//  Description: This constructor accepts a pointer to a data array
+//               containing a packed numeric value, the offset within
+//               the array at which the numeric value starts, and the
+//               size of the numeric value.
 //
-//               It is essential that the string not be destructed or
+//               It is essential that the array not be destructed or
 //               modified as long as the NumericData object remains;
 //               it may just store a pointer into that string's
 //               internal buffer.
 ////////////////////////////////////////////////////////////////////
 INLINE NativeNumericData::
-NativeNumericData(const string &data, size_t start, size_t) {
-  _source = (void *)(data.data() + start);
+NativeNumericData(const void *data, size_t start, size_t) {
+  _source = (void *)((const char *)data + start);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -55,17 +55,17 @@ NativeNumericData(const string &data, size_t start, size_t) {
 //               and sizeof are given.
 ////////////////////////////////////////////////////////////////////
 INLINE void NativeNumericData::
-store_value(void *dest, size_t length) {
+store_value(void *dest, size_t length) const {
   memcpy(dest, _source, length);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: NativeNumericData::append_to
+//     Function: NativeNumericData::get_data
 //       Access: Public
-//  Description: Packs the numeric data, with byte reversal if
-//               appropriate, onto the end of the given string.
+//  Description: Returns the pointer to the first byte of the data,
+//               either reversed or nonreversed, as appropriate.
 ////////////////////////////////////////////////////////////////////
-INLINE void NativeNumericData::
-append_to(string &dest, size_t length) {
-  dest.append((const char *)_source, length);
+INLINE const void *NativeNumericData::
+get_data() const {
+  return _source;
 }

+ 4 - 4
panda/src/express/nativeNumericData.h

@@ -19,7 +19,7 @@
 #ifndef NATIVENUMERICDATA_H
 #define NATIVENUMERICDATA_H
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 #include <string.h>  // for memcpy()
 
@@ -48,10 +48,10 @@
 class EXPCL_PANDAEXPRESS NativeNumericData {
 public:
   INLINE NativeNumericData(const void *data, size_t length);
-  INLINE NativeNumericData(const string &data, size_t start, size_t length);
+  INLINE NativeNumericData(const void *data, size_t start, size_t length);
 
-  INLINE void store_value(void *dest, size_t length);
-  INLINE void append_to(string &dest, size_t length);
+  INLINE void store_value(void *dest, size_t length) const;
+  INLINE const void *get_data() const;
 
 private:
   const void *_source;

+ 0 - 0
panda/src/putil/pointerToArray.I → panda/src/express/pointerToArray.I


+ 0 - 0
panda/src/putil/pointerToArray.h → panda/src/express/pointerToArray.h


+ 0 - 0
panda/src/putil/pta_uchar.cxx → panda/src/express/pta_uchar.cxx


+ 6 - 6
panda/src/putil/pta_uchar.h → panda/src/express/pta_uchar.h

@@ -27,16 +27,16 @@
 ////////////////////////////////////////////////////////////////////
 //       Class : PTA_uchar
 // Description : A pta of uchars.  This class is defined once here,
-//               and exported to PANDA.DLL; other packages that want
-//               to use a pta of this type (whether they need to
+//               and exported to PANDAEXPRESS.DLL; other packages that
+//               want to use a pta of this type (whether they need to
 //               export it or not) should include this header file,
 //               rather than defining the pta again.
 ////////////////////////////////////////////////////////////////////
 
-EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, RefCountObj<vector_uchar>);
-EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, PointerToBase<RefCountObj<vector_uchar> >);
-EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, PointerToArray<unsigned char>)
-EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, ConstPointerToArray<unsigned char>)
+EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, RefCountObj<vector_uchar>);
+EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToBase<RefCountObj<vector_uchar> >);
+EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArray<unsigned char>)
+EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, ConstPointerToArray<unsigned char>)
 
 typedef PointerToArray<unsigned char> PTA_uchar;
 typedef ConstPointerToArray<unsigned char> CPTA_uchar;

+ 14 - 14
panda/src/express/reversedNumericData.I

@@ -31,19 +31,19 @@ ReversedNumericData(const void *data, size_t length) {
 ////////////////////////////////////////////////////////////////////
 //     Function: ReversedNumericData::Constructor
 //       Access: Public
-//  Description: This constructor accepts a string containing a packed
-//               numeric value, the offset within the string at which
-//               the numeric value starts, and the size of the numeric
-//               value.
+//  Description: This constructor accepts a pointer to a data array
+//               containing a packed numeric value, the offset within
+//               the array at which the numeric value starts, and the
+//               size of the numeric value.
 //
-//               It is essential that the string not be destructed or
+//               It is essential that the array not be destructed or
 //               modified as long as the NumericData object remains;
 //               it may just store a pointer into that string's
 //               internal buffer.
 ////////////////////////////////////////////////////////////////////
 INLINE ReversedNumericData::
-ReversedNumericData(const string &data, size_t start, size_t length) {
-  reverse_assign(data.data() + start, length);
+ReversedNumericData(const void *data, size_t start, size_t length) {
+  reverse_assign((const char *)data + start, length);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -54,17 +54,17 @@ ReversedNumericData(const string &data, size_t start, size_t length) {
 //               and sizeof are given.
 ////////////////////////////////////////////////////////////////////
 INLINE void ReversedNumericData::
-store_value(void *dest, size_t length) {
+store_value(void *dest, size_t length) const {
   memcpy(dest, _data, length);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: ReversedNumericData::append_to
+//     Function: ReversedNumericData::get_data
 //       Access: Public
-//  Description: Packs the numeric data, with byte reversal if
-//               appropriate, onto the end of the given string.
+//  Description: Returns the pointer to the first byte of the data,
+//               either reversed or nonreversed, as appropriate.
 ////////////////////////////////////////////////////////////////////
-INLINE void ReversedNumericData::
-append_to(string &dest, size_t length) {
-  dest.append((const char *)_data, length);
+INLINE const void *ReversedNumericData::
+get_data() const {
+  return _data;
 }

+ 3 - 3
panda/src/express/reversedNumericData.h

@@ -52,10 +52,10 @@ static const int max_numeric_size = 8;
 class EXPCL_PANDAEXPRESS ReversedNumericData {
 public:
   INLINE ReversedNumericData(const void *data, size_t length);
-  INLINE ReversedNumericData(const string &data, size_t start, size_t length);
+  INLINE ReversedNumericData(const void *data, size_t start, size_t length);
 
-  INLINE void store_value(void *dest, size_t length);
-  INLINE void append_to(string &dest, size_t length);
+  INLINE void store_value(void *dest, size_t length) const;
+  INLINE const void *get_data() const;
 
 private:
   void reverse_assign(const char *source, size_t length);

+ 0 - 0
panda/src/putil/vector_uchar.cxx → panda/src/express/vector_uchar.cxx


+ 5 - 5
panda/src/putil/vector_uchar.h → panda/src/express/vector_uchar.h

@@ -26,14 +26,14 @@
 ////////////////////////////////////////////////////////////////////
 //       Class : vector_uchar
 // Description : A vector of uchars.  This class is defined once here,
-//               and exported to PANDA.DLL; other packages that want
-//               to use a vector of this type (whether they need to
-//               export it or not) should include this header file,
+//               and exported to PANDAEXPRESS.DLL; other packages that
+//               want to use a vector of this type (whether they need
+//               to export it or not) should include this header file,
 //               rather than defining the vector again.
 ////////////////////////////////////////////////////////////////////
 
-#define EXPCL EXPCL_PANDA
-#define EXPTP EXPTP_PANDA
+#define EXPCL EXPCL_PANDAEXPRESS
+#define EXPTP EXPTP_PANDAEXPRESS
 #define TYPE unsigned char
 #define NAME vector_uchar
 

+ 7 - 3
panda/src/net/Sources.pp

@@ -15,8 +15,10 @@
   #define SOURCES \
      config_net.h connection.h connectionListener.h  \
      connectionManager.N connectionManager.h connectionReader.h  \
-     connectionWriter.h datagramQueue.h datagramTCPHeader.h  \
-     datagramUDPHeader.h netAddress.h netDatagram.I netDatagram.h  \
+     connectionWriter.h datagramQueue.h \
+     datagramTCPHeader.I datagramTCPHeader.h  \
+     datagramUDPHeader.I datagramUDPHeader.h  \
+     netAddress.h netDatagram.I netDatagram.h  \
      pprerror.h queuedConnectionListener.I  \
      queuedConnectionListener.h queuedConnectionManager.h  \
      queuedConnectionReader.h recentConnectionReader.h 
@@ -33,7 +35,9 @@
   #define INSTALL_HEADERS \
     config_net.h connection.h connectionListener.h connectionManager.h \
     connectionReader.h connectionWriter.h datagramQueue.h \
-    datagramTCPHeader.h datagramUDPHeader.h netAddress.h netDatagram.I \
+    datagramTCPHeader.I datagramTCPHeader.h \
+    datagramUDPHeader.I datagramUDPHeader.h \
+    netAddress.h netDatagram.I \
     netDatagram.h pprerror.h queuedConnectionListener.I \
     queuedConnectionListener.h queuedConnectionManager.h \
     queuedConnectionReader.h queuedReturn.I queuedReturn.h \

+ 42 - 0
panda/src/net/datagramTCPHeader.I

@@ -0,0 +1,42 @@
+// Filename: datagramTCPHeader.I
+// Created by:  drose (01Aug01)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: DatagramTCPHeader::get_datagram_size
+//       Access: Public
+//  Description: Returns the number of bytes in the associated
+//               datagram.
+////////////////////////////////////////////////////////////////////
+INLINE int DatagramTCPHeader::
+get_datagram_size() const {
+  DatagramIterator di(_header);
+  return di.get_uint16();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DatagramTCPHeader::get_header
+//       Access: Public
+//  Description: Returns a pointer to a block of data of length
+//               datagram_tcp_header_size, which can be written to the
+//               network as the header information.
+////////////////////////////////////////////////////////////////////
+INLINE string DatagramTCPHeader::
+get_header() const {
+  return _header.get_message();
+}

+ 0 - 24
panda/src/net/datagramTCPHeader.cxx

@@ -51,30 +51,6 @@ DatagramTCPHeader::
 DatagramTCPHeader(const void *data) : _header(data, datagram_tcp_header_size) {
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: DatagramTCPHeader::get_datagram_size
-//       Access: Public
-//  Description: Returns the number of bytes in the associated
-//               datagram.
-////////////////////////////////////////////////////////////////////
-int DatagramTCPHeader::
-get_datagram_size() const {
-  DatagramIterator di(_header);
-  return di.get_uint16();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DatagramTCPHeader::get_header
-//       Access: Public
-//  Description: Returns a pointer to a block of data of length
-//               datagram_tcp_header_size, which can be written to the
-//               network as the header information.
-////////////////////////////////////////////////////////////////////
-const string &DatagramTCPHeader::
-get_header() const {
-  return _header.get_message();
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: DatagramTCPHeader::verify_datagram
 //       Access: Public

+ 7 - 4
panda/src/net/datagramTCPHeader.h

@@ -19,10 +19,12 @@
 #ifndef DATAGRAMTCPHEADER_H
 #define DATAGRAMTCPHEADER_H
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 #include "netDatagram.h"
 
+#include "datagramIterator.h"
+
 #include <prtypes.h>
 
 static const int datagram_tcp_header_size = sizeof(PRUint16);
@@ -42,9 +44,8 @@ public:
   DatagramTCPHeader(const NetDatagram &datagram);
   DatagramTCPHeader(const void *data);
 
-  int get_datagram_size() const;
-
-  const string &get_header() const;
+  INLINE int get_datagram_size() const;
+  INLINE string get_header() const;
 
   bool verify_datagram(const NetDatagram &datagram) const;
 
@@ -55,6 +56,8 @@ private:
   NetDatagram _header;
 };
 
+#include "datagramTCPHeader.I"
+
 #endif
 
 

+ 42 - 0
panda/src/net/datagramUDPHeader.I

@@ -0,0 +1,42 @@
+// Filename: datagramUDPHeader.I
+// Created by:  drose (01Aug01)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////
+//     Function: DatagramUDPHeader::get_datagram_checksum
+//       Access: Public
+//  Description: Returns the checksum appropriate for the indicated
+//               datagram.
+////////////////////////////////////////////////////////////////////
+INLINE int DatagramUDPHeader::
+get_datagram_checksum() const {
+  DatagramIterator di(_header);
+  return di.get_uint16();
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: DatagramUDPHeader::get_header
+//       Access: Public
+//  Description: Returns a pointer to a block of data of length
+//               datagram_udp_header_size, which can be written to the
+//               network as the header information.
+////////////////////////////////////////////////////////////////////
+INLINE string DatagramUDPHeader::
+get_header() const {
+  return _header.get_message();
+}

+ 0 - 24
panda/src/net/datagramUDPHeader.cxx

@@ -53,30 +53,6 @@ DatagramUDPHeader::
 DatagramUDPHeader(const void *data) : _header(data, datagram_udp_header_size) {
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: DatagramUDPHeader::get_datagram_checksum
-//       Access: Public
-//  Description: Returns the checksum appropriate for the indicated
-//               datagram.
-////////////////////////////////////////////////////////////////////
-int DatagramUDPHeader::
-get_datagram_checksum() const {
-  DatagramIterator di(_header);
-  return di.get_uint16();
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: DatagramUDPHeader::get_header
-//       Access: Public
-//  Description: Returns a pointer to a block of data of length
-//               datagram_udp_header_size, which can be written to the
-//               network as the header information.
-////////////////////////////////////////////////////////////////////
-const string &DatagramUDPHeader::
-get_header() const {
-  return _header.get_message();
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: DatagramUDPHeader::verify_datagram
 //       Access: Public

+ 7 - 4
panda/src/net/datagramUDPHeader.h

@@ -19,10 +19,12 @@
 #ifndef DATAGRAMUDPHEADER_H
 #define DATAGRAMUDPHEADER_H
 
-#include <pandabase.h>
+#include "pandabase.h"
 
 #include "netDatagram.h"
 
+#include "datagramIterator.h"
+
 #include <prtypes.h>
 
 static const int datagram_udp_header_size = sizeof(PRUint16);
@@ -42,9 +44,8 @@ public:
   DatagramUDPHeader(const NetDatagram &datagram);
   DatagramUDPHeader(const void *data);
 
-  int get_datagram_checksum() const;
-
-  const string &get_header() const;
+  INLINE int get_datagram_checksum() const;
+  INLINE string get_header() const;
 
   bool verify_datagram(const NetDatagram &datagram) const;
 
@@ -55,6 +56,8 @@ private:
   NetDatagram _header;
 };
 
+#include "datagramUDPHeader.I"
+
 #endif
 
 

+ 8 - 8
panda/src/putil/Sources.pp

@@ -25,14 +25,14 @@
      lineStream.h lineStreamBuf.I lineStreamBuf.h \
      modifierButtons.I modifierButtons.h mouseButton.h \
      mouseData.h nameUniquifier.I nameUniquifier.h \
-     pointerToArray.I pointerToArray.h pta_double.h \
-     pta_float.h pta_int.h pta_uchar.h pta_ushort.h \
+     pta_double.h \
+     pta_float.h pta_int.h \
      string_utils.I string_utils.N string_utils.h \
      timedCycle.I timedCycle.h typedWritable.I \
      typedWritable.h typedWritableReferenceCount.I \
      typedWritableReferenceCount.h updateSeq.I updateSeq.h \
      vector_double.h vector_float.h vector_typedWritable.h \
-     vector_uchar.h vector_ushort.h vector_writable.h \
+     vector_ushort.h vector_writable.h \
      writable.I writable.h writableConfigurable.h \
      writableParam.I writableParam.h 
     
@@ -46,11 +46,11 @@
      keyboardButton.cxx lineStream.cxx lineStreamBuf.cxx \
      modifierButtons.cxx mouseButton.cxx mouseData.cxx \
      nameUniquifier.cxx pta_double.cxx pta_float.cxx \
-     pta_int.cxx pta_uchar.cxx pta_ushort.cxx \
+     pta_int.cxx pta_ushort.cxx \
      string_utils.cxx timedCycle.cxx typedWritable.cxx \
      typedWritableReferenceCount.cxx updateSeq.cxx \
      vector_double.cxx vector_float.cxx \
-     vector_typedWritable.cxx vector_uchar.cxx \
+     vector_typedWritable.cxx \
      vector_ushort.cxx vector_writable.cxx writable.cxx \
      writableConfigurable.cxx writableParam.cxx 
 
@@ -70,13 +70,13 @@
     ioPtaDatagramShort.h iterator_types.h keyboardButton.h lineStream.I \
     lineStream.h lineStreamBuf.I lineStreamBuf.h modifierButtons.I \
     modifierButtons.h mouseButton.h mouseData.h nameUniquifier.I \
-    nameUniquifier.h pointerToArray.I pointerToArray.h pta_double.h \
-    pta_float.h pta_int.h pta_uchar.h pta_ushort.h string_utils.I \
+    nameUniquifier.h pta_double.h \
+    pta_float.h pta_int.h pta_ushort.h string_utils.I \
     string_utils.h timedCycle.I timedCycle.h typedWritable.I \
     typedWritable.h typedWritableReferenceCount.I \
     typedWritableReferenceCount.h updateSeq.I updateSeq.h \
     vector_double.h vector_float.h vector_typedWritable.h \
-    vector_uchar.h vector_ushort.h vector_writable.h writable.I \
+    vector_ushort.h vector_writable.h writable.I \
     writable.h writableConfigurable.h writableParam.I \
     writableParam.h
 

+ 0 - 2
panda/src/putil/putil_composite2.cxx

@@ -3,7 +3,6 @@
 #include "pta_double.cxx"
 #include "pta_float.cxx"
 #include "pta_int.cxx"
-#include "pta_uchar.cxx"
 #include "pta_ushort.cxx"
 #include "string_utils.cxx"
 #include "timedCycle.cxx"
@@ -13,7 +12,6 @@
 #include "vector_double.cxx"
 #include "vector_float.cxx"
 #include "vector_typedWritable.cxx"
-#include "vector_uchar.cxx"
 #include "vector_ushort.cxx"
 #include "vector_writable.cxx"
 #include "writable.cxx"