Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parsing #13

Merged
merged 19 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest

timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20'
- name: Run npm steps
run: |
npm install
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
output
downport
downport
output.proto2
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"configurations": [
{
"name": "All Unit Tests",
"type": "pwa-node",
"type": "node",
"request": "launch",
"pauseForSourceMap": true,
"trace": false,
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"proto",
"protobuf"
]
}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# abap-protobuf
work in progress, ABAP protobuf

Currently only `proto2` supported

https://protobuf.dev/reference/protobuf/proto2-spec/

39 changes: 32 additions & 7 deletions abaplint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,40 @@
],
"syntax": {
"version": "v740sp02",
"errorNamespace": ".",
"globalConstants": [],
"globalMacros": []
"errorNamespace": "."
},
"rules": {
"call_transaction_authority_check": true,
"align_parameters": true,
"cds_comment_style": true,
"cds_legacy_view": true,
"cds_parser_error": true,
"change_if_to_case": true,
"classic_exceptions_overlap": true,
"constant_classes": true,
"easy_to_find_messages": true,
"expand_macros": true,
"fully_type_itabs": true,
"local_testclass_consistency": true,
"no_aliases": true,
"no_external_form_calls": true,
"no_inline_in_optional_branches": false,
"nrob_consistency": true,
"select_single_full_key": true,
"slow_parameter_passing": true,
"smim_consistency": true,
"sql_value_conversion": true,
"static_call_via_instance": true,
"strict_sql": false,
"superfluous_value": true,
"unnecessary_chaining": true,
"unnecessary_pragma": true,
"unnecessary_return": true,
"omit_preceding_zeros": true,
"pragma_style": true,
"prefer_corresponding": true,
"prefer_pragmas": true,
"no_chained_assignment": true,
"check_subrc": true,
"cyclomatic_complexity": true,
"dangerous_statement": true,
Expand All @@ -43,7 +71,6 @@
"line_break_style": false,
"many_parentheses": true,
"cyclic_oo": true,
"pragma_placement": true,
"max_one_method_parameter_per_line": true,
"method_implemented_twice": true,
"method_overwrites_builtin": true,
Expand Down Expand Up @@ -78,7 +105,6 @@
"forbidden_void_type": true,
"fully_type_constants": true,
"allowed_object_naming": true,
"check_no_handler_pragma": true,
"newline_between_methods": true,
"chain_mainly_declarations": true,
"check_abstract": true,
Expand All @@ -97,7 +123,7 @@
"class_attribute_names": true,
"cloud_types": true,
"colon_missing_space": true,
"commented_code": true,
"commented_code": false,
"constructor_visibility_public": true,
"contains_tab": true,
"definitions_top": true,
Expand All @@ -121,7 +147,6 @@
"line_length": true,
"line_only_punc": true,
"local_class_naming": true,
"local_testclass_location": true,
"local_variable_names": true,
"main_file_contents": true,
"max_one_statement": true,
Expand Down
83 changes: 46 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"scripts": {
"lint": "abaplint",
"unit": "rm -rf output && abap_transpile && echo RUNNING && node output/index.mjs",
"test": "npm run lint && npm run downport && npm run unit",
"integration": "node test/test.mjs",
"test": "npm run lint && npm run downport && npm run unit && npm run integration",
"downport": "rm -rf downport && cp src -r downport && abaplint --fix abaplint_downport.json"
},
"repository": {
Expand All @@ -21,8 +22,8 @@
},
"homepage": "https://github.com/heliconialabs/abap-protobuf#readme",
"devDependencies": {
"@abaplint/cli": "^2.93.31",
"@abaplint/runtime": "^2.1.78",
"@abaplint/transpiler-cli": "^2.1.78"
"@abaplint/cli": "^2.102.22",
"@abaplint/runtime": "^2.7.74",
"@abaplint/transpiler-cli": "^2.7.74"
}
}
34 changes: 34 additions & 0 deletions src/model/zcl_protobuf2_enum.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CLASS zcl_protobuf2_enum DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES zif_protobuf2_artefact.
METHODS constructor IMPORTING iv_name TYPE string.
DATA mv_name TYPE string.

TYPES: BEGIN OF ty_enum,
name TYPE string,
value TYPE string,
END OF ty_enum.
DATA mt_fields TYPE STANDARD TABLE OF ty_enum WITH EMPTY KEY.
ENDCLASS.

CLASS zcl_protobuf2_enum IMPLEMENTATION.

METHOD constructor.
mv_name = iv_name.
ENDMETHOD.

METHOD zif_protobuf2_artefact~serialize.
rv_string = |enum { mv_name } \{\n|.
DATA(lv_spaces) = repeat(
val = | |
occ = iv_nesting + 1 ).
LOOP AT mt_fields INTO DATA(ls_field).
rv_string = rv_string && lv_spaces && ls_field-name && | = { ls_field-value };\n|.
ENDLOOP.
lv_spaces = repeat(
val = | |
occ = iv_nesting ).
rv_string = rv_string && lv_spaces && |}|.
ENDMETHOD.

ENDCLASS.
16 changes: 16 additions & 0 deletions src/model/zcl_protobuf2_enum.clas.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>ZCL_PROTOBUF2_ENUM</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>ZCL_PROTOBUF2_ENUM</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
22 changes: 22 additions & 0 deletions src/model/zcl_protobuf2_field.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CLASS zcl_protobuf2_field DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES zif_protobuf2_artefact.

DATA mv_label TYPE string.
DATA mv_type TYPE string.
DATA mv_field_name TYPE string.
DATA mv_options TYPE string.
DATA mv_field_number TYPE i.
ENDCLASS.

CLASS zcl_protobuf2_field IMPLEMENTATION.

METHOD zif_protobuf2_artefact~serialize.
DATA(lv_options) = mv_options.
IF lv_options IS NOT INITIAL.
lv_options = | { mv_options }|.
ENDIF.
rv_string = |{ mv_label } { mv_type } { mv_field_name } = { mv_field_number }{ lv_options };|.
ENDMETHOD.

ENDCLASS.
16 changes: 16 additions & 0 deletions src/model/zcl_protobuf2_field.clas.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>ZCL_PROTOBUF2_FIELD</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>ZCL_PROTOBUF2_FIELD</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
Loading
Loading