Ignore:
Timestamp:
03/20/15 15:57:29 (10 years ago)
Author:
Eric.Larour
Message:

CHG: going deeper in the low level objects to propagate the new MARSHALL capability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/shared/io/Marshalling/Marshalling.h

    r19198 r19215  
    88enum marshall_directions{
    99        MARSHALLING_FORWARD,
    10         MARSHALLING_BACKWARDS
     10        MARSHALLING_BACKWARD,
     11        MARSHALLING_SIZE
    1112};
    1213
    13 #define MARSHALLING_ENUM(EN) \
    14         int enum_type=EN; \
     14#define MARSHALLING_ENUM(EN)\
     15        int enum_type=EN;\
    1516        if(marshall_direction==MARSHALLING_FORWARD){\
    16                 if(pmarshalled_data){\
    17                         memcpy(*pmarshalled_data,&enum_type,sizeof(int));\
    18                         *pmarshalled_data+=sizeof(int);\
    19                 }\
     17                memcpy(*pmarshalled_data,&enum_type,sizeof(int));\
     18                *pmarshalled_data+=sizeof(int);\
    2019                *pmarshalled_data_size+=sizeof(int);\
    21         }
     20        }\
     21        else if(marshall_direction==MARSHALLING_SIZE){\
     22                *pmarshalled_data_size+=sizeof(int);\
     23        }\
     24        else if(marshall_direction==MARSHALLING_BACKWARD){\
     25        }\
     26        else _error_("Wrong direction during the Marshall process");\
    2227
    23 #define MARSHALLING(FIELD) \
    24 \
     28
     29#define MARSHALLING(FIELD)\
     30        \
    2531        if(marshall_direction==MARSHALLING_FORWARD){\
    26                 if(pmarshalled_data){\
    27                         memcpy(*pmarshalled_data,&FIELD,sizeof(FIELD));\
    28                         *pmarshalled_data+=sizeof(FIELD);\
    29                 }\
     32                memcpy(*pmarshalled_data,&FIELD,sizeof(FIELD));\
     33                *pmarshalled_data+=sizeof(FIELD);\
    3034                *pmarshalled_data_size+=sizeof(FIELD);\
    3135        }\
    32         else{\
     36        else if(marshall_direction==MARSHALLING_SIZE){\
     37                *pmarshalled_data_size+=sizeof(FIELD);\
     38        }\
     39        else if(marshall_direction==MARSHALLING_BACKWARD){\
    3340                memcpy(&FIELD,*pmarshalled_data,sizeof(FIELD));\
    3441                *pmarshalled_data+=sizeof(FIELD);\
    35         }
     42        }\
     43        else _error_("Wrong direction during the Marshall process");
     44
    3645
    3746#define MARSHALLING_ARRAY(FIELD,TYPE,SIZE) \
    38 \
     47        \
    3948        if(marshall_direction==MARSHALLING_FORWARD){\
    40                 if(pmarshalled_data){\
    41                         memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
    42                         *pmarshalled_data+=SIZE*sizeof(TYPE);\
    43                 }\
     49                memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
     50                *pmarshalled_data+=SIZE*sizeof(TYPE);\
    4451                *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
    4552        }\
    46         else{\
     53        else if(marshall_direction==MARSHALLING_SIZE){\
     54                *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
     55        }\
     56        else if(marshall_direction==MARSHALLING_BACKWARD){\
    4757                memcpy(FIELD,*pmarshalled_data,SIZE*sizeof(TYPE));\
    4858                *pmarshalled_data+=SIZE*sizeof(TYPE);\
    49         }
     59        }\
     60        else _error_("Wrong direction during the Marshall process");
     61
    5062
    5163#define MARSHALLING_DYNAMIC(FIELD,TYPE,SIZE) \
    52 \
     64        \
    5365        if(marshall_direction==MARSHALLING_FORWARD){\
    54                 if(pmarshalled_data){\
    55                         memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
    56                         *pmarshalled_data+=SIZE*sizeof(TYPE);\
    57                 }\
     66                memcpy(*pmarshalled_data,FIELD,SIZE*sizeof(TYPE));\
     67                *pmarshalled_data+=SIZE*sizeof(TYPE);\
    5868                *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
    5969        }\
    60         else{\
     70        else if(marshall_direction==MARSHALLING_SIZE){\
     71                *pmarshalled_data_size+=SIZE*sizeof(TYPE);\
     72        }\
     73        else if(marshall_direction==MARSHALLING_BACKWARD){\
    6174                FIELD=xNew<TYPE>(SIZE);\
    6275                memcpy(FIELD,*pmarshalled_data,SIZE*sizeof(TYPE));\
    6376                *pmarshalled_data+=SIZE*sizeof(TYPE);\
    64         }
     77        }\
     78        else _error_("Wrong direction during the Marshall process");
    6579
    6680#endif 
Note: See TracChangeset for help on using the changeset viewer.