def generate_annotated_values_binary(scalars_map, container_map): for value_p in chain( generate_scalars_binary(scalars_map, preceding_symbols=2), generate_containers_binary(container_map, preceding_symbols=2)): obj = value_p.obj if not isinstance(obj, _IonNature): continue obj.ion_annotations = ( _st(u'annot1'), _st(u'annot2'), ) annot_length = 2 # 10 and 11 each fit in one VarUInt byte annot_length_length = 1 # 2 fits in one VarUInt byte value_length = len(value_p.expected) length_field = annot_length + annot_length_length + value_length wrapper = [] _write_length(wrapper, length_field, 0xE0) wrapper.extend([ VARUINT_END_BYTE | annot_length, VARUINT_END_BYTE | 10, VARUINT_END_BYTE | 11 ]) yield _Parameter(desc='ANNOTATED %s' % value_p.desc, obj=obj, expected=bytearray(wrapper) + value_p.expected, has_symbols=True, stream=value_p.stream)
def generate_annotated_values_binary(scalars_map, container_map): for value_p in chain(generate_scalars_binary(scalars_map, preceding_symbols=2), generate_containers_binary(container_map, preceding_symbols=2)): obj = value_p.obj if not isinstance(obj, _IonNature): continue obj.ion_annotations = (_st(u'annot1'), _st(u'annot2'),) annot_length = 2 # 10 and 11 each fit in one VarUInt byte annot_length_length = 1 # 2 fits in one VarUInt byte value_length = len(value_p.expected) length_field = annot_length + annot_length_length + value_length wrapper = [] _write_length(wrapper, length_field, 0xE0) wrapper.extend([ VARUINT_END_BYTE | annot_length, VARUINT_END_BYTE | 10, VARUINT_END_BYTE | 11 ]) yield _Parameter( desc='ANNOTATED %s' % value_p.desc, obj=obj, expected=bytearray(wrapper) + value_p.expected, has_symbols=True, stream=value_p.stream )
def _generate_annotated_values(): for value_p in chain(_generate_simple_scalars(), _generate_simple_containers()): events = (value_p.events[0].derive_annotations( [10, 11]), ) + value_p.events[1:] annot_length = 2 # 10 and 11 each fit in one VarUInt byte annot_length_length = 1 # 2 fits in one VarUInt byte value_length = len(value_p.expected) length_field = annot_length + annot_length_length + value_length wrapper = [] _write_length(wrapper, length_field, 0xE0) wrapper.extend([ _VARUINT_END_BYTE | annot_length, _VARUINT_END_BYTE | 10, _VARUINT_END_BYTE | 11 ]) yield _P( desc='ANN %s' % value_p.desc, events=events + (_E(_ET.STREAM_END), ), expected=bytearray(wrapper) + value_p.expected, )