Could anybody help with translation of this C macro to D mixin/mixin template? Here a - unsigned char, b - int. It's simple with STARTDATA as mixin, but STOREBITS and ADDBITS use variables defined in STARTDATA scope, so I can't understand how to do mixin template with it.

    #define STARTDATA \
      size_t ressize=0; \
      char *blockstart; \
      int numbits; \
      uint64_t bitbuffer=0;

    #define STOREBITS \
      while(numbits >= 8) \
      { \
        if(!size) return 0; \
        *(buffer++) = bitbuffer>>(numbits-8); \
        numbits -= 8; \
        ++ressize; \
        --size; \
      }

    #define ADDBITS(a, b) \
      { \
        bitbuffer = (bitbuffer<<(a))|((b)&((1<<a)-1)); \
        numbits += (a); \
        STOREBITS \
      }

Reply via email to