@abaplint/runtime 2.0.10 → 2.0.11

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.
@@ -0,0 +1,2 @@
1
+ import { ABAPObject } from "../types";
2
+ export declare function cast(target: ABAPObject, source: ABAPObject): Promise<void>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cast = void 0;
4
+ const compare_1 = require("../compare");
5
+ // todo, field symbols as input?
6
+ // todo, local classes?
7
+ async function cast(target, source) {
8
+ if ((0, compare_1.initial)(source)) {
9
+ target.clear();
10
+ return;
11
+ }
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) {
17
+ // @ts-ignore
18
+ if (abap.Classes["CX_SY_MOVE_CAST_ERROR"] !== undefined) {
19
+ // @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";
24
+ }
25
+ }
26
+ // throw cx_sy_move_cast_error if incompatible
27
+ // check with javascript instanceof?
28
+ // handling interfaces?
29
+ target.set(source);
30
+ }
31
+ exports.cast = cast;
32
+ //# sourceMappingURL=cast.js.map
@@ -10,6 +10,7 @@ import { createData } from "./create_data";
10
10
  import { deleteInternal } from "./delete_internal";
11
11
  import { describe } from "./describe";
12
12
  import { find } from "./find";
13
+ import { cast } from "./cast";
13
14
  import { getBit } from "./get_bit";
14
15
  import { getRunTime } from "./get_run_time";
15
16
  import { getTime } from "./get_time";
@@ -41,6 +42,7 @@ export declare class Statements {
41
42
  append: typeof append;
42
43
  assert: typeof assert;
43
44
  assign: typeof assign;
45
+ cast: typeof cast;
44
46
  clear: typeof clear;
45
47
  commit: typeof commit;
46
48
  concatenate: typeof concatenate;
@@ -13,6 +13,7 @@ const create_data_1 = require("./create_data");
13
13
  const delete_internal_1 = require("./delete_internal");
14
14
  const describe_1 = require("./describe");
15
15
  const find_1 = require("./find");
16
+ const cast_1 = require("./cast");
16
17
  const get_bit_1 = require("./get_bit");
17
18
  const get_run_time_1 = require("./get_run_time");
18
19
  const get_time_1 = require("./get_time");
@@ -43,6 +44,7 @@ class Statements {
43
44
  this.append = append_1.append;
44
45
  this.assert = assert_1.assert;
45
46
  this.assign = assign_1.assign;
47
+ this.cast = cast_1.cast;
46
48
  this.clear = clear_1.clear;
47
49
  this.commit = commit_1.commit;
48
50
  this.concatenate = concatenate_1.concatenate;
@@ -1,7 +1,11 @@
1
1
  export declare class ABAPObject {
2
2
  private value;
3
- constructor();
3
+ private readonly qualifiedName;
4
+ constructor(input?: {
5
+ qualifiedName?: string;
6
+ });
4
7
  get(): any;
5
8
  clear(): void;
9
+ getQualifiedName(): string | undefined;
6
10
  set(value: ABAPObject | any): void;
7
11
  }
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ABAPObject = void 0;
4
4
  class ABAPObject {
5
- constructor() {
6
- this.value = undefined;
5
+ constructor(input) {
6
+ this.qualifiedName = input === null || input === void 0 ? void 0 : input.qualifiedName;
7
+ this.clear();
7
8
  }
8
9
  get() {
9
10
  return this.value;
@@ -11,6 +12,9 @@ class ABAPObject {
11
12
  clear() {
12
13
  this.value = undefined;
13
14
  }
15
+ getQualifiedName() {
16
+ return this.qualifiedName;
17
+ }
14
18
  set(value) {
15
19
  if (value instanceof ABAPObject) {
16
20
  this.value = value.get();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
31
  "@types/chai": "^4.3.1",
32
- "@types/mocha": "^9.1.0",
32
+ "@types/mocha": "^9.1.1",
33
33
  "@types/sql.js": "^1.4.3",
34
34
  "chai": "^4.3.6",
35
35
  "mocha": "^9.2.2",