Skip to content

Commit

Permalink
yay
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp committed Aug 18, 2023
1 parent a0c71ac commit 680960a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
15 changes: 12 additions & 3 deletions src/generator/zcl_protobuf_generator.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Check failure on line 41 in src/generator/zcl_protobuf_generator.clas.abap

View check run for this annotation

abaplint / abaplint

Variable "lo_artefact" not used

https://rules.abaplint.org/unused_variables
CASE TYPE OF lo_artefact.
WHEN TYPE zcl_protobuf2_message INTO DATA(lo_message).
Expand All @@ -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.
Expand All @@ -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.
28 changes: 16 additions & 12 deletions src/generator/zcl_protobuf_generator.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ).
Expand Down

0 comments on commit 680960a

Please sign in to comment.