set sequence and supply auto version feature sync
authorVolker Birk <vb@pep.foundation>
Thu, 16 Aug 2018 23:57:52 +0200
branchsync
changeset 28554db88ce549ee
parent 2854 f4728cd6a9b8
child 2856 451ac4260963
set sequence and supply auto version feature
sync/gen_message_func.ysl2
     1.1 --- a/sync/gen_message_func.ysl2	Thu Aug 16 23:17:34 2018 +0200
     1.2 +++ b/sync/gen_message_func.ysl2	Thu Aug 16 23:57:52 2018 +0200
     1.3 @@ -187,6 +187,8 @@
     1.4  ||
     1.5  case «../@name»_PR_«yml:lcase(@name)»:
     1.6      {
     1.7 +        static long sequence = 0;
     1.8 +        msg->choice.«yml:lcase(@name)».header.sequence = ++sequence;
     1.9          int message_type = msg->choice.«yml:lcase(@name)».payload.present;
    1.10          switch (message_type) {
    1.11              case «@name»__payload_PR_NOTHING:
    1.12 @@ -204,12 +206,36 @@
    1.13      const "message_name", "concat(yml:lcase(substring(@name,1,1)), substring(@name,2))";
    1.14      ||
    1.15      case «../@name»__payload_PR_«$message_name»:
    1.16 +        `` apply "auto"
    1.17          `` apply "field", mode=update_message with "message_name", "$message_name"
    1.18          break;
    1.19  
    1.20      ||
    1.21  }
    1.22  
    1.23 +template "auto" choose {
    1.24 +    when "@type = 'Version'"
    1.25 +        ||
    1.26 +        {
    1.27 +            long *major = (long *) malloc(sizeof(long));
    1.28 +            long *minor = (long *) malloc(sizeof(long));
    1.29 +            assert(major && minor);
    1.30 +            if (!(major && minor))
    1.31 +                return PEP_OUT_OF_MEMORY;
    1.32 +
    1.33 +            *major = «../../version/@major»;
    1.34 +            *minor = «../../version/@minor»;
    1.35 +
    1.36 +            msg->choice.«yml:lcase(../../@name)».payload.choice.«yml:mixedCase(../@name)».«@name».major = major;
    1.37 +            msg->choice.«yml:lcase(../../@name)».payload.choice.«yml:mixedCase(../@name)».«@name».minor = minor;
    1.38 +        }
    1.39 +
    1.40 +        ||
    1.41 +
    1.42 +    otherwise
    1.43 +        error "unkown type for auto in message: {@type}; allowed types: Version";
    1.44 +}
    1.45 +
    1.46  template "field", mode=update_message {
    1.47      param "message_name";
    1.48      choose {