All files / output zcl_abapgit_zlib_stream.clas.mjs

100% Statements 97/97
100% Branches 20/20
47.36% Functions 9/19
100% Lines 97/97

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 971x 1x 6x 6x 6x 6x 6x 6x 6x 1x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 7343x 7343x 7343x 7343x 7343x 7343x 7343x 7343x 7343x 7343x 7311x 7311x 1063x 1063x 1063x 1063x 7311x 7311x 1058x 1058x 7311x 6253x 6253x 6253x 6253x 7311x 7343x 7343x 7343x 6x 2x 2x 2x 2x 2x 2x 2x 2x 6x 503x 503x 503x 503x 503x 503x 503x 6x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_zlib_stream.clas.abap
class zcl_abapgit_zlib_stream {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_ZLIB_STREAM';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"MV_BITS": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_COMPRESSED": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "}};
  static METHODS = {"CONSTRUCTOR": {"visibility": "U", "parameters": {"IV_DATA": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}}},
  "TAKE_BITS": {"visibility": "U", "parameters": {"RV_BITS": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " "}, "IV_LENGTH": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}},
  "TAKE_INT": {"visibility": "U", "parameters": {"RV_INT": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}, "IV_LENGTH": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}},
  "REMAINING": {"visibility": "U", "parameters": {"RV_LENGTH": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}},
  "TAKE_BYTES": {"visibility": "U", "parameters": {"RV_BYTES": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " "}, "IV_LENGTH": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " "}}},
  "CLEAR_BITS": {"visibility": "U", "parameters": {}}};
  #mv_bits;
  #mv_compressed;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "take_bits": this.take_bits.bind(this),
      "take_int": this.take_int.bind(this),
      "remaining": this.remaining.bind(this),
      "take_bytes": this.take_bytes.bind(this),
      "clear_bits": this.clear_bits.bind(this),
    };
    this.#mv_bits = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_bits"] = this.#mv_bits;
    this.#mv_compressed = new abap.types.XString({qualifiedName: "XSTRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_compressed"] = this.#mv_compressed;
  }
  async clear_bits() {
    this.#mv_bits.clear();
  }
  async constructor_(INPUT) {
    let iv_data = INPUT?.iv_data;
    if (iv_data?.getQualifiedName === undefined || iv_data.getQualifiedName() !== "XSTRING") { iv_data = undefined; }
    if (iv_data === undefined) { iv_data = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.iv_data); }
    this.#mv_compressed.set(iv_data);
    return this;
  }
  async remaining() {
    let rv_length = new abap.types.Integer({qualifiedName: "I"});
    rv_length.set(abap.operators.add(abap.builtin.xstrlen({val: this.#mv_compressed}),abap.IntegerFactory.get(1)));
    return rv_length;
  }
  async take_bits(INPUT) {
    let rv_bits = new abap.types.String({qualifiedName: "STRING"});
    let iv_length = INPUT?.iv_length;
    if (iv_length?.getQualifiedName === undefined || iv_length.getQualifiedName() !== "I") { iv_length = undefined; }
    if (iv_length === undefined) { iv_length = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_length); }
    let lv_left = new abap.types.Integer({qualifiedName: "I"});
    let lv_index = new abap.types.Integer({qualifiedName: "I"});
    let lv_x = new abap.types.Hex();
    const indexBackup1 = abap.builtin.sy.get().index.get();
    let unique228 = 1;
    while (abap.compare.lt(abap.builtin.strlen({val: rv_bits}), iv_length)) {
      abap.builtin.sy.get().index.set(unique228++);
      if (abap.compare.initial(this.#mv_bits)) {
        lv_x.set(this.#mv_compressed.getOffset({length: 1}));
        this.#mv_bits.set((await abap.Classes['ZCL_ABAPGIT_ZLIB_CONVERT'].hex_to_bits({iv_hex: lv_x})));
        this.#mv_compressed.set(this.#mv_compressed.getOffset({offset: 1}));
      }
      lv_left.set(abap.operators.minus(iv_length,abap.builtin.strlen({val: rv_bits})));
      if (abap.compare.ge(lv_left, abap.builtin.strlen({val: this.#mv_bits}))) {
        abap.statements.concatenate({source: [this.#mv_bits, rv_bits], target: rv_bits});
        this.#mv_bits.clear();
      } else {
        lv_index.set(abap.operators.minus(abap.builtin.strlen({val: this.#mv_bits}),lv_left));
        abap.statements.concatenate({source: [this.#mv_bits.getOffset({offset: lv_index, length: lv_left}), rv_bits], target: rv_bits});
        this.#mv_bits.set(this.#mv_bits.getOffset({length: lv_index}));
      }
    }
    abap.builtin.sy.get().index.set(indexBackup1);
    return rv_bits;
  }
  async take_bytes(INPUT) {
    let rv_bytes = new abap.types.XString({qualifiedName: "XSTRING"});
    let iv_length = INPUT?.iv_length;
    if (iv_length?.getQualifiedName === undefined || iv_length.getQualifiedName() !== "I") { iv_length = undefined; }
    if (iv_length === undefined) { iv_length = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_length); }
    rv_bytes.set(this.#mv_compressed.getOffset({length: iv_length}));
    this.#mv_compressed.set(this.#mv_compressed.getOffset({offset: iv_length}));
    return rv_bytes;
  }
  async take_int(INPUT) {
    let rv_int = new abap.types.Integer({qualifiedName: "I"});
    let iv_length = INPUT?.iv_length;
    if (iv_length?.getQualifiedName === undefined || iv_length.getQualifiedName() !== "I") { iv_length = undefined; }
    if (iv_length === undefined) { iv_length = new abap.types.Integer({qualifiedName: "I"}).set(INPUT.iv_length); }
    rv_int.set((await abap.Classes['ZCL_ABAPGIT_ZLIB_CONVERT'].bits_to_int({iv_bits: (await this.take_bits({iv_length: iv_length}))})));
    return rv_int;
  }
}
abap.Classes['ZCL_ABAPGIT_ZLIB_STREAM'] = zcl_abapgit_zlib_stream;
export {zcl_abapgit_zlib_stream};