Branch: Tag:

2014-06-21

2014-06-21 14:57:14 by Martin Nilsson <nilsson@opera.com>

Support constructed strings.

89:    mapping(int:program(Object)):    Object) decoder,    mapping(int:program(Object)) types); -  this_program begin_decode_constructed(string raw); -  this_program decode_constructed_element(int i, object e); +  void begin_decode_constructed(string raw); +  void decode_constructed_element(int i, object e);    this_program end_decode_constructed(int length);       mapping(int:program(Object)) element_types(int i,
188:    return this;    }    -  this_program begin_decode_constructed(string(0..255) raw) { +  void begin_decode_constructed(string(0..255) raw) {    WERROR("asn1_compound[%s]->begin_decode_constructed\n", type_name);    record_der_contents(raw); -  return this; +     }    -  this_program decode_constructed_element(int i, object e) { +  void decode_constructed_element(int i, object e) {    WERROR("asn1_compound[%s]->decode_constructed_element(%O)\n",    type_name, e);    if (i != sizeof(elements))    error("Unexpected index!\n");    elements += ({ e }); -  return this; +     }       this_program end_decode_constructed(int length) {
262:    return this;    }    +  void begin_decode_constructed(string raw) +  { +  value = ""; +  } +  +  void decode_constructed_element(int i, object(this_program) e) +  { +  value += e->value; +  } +  +  this_program end_decode_constructed(int length) +  { +  return this; +  } +     protected string _sprintf(int t) {    return t=='O' && sprintf("%O(%O)", this_program, value);    }
557:    return this;    }    +  void begin_decode_constructed(string raw) +  { +  unused = 0; +  value = ""; +  } +  +  void decode_constructed_element(int i, object(this_program) e) +  { +  if( unused ) error("Adding to a non-aligned bit stream.\n"); +  value += e->value; +  unused = e->unused; +  } +  +  this_program end_decode_constructed(int length) +  { +  return this; +  } +     protected string _sprintf(int t) {    if(t!='O') return UNDEFINED;    if(!value) return sprintf("%O(0)", this_program);