From 3273c3b3b045bb12492f5a531bab1b39c1b2280a Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 06:47:11 +0200 Subject: [PATCH 01/19] cleanup --- src/zcl_protobuf.clas.abap | 35 -------------------------- src/zcl_protobuf.clas.testclasses.abap | 23 ----------------- src/zcl_protobuf.clas.xml | 17 ------------- src/zif_protobuf.intf.abap | 3 --- src/zif_protobuf.intf.xml | 15 ----------- 5 files changed, 93 deletions(-) delete mode 100644 src/zcl_protobuf.clas.abap delete mode 100644 src/zcl_protobuf.clas.testclasses.abap delete mode 100644 src/zcl_protobuf.clas.xml delete mode 100644 src/zif_protobuf.intf.abap delete mode 100644 src/zif_protobuf.intf.xml diff --git a/src/zcl_protobuf.clas.abap b/src/zcl_protobuf.clas.abap deleted file mode 100644 index ef05d3f..0000000 --- a/src/zcl_protobuf.clas.abap +++ /dev/null @@ -1,35 +0,0 @@ -CLASS zcl_protobuf DEFINITION - PUBLIC - CREATE PRIVATE . - - PUBLIC SECTION. - - INTERFACES zif_protobuf . - - CLASS-METHODS create - IMPORTING - !iv_hex TYPE xstring OPTIONAL - RETURNING - VALUE(ri_protobuf) TYPE REF TO zif_protobuf . - METHODS constructor - IMPORTING - !iv_hex2 TYPE xstring . - PROTECTED SECTION. - PRIVATE SECTION. - DATA mo_stream TYPE REF TO zcl_protobuf_stream. -ENDCLASS. - - - -CLASS ZCL_PROTOBUF IMPLEMENTATION. - - - METHOD constructor. - mo_stream = NEW #( iv_hex2 ). - ENDMETHOD. - - - METHOD create. - ri_protobuf = NEW zcl_protobuf( iv_hex ). - ENDMETHOD. -ENDCLASS. diff --git a/src/zcl_protobuf.clas.testclasses.abap b/src/zcl_protobuf.clas.testclasses.abap deleted file mode 100644 index 102398b..0000000 --- a/src/zcl_protobuf.clas.testclasses.abap +++ /dev/null @@ -1,23 +0,0 @@ -CLASS ltcl_test DEFINITION FOR TESTING - DURATION SHORT - RISK LEVEL HARMLESS - FINAL. - - PRIVATE SECTION. - DATA mi_cut TYPE REF TO zif_protobuf. - METHODS setup. - METHODS test1 FOR TESTING RAISING cx_static_check. - -ENDCLASS. - -CLASS ltcl_test IMPLEMENTATION. - - METHOD setup. - mi_cut = zcl_protobuf=>create( ). - ENDMETHOD. - - METHOD test1. - RETURN. " todo - ENDMETHOD. - -ENDCLASS. diff --git a/src/zcl_protobuf.clas.xml b/src/zcl_protobuf.clas.xml deleted file mode 100644 index 61bf17c..0000000 --- a/src/zcl_protobuf.clas.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - ZCL_PROTOBUF - E - ZCL_PROTOBUF - 1 - X - X - X - X - - - - diff --git a/src/zif_protobuf.intf.abap b/src/zif_protobuf.intf.abap deleted file mode 100644 index e292671..0000000 --- a/src/zif_protobuf.intf.abap +++ /dev/null @@ -1,3 +0,0 @@ -INTERFACE zif_protobuf PUBLIC. - -ENDINTERFACE. diff --git a/src/zif_protobuf.intf.xml b/src/zif_protobuf.intf.xml deleted file mode 100644 index e641dc4..0000000 --- a/src/zif_protobuf.intf.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - ZIF_PROTOBUF - E - ZIF_PROTOBUF - 2 - 1 - X - - - - From c7c95d33758194ff878cac26bc6397d16e303b17 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 06:52:22 +0200 Subject: [PATCH 02/19] wip --- src/generator/package.devc.xml | 10 ++++++ .../zcl_protobuf_generator.clas.abap | 21 +++++++++++++ ...l_protobuf_generator.clas.testclasses.abap | 31 +++++++++++++++++++ src/generator/zcl_protobuf_generator.clas.xml | 17 ++++++++++ src/stream/package.devc.xml | 10 ++++++ .../zcl_protobuf_stream.clas.abap | 0 .../zcl_protobuf_stream.clas.testclasses.abap | 0 src/{ => stream}/zcl_protobuf_stream.clas.xml | 0 8 files changed, 89 insertions(+) create mode 100644 src/generator/package.devc.xml create mode 100644 src/generator/zcl_protobuf_generator.clas.abap create mode 100644 src/generator/zcl_protobuf_generator.clas.testclasses.abap create mode 100644 src/generator/zcl_protobuf_generator.clas.xml create mode 100644 src/stream/package.devc.xml rename src/{ => stream}/zcl_protobuf_stream.clas.abap (100%) rename src/{ => stream}/zcl_protobuf_stream.clas.testclasses.abap (100%) rename src/{ => stream}/zcl_protobuf_stream.clas.xml (100%) diff --git a/src/generator/package.devc.xml b/src/generator/package.devc.xml new file mode 100644 index 0000000..4af80c4 --- /dev/null +++ b/src/generator/package.devc.xml @@ -0,0 +1,10 @@ + + + + + + abap-protobuf + + + + diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap new file mode 100644 index 0000000..b8de331 --- /dev/null +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -0,0 +1,21 @@ +CLASS zcl_protobuf_generator DEFINITION PUBLIC. + PUBLIC SECTION. + CLASS-METHODS generate + IMPORTING + io_file TYPE REF TO zcl_protobuf2_file + RETURNING + VALUE(rv_abap) TYPE string. + PRIVATE SECTION. +ENDCLASS. + +CLASS zcl_protobuf_generator IMPLEMENTATION. + + METHOD generate. + + LOOP AT io_file->mt_artefacts INTO DATA(lo_artefact). + rv_abap = 'sdfs'. + ENDLOOP. + + ENDMETHOD. + +ENDCLASS. diff --git a/src/generator/zcl_protobuf_generator.clas.testclasses.abap b/src/generator/zcl_protobuf_generator.clas.testclasses.abap new file mode 100644 index 0000000..fccd32d --- /dev/null +++ b/src/generator/zcl_protobuf_generator.clas.testclasses.abap @@ -0,0 +1,31 @@ +CLASS ltcl_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS FINAL. + PRIVATE SECTION. + METHODS test FOR TESTING RAISING cx_static_check. +ENDCLASS. + +CLASS ltcl_test IMPLEMENTATION. + + METHOD test. + + DATA(lv_proto) = + |syntax = "proto2";\n| && + |message Point \{\n| && + | required int32 x = 1;\n| && + | required int32 y = 2;\n| && + | optional string label = 3;\n| && + |\}\n| && + |message Line \{\n| && + | required Point start = 1;\n| && + | required Point end = 2;\n| && + | optional string label = 3;\n| && + |\}\n| && + |message Polyline \{\n| && + | repeated Point point = 1;\n| && + | optional string label = 2;\n| && + |\}|. + + zcl_protobuf_generator=>generate( zcl_protobuf2_parser=>parse( lv_proto ) ). + + ENDMETHOD. + +ENDCLASS. diff --git a/src/generator/zcl_protobuf_generator.clas.xml b/src/generator/zcl_protobuf_generator.clas.xml new file mode 100644 index 0000000..4c12f2a --- /dev/null +++ b/src/generator/zcl_protobuf_generator.clas.xml @@ -0,0 +1,17 @@ + + + + + + ZCL_PROTOBUF_GENERATOR + E + ZCL_PROTOBUF_GENERATOR + 1 + X + X + X + X + + + + diff --git a/src/stream/package.devc.xml b/src/stream/package.devc.xml new file mode 100644 index 0000000..4af80c4 --- /dev/null +++ b/src/stream/package.devc.xml @@ -0,0 +1,10 @@ + + + + + + abap-protobuf + + + + diff --git a/src/zcl_protobuf_stream.clas.abap b/src/stream/zcl_protobuf_stream.clas.abap similarity index 100% rename from src/zcl_protobuf_stream.clas.abap rename to src/stream/zcl_protobuf_stream.clas.abap diff --git a/src/zcl_protobuf_stream.clas.testclasses.abap b/src/stream/zcl_protobuf_stream.clas.testclasses.abap similarity index 100% rename from src/zcl_protobuf_stream.clas.testclasses.abap rename to src/stream/zcl_protobuf_stream.clas.testclasses.abap diff --git a/src/zcl_protobuf_stream.clas.xml b/src/stream/zcl_protobuf_stream.clas.xml similarity index 100% rename from src/zcl_protobuf_stream.clas.xml rename to src/stream/zcl_protobuf_stream.clas.xml From 5846ad182c6f8d983dbc1ae594d272d0a3690e4f Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 06:59:40 +0200 Subject: [PATCH 03/19] update --- src/model/zcl_protobuf2_enum.clas.abap | 2 +- src/model/zcl_protobuf2_message.clas.abap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/model/zcl_protobuf2_enum.clas.abap b/src/model/zcl_protobuf2_enum.clas.abap index 48f4101..c0dfe7d 100644 --- a/src/model/zcl_protobuf2_enum.clas.abap +++ b/src/model/zcl_protobuf2_enum.clas.abap @@ -28,7 +28,7 @@ CLASS zcl_protobuf2_enum IMPLEMENTATION. lv_spaces = repeat( val = | | occ = iv_nesting ). - rv_string = rv_string && lv_spaces && |}|. + rv_string = rv_string && lv_spaces && |\}|. ENDMETHOD. ENDCLASS. diff --git a/src/model/zcl_protobuf2_message.clas.abap b/src/model/zcl_protobuf2_message.clas.abap index 8c60364..1027e99 100644 --- a/src/model/zcl_protobuf2_message.clas.abap +++ b/src/model/zcl_protobuf2_message.clas.abap @@ -25,7 +25,7 @@ CLASS zcl_protobuf2_message IMPLEMENTATION. lv_spaces = repeat( val = | | occ = iv_nesting ). - rv_string = rv_string && lv_spaces && |}|. + rv_string = rv_string && lv_spaces && |\}|. ENDMETHOD. ENDCLASS. From 528a5490351fa6643a11d666372a8ffb0fd0bf1a Mon Sep 17 00:00:00 2001 From: larshp Date: Fri, 18 Aug 2023 05:00:19 +0000 Subject: [PATCH 04/19] add boms --- src/generator/zcl_protobuf_generator.clas.xml | 2 +- src/model/zcl_protobuf2_enum.clas.xml | 4 ++-- src/model/zcl_protobuf2_field.clas.xml | 4 ++-- src/model/zif_protobuf2_artefact.intf.xml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.xml b/src/generator/zcl_protobuf_generator.clas.xml index 4c12f2a..aec89f2 100644 --- a/src/generator/zcl_protobuf_generator.clas.xml +++ b/src/generator/zcl_protobuf_generator.clas.xml @@ -1,4 +1,4 @@ - + diff --git a/src/model/zcl_protobuf2_enum.clas.xml b/src/model/zcl_protobuf2_enum.clas.xml index fcb88b0..8d24898 100644 --- a/src/model/zcl_protobuf2_enum.clas.xml +++ b/src/model/zcl_protobuf2_enum.clas.xml @@ -1,4 +1,4 @@ - + @@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/src/model/zcl_protobuf2_field.clas.xml b/src/model/zcl_protobuf2_field.clas.xml index 303817b..05c77c9 100644 --- a/src/model/zcl_protobuf2_field.clas.xml +++ b/src/model/zcl_protobuf2_field.clas.xml @@ -1,4 +1,4 @@ - + @@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/src/model/zif_protobuf2_artefact.intf.xml b/src/model/zif_protobuf2_artefact.intf.xml index 8a76c23..8570419 100644 --- a/src/model/zif_protobuf2_artefact.intf.xml +++ b/src/model/zif_protobuf2_artefact.intf.xml @@ -1,4 +1,4 @@ - + From e1565e71636f2555ba1ae8ad3e4149852a15d0fa Mon Sep 17 00:00:00 2001 From: larshp Date: Fri, 18 Aug 2023 05:02:49 +0000 Subject: [PATCH 05/19] syntax fixes --- src/parser/zcl_protobuf2_parser.clas.abap | 9 +++++++-- src/parser/zcl_protobuf2_parser.clas.locals_imp.abap | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/parser/zcl_protobuf2_parser.clas.abap b/src/parser/zcl_protobuf2_parser.clas.abap index 2560477..82e2615 100644 --- a/src/parser/zcl_protobuf2_parser.clas.abap +++ b/src/parser/zcl_protobuf2_parser.clas.abap @@ -40,7 +40,8 @@ ENDCLASS. -CLASS zcl_protobuf2_parser IMPLEMENTATION. +CLASS ZCL_PROTOBUF2_PARSER IMPLEMENTATION. + METHOD enum. * https://protobuf.dev/reference/protobuf/proto2-spec/#enum_definition @@ -59,6 +60,7 @@ CLASS zcl_protobuf2_parser IMPLEMENTATION. ENDMETHOD. + METHOD field. * https://protobuf.dev/reference/protobuf/proto2-spec/#fields @@ -72,6 +74,7 @@ CLASS zcl_protobuf2_parser IMPLEMENTATION. ro_field->mv_options = io_stream->get( ). ENDMETHOD. + METHOD message. * https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#message_definition ro_message = NEW #( io_stream->take_token( ) ). @@ -112,6 +115,7 @@ CLASS zcl_protobuf2_parser IMPLEMENTATION. ro_file = traverse( NEW lcl_stream( lv_proto ) ). ENDMETHOD. + METHOD remove_comments. DATA lv_start TYPE i. DATA lv_end TYPE i. @@ -138,11 +142,12 @@ CLASS zcl_protobuf2_parser IMPLEMENTATION. = (lv_start). ENDIF. ENDLOOP. - CONCATENATE LINES OF lt_lines INTO rv_output SEPARATED BY |\n|. + CONCATENATE LINES OF lt_lines INTO rv_output SEPARATED BY cl_abap_char_utilities=>newline. CONDENSE rv_output. ENDMETHOD. + METHOD traverse. * https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#proto_file diff --git a/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap b/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap index 74edb64..4f5b903 100644 --- a/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap +++ b/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap @@ -52,11 +52,13 @@ CLASS lcl_stream IMPLEMENTATION. METHOD take_statement. DATA lv_offset TYPE i. + DATA lv_tmp TYPE string. FIND FIRST OCCURRENCE OF |;| IN mv_str MATCH OFFSET lv_offset. ASSERT sy-subrc = 0. - ro_stream = NEW #( mv_str(lv_offset) ). + lv_tmp = mv_str(lv_offset). + ro_stream = NEW #( lv_tmp ). lv_offset = lv_offset + 1. mv_str = mv_str+lv_offset. From f9185b07b05f0bf53576aa29dc90da69514c66cc Mon Sep 17 00:00:00 2001 From: larshp Date: Fri, 18 Aug 2023 05:06:07 +0000 Subject: [PATCH 06/19] case type --- src/generator/zcl_protobuf_generator.clas.abap | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index b8de331..af38cbd 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -5,17 +5,26 @@ CLASS zcl_protobuf_generator DEFINITION PUBLIC. io_file TYPE REF TO zcl_protobuf2_file RETURNING VALUE(rv_abap) TYPE string. + PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. -CLASS zcl_protobuf_generator IMPLEMENTATION. + + +CLASS ZCL_PROTOBUF_GENERATOR IMPLEMENTATION. + METHOD generate. LOOP AT io_file->mt_artefacts INTO DATA(lo_artefact). rv_abap = 'sdfs'. + CASE TYPE OF lo_artefact. + WHEN TYPE zcl_protobuf2_message. + BREAK-POINT. + WHEN OTHERS. + BREAK-POINT. + ENDCASE. ENDLOOP. ENDMETHOD. - ENDCLASS. From 1c9139e933dfe1e1e1e41e4b4f9bedbab19b827b Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 07:20:03 +0200 Subject: [PATCH 07/19] update --- abaplint.json | 2 +- abaplint_downport.json | 2 +- src/generator/zcl_protobuf_generator.clas.abap | 6 +++--- src/parser/zcl_protobuf2_parser.clas.locals_imp.abap | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/abaplint.json b/abaplint.json index da2c1ca..59dffb8 100644 --- a/abaplint.json +++ b/abaplint.json @@ -13,7 +13,7 @@ } ], "syntax": { - "version": "v740sp02", + "version": "v750", "errorNamespace": "." }, "rules": { diff --git a/abaplint_downport.json b/abaplint_downport.json index 8bba7ce..1e6764d 100644 --- a/abaplint_downport.json +++ b/abaplint_downport.json @@ -14,7 +14,7 @@ } ], "syntax": { - "version": "v702", + "version": "open-abap", "errorNamespace": "" }, "rules": { diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index af38cbd..2733609 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -11,7 +11,7 @@ ENDCLASS. -CLASS ZCL_PROTOBUF_GENERATOR IMPLEMENTATION. +CLASS zcl_protobuf_generator IMPLEMENTATION. METHOD generate. @@ -20,9 +20,9 @@ CLASS ZCL_PROTOBUF_GENERATOR IMPLEMENTATION. rv_abap = 'sdfs'. CASE TYPE OF lo_artefact. WHEN TYPE zcl_protobuf2_message. - BREAK-POINT. + WRITE / 'todo'. WHEN OTHERS. - BREAK-POINT. + WRITE / 'todo'. ENDCASE. ENDLOOP. diff --git a/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap b/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap index 4f5b903..3b9236c 100644 --- a/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap +++ b/src/parser/zcl_protobuf2_parser.clas.locals_imp.abap @@ -9,7 +9,7 @@ CLASS lcl_stream IMPLEMENTATION. ENDMETHOD. METHOD is_empty. - rv_empty = boolc( strlen( condense( mv_str ) ) = 0 ). + rv_empty = xsdbool( strlen( condense( mv_str ) ) = 0 ). ENDMETHOD. METHOD take_token. From 2a6a9b15ba855b5085c2bf042e50bfd8d6c3f36e Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 07:21:29 +0200 Subject: [PATCH 08/19] wip --- src/generator/zcl_protobuf_generator.clas.abap | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index 2733609..8128d5a 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -7,24 +7,30 @@ CLASS zcl_protobuf_generator DEFINITION PUBLIC. VALUE(rv_abap) TYPE string. PROTECTED SECTION. PRIVATE SECTION. + METHODS message + IMPORTING + io_message TYPE REF TO zcl_protobuf2_message. ENDCLASS. CLASS zcl_protobuf_generator IMPLEMENTATION. - METHOD generate. LOOP AT io_file->mt_artefacts INTO DATA(lo_artefact). rv_abap = 'sdfs'. CASE TYPE OF lo_artefact. - WHEN TYPE zcl_protobuf2_message. - WRITE / 'todo'. + WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message). + message( lo_message ). WHEN OTHERS. WRITE / 'todo'. ENDCASE. ENDLOOP. ENDMETHOD. + + METHOD message. +* todo + ENDMETHOD. ENDCLASS. From 5ab65d72f66799dc392790696195ca9d9a12d6a1 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 08:55:21 +0200 Subject: [PATCH 09/19] update --- package-lock.json | 42 +++++++++++++++++++++--------------------- package.json | 6 +++--- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca28f46..25e816d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,15 @@ "version": "1.0.0", "license": "MIT", "devDependencies": { - "@abaplint/cli": "^2.102.22", - "@abaplint/runtime": "^2.7.74", - "@abaplint/transpiler-cli": "^2.7.74" + "@abaplint/cli": "^2.102.23", + "@abaplint/runtime": "^2.7.75", + "@abaplint/transpiler-cli": "^2.7.75" } }, "node_modules/@abaplint/cli": { - "version": "2.102.22", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.22.tgz", - "integrity": "sha512-BNVvb6Fk1/h1HvfsRL0tph28/MN1hdRLZRQwu0Rn2y0VPtUFj/yS+b7qiLEhNF8XJSFsY+Kv6IwBU9efDCyt3A==", + "version": "2.102.23", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.23.tgz", + "integrity": "sha512-2duRhFYUb0KqSKky8rE/IIF9GQZ7CTPSX7nVpiZiMBQAdhTapssnXg8WL7Y1xhdZ8zbNwWWALFoBSsNnPXLjdA==", "dev": true, "bin": { "abaplint": "abaplint" @@ -30,9 +30,9 @@ } }, "node_modules/@abaplint/runtime": { - "version": "2.7.74", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.74.tgz", - "integrity": "sha512-+IECl1aLnLPwCNu8Kkcup2a5BTwEPKHAANVveGA76yxReuCtqCMaw/2hfDNQipO7iLN5WpEmL831JUcSuvR+ew==", + "version": "2.7.75", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.75.tgz", + "integrity": "sha512-XYeB43PNtwUk8gIJzahQzrmSr2WiV9fswk6akhrTvNYd0qaX85iv09OoSnNHJGbOF1wZ5D6LSGWVhdKyyxrW1g==", "dev": true, "dependencies": { "temporal-polyfill": "^0.1.1" @@ -42,9 +42,9 @@ } }, "node_modules/@abaplint/transpiler-cli": { - "version": "2.7.74", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.74.tgz", - "integrity": "sha512-0YU6TylvOW/hP1XGDKxCEGyg/pe7wn66+8sgyDJbpi7cZyoWNrlsVvvIX803m7BjYwpawPLmkqdyPUkoUhXuFw==", + "version": "2.7.75", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.75.tgz", + "integrity": "sha512-mdgkXjsWVT7CsNxM9OGRZwF28StTFprpciNu8laTu4/0tMwF1rsnewVfej9v3MEZfO8rlkHm0homIqHZiJXzhw==", "dev": true, "bin": { "abap_transpile": "abap_transpile" @@ -71,24 +71,24 @@ }, "dependencies": { "@abaplint/cli": { - "version": "2.102.22", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.22.tgz", - "integrity": "sha512-BNVvb6Fk1/h1HvfsRL0tph28/MN1hdRLZRQwu0Rn2y0VPtUFj/yS+b7qiLEhNF8XJSFsY+Kv6IwBU9efDCyt3A==", + "version": "2.102.23", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.23.tgz", + "integrity": "sha512-2duRhFYUb0KqSKky8rE/IIF9GQZ7CTPSX7nVpiZiMBQAdhTapssnXg8WL7Y1xhdZ8zbNwWWALFoBSsNnPXLjdA==", "dev": true }, "@abaplint/runtime": { - "version": "2.7.74", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.74.tgz", - "integrity": "sha512-+IECl1aLnLPwCNu8Kkcup2a5BTwEPKHAANVveGA76yxReuCtqCMaw/2hfDNQipO7iLN5WpEmL831JUcSuvR+ew==", + "version": "2.7.75", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.75.tgz", + "integrity": "sha512-XYeB43PNtwUk8gIJzahQzrmSr2WiV9fswk6akhrTvNYd0qaX85iv09OoSnNHJGbOF1wZ5D6LSGWVhdKyyxrW1g==", "dev": true, "requires": { "temporal-polyfill": "^0.1.1" } }, "@abaplint/transpiler-cli": { - "version": "2.7.74", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.74.tgz", - "integrity": "sha512-0YU6TylvOW/hP1XGDKxCEGyg/pe7wn66+8sgyDJbpi7cZyoWNrlsVvvIX803m7BjYwpawPLmkqdyPUkoUhXuFw==", + "version": "2.7.75", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.75.tgz", + "integrity": "sha512-mdgkXjsWVT7CsNxM9OGRZwF28StTFprpciNu8laTu4/0tMwF1rsnewVfej9v3MEZfO8rlkHm0homIqHZiJXzhw==", "dev": true }, "temporal-polyfill": { diff --git a/package.json b/package.json index 0e1224c..8b907bf 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ }, "homepage": "https://github.com/heliconialabs/abap-protobuf#readme", "devDependencies": { - "@abaplint/cli": "^2.102.22", - "@abaplint/runtime": "^2.7.74", - "@abaplint/transpiler-cli": "^2.7.74" + "@abaplint/cli": "^2.102.23", + "@abaplint/runtime": "^2.7.75", + "@abaplint/transpiler-cli": "^2.7.75" } } From d8a8168f28506ab5e5009bd66b3a287b52b1bfe1 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 08:58:18 +0200 Subject: [PATCH 10/19] update --- src/generator/zcl_protobuf_generator.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index 8128d5a..c989ccb 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -7,7 +7,7 @@ CLASS zcl_protobuf_generator DEFINITION PUBLIC. VALUE(rv_abap) TYPE string. PROTECTED SECTION. PRIVATE SECTION. - METHODS message + CLASS-METHODS message IMPORTING io_message TYPE REF TO zcl_protobuf2_message. ENDCLASS. From fe8ca66651d2c5928c6dcc7c567186e92ace9f74 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 09:44:00 +0200 Subject: [PATCH 11/19] update --- .../zcl_protobuf_generator.clas.abap | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index c989ccb..15ffeb2 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -9,7 +9,19 @@ CLASS zcl_protobuf_generator DEFINITION PUBLIC. PRIVATE SECTION. CLASS-METHODS message IMPORTING - io_message TYPE REF TO zcl_protobuf2_message. + io_message TYPE REF TO zcl_protobuf2_message + RETURNING + VALUE(rv_abap) TYPE string. + " CLASS-METHODS enum + " IMPORTING + " io_enum TYPE REF TO zcl_protobuf2_enum + " RETURNING + " VALUE(rv_abap) TYPE string. + " CLASS-METHODS field + " IMPORTING + " io_field TYPE REF TO zcl_protobuf2_field + " RETURNING + " VALUE(rv_abap) TYPE string. ENDCLASS. @@ -18,11 +30,12 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. METHOD generate. + rv_abap = 'sdfs'. + LOOP AT io_file->mt_artefacts INTO DATA(lo_artefact). - rv_abap = 'sdfs'. CASE TYPE OF lo_artefact. WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message). - message( lo_message ). + rv_abap = rv_abap && message( lo_message ). WHEN OTHERS. WRITE / 'todo'. ENDCASE. @@ -31,6 +44,35 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. ENDMETHOD. METHOD message. -* todo + + rv_abap = 'sdfs'. + + LOOP AT io_message->mt_artefacts INTO DATA(lo_artefact). + CASE TYPE OF lo_artefact. + WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message). + rv_abap = rv_abap && message( lo_message ). + " WHEN TYPE zcl_protobuf2_enum INTO DATA(lo_enum). + " rv_abap = rv_abap && enum( lo_enum ). + " WHEN TYPE zcl_protobuf2_field INTO DATA(lo_field). + " rv_abap = rv_abap && field( lo_field ). + WHEN OTHERS. + WRITE / 'todo'. + ENDCASE. + ENDLOOP. + ENDMETHOD. + + " METHOD enum. + + " rv_abap = 'sdfs'. + + " LOOP AT io_enum->mt_fields INTO DATA(ls_field). + " rv_abap = rv_abap && ls_field-name. + " ENDLOOP. + + " ENDMETHOD. + + " METHOD field. + " rv_abap = io_field->mv_field_name. + " ENDMETHOD. ENDCLASS. From 2e2c27f9c422bd112732d66270a42390e7165eeb Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 10:09:51 +0200 Subject: [PATCH 12/19] update --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25e816d..cf9179d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,15 +9,15 @@ "version": "1.0.0", "license": "MIT", "devDependencies": { - "@abaplint/cli": "^2.102.23", + "@abaplint/cli": "^2.102.24", "@abaplint/runtime": "^2.7.75", "@abaplint/transpiler-cli": "^2.7.75" } }, "node_modules/@abaplint/cli": { - "version": "2.102.23", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.23.tgz", - "integrity": "sha512-2duRhFYUb0KqSKky8rE/IIF9GQZ7CTPSX7nVpiZiMBQAdhTapssnXg8WL7Y1xhdZ8zbNwWWALFoBSsNnPXLjdA==", + "version": "2.102.24", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.24.tgz", + "integrity": "sha512-P/Q8F2JA+F79ARi9/PFqG40npPD9i1S6HfZL7s3roLgnOnx4jgRSsmIvklaeR5R5+Nuytlnd+9o7D/9TTAO3sQ==", "dev": true, "bin": { "abaplint": "abaplint" @@ -71,9 +71,9 @@ }, "dependencies": { "@abaplint/cli": { - "version": "2.102.23", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.23.tgz", - "integrity": "sha512-2duRhFYUb0KqSKky8rE/IIF9GQZ7CTPSX7nVpiZiMBQAdhTapssnXg8WL7Y1xhdZ8zbNwWWALFoBSsNnPXLjdA==", + "version": "2.102.24", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.102.24.tgz", + "integrity": "sha512-P/Q8F2JA+F79ARi9/PFqG40npPD9i1S6HfZL7s3roLgnOnx4jgRSsmIvklaeR5R5+Nuytlnd+9o7D/9TTAO3sQ==", "dev": true }, "@abaplint/runtime": { diff --git a/package.json b/package.json index 8b907bf..09f8a34 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/heliconialabs/abap-protobuf#readme", "devDependencies": { - "@abaplint/cli": "^2.102.23", + "@abaplint/cli": "^2.102.24", "@abaplint/runtime": "^2.7.75", "@abaplint/transpiler-cli": "^2.7.75" } From 491c80447dfc762ec03d34bd254f0e223abdd433 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 10:12:32 +0200 Subject: [PATCH 13/19] update --- .../zcl_protobuf_generator.clas.abap | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index 15ffeb2..eca31a1 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -12,16 +12,16 @@ CLASS zcl_protobuf_generator DEFINITION PUBLIC. io_message TYPE REF TO zcl_protobuf2_message RETURNING VALUE(rv_abap) TYPE string. - " CLASS-METHODS enum - " IMPORTING - " io_enum TYPE REF TO zcl_protobuf2_enum - " RETURNING - " VALUE(rv_abap) TYPE string. - " CLASS-METHODS field - " IMPORTING - " io_field TYPE REF TO zcl_protobuf2_field - " RETURNING - " VALUE(rv_abap) TYPE string. + CLASS-METHODS enum + IMPORTING + io_enum TYPE REF TO zcl_protobuf2_enum + RETURNING + VALUE(rv_abap) TYPE string. + CLASS-METHODS field + IMPORTING + io_field TYPE REF TO zcl_protobuf2_field + RETURNING + VALUE(rv_abap) TYPE string. ENDCLASS. @@ -51,10 +51,10 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. CASE TYPE OF lo_artefact. WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message). rv_abap = rv_abap && message( lo_message ). - " WHEN TYPE zcl_protobuf2_enum INTO DATA(lo_enum). - " rv_abap = rv_abap && enum( lo_enum ). - " WHEN TYPE zcl_protobuf2_field INTO DATA(lo_field). - " rv_abap = rv_abap && field( lo_field ). + WHEN TYPE zcl_protobuf2_enum INTO DATA(lo_enum). + rv_abap = rv_abap && enum( lo_enum ). + WHEN TYPE zcl_protobuf2_field INTO DATA(lo_field). + rv_abap = rv_abap && field( lo_field ). WHEN OTHERS. WRITE / 'todo'. ENDCASE. @@ -62,17 +62,17 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. ENDMETHOD. - " METHOD enum. + METHOD enum. - " rv_abap = 'sdfs'. + rv_abap = 'sdfs'. - " LOOP AT io_enum->mt_fields INTO DATA(ls_field). - " rv_abap = rv_abap && ls_field-name. - " ENDLOOP. + LOOP AT io_enum->mt_fields INTO DATA(ls_field). + rv_abap = rv_abap && ls_field-name. + ENDLOOP. - " ENDMETHOD. + ENDMETHOD. - " METHOD field. - " rv_abap = io_field->mv_field_name. - " ENDMETHOD. + METHOD field. + rv_abap = io_field->mv_field_name. + ENDMETHOD. ENDCLASS. From 9d0a2f4a97ba47ef21b74dfb59c0fe6253c6ba31 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 10:20:09 +0200 Subject: [PATCH 14/19] update --- src/generator/zcl_protobuf_generator.clas.abap | 18 ++++++++++-------- ...cl_protobuf_generator.clas.testclasses.abap | 3 ++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index eca31a1..f436503 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -30,14 +30,12 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. METHOD generate. - rv_abap = 'sdfs'. - LOOP AT io_file->mt_artefacts INTO DATA(lo_artefact). CASE TYPE OF lo_artefact. WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message). rv_abap = rv_abap && message( lo_message ). WHEN OTHERS. - WRITE / 'todo'. + ASSERT 1 = 'todo'. ENDCASE. ENDLOOP. @@ -45,7 +43,7 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. METHOD message. - rv_abap = 'sdfs'. + rv_abap = |TYPES BEGIN OF { io_message->mv_name }.\n|. LOOP AT io_message->mt_artefacts INTO DATA(lo_artefact). CASE TYPE OF lo_artefact. @@ -56,23 +54,27 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. WHEN TYPE zcl_protobuf2_field INTO DATA(lo_field). rv_abap = rv_abap && field( lo_field ). WHEN OTHERS. - WRITE / 'todo'. + ASSERT 1 = 'todo'. ENDCASE. ENDLOOP. + rv_abap = rv_abap && |TYPES END OF { io_message->mv_name }.\n|. + ENDMETHOD. METHOD enum. - rv_abap = 'sdfs'. + rv_abap = |TYPES BEGIN OF ENUM { io_enum->mv_name }.\n|. LOOP AT io_enum->mt_fields INTO DATA(ls_field). - rv_abap = rv_abap && ls_field-name. + rv_abap = rv_abap && |TYPES { ls_field-name }.\n|. ENDLOOP. + rv_abap = rv_abap && |TYPES END OF ENUM { io_enum->mv_name }.\n|. + ENDMETHOD. METHOD field. - rv_abap = io_field->mv_field_name. + rv_abap = |TYPES { io_field->mv_field_name } TYPE i.\n|. ENDMETHOD. ENDCLASS. diff --git a/src/generator/zcl_protobuf_generator.clas.testclasses.abap b/src/generator/zcl_protobuf_generator.clas.testclasses.abap index fccd32d..5ad16b3 100644 --- a/src/generator/zcl_protobuf_generator.clas.testclasses.abap +++ b/src/generator/zcl_protobuf_generator.clas.testclasses.abap @@ -24,7 +24,8 @@ CLASS ltcl_test IMPLEMENTATION. | optional string label = 2;\n| && |\}|. - zcl_protobuf_generator=>generate( zcl_protobuf2_parser=>parse( lv_proto ) ). + DATA(lv_abap) = zcl_protobuf_generator=>generate( zcl_protobuf2_parser=>parse( lv_proto ) ). + WRITE / lv_abap. ENDMETHOD. From 6d90b5ce77f24e63db9ba1b46ea29830b0b41fc1 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 10:29:18 +0200 Subject: [PATCH 15/19] update --- src/generator/zcl_protobuf_generator.clas.abap | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index f436503..208b822 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -43,7 +43,7 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. METHOD message. - rv_abap = |TYPES BEGIN OF { io_message->mv_name }.\n|. + rv_abap = |TYPES: BEGIN OF { io_message->mv_name },\n|. LOOP AT io_message->mt_artefacts INTO DATA(lo_artefact). CASE TYPE OF lo_artefact. @@ -58,23 +58,21 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. ENDCASE. ENDLOOP. - rv_abap = rv_abap && |TYPES END OF { io_message->mv_name }.\n|. + rv_abap = rv_abap && | END OF { io_message->mv_name }.\n|. ENDMETHOD. METHOD enum. - rv_abap = |TYPES BEGIN OF ENUM { io_enum->mv_name }.\n|. - + rv_abap = |TYPES: BEGIN OF ENUM { io_enum->mv_name },\n|. LOOP AT io_enum->mt_fields INTO DATA(ls_field). - rv_abap = rv_abap && |TYPES { ls_field-name }.\n|. + rv_abap = rv_abap && | { ls_field-name } VALUE { ls_field-value },\n|. ENDLOOP. - - rv_abap = rv_abap && |TYPES END OF ENUM { io_enum->mv_name }.\n|. + rv_abap = rv_abap && | END OF ENUM { io_enum->mv_name }.\n|. ENDMETHOD. METHOD field. - rv_abap = |TYPES { io_field->mv_field_name } TYPE i.\n|. + rv_abap = | { io_field->mv_field_name } TYPE { io_field->mv_type }.\n|. ENDMETHOD. ENDCLASS. From ba7222bf5c009872c71cf5ca9d63a5c0401242fa Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 10:34:37 +0200 Subject: [PATCH 16/19] cleanup --- src/generator/zcl_protobuf_generator.clas.abap | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index 208b822..7105969 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -43,14 +43,22 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. METHOD message. - rv_abap = |TYPES: BEGIN OF { io_message->mv_name },\n|. - +* do the nested messages and types first, if any LOOP AT io_message->mt_artefacts INTO DATA(lo_artefact). CASE TYPE OF lo_artefact. WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message). rv_abap = rv_abap && message( lo_message ). WHEN TYPE zcl_protobuf2_enum INTO DATA(lo_enum). rv_abap = rv_abap && enum( lo_enum ). + WHEN OTHERS. + ASSERT 1 = 'todo'. + ENDCASE. + ENDLOOP. + + rv_abap = |TYPES: BEGIN OF { io_message->mv_name },\n|. + + LOOP AT io_message->mt_artefacts INTO lo_artefact. + CASE TYPE OF lo_artefact. WHEN TYPE zcl_protobuf2_field INTO DATA(lo_field). rv_abap = rv_abap && field( lo_field ). WHEN OTHERS. From a0c71ac8f0958556348b0b2c3282d01a7dff826d Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 10:35:58 +0200 Subject: [PATCH 17/19] fix --- src/generator/zcl_protobuf_generator.clas.abap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index 7105969..446b14d 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -51,7 +51,7 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. WHEN TYPE zcl_protobuf2_enum INTO DATA(lo_enum). rv_abap = rv_abap && enum( lo_enum ). WHEN OTHERS. - ASSERT 1 = 'todo'. + CONTINUE. ENDCASE. ENDLOOP. @@ -62,7 +62,7 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. WHEN TYPE zcl_protobuf2_field INTO DATA(lo_field). rv_abap = rv_abap && field( lo_field ). WHEN OTHERS. - ASSERT 1 = 'todo'. + CONTINUE. ENDCASE. ENDLOOP. From 680960a102c70182446a3b957c023a065dd0e569 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 10:55:44 +0200 Subject: [PATCH 18/19] yay --- .../zcl_protobuf_generator.clas.abap | 15 ++++++++-- ...l_protobuf_generator.clas.testclasses.abap | 28 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/generator/zcl_protobuf_generator.clas.abap b/src/generator/zcl_protobuf_generator.clas.abap index 446b14d..fe73a71 100644 --- a/src/generator/zcl_protobuf_generator.clas.abap +++ b/src/generator/zcl_protobuf_generator.clas.abap @@ -30,6 +30,14 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. METHOD generate. + rv_abap = rv_abap && |TYPES int32 TYPE i.\n|. + rv_abap = rv_abap && |TYPES uint32 TYPE int8.\n|. + rv_abap = rv_abap && |TYPES uint64 TYPE int8.\n|. " hmm + rv_abap = rv_abap && |TYPES bool TYPE abap_bool.\n|. + rv_abap = rv_abap && |TYPES bytes TYPE xstring.\n|. + rv_abap = rv_abap && |TYPES double TYPE f.\n|. + rv_abap = rv_abap && |TYPES float TYPE f.\n|. + LOOP AT io_file->mt_artefacts INTO DATA(lo_artefact). CASE TYPE OF lo_artefact. WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message). @@ -55,7 +63,7 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. ENDCASE. ENDLOOP. - rv_abap = |TYPES: BEGIN OF { io_message->mv_name },\n|. + rv_abap = rv_abap && |TYPES: BEGIN OF { io_message->mv_name },\n|. LOOP AT io_message->mt_artefacts INTO lo_artefact. CASE TYPE OF lo_artefact. @@ -74,13 +82,14 @@ CLASS zcl_protobuf_generator IMPLEMENTATION. rv_abap = |TYPES: BEGIN OF ENUM { io_enum->mv_name },\n|. LOOP AT io_enum->mt_fields INTO DATA(ls_field). - rv_abap = rv_abap && | { ls_field-name } VALUE { ls_field-value },\n|. + rv_abap = rv_abap && | { ls_field-name },\n|. ENDLOOP. rv_abap = rv_abap && | END OF ENUM { io_enum->mv_name }.\n|. ENDMETHOD. METHOD field. - rv_abap = | { io_field->mv_field_name } TYPE { io_field->mv_type }.\n|. +" todo, handle repeated + rv_abap = | { io_field->mv_field_name } TYPE { io_field->mv_type },\n|. ENDMETHOD. ENDCLASS. diff --git a/src/generator/zcl_protobuf_generator.clas.testclasses.abap b/src/generator/zcl_protobuf_generator.clas.testclasses.abap index 5ad16b3..38db0ee 100644 --- a/src/generator/zcl_protobuf_generator.clas.testclasses.abap +++ b/src/generator/zcl_protobuf_generator.clas.testclasses.abap @@ -9,19 +9,23 @@ CLASS ltcl_test IMPLEMENTATION. DATA(lv_proto) = |syntax = "proto2";\n| && - |message Point \{\n| && - | required int32 x = 1;\n| && - | required int32 y = 2;\n| && - | optional string label = 3;\n| && + |message Person \{\n| && + | required string name = 1;\n| && + | required int32 id = 2;\n| && + | optional string email = 3;\n| && + | enum PhoneType \{\n| && + | MOBILE = 0;\n| && + | HOME = 1;\n| && + | WORK = 2;\n| && + | \}\n| && + | message PhoneNumber \{\n| && + | required string number = 1;\n| && + | optional PhoneType type = 2 [default = HOME];\n| && + | \}\n| && + | repeated PhoneNumber phones = 4;\n| && |\}\n| && - |message Line \{\n| && - | required Point start = 1;\n| && - | required Point end = 2;\n| && - | optional string label = 3;\n| && - |\}\n| && - |message Polyline \{\n| && - | repeated Point point = 1;\n| && - | optional string label = 2;\n| && + |message AddressBook \{\n| && + | repeated Person people = 1;\n| && |\}|. DATA(lv_abap) = zcl_protobuf_generator=>generate( zcl_protobuf2_parser=>parse( lv_proto ) ). From 888a832f9f2d5d5a477cccc98e917aef845da7bc Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 18 Aug 2023 13:06:05 +0200 Subject: [PATCH 19/19] update --- src/parser/zcl_protobuf2_parser.clas.abap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser/zcl_protobuf2_parser.clas.abap b/src/parser/zcl_protobuf2_parser.clas.abap index 82e2615..be8da78 100644 --- a/src/parser/zcl_protobuf2_parser.clas.abap +++ b/src/parser/zcl_protobuf2_parser.clas.abap @@ -40,7 +40,7 @@ ENDCLASS. -CLASS ZCL_PROTOBUF2_PARSER IMPLEMENTATION. +CLASS zcl_protobuf2_parser IMPLEMENTATION. METHOD enum. @@ -135,6 +135,7 @@ CLASS ZCL_PROTOBUF2_PARSER IMPLEMENTATION. rv_output = rv_output(lv_start) && rv_output+lv_end. ENDWHILE. + SPLIT rv_output AT |\n| INTO TABLE DATA(lt_lines). LOOP AT lt_lines ASSIGNING FIELD-SYMBOL(). FIND FIRST OCCURRENCE OF '//' IN MATCH OFFSET lv_start.