@abaplint/runtime 2.7.97 → 2.7.98

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.
@@ -5,6 +5,7 @@ export type countInput = {
5
5
  val: ICharacter;
6
6
  sub: ICharacter;
7
7
  regex?: ICharacter;
8
+ pcre?: ICharacter;
8
9
  case?: ICharacter;
9
10
  len?: INumeric;
10
11
  off?: INumeric;
@@ -22,6 +22,9 @@ function count(input) {
22
22
  else if (input.regex) {
23
23
  reg = input.regex.get();
24
24
  }
25
+ else if (input.pcre) {
26
+ reg = input.pcre.get();
27
+ }
25
28
  let options = "g";
26
29
  if (input.case && (0, compare_1.initial)(input.case)) {
27
30
  options += "i";
@@ -8,6 +8,7 @@ export interface IFindInput {
8
8
  occ?: INumeric | number;
9
9
  len?: INumeric | number;
10
10
  regex?: ICharacter | string;
11
+ pcre?: ICharacter | string;
11
12
  case?: ICharacter | string;
12
13
  }
13
14
  export declare function find(input: IFindInput): Integer;
@@ -9,12 +9,18 @@ function find(input) {
9
9
  if (input.len !== undefined) {
10
10
  throw "transpiler find(), todo len";
11
11
  }
12
- if (input.regex) {
12
+ if (input.regex || input.pcre) {
13
13
  if (input.off !== undefined) {
14
14
  throw "transpiler find(), todo off regex";
15
15
  }
16
16
  const caseInput = typeof input.case === "string" ? input.case : (_a = input.case) === null || _a === void 0 ? void 0 : _a.get();
17
- const regex = typeof input.regex === "string" ? input.regex : input.regex.get();
17
+ let regex = "";
18
+ if (input.regex) {
19
+ regex = typeof input.regex === "string" ? input.regex : input.regex.get();
20
+ }
21
+ else if (input.pcre) {
22
+ regex = typeof input.pcre === "string" ? input.pcre : input.pcre.get();
23
+ }
18
24
  const flags = caseInput !== "X" ? "i" : "";
19
25
  const reg = new RegExp(regex, flags);
20
26
  const ret = (_b = val.match(reg)) === null || _b === void 0 ? void 0 : _b.index;
@@ -3,19 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.matches = void 0;
4
4
  const types_1 = require("../types");
5
5
  function matches(input) {
6
- if (input.pcre !== undefined) {
7
- throw "matches(), todo, pcre";
8
- }
9
- else if (input.regex === undefined) {
10
- throw "matches(), regex input expected";
6
+ if (input.pcre === undefined && input.regex === undefined) {
7
+ throw "matches(), todo";
11
8
  }
12
9
  const val = typeof input.val === "string" ? input.val : input.val.get();
13
10
  let reg = "";
14
- if (typeof input.regex === "string") {
15
- reg = input.regex;
11
+ if (input.regex) {
12
+ if (typeof input.regex === "string") {
13
+ reg = input.regex;
14
+ }
15
+ else {
16
+ reg = input.regex.get();
17
+ }
16
18
  }
17
- else {
18
- reg = input.regex.get();
19
+ else if (input.pcre) {
20
+ if (typeof input.pcre === "string") {
21
+ reg = input.pcre;
22
+ }
23
+ else {
24
+ reg = input.pcre.get();
25
+ }
19
26
  }
20
27
  const r = new RegExp("^" + reg + "$");
21
28
  const res = val.match(r);
@@ -1,6 +1,9 @@
1
1
  import { ICharacter } from "../types/_character";
2
- export declare function substring_after(input: {
2
+ interface ISubstringAfterInput {
3
3
  val: ICharacter | string;
4
4
  sub?: ICharacter | string;
5
5
  regex?: ICharacter | string;
6
- }): ICharacter;
6
+ pcre?: ICharacter | string;
7
+ }
8
+ export declare function substring_after(input: ISubstringAfterInput): ICharacter;
9
+ export {};
@@ -13,9 +13,15 @@ function substring_after(input) {
13
13
  if (typeof input.regex === "string") {
14
14
  reg = input.regex;
15
15
  }
16
+ else if (typeof input.pcre === "string") {
17
+ reg = input.pcre;
18
+ }
16
19
  else if (input === null || input === void 0 ? void 0 : input.regex) {
17
20
  reg = input.regex.get();
18
21
  }
22
+ else if (input === null || input === void 0 ? void 0 : input.pcre) {
23
+ reg = input.pcre.get();
24
+ }
19
25
  else if (typeof input.sub === "string") {
20
26
  reg = abap_regex_1.ABAPRegExp.escapeRegExp(input.sub);
21
27
  }
@@ -11,6 +11,7 @@ export interface ICreateDataOptions {
11
11
  decimals?: INumeric;
12
12
  likeLineOf?: FieldSymbol | Table;
13
13
  typeLineOf?: boolean;
14
+ refTo?: boolean;
14
15
  like?: any;
15
16
  }
16
17
  export declare function createData(target: DataReference | FieldSymbol, options?: ICreateDataOptions): void;
@@ -73,6 +73,14 @@ function createData(target, options) {
73
73
  else if (options.name.trimEnd() === "INT8") {
74
74
  target.assign(new types_1.Integer8());
75
75
  }
76
+ else if (options.refTo === true) {
77
+ // @ts-ignore
78
+ if (abap.Classes[options.name.toUpperCase()] === undefined) {
79
+ (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
80
+ }
81
+ // @ts-ignore
82
+ target.assign(new abap.types.ABAPObject({ qualifiedName: options.name, RTTIName: options.name }));
83
+ }
76
84
  else {
77
85
  (0, throw_error_1.throwError)("CX_SY_CREATE_DATA_ERROR");
78
86
  }
@@ -5,6 +5,7 @@ export interface IFindOptions {
5
5
  find?: ICharacter | string;
6
6
  first?: boolean;
7
7
  regex?: string | ICharacter | ABAPObject;
8
+ pcre?: string | ICharacter;
8
9
  offset?: INumeric;
9
10
  sectionOffset?: INumeric;
10
11
  byteMode?: boolean;
@@ -31,16 +31,21 @@ function find(input, options) {
31
31
  s = s.replace(/\+/g, "\\+");
32
32
  s = new RegExp(s, "g");
33
33
  }
34
- else if (options.regex) {
35
- if (typeof options.regex === "string") {
36
- if (options.regex === "") {
34
+ else if (options.regex || options.pcre) {
35
+ if (options.regex) {
36
+ if (typeof options.regex === "string") {
37
+ if (options.regex === "") {
38
+ throw new Error("FIND, runtime, no input, regex empty");
39
+ }
40
+ }
41
+ else if (options.regex.get() === "") {
37
42
  throw new Error("FIND, runtime, no input, regex empty");
38
43
  }
39
44
  }
40
- else if (options.regex.get() === "") {
41
- throw new Error("FIND, runtime, no input, regex empty");
42
- }
43
45
  let r = options.regex;
46
+ if (r === undefined) {
47
+ r = options.pcre;
48
+ }
44
49
  if (typeof r !== "string") {
45
50
  r = r.get();
46
51
  }
@@ -37,6 +37,7 @@ import { setBit } from "./set_bit";
37
37
  import { shift } from "./shift";
38
38
  import { sort } from "./sort";
39
39
  import { wait } from "./wait";
40
+ import { IOpenCursorDatabaseOptions } from "./open_cursor";
40
41
  import { setHandler } from "./set_handler";
41
42
  import { split } from "./split";
42
43
  import { translate } from "./translate";
@@ -95,7 +96,7 @@ export declare class Statements {
95
96
  private _trace;
96
97
  private _traceAsync;
97
98
  _setTrace(min?: number, totals?: boolean): void;
98
- openCursor(target: INumeric, select: string): Promise<void>;
99
+ openCursor(target: INumeric, select: string, options: IOpenCursorDatabaseOptions): Promise<void>;
99
100
  fetchNextCursor(cursor: INumeric, target: any, packageSize?: INumeric): Promise<void>;
100
101
  closeCursor(cursor: INumeric): Promise<void>;
101
102
  deleteDatabase(table: string | ICharacter, options: IDeleteDatabaseOptions): Promise<void>;
@@ -157,8 +157,8 @@ class Statements {
157
157
  }
158
158
  }
159
159
  }
160
- async openCursor(target, select) {
161
- const num = await (0, open_cursor_1.openCursor)(this.context, select);
160
+ async openCursor(target, select, options) {
161
+ const num = await (0, open_cursor_1.openCursor)(this.context, select, options);
162
162
  target.set(num);
163
163
  }
164
164
  async fetchNextCursor(cursor, target, packageSize) {
@@ -1,2 +1,5 @@
1
1
  import { Context } from "../context";
2
- export declare function openCursor(context: Context, select: string): Promise<number>;
2
+ export interface IOpenCursorDatabaseOptions {
3
+ connection?: string;
4
+ }
5
+ export declare function openCursor(context: Context, select: string, options: IOpenCursorDatabaseOptions): Promise<number>;
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.openCursor = void 0;
4
- async function openCursor(context, select) {
5
- const callbacks = await context.defaultDB().openCursor({ select: select });
4
+ async function openCursor(context, select, options) {
5
+ let db = context.defaultDB();
6
+ if (options === null || options === void 0 ? void 0 : options.connection) {
7
+ db = context.databaseConnections[options.connection];
8
+ }
9
+ const callbacks = await db.openCursor({ select: select });
6
10
  const num = context.cursorCounter++;
7
11
  context.cursors[num] = callbacks;
8
12
  return num;
@@ -6,6 +6,7 @@ export type replaceInput = {
6
6
  sectionLength?: INumeric;
7
7
  sectionOffset?: INumeric;
8
8
  regex?: ICharacter;
9
+ pcre?: ICharacter;
9
10
  all: boolean;
10
11
  with: ICharacter;
11
12
  of: ICharacter;
@@ -29,6 +29,7 @@ function replace(input) {
29
29
  search = new RegExp(inp, ignoreCase + allOccurrences);
30
30
  }
31
31
  else if (input.regex) {
32
+ // TODO: this is a bit wrong, ABAP regex is not like JS regex
32
33
  const regex = abap_regex_1.ABAPRegExp.convert(input.regex.get());
33
34
  if (regex.length === 0 && input.all === true) {
34
35
  throw "REPLACE, zero length input";
@@ -36,6 +37,14 @@ function replace(input) {
36
37
  found = temp.match(regex) !== null;
37
38
  search = new RegExp(regex, ignoreCase + allOccurrences);
38
39
  }
40
+ else if (input.pcre) {
41
+ const regex = abap_regex_1.ABAPRegExp.convert(input.pcre.get());
42
+ if (regex.length === 0 && input.all === true) {
43
+ throw "REPLACE, zero length input";
44
+ }
45
+ found = temp.match(regex) !== null;
46
+ search = new RegExp(regex, ignoreCase + allOccurrences);
47
+ }
39
48
  else if (input.sectionLength && input.sectionOffset) {
40
49
  const before = input.target.getOffset({ length: input.sectionOffset });
41
50
  const after = input.target.getOffset({ offset: input.sectionLength.get() + input.sectionOffset.get() });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.7.97",
3
+ "version": "2.7.98",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",