Moved definition to separate .h file
authorFilippo Gioachin <gioachin@illinois.edu>
Tue, 25 Nov 2008 02:41:53 +0000 (02:41 +0000)
committerFilippo Gioachin <gioachin@illinois.edu>
Tue, 25 Nov 2008 02:41:53 +0000 (02:41 +0000)
src/conv-ccs/ccs-builtins.C
src/conv-ccs/ccs-builtins.h [new file with mode: 0644]

index 07598e90e42644e6e5ccfd5afe9232fd829ce7d3..a842860da608b22e1b1e3aab1a1ed328e14af9b7 100644 (file)
@@ -261,65 +261,29 @@ void CpdMachineArchitecture(char *msg) {
   CcsSendReply(6, (void*)reply);
 }
 
-
-/**
-  A PUP_fmt inserts a 1-byte data format code 
-  before each pup'd data item.  This makes it possible
-  to unpack items without using PUP.
-*/
-class PUP_fmt : public PUP::wrap_er {
-       typedef PUP::er parent;
-       
-       typedef unsigned char byte;
-       /**
-         The introductory byte for each field is bit-coded as:
-              | unused(2) | lengthLen(2) | typeCode(4) |
-       */
-       typedef enum {
-               lengthLen_single=0, // field is a single item
-               lengthLen_byte=1, // following 8 bits gives length of array
-               lengthLen_int=2, // following 32 bits gives length of array
-               lengthLen_long=3 // following 64 bits gives length of array (unimpl)
-       } lengthLen_t;
-       typedef enum { 
-               typeCode_byte=0, // unknown data type: nItems bytes
-               typeCode_int=2, // 32-bit integer array: nItems ints
-               typeCode_long=3, // 64-bit integer array: nItems ints
-               typeCode_float=5, // 32-bit floating-point array: nItems floats
-               typeCode_double=6, // 64-bit floating-point array: nItems floats
-               typeCode_comment=10, // comment/label: nItems byte characters
-               typeCode_sync=11, // synchronization code
-               typeCode_pointer=12 // 32 or 64 bit pointer, depending on the machine architecture
-       } typeCode_t;
-       void fieldHeader(typeCode_t typeCode,int nItems) {
-               // Compute and write intro byte:
-               lengthLen_t ll;
-               if (nItems==1) ll=lengthLen_single;
-               else if (nItems<256) ll=lengthLen_byte;
-               else ll=lengthLen_int;
-               // CmiPrintf("Intro byte: l=%d t=%d\n",(int)ll,(int)typeCode);
-               byte intro=(((int)ll)<<4)+(int)typeCode;
-               p(intro);
-               // Compute and write length:
-               switch(ll) {
-               case lengthLen_single: break; // Single item
-               case lengthLen_byte: {
-                       byte l=nItems;
-                       p(l);
-                       } break;
-               case lengthLen_int: {
-                       p(nItems); 
-                       } break; 
-               };
-       }
-public:
-       PUP_fmt(PUP::er &parent_) 
-               :PUP::wrap_er(parent_,PUP::er::IS_COMMENTS) {}
-       
-       virtual void comment(const char *message);
-       virtual void synchronize(unsigned int m);
-       virtual void bytes(void *p,int n,size_t itemSize,PUP::dataType t);
-};
+#include "ccs-builtins.h"
+
+void PUP_fmt::fieldHeader(typeCode_t typeCode,int nItems) {
+    // Compute and write intro byte:
+    lengthLen_t ll;
+    if (nItems==1) ll=lengthLen_single;
+    else if (nItems<256) ll=lengthLen_byte;
+    else ll=lengthLen_int;
+    // CmiPrintf("Intro byte: l=%d t=%d\n",(int)ll,(int)typeCode);
+    byte intro=(((int)ll)<<4)+(int)typeCode;
+    p(intro);
+    // Compute and write length:
+    switch(ll) {
+    case lengthLen_single: break; // Single item
+    case lengthLen_byte: {
+        byte l=nItems;
+        p(l);
+        } break;
+    case lengthLen_int: {
+        p(nItems); 
+        } break; 
+    };
+}
 
 void PUP_fmt::comment(const char *message) {
        int nItems=strlen(message);
diff --git a/src/conv-ccs/ccs-builtins.h b/src/conv-ccs/ccs-builtins.h
new file mode 100644 (file)
index 0000000..9d112fb
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+  A PUP_fmt inserts a 1-byte data format code 
+  before each pup'd data item.  This makes it possible
+  to unpack items without using PUP.
+*/
+class PUP_fmt : public PUP::wrap_er {
+    typedef PUP::er parent;
+    
+    typedef unsigned char byte;
+    /**
+      The introductory byte for each field is bit-coded as:
+           | unused(2) | lengthLen(2) | typeCode(4) |
+    */
+    typedef enum {
+        lengthLen_single=0, // field is a single item
+        lengthLen_byte=1, // following 8 bits gives length of array
+        lengthLen_int=2, // following 32 bits gives length of array
+        lengthLen_long=3 // following 64 bits gives length of array (unimpl)
+    } lengthLen_t;
+    typedef enum { 
+        typeCode_byte=0, // unknown data type: nItems bytes
+        typeCode_int=2, // 32-bit integer array: nItems ints
+        typeCode_long=3, // 64-bit integer array: nItems ints
+        typeCode_float=5, // 32-bit floating-point array: nItems floats
+        typeCode_double=6, // 64-bit floating-point array: nItems floats
+        typeCode_comment=10, // comment/label: nItems byte characters
+        typeCode_sync=11, // synchronization code
+        typeCode_pointer=12 // 32 or 64 bit pointer, depending on the machine architecture
+    } typeCode_t;
+    void fieldHeader(typeCode_t typeCode,int nItems);
+public:
+    PUP_fmt(PUP::er &parent_) 
+        :PUP::wrap_er(parent_,PUP::er::IS_COMMENTS) {}
+    
+    virtual void comment(const char *message);
+    virtual void synchronize(unsigned int m);
+    virtual void bytes(void *p,int n,size_t itemSize,PUP::dataType t);
+};
+