All files / output zcl_abapgit_git_delta.clas.mjs

75.33% Statements 168/223
48.27% Branches 14/29
38.88% Functions 7/18
75.33% Lines 168/223

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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 2231x 1x 1x 1x 1x 1x 1x 1x 1x         1x         1x 1x 1x         1x 1x             1x       1x     1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 1x 6x 6x 6x 3x 3x 6x 1x 1x     1x 1x 6x 1x     1x 1x 1x 1x           1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x     1x     1x     1x 1x 1x 1x 1x     1x     1x     1x 1x         1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x
await import("./zcl_abapgit_git_delta.clas.locals.mjs");
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_git_delta.clas.abap
class zcl_abapgit_git_delta {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_GIT_DELTA';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"DELTA": {"visibility": "I", "parameters": {"IS_OBJECT": {"type": () => {return new abap.types.Structure({
  "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
  "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
  "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
  "adler32": new abap.types.Hex({length: 4}),
  "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {});}, "is_optional": " "}, "CT_OBJECTS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.Structure({
  "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
  "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
  "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
  "adler32": new abap.types.Hex({length: 4}),
  "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[{"name":"sha","type":"SORTED","isUnique":false,"keyFields":["SHA1"]},{"name":"type","type":"SORTED","isUnique":false,"keyFields":["TYPE","SHA1"]}]}, "zif_abapgit_definitions=>ty_objects_tt");}, "is_optional": " "}}},
  "DELTA_HEADER": {"visibility": "I", "parameters": {"IO_STREAM": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "LCL_STREAM", RTTIName: "\\CLASS-POOL=ZCL_ABAPGIT_GIT_DELTA\\CLASS=LCL_STREAM"});}, "is_optional": " "}}},
  "DECODE_DELTAS": {"visibility": "U", "parameters": {"IV_SHOW_PROGRESS": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " "}, "CT_OBJECTS": {"type": () => {return abap.types.TableFactory.construct(new abap.types.Structure({
  "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
  "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
  "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
  "adler32": new abap.types.Hex({length: 4}),
  "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[{"name":"sha","type":"SORTED","isUnique":false,"keyFields":["SHA1"]},{"name":"type","type":"SORTED","isUnique":false,"keyFields":["TYPE","SHA1"]}]}, "zif_abapgit_definitions=>ty_objects_tt");}, "is_optional": " "}}}};
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async decode_deltas(INPUT) {
    return zcl_abapgit_git_delta.decode_deltas(INPUT);
  }
  static async decode_deltas(INPUT) {
    let iv_show_progress = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    if (INPUT && INPUT.iv_show_progress) {iv_show_progress.set(INPUT.iv_show_progress);}
    if (INPUT === undefined || INPUT.iv_show_progress === undefined) {iv_show_progress = abap.builtin.abap_true;}
    let ct_objects = abap.types.TableFactory.construct(new abap.types.Structure({
    "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
    "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
    "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
    "adler32": new abap.types.Hex({length: 4}),
    "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[{"name":"sha","type":"SORTED","isUnique":false,"keyFields":["SHA1"]},{"name":"type","type":"SORTED","isUnique":false,"keyFields":["TYPE","SHA1"]}]}, "zif_abapgit_definitions=>ty_objects_tt");
    if (INPUT && INPUT.ct_objects) {ct_objects = INPUT.ct_objects;}
    let ls_object = new abap.types.Structure({
    "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
    "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
    "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
    "adler32": new abap.types.Hex({length: 4}),
    "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {});
    let li_progress = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_PROGRESS", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_PROGRESS"});
    let lt_deltas = abap.types.TableFactory.construct(new abap.types.Structure({
    "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
    "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
    "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
    "adler32": new abap.types.Hex({length: 4}),
    "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[{"name":"sha","type":"SORTED","isUnique":false,"keyFields":["SHA1"]},{"name":"type","type":"SORTED","isUnique":false,"keyFields":["TYPE","SHA1"]}]}, "zif_abapgit_definitions=>ty_objects_tt");
    for await (const unique132 of abap.statements.loop(ct_objects,{usingKey: "type",where: async (I) => {return abap.compare.eq(I.type, abap.Classes['ZIF_ABAPGIT_GIT_DEFINITIONS'].zif_abapgit_git_definitions$c_type.get().ref_d);},topEquals: {"type": abap.Classes['ZIF_ABAPGIT_GIT_DEFINITIONS'].zif_abapgit_git_definitions$c_type.get().ref_d}})) {
      ls_object.set(unique132);
      abap.statements.insertInternal({data: ls_object, table: lt_deltas});
    }
    await abap.statements.deleteInternal(ct_objects,{where: async (I) => {return abap.compare.eq(I.type, abap.Classes['ZIF_ABAPGIT_GIT_DEFINITIONS'].zif_abapgit_git_definitions$c_type.get().ref_d);}});
    abap.statements.sort(lt_deltas,{by: [{component: "index"}]});
    if (abap.compare.eq(iv_show_progress, abap.builtin.abap_true)) {
      li_progress.set((await abap.Classes['ZCL_ABAPGIT_PROGRESS'].get_instance({iv_total: abap.builtin.lines({val: lt_deltas})})));
    }
    for await (const unique133 of abap.statements.loop(lt_deltas)) {
      ls_object.set(unique133);
      if (abap.compare.initial(li_progress) === false) {
        await li_progress.get().zif_abapgit_progress$show({iv_current: abap.builtin.sy.get().tabix, iv_text: abap.CharacterFactory.get(13, 'Decode deltas')});
      }
      await this.delta({is_object: ls_object, ct_objects: ct_objects});
    }
  }
  async delta(INPUT) {
    return zcl_abapgit_git_delta.delta(INPUT);
  }
  static async delta(INPUT) {
    let is_object = INPUT?.is_object;
    if (is_object?.getQualifiedName === undefined || is_object.getQualifiedName() !== "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT") { is_object = undefined; }
    if (is_object === undefined) { is_object = new abap.types.Structure({
    "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
    "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
    "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
    "adler32": new abap.types.Hex({length: 4}),
    "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {}).set(INPUT.is_object); }
    let ct_objects = abap.types.TableFactory.construct(new abap.types.Structure({
    "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
    "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
    "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
    "adler32": new abap.types.Hex({length: 4}),
    "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[{"name":"sha","type":"SORTED","isUnique":false,"keyFields":["SHA1"]},{"name":"type","type":"SORTED","isUnique":false,"keyFields":["TYPE","SHA1"]}]}, "zif_abapgit_definitions=>ty_objects_tt");
    if (INPUT && INPUT.ct_objects) {ct_objects = INPUT.ct_objects;}
    let lc_1 = new abap.types.Hex();
    lc_1.set('01');
    let lc_2 = new abap.types.Hex();
    lc_2.set('02');
    let lc_4 = new abap.types.Hex();
    lc_4.set('04');
    let lc_8 = new abap.types.Hex();
    lc_8.set('08');
    let lc_16 = new abap.types.Hex();
    lc_16.set('10');
    let lc_32 = new abap.types.Hex();
    lc_32.set('20');
    let lc_64 = new abap.types.Hex();
    lc_64.set('40');
    let lc_128 = new abap.types.Hex();
    lc_128.set('80');
    let lv_base = new abap.types.XString({qualifiedName: "XSTRING"});
    let lv_result = new abap.types.XString({qualifiedName: "XSTRING"});
    let lv_offset = new abap.types.Integer({qualifiedName: "I"});
    let lo_stream = new abap.types.ABAPObject({qualifiedName: "LCL_STREAM", RTTIName: "\\CLASS-POOL=ZCL_ABAPGIT_GIT_DELTA\\CLASS=LCL_STREAM"});
    let lv_sha1 = new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"});
    let ls_object = new abap.types.Structure({
    "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
    "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
    "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
    "adler32": new abap.types.Hex({length: 4}),
    "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {});
    let lv_len = new abap.types.Integer({qualifiedName: "I"});
    let lv_tmp = new abap.types.XString({qualifiedName: "XSTRING"});
    let lv_org = new abap.types.Hex();
    let fs_ls_object_ = new abap.types.FieldSymbol(new abap.types.Structure({
    "sha1": new abap.types.Character(40, {"qualifiedName":"zif_abapgit_git_definitions=>ty_sha1"}),
    "type": new abap.types.Character(6, {"qualifiedName":"zif_abapgit_git_definitions=>ty_type"}),
    "data": new abap.types.XString({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-DATA"}),
    "adler32": new abap.types.Hex({length: 4}),
    "index": new abap.types.Integer({qualifiedName: "ZIF_ABAPGIT_DEFINITIONS=>TY_OBJECT-INDEX"})}, "zif_abapgit_definitions=>ty_object", undefined, {}, {}));
    lo_stream.set(await (new abap.Classes['CLAS-ZCL_ABAPGIT_GIT_DELTA-LCL_STREAM']()).constructor_({iv_data: is_object.get().data}));
    abap.statements.readTable(ct_objects,{keyName: "sha",
      assigning: fs_ls_object_,
      withKey: (i) => {return abap.compare.eq(i.sha1, is_object.get().sha1);},
      withKeyValue: [{key: (i) => {return i.sha1}, value: is_object.get().sha1}],
      usesTableLine: false,
      withKeySimple: {"sha1": is_object.get().sha1}});
    if (abap.compare.ne(abap.builtin.sy.get().subrc, abap.IntegerFactory.get(0))) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Base not found, ${abap.templateFormatting(is_object.get().sha1)}`)});
    } else if (abap.compare.eq(fs_ls_object_.get().type, abap.Classes['ZIF_ABAPGIT_GIT_DEFINITIONS'].zif_abapgit_git_definitions$c_type.get().ref_d)) {
      await abap.Classes['ZCX_ABAPGIT_EXCEPTION'].raise({iv_text: new abap.types.String().set(`Delta, base eq delta`)});
    }
    lv_base.set(fs_ls_object_.get().data);
    await this.delta_header({io_stream: lo_stream});
    await this.delta_header({io_stream: lo_stream});
    const indexBackup1 = abap.builtin.sy.get().index.get();
    let unique134 = 1;
    while (abap.compare.eq((await lo_stream.get().has_data()), abap.builtin.abap_true)) {
      abap.builtin.sy.get().index.set(unique134++);
      lv_org.set((await lo_stream.get().eat_byte()));
      if (abap.compare.eq(abap.operators.bitand(lv_org,lc_128), lc_128)) {
        lv_offset.set(abap.IntegerFactory.get(0));
        if (abap.compare.eq(abap.operators.bitand(lv_org,lc_1), lc_1)) {
          lv_offset.set((await lo_stream.get().eat_byte()));
        }
        if (abap.compare.eq(abap.operators.bitand(lv_org,lc_2), lc_2)) {
          lv_offset.set(abap.operators.add(lv_offset,abap.operators.multiply((await lo_stream.get().eat_byte()),new abap.types.Integer().set(256))));
        }
        if (abap.compare.eq(abap.operators.bitand(lv_org,lc_4), lc_4)) {
          lv_offset.set(abap.operators.add(lv_offset,abap.operators.multiply((await lo_stream.get().eat_byte()),new abap.types.Integer().set(65536))));
        }
        if (abap.compare.eq(abap.operators.bitand(lv_org,lc_8), lc_8)) {
          lv_offset.set(abap.operators.add(lv_offset,abap.operators.multiply((await lo_stream.get().eat_byte()),new abap.types.Integer().set(16777216))));
        }
        lv_len.set(abap.IntegerFactory.get(0));
        if (abap.compare.eq(abap.operators.bitand(lv_org,lc_16), lc_16)) {
          lv_len.set((await lo_stream.get().eat_byte()));
        }
        if (abap.compare.eq(abap.operators.bitand(lv_org,lc_32), lc_32)) {
          lv_len.set(abap.operators.add(lv_len,abap.operators.multiply((await lo_stream.get().eat_byte()),new abap.types.Integer().set(256))));
        }
        if (abap.compare.eq(abap.operators.bitand(lv_org,lc_64), lc_64)) {
          lv_len.set(abap.operators.add(lv_len,abap.operators.multiply((await lo_stream.get().eat_byte()),new abap.types.Integer().set(65536))));
        }
        if (abap.compare.eq(lv_len, abap.IntegerFactory.get(0))) {
          lv_len.set(new abap.types.Integer().set(65536));
        }
        abap.statements.concatenate({source: [lv_result, lv_base.getOffset({offset: lv_offset, length: lv_len})], target: lv_result});
      } else {
        lv_len.set(lv_org);
        lv_tmp.set((await lo_stream.get().eat_bytes({iv_length: lv_len})));
        abap.statements.concatenate({source: [lv_result, lv_tmp], target: lv_result});
      }
    }
    abap.builtin.sy.get().index.set(indexBackup1);
    lv_sha1.set((await abap.Classes['ZCL_ABAPGIT_HASH'].sha1({iv_type: fs_ls_object_.get().type, iv_data: lv_result})));
    ls_object.clear();
    ls_object.get().sha1.set(lv_sha1);
    ls_object.get().type.set(fs_ls_object_.get().type);
    ls_object.get().data.set(lv_result);
    ls_object.get().index.set(fs_ls_object_.get().index);
    abap.statements.append({source: ls_object, target: ct_objects});
  }
  async delta_header(INPUT) {
    return zcl_abapgit_git_delta.delta_header(INPUT);
  }
  static async delta_header(INPUT) {
    let io_stream = INPUT?.io_stream;
    if (io_stream?.getQualifiedName === undefined || io_stream.getQualifiedName() !== "LCL_STREAM") { io_stream = undefined; }
    if (io_stream === undefined) { io_stream = new abap.types.ABAPObject({qualifiedName: "LCL_STREAM", RTTIName: "\\CLASS-POOL=ZCL_ABAPGIT_GIT_DELTA\\CLASS=LCL_STREAM"}).set(INPUT.io_stream); }
    let lv_x = new abap.types.Hex();
    let lv_bit = new abap.types.Character(1, {});
    const indexBackup1 = abap.builtin.sy.get().index.get();
    let unique135 = 1;
    while (true) {
      abap.builtin.sy.get().index.set(unique135++);
      lv_x.set((await io_stream.get().eat_byte()));
      abap.statements.getBit(abap.IntegerFactory.get(1), lv_x, lv_bit);
      if (abap.compare.eq(lv_bit, abap.CharacterFactory.get(1, '0'))) {
        break;
      }
    }
    abap.builtin.sy.get().index.set(indexBackup1);
  }
}
abap.Classes['ZCL_ABAPGIT_GIT_DELTA'] = zcl_abapgit_git_delta;
export {zcl_abapgit_git_delta};