@abaplint/runtime 2.10.45 → 2.10.46

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,28 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.clone = clone;
4
- const types_1 = require("./types");
5
4
  function clone(obj) {
6
- if (null == obj || "object" != typeof obj) {
7
- return obj;
8
- }
9
- if (obj instanceof types_1.ABAPObject) {
10
- const n = new types_1.ABAPObject();
11
- n.set(obj.get());
12
- // @ts-ignore
13
- return n;
14
- }
15
- else if (obj instanceof types_1.DataReference) {
16
- const n = new types_1.DataReference(obj.getType());
17
- n.assign(obj.getPointer());
18
- // @ts-ignore
19
- return n;
20
- }
21
- else if (obj instanceof types_1.HexUInt8) {
22
- const n = new types_1.HexUInt8({ length: obj.getLength(), qualifiedName: obj.getQualifiedName() });
23
- n.set(obj.get());
5
+ // @ts-ignore
6
+ if (obj.clone) {
24
7
  // @ts-ignore
25
- return n;
8
+ return obj.clone();
26
9
  }
27
10
  // @ts-ignore
28
11
  const copy = new obj.constructor();
@@ -30,7 +13,7 @@ function clone(obj) {
30
13
  // @ts-ignore
31
14
  // eslint-disable-next-line no-prototype-builtins
32
15
  if (obj.hasOwnProperty(attr)) {
33
- if ("object" !== typeof obj[attr]) {
16
+ if ("object" !== typeof obj[attr] || obj[attr] === null) {
34
17
  copy[attr] = obj[attr];
35
18
  }
36
19
  else {
@@ -38,9 +21,6 @@ function clone(obj) {
38
21
  }
39
22
  }
40
23
  }
41
- if (copy["constant"]) {
42
- copy["constant"] = false;
43
- }
44
24
  return copy;
45
25
  }
46
26
  //# sourceMappingURL=clone.js.map
@@ -6,6 +6,7 @@ export declare class ABAPObject {
6
6
  qualifiedName?: string;
7
7
  RTTIName?: string;
8
8
  });
9
+ clone(): ABAPObject;
9
10
  get(): any;
10
11
  clear(): void;
11
12
  getQualifiedName(): string | undefined;
@@ -8,6 +8,11 @@ class ABAPObject {
8
8
  this.RTTIName = input?.RTTIName;
9
9
  this.clear();
10
10
  }
11
+ clone() {
12
+ const n = new ABAPObject({ qualifiedName: this.qualifiedName, RTTIName: this.RTTIName });
13
+ n.value = this.value;
14
+ return n;
15
+ }
11
16
  get() {
12
17
  return this.value;
13
18
  }
@@ -11,6 +11,7 @@ export declare class Character implements ICharacter {
11
11
  private readonly length;
12
12
  private readonly extra;
13
13
  constructor(length?: number, extra?: AbstractTypeData);
14
+ clone(): Character;
14
15
  setConstant(): this;
15
16
  set(value: ICharacter | string | Structure | FieldSymbol | Integer): this;
16
17
  getQualifiedName(): string | undefined;
@@ -20,6 +20,12 @@ class Character {
20
20
  this.extra = extra;
21
21
  this.clear();
22
22
  }
23
+ clone() {
24
+ const n = new Character(this.length, this.extra);
25
+ // set without trigger checks and padding
26
+ n.value = this.value;
27
+ return n;
28
+ }
23
29
  setConstant() {
24
30
  this.constant = true;
25
31
  return this;
@@ -12,6 +12,7 @@ export declare class DataReference {
12
12
  private pointer;
13
13
  private readonly type;
14
14
  constructor(type: PointerType);
15
+ clone(): DataReference;
15
16
  getType(): PointerType;
16
17
  assign(pointer: PointerType): void;
17
18
  unassign(): void;
@@ -21,7 +22,7 @@ export declare class DataReference {
21
22
  get(): any;
22
23
  array(): any;
23
24
  getArrayLength(): any;
24
- set(value: any): void | Integer8 | Float | ABAPObject | this | Table | Structure;
25
+ set(value: any): void | Integer8 | Float | Table | ABAPObject | Structure | this;
25
26
  getOffset(input: {
26
27
  offset?: number | INumeric | Hex;
27
28
  length?: number | INumeric | Hex;
@@ -9,6 +9,11 @@ class DataReference {
9
9
  this.pointer = undefined;
10
10
  this.type = type;
11
11
  }
12
+ clone() {
13
+ const n = new DataReference(this.type);
14
+ n.pointer = this.pointer;
15
+ return n;
16
+ }
12
17
  getType() {
13
18
  return this.type;
14
19
  }
@@ -17,7 +17,7 @@ export declare class FieldSymbol {
17
17
  unassign(): void;
18
18
  isAssigned(): boolean;
19
19
  getPointer(): any;
20
- dereference(): INumeric | ICharacter | import("./integer8").Integer8 | Float | ABAPObject | Table | Structure | undefined;
20
+ dereference(): INumeric | ICharacter | import("./integer8").Integer8 | Float | Table | ABAPObject | Structure | undefined;
21
21
  clear(): void | Structure | undefined;
22
22
  get(): any;
23
23
  appendInitial(): import("./table").TableRowType | undefined;
@@ -14,6 +14,7 @@ export declare class HexUInt8 implements ICharacter {
14
14
  qualifiedName?: string;
15
15
  });
16
16
  getQualifiedName(): string | undefined;
17
+ clone(): HexUInt8;
17
18
  setOffset(offset: number, value: number): void;
18
19
  getOffsetRaw(offset: number): number;
19
20
  set(value: ICharacter | INumeric | string | number | Integer | Integer8 | Float | Hex | XString): HexUInt8;
@@ -22,6 +22,11 @@ class HexUInt8 {
22
22
  getQualifiedName() {
23
23
  return this.qualifiedName;
24
24
  }
25
+ clone() {
26
+ const n = new HexUInt8({ length: this.length, qualifiedName: this.qualifiedName });
27
+ n.value = this.value.slice(0);
28
+ return n;
29
+ }
25
30
  setOffset(offset, value) {
26
31
  // caller must validate offset
27
32
  this.value[offset] = value;
@@ -14,6 +14,7 @@ export declare class Integer implements INumeric {
14
14
  qualifiedName?: string;
15
15
  });
16
16
  getQualifiedName(): string | undefined;
17
+ clone(): Integer;
17
18
  setConstant(): this;
18
19
  set(value: INumeric | ICharacter | Hex | string | number | Integer | Float): this;
19
20
  clear(): void;
@@ -37,6 +37,12 @@ class Integer {
37
37
  getQualifiedName() {
38
38
  return this.qualifiedName;
39
39
  }
40
+ clone() {
41
+ const n = new Integer({ qualifiedName: this.qualifiedName });
42
+ // set without trigger checks and padding
43
+ n.value = this.value;
44
+ return n;
45
+ }
40
46
  setConstant() {
41
47
  this.constant = true;
42
48
  return this;
@@ -11,6 +11,7 @@ export declare class Structure {
11
11
  private readonly suffix;
12
12
  private readonly asInclude;
13
13
  constructor(fields: any, qualifiedName?: string, ddicName?: string, suffix?: any, asInclude?: any);
14
+ clone(): Structure;
14
15
  clear(): this;
15
16
  getDDICName(): string | undefined;
16
17
  getRenamingSuffix(): {
@@ -15,9 +15,12 @@ class Structure {
15
15
  this.suffix = suffix;
16
16
  this.asInclude = asInclude;
17
17
  }
18
+ clone() {
19
+ const n = new Structure((0, clone_1.clone)(this.value), this.qualifiedName, this.ddicName, this.suffix, this.asInclude);
20
+ return n;
21
+ }
18
22
  clear() {
19
23
  for (const f in this.value) {
20
- // @ts-ignore
21
24
  this.value[f].clear();
22
25
  }
23
26
  return this;
@@ -48,21 +51,11 @@ class Structure {
48
51
  const obj = input.get();
49
52
  const keys1 = Object.keys(obj);
50
53
  const keys2 = Object.keys(this.value);
51
- /*
52
- console.dir(keys1);
53
- console.dir(keys2);
54
- */
55
54
  for (let i = 0; i < keys1.length; i++) {
56
55
  const key1 = keys1[i];
57
56
  const key2 = keys2[i];
58
57
  this.value[key2].set((0, clone_1.clone)(obj[key1]));
59
58
  }
60
- /*
61
- for (const f in obj) {
62
- // @ts-ignore
63
- this.value[f].set(clone(obj[f]));
64
- }
65
- */
66
59
  }
67
60
  else {
68
61
  this.setCharacter(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.10.45",
3
+ "version": "2.10.46",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",