All files / output cl_abap_conv_out_ce.clas.mjs

66.92% Statements 85/127
73.91% Branches 17/23
20% Functions 6/30
66.92% Lines 85/127

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 1271x 1x 416x 416x 416x 416x 416x 416x 416x 416x 1x 1x 1x 1x 1x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x     416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 416x         416x 416x 416x     416x                       416x           416x         416x     416x                     416x     416x 416x 416x 416x 416x 416x 416x 416x 416x 416x 69x 69x 69x 416x 347x 347x 416x 416x 416x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// cl_abap_conv_out_ce.clas.abap
class cl_abap_conv_out_ce {
  static STATIC_SUPER = undefined;
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'CL_ABAP_CONV_OUT_CE';
  static IMPLEMENTED_INTERFACES = [];
  static ATTRIBUTES = {"MV_JS_ENCODING": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_BUFFER": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "}};
  static METHODS = {"CREATE": {"visibility": "U", "parameters": {"RET": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CONV_OUT_CE", RTTIName: "\\CLASS=CL_ABAP_CONV_OUT_CE"});}, "is_optional": " ", "parm_kind": "R", "type_name": "ObjectReferenceType"}, "ENCODING": {"type": () => {return new abap.types.Character(20, {"qualifiedName":"abap_encoding"});}, "is_optional": " ", "parm_kind": "I", "type_name": "CharacterType"}, "IGNORE_CERR": {"type": () => {return new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});}, "is_optional": " ", "parm_kind": "I", "type_name": "CharacterType"}, "ENDIAN": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}, "REPLACEMENT": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "is_optional": " ", "parm_kind": "I", "type_name": "StringType"}}},
  "UCCPI": {"visibility": "U", "parameters": {"RET": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " ", "parm_kind": "R", "type_name": "IntegerType"}, "CHAR": {"type": () => {return new abap.types.Character();}, "is_optional": " ", "parm_kind": "I", "type_name": "CLikeType"}}},
  "UCCP": {"visibility": "U", "parameters": {"UCCP": {"type": () => {return new abap.types.Hex({length: 2});}, "is_optional": " ", "parm_kind": "R", "type_name": "HexType"}, "CHAR": {"type": () => {return new abap.types.Character();}, "is_optional": " ", "parm_kind": "I", "type_name": "CLikeType"}}},
  "CONVERT": {"visibility": "U", "parameters": {"DATA": {"type": () => {return new abap.types.Character();}, "is_optional": " ", "parm_kind": "I", "type_name": "SimpleType"}, "N": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "is_optional": " ", "parm_kind": "I", "type_name": "IntegerType"}, "BUFFER": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " ", "parm_kind": "E", "type_name": "XStringType"}}},
  "WRITE": {"visibility": "U", "parameters": {"DATA": {"type": () => {return new abap.types.Character(4);}, "is_optional": " ", "parm_kind": "I", "type_name": "AnyType"}}},
  "GET_BUFFER": {"visibility": "U", "parameters": {"BUFFER": {"type": () => {return new abap.types.XString({qualifiedName: "XSTRING"});}, "is_optional": " ", "parm_kind": "R", "type_name": "XStringType"}}},
  "RESET": {"visibility": "U", "parameters": {}}};
  #mv_js_encoding;
  #mv_buffer;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
      "convert": this.convert.bind(this),
      "write": this.write.bind(this),
      "get_buffer": this.get_buffer.bind(this),
      "reset": this.reset.bind(this),
    };
    this.#mv_js_encoding = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_js_encoding"] = this.#mv_js_encoding;
    this.#mv_buffer = new abap.types.XString({qualifiedName: "XSTRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_buffer"] = this.#mv_buffer;
  }
  async constructor_(INPUT) {
    if (super.constructor_) { await super.constructor_(INPUT); }
    return this;
  }
  async create(INPUT) {
    return cl_abap_conv_out_ce.create(INPUT);
  }
  static async create(INPUT) {
    let ret = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CONV_OUT_CE", RTTIName: "\\CLASS=CL_ABAP_CONV_OUT_CE"});
    let encoding = new abap.types.Character(20, {"qualifiedName":"abap_encoding"});
    if (INPUT && INPUT.encoding) {encoding.set(INPUT.encoding);}
    let ignore_cerr = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"});
    if (INPUT && INPUT.ignore_cerr) {ignore_cerr.set(INPUT.ignore_cerr);}
    if (INPUT === undefined || INPUT.ignore_cerr === undefined) {ignore_cerr = abap.builtin.abap_false;}
    let endian = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.endian) {endian.set(INPUT.endian);}
    let replacement = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.replacement) {replacement.set(INPUT.replacement);}
    ret.set(await (new abap.Classes['CL_ABAP_CONV_OUT_CE']()).constructor_());
    let unique1390 = encoding;
    if (abap.compare.eq(unique1390, abap.CharacterFactory.get(5, 'UTF-8')) || abap.compare.eq(unique1390, abap.CharacterFactory.get(1, ''))) {
      ret.get().FRIENDS_ACCESS_INSTANCE["mv_js_encoding"].set(abap.CharacterFactory.get(4, 'utf8'));
    } else if (abap.compare.eq(unique1390, abap.CharacterFactory.get(4, '4103'))) {
      ret.get().FRIENDS_ACCESS_INSTANCE["mv_js_encoding"].set(abap.CharacterFactory.get(7, 'utf16le'));
    } else {
      abap.statements.assert(abap.compare.eq(abap.IntegerFactory.get(1), abap.CharacterFactory.get(13, 'not supported')));
    }
    return ret;
  }
  async uccpi(INPUT) {
    return cl_abap_conv_out_ce.uccpi(INPUT);
  }
  static async uccpi(INPUT) {
    let ret = new abap.types.Integer({qualifiedName: "I"});
    let char = INPUT?.char;
    let lo_out = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CONV_OUT_CE", RTTIName: "\\CLASS=CL_ABAP_CONV_OUT_CE"});
    let lv_hex = new abap.types.XString({qualifiedName: "XSTRING"});
    lo_out.set((await this.create({encoding: abap.CharacterFactory.get(4, '4103')})));
    await lo_out.get().convert({data: char, buffer: lv_hex});
    abap.statements.assert(abap.compare.eq(abap.builtin.xstrlen({val: lv_hex}), abap.IntegerFactory.get(2)));
    ret.set(lv_hex.getOffset({length: 1}));
    ret.set(abap.operators.add(ret,abap.operators.multiply(lv_hex.getOffset({offset: 1, length: 1}),new abap.types.Integer().set(255))));
    return ret;
  }
  async write(INPUT) {
    let data = INPUT?.data;
    let res = new abap.types.XString({qualifiedName: "XSTRING"});
    await this.convert({data: data, buffer: res});
    abap.statements.concatenate({source: [this.#mv_buffer, res], target: this.#mv_buffer});
  }
  async get_buffer() {
    let buffer = new abap.types.XString({qualifiedName: "XSTRING"});
    buffer.set(this.#mv_buffer);
    return buffer;
  }
  async uccp(INPUT) {
    return cl_abap_conv_out_ce.uccp(INPUT);
  }
  static async uccp(INPUT) {
    let uccp = new abap.types.Hex({length: 2});
    let char = INPUT?.char;
    let lv_char = new abap.types.Character(1, {});
    let lo_obj = new abap.types.ABAPObject({qualifiedName: "CL_ABAP_CONV_OUT_CE", RTTIName: "\\CLASS=CL_ABAP_CONV_OUT_CE"});
    lv_char.set(char.getOffset({length: 1}));
    lo_obj.set((await this.create({encoding: abap.CharacterFactory.get(4, '4103')})));
    await lo_obj.get().convert({data: lv_char, buffer: uccp});
    abap.statements.shift(uccp, {direction: 'LEFT',circular: true,mode: 'BYTE'});
    return uccp;
  }
  async reset() {
    this.#mv_buffer.clear();
  }
  async convert(INPUT) {
    let data = INPUT?.data;
    let n = new abap.types.Integer({qualifiedName: "I"});
    if (INPUT && INPUT.n) {n.set(INPUT.n);}
    let buffer = INPUT?.buffer || new abap.types.XString({qualifiedName: "XSTRING"});
    let lv_str = new abap.types.String({qualifiedName: "STRING"});
    let encoding = new abap.types.String({qualifiedName: "STRING"});
    encoding.set(this.#mv_js_encoding);
    let result = "";
    if ((INPUT && INPUT.n)) {
      lv_str.set(data);
      lv_str.set(lv_str.getOffset({length: n}));
      result = Buffer.from(lv_str.get(), encoding.get()).toString("hex");
    } else {
      result = Buffer.from(data.get(), encoding.get()).toString("hex");
    }
    buffer.set(result.toUpperCase());
  }
}
abap.Classes['CL_ABAP_CONV_OUT_CE'] = cl_abap_conv_out_ce;
cl_abap_conv_out_ce.hex02 = new abap.types.Hex({length: 2});
export {cl_abap_conv_out_ce};