@abaplint/runtime 2.0.11 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { ICharacter } from "../types/_character";
2
2
  export declare function substring_after(input: {
3
3
  val: ICharacter | string;
4
- sub: ICharacter | string;
4
+ sub?: ICharacter | string;
5
+ regex?: ICharacter | string;
5
6
  }): ICharacter;
@@ -4,8 +4,20 @@ exports.substring_after = void 0;
4
4
  const string_1 = require("../types/string");
5
5
  function substring_after(input) {
6
6
  const val = typeof input.val === "string" ? input.val : input.val.get();
7
- const s = typeof input.sub === "string" ? input.sub : input.sub.get();
8
- const r = new RegExp(s + "(.*)");
7
+ let reg = "";
8
+ if (typeof input.regex === "string") {
9
+ reg = input.regex;
10
+ }
11
+ else if (input === null || input === void 0 ? void 0 : input.regex) {
12
+ reg = input.regex.get();
13
+ }
14
+ else if (typeof input.sub === "string") {
15
+ reg = input.sub;
16
+ }
17
+ else if (input === null || input === void 0 ? void 0 : input.sub) {
18
+ reg = input.sub.get();
19
+ }
20
+ const r = new RegExp(reg + "(.*)");
9
21
  const res = val.match(r);
10
22
  let ret = "";
11
23
  if (res && res[1]) {
@@ -5,22 +5,26 @@ const compare_1 = require("../compare");
5
5
  // todo, field symbols as input?
6
6
  // todo, local classes?
7
7
  async function cast(target, source) {
8
+ var _a;
8
9
  if ((0, compare_1.initial)(source)) {
9
10
  target.clear();
10
11
  return;
11
12
  }
12
- const targetName = target.getQualifiedName();
13
- // using "instanceof" is probably wrong in some cases,
14
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
15
- // @ts-ignore
16
- if (abap.Classes[targetName] && source instanceof abap.Classes[targetName] === false) {
13
+ const targetName = (_a = target.getQualifiedName()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
14
+ if ((targetName === null || targetName === void 0 ? void 0 : targetName.startsWith("IF_")) === false
15
+ && (targetName === null || targetName === void 0 ? void 0 : targetName.startsWith("ZIF_")) === false) { // todo, interfaces are also classes but not inherited
16
+ // using "instanceof" is probably wrong in some cases,
17
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
17
18
  // @ts-ignore
18
- if (abap.Classes["CX_SY_MOVE_CAST_ERROR"] !== undefined) {
19
+ if (abap.Classes[targetName] && source instanceof abap.Classes[targetName] === false) {
19
20
  // @ts-ignore
20
- throw new abap.Classes["CX_SY_MOVE_CAST_ERROR"]();
21
- }
22
- else {
23
- throw "Global class CX_SY_MOVE_CAST_ERROR not found";
21
+ if (abap.Classes["CX_SY_MOVE_CAST_ERROR"] !== undefined) {
22
+ // @ts-ignore
23
+ throw new abap.Classes["CX_SY_MOVE_CAST_ERROR"]();
24
+ }
25
+ else {
26
+ throw "Global class CX_SY_MOVE_CAST_ERROR not found";
27
+ }
24
28
  }
25
29
  }
26
30
  // throw cx_sy_move_cast_error if incompatible
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",