Browse Source

add blob32

David Rose 22 years ago
parent
commit
1c7b384f65

+ 6 - 2
direct/src/dcparser/dcAtomicField.cxx

@@ -101,7 +101,7 @@ set_default_value(double num) {
 ////////////////////////////////////////////////////////////////////
 bool DCAtomicField::ElementType::
 set_default_value(const string &str) {
-  if (_type != ST_string && _type != ST_blob) {
+  if (_type != ST_string && _type != ST_blob && _type != ST_blob32) {
     // Only fields of type string or blob accept quoted strings.
     return false;
   }
@@ -175,7 +175,7 @@ add_default_value(const string &str) {
 ////////////////////////////////////////////////////////////////////
 bool DCAtomicField::ElementType::
 add_default_value_literal(const string &str) {
-  if (_type != ST_blob) {
+  if (_type != ST_blob && _type != ST_blob32) {
     // Only blobs can have literal hex strings nested within arrays.
     return false;
   }
@@ -201,6 +201,7 @@ end_array() {
   case ST_uint16array:
   case ST_uint32array:
   case ST_blob:
+  case ST_blob32:
     // These types accept arrays.
     return true;
 
@@ -248,6 +249,7 @@ format_default_value(double num, string &formatted) const {
   case ST_int8array:
   case ST_uint8array:
   case ST_blob:
+  case ST_blob32:
     formatted = string(1, (char)(int_value & 0xff));
     break;
 
@@ -337,6 +339,7 @@ format_default_value(const string &str, string &formatted) const {
   switch (_type) {
   case ST_string:
   case ST_blob:
+  case ST_blob32:
     {
       int length = str.length();
       formatted =
@@ -446,6 +449,7 @@ get_element_default(int n) const {
   case ST_uint32array:
   case ST_uint32uint8array:
   case ST_blob:
+  case ST_blob32:
   case ST_string:
     // These array types also want an implicit length.
     {

+ 5 - 0
direct/src/dcparser/dcLexer.lxx

@@ -388,6 +388,11 @@ REALNUM          ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?)
   return KW_BLOB;
 }
 
+"blob32" {
+  accept();
+  return KW_BLOB32;
+}
+
 "int8array" {
   accept();
   return KW_INT8ARRAY;

+ 5 - 0
direct/src/dcparser/dcParser.yxx

@@ -59,6 +59,7 @@ dc_cleanup_parser() {
 %token KW_FLOAT64
 %token KW_STRING
 %token KW_BLOB
+%token KW_BLOB32
 %token KW_INT8ARRAY
 %token KW_INT16ARRAY
 %token KW_INT32ARRAY
@@ -350,6 +351,10 @@ type_token:
         | KW_BLOB
 {
   $$ = ST_blob;
+}
+        | KW_BLOB32
+{
+  $$ = ST_blob32;
 }
         | KW_INT8ARRAY
 {

+ 3 - 0
direct/src/dcparser/dcSubatomicType.cxx

@@ -54,6 +54,9 @@ operator << (ostream &out, DCSubatomicType type) {
   case ST_blob:
     return out << "blob";
 
+  case ST_blob32:
+    return out << "blob32";
+
   case ST_int8array:
     return out << "int8array";
 

+ 1 - 0
direct/src/dcparser/dcSubatomicType.h

@@ -44,6 +44,7 @@ enum DCSubatomicType {
 
   ST_string,      // a human-printable string
   ST_blob,        // any variable length message, stored as a string
+  ST_blob32,      // a blob with a 32-bit length, up to 4.2 GB long
   ST_int16array,
   ST_int32array,
   ST_uint16array,

+ 2 - 0
direct/src/extensions/Datagram-extensions.py

@@ -25,6 +25,8 @@
                 self.addString(arg)
             elif subatomicType == DCSubatomicType.STBlob:
                 self.addString(arg)
+            elif subatomicType == DCSubatomicType.STBlob32:
+                self.addString32(arg)
             elif subatomicType == DCSubatomicType.STInt8array:
                 self.addUint16(len(arg))
                 for i in arg:

+ 2 - 0
direct/src/extensions/DatagramIterator-extensions.py

@@ -26,6 +26,8 @@
                 retVal = self.getString()
             elif subatomicType == DCSubatomicType.STBlob:
                 retVal = self.getString()
+            elif subatomicType == DCSubatomicType.STBlob32:
+                retVal = self.getString32()
             elif subatomicType == DCSubatomicType.STInt8array:
                 len = self.getUint16()
                 retVal = []