All files / output zcl_abapgit_utils.clas.locals.mjs

72.64% Statements 85/117
56.25% Branches 9/16
28.57% Functions 2/7
72.64% Lines 85/117

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 1171x 1x 1x 1x 1x 1x 1x 1x 1x 1x             1x       1x     1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x     5x 5x 5x 5x 6x 6x 6x 6x 5x 5x 1x 1x 5x 5x       5x 5x 5x 4x 5x 1x 1x   1x 1x 1x 1x 1x                           1x 1x 5x 5x 1x 1x 1x 1x     1x 5x 5x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_utils.clas.locals_imp.abap
class lcl_utf8_utils {
  static STATIC_SUPER = undefined;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CLAS-ZCL_ABAPGIT_UTILS-LCL_UTF8_UTILS';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {};
  static METHODS = {"STRIP_INCOMPLETE_UTF8_TAIL": {"visibility": "U", "parameters": {"RV_BYTES": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " ", "parm_kind": "R", "type_name": "XStringType"}, "IV_BYTES": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "XStringType"}}}};
  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 strip_incomplete_utf8_tail(INPUT) {
    return lcl_utf8_utils.strip_incomplete_utf8_tail(INPUT);
  }
  static async strip_incomplete_utf8_tail(INPUT) {
    let rv_bytes = new abap.types.XString({qualifiedName: "XSTRING"});
    let iv_bytes = INPUT?.iv_bytes;
    if (iv_bytes?.getQualifiedName === undefined || iv_bytes.getQualifiedName() !== "XSTRING") { iv_bytes = undefined; }
    if (iv_bytes === undefined) { iv_bytes = new abap.types.XString({qualifiedName: "XSTRING"}).set(INPUT.iv_bytes); }
    let lc_mask_80 = new abap.types.Hex();
    lc_mask_80.set('80');
    let lc_mask_c0 = new abap.types.Hex();
    lc_mask_c0.set('C0');
    let lc_mask_e0 = new abap.types.Hex();
    lc_mask_e0.set('E0');
    let lc_mask_f0 = new abap.types.Hex();
    lc_mask_f0.set('F0');
    let lc_mask_f8 = new abap.types.Hex();
    lc_mask_f8.set('F8');
    let lc_val_00 = new abap.types.Hex();
    lc_val_00.set('00');
    let lc_val_c0 = new abap.types.Hex();
    lc_val_c0.set('C0');
    let lc_val_e0 = new abap.types.Hex();
    lc_val_e0.set('E0');
    let lc_val_f0 = new abap.types.Hex();
    lc_val_f0.set('F0');
    let lv_len = new abap.types.Integer({qualifiedName: "I"});
    let lv_i = new abap.types.Integer({qualifiedName: "I"});
    let lv_b = new abap.types.Hex();
    let lv_and = new abap.types.Hex();
    let lv_expected = new abap.types.Integer({qualifiedName: "I"});
    let lv_actual = new abap.types.Integer({qualifiedName: "I"});
    let lv_cut = new abap.types.Integer({qualifiedName: "I"});
    rv_bytes.set(iv_bytes);
    lv_len.set(abap.builtin.xstrlen({val: rv_bytes}));
    if (abap.compare.eq(lv_len, abap.IntegerFactory.get(0))) {
      return rv_bytes;
    }
    lv_i.set(abap.operators.minus(lv_len,abap.IntegerFactory.get(1)));
    const indexBackup1 = abap.builtin.sy.get().index.get();
    let unique1414 = 1;
    while (abap.compare.ge(lv_i, abap.IntegerFactory.get(0))) {
      abap.builtin.sy.get().index.set(unique1414++);
      lv_b.set(rv_bytes.getOffset({offset: lv_i, length: 1}));
      lv_and.set(abap.operators.bitand(lv_b,lc_mask_c0));
      if (abap.compare.ne(lv_and, lc_mask_80)) {
        break;
      }
      lv_i.set(abap.operators.minus(lv_i,abap.IntegerFactory.get(1)));
    }
    abap.builtin.sy.get().index.set(indexBackup1);
    if (abap.compare.lt(lv_i, abap.IntegerFactory.get(0))) {
      rv_bytes.clear();
      return rv_bytes;
    }
    lv_b.set(rv_bytes.getOffset({offset: lv_i, length: 1}));
    lv_and.set(abap.operators.bitand(lv_b,lc_mask_80));
    if (abap.compare.eq(lv_and, lc_val_00)) {
      lv_expected.set(abap.IntegerFactory.get(1));
    } else {
      lv_and.set(abap.operators.bitand(lv_b,lc_mask_e0));
      if (abap.compare.eq(lv_and, lc_val_c0)) {
        lv_expected.set(abap.IntegerFactory.get(2));
      } else {
        lv_and.set(abap.operators.bitand(lv_b,lc_mask_f0));
        if (abap.compare.eq(lv_and, lc_val_e0)) {
          lv_expected.set(abap.IntegerFactory.get(3));
        } else {
          lv_and.set(abap.operators.bitand(lv_b,lc_mask_f8));
          if (abap.compare.eq(lv_and, lc_val_f0)) {
            lv_expected.set(abap.IntegerFactory.get(4));
          } else {
            lv_cut.set(lv_i);
            if (abap.compare.gt(lv_cut, abap.IntegerFactory.get(0))) {
              rv_bytes.set(rv_bytes.getOffset({length: lv_cut}));
            } else {
              rv_bytes.clear();
            }
            return rv_bytes;
          }
        }
      }
    }
    lv_actual.set(abap.operators.minus(lv_len,lv_i));
    if (abap.compare.lt(lv_actual, lv_expected)) {
      lv_cut.set(lv_i);
      if (abap.compare.gt(lv_cut, abap.IntegerFactory.get(0))) {
        rv_bytes.set(rv_bytes.getOffset({length: lv_cut}));
      } else {
        rv_bytes.clear();
      }
    }
    return rv_bytes;
  }
}
abap.Classes['CLAS-ZCL_ABAPGIT_UTILS-LCL_UTF8_UTILS'] = lcl_utf8_utils;
export {lcl_utf8_utils};