aas-core-codegen 0.0.16__py3-none-any.whl

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.
Files changed (604) hide show
  1. aas_core_codegen/__init__.py +6 -0
  2. aas_core_codegen/__main__.py +8 -0
  3. aas_core_codegen/common.py +500 -0
  4. aas_core_codegen/cpp/__init__.py +1 -0
  5. aas_core_codegen/cpp/aas_common/__init__.py +6 -0
  6. aas_core_codegen/cpp/aas_common/_generate.py +713 -0
  7. aas_core_codegen/cpp/common.py +681 -0
  8. aas_core_codegen/cpp/constants/__init__.py +6 -0
  9. aas_core_codegen/cpp/constants/_generate.py +568 -0
  10. aas_core_codegen/cpp/description.py +654 -0
  11. aas_core_codegen/cpp/enhancing/__init__.py +4 -0
  12. aas_core_codegen/cpp/enhancing/_generate.py +993 -0
  13. aas_core_codegen/cpp/iteration/__init__.py +6 -0
  14. aas_core_codegen/cpp/iteration/_generate.py +2332 -0
  15. aas_core_codegen/cpp/jsonization/__init__.py +6 -0
  16. aas_core_codegen/cpp/jsonization/_generate.py +2619 -0
  17. aas_core_codegen/cpp/main.py +694 -0
  18. aas_core_codegen/cpp/naming.py +170 -0
  19. aas_core_codegen/cpp/optionaling.py +557 -0
  20. aas_core_codegen/cpp/pattern/__init__.py +6 -0
  21. aas_core_codegen/cpp/pattern/_generate.py +508 -0
  22. aas_core_codegen/cpp/revm/__init__.py +6 -0
  23. aas_core_codegen/cpp/revm/_generate.py +1149 -0
  24. aas_core_codegen/cpp/stringification/__init__.py +5 -0
  25. aas_core_codegen/cpp/stringification/_generate.py +955 -0
  26. aas_core_codegen/cpp/structure/__init__.py +7 -0
  27. aas_core_codegen/cpp/structure/_generate.py +1503 -0
  28. aas_core_codegen/cpp/transpilation.py +1383 -0
  29. aas_core_codegen/cpp/unrolling.py +159 -0
  30. aas_core_codegen/cpp/verification/__init__.py +6 -0
  31. aas_core_codegen/cpp/verification/_generate.py +3073 -0
  32. aas_core_codegen/cpp/visitation/__init__.py +6 -0
  33. aas_core_codegen/cpp/visitation/_generate.py +521 -0
  34. aas_core_codegen/cpp/wstringification/__init__.py +5 -0
  35. aas_core_codegen/cpp/wstringification/_generate.py +586 -0
  36. aas_core_codegen/cpp/xmlization/__init__.py +6 -0
  37. aas_core_codegen/cpp/xmlization/_generate.py +5373 -0
  38. aas_core_codegen/cpp/yielding.py +201 -0
  39. aas_core_codegen/csharp/__init__.py +1 -0
  40. aas_core_codegen/csharp/common.py +224 -0
  41. aas_core_codegen/csharp/constants/__init__.py +5 -0
  42. aas_core_codegen/csharp/constants/_generate.py +409 -0
  43. aas_core_codegen/csharp/copying/__init__.py +4 -0
  44. aas_core_codegen/csharp/copying/_generate.py +498 -0
  45. aas_core_codegen/csharp/description.py +1103 -0
  46. aas_core_codegen/csharp/enhancing/__init__.py +4 -0
  47. aas_core_codegen/csharp/enhancing/_generate.py +667 -0
  48. aas_core_codegen/csharp/jsonization/__init__.py +4 -0
  49. aas_core_codegen/csharp/jsonization/_generate.py +1630 -0
  50. aas_core_codegen/csharp/main.py +421 -0
  51. aas_core_codegen/csharp/naming.py +157 -0
  52. aas_core_codegen/csharp/reporting/__init__.py +4 -0
  53. aas_core_codegen/csharp/reporting/_generate.py +266 -0
  54. aas_core_codegen/csharp/stringification/__init__.py +4 -0
  55. aas_core_codegen/csharp/stringification/_generate.py +243 -0
  56. aas_core_codegen/csharp/structure/__init__.py +6 -0
  57. aas_core_codegen/csharp/structure/_generate.py +1341 -0
  58. aas_core_codegen/csharp/transpilation.py +990 -0
  59. aas_core_codegen/csharp/unrolling.py +211 -0
  60. aas_core_codegen/csharp/verification/__init__.py +6 -0
  61. aas_core_codegen/csharp/verification/_generate.py +1457 -0
  62. aas_core_codegen/csharp/visitation/__init__.py +5 -0
  63. aas_core_codegen/csharp/visitation/_generate.py +579 -0
  64. aas_core_codegen/csharp/xmlization/__init__.py +4 -0
  65. aas_core_codegen/csharp/xmlization/_generate.py +1980 -0
  66. aas_core_codegen/golang/__init__.py +1 -0
  67. aas_core_codegen/golang/aas_common/__init__.py +4 -0
  68. aas_core_codegen/golang/aas_common/_generate.py +152 -0
  69. aas_core_codegen/golang/common.py +303 -0
  70. aas_core_codegen/golang/constants/__init__.py +5 -0
  71. aas_core_codegen/golang/constants/_generate.py +339 -0
  72. aas_core_codegen/golang/description.py +501 -0
  73. aas_core_codegen/golang/enhancing/__init__.py +4 -0
  74. aas_core_codegen/golang/enhancing/_generate.py +527 -0
  75. aas_core_codegen/golang/jsonization/__init__.py +4 -0
  76. aas_core_codegen/golang/jsonization/_generate.py +1740 -0
  77. aas_core_codegen/golang/main.py +368 -0
  78. aas_core_codegen/golang/naming.py +412 -0
  79. aas_core_codegen/golang/pointering.py +631 -0
  80. aas_core_codegen/golang/reporting/__init__.py +4 -0
  81. aas_core_codegen/golang/reporting/_generate.py +218 -0
  82. aas_core_codegen/golang/stringification/__init__.py +4 -0
  83. aas_core_codegen/golang/stringification/_generate.py +394 -0
  84. aas_core_codegen/golang/structure/__init__.py +6 -0
  85. aas_core_codegen/golang/structure/_generate.py +1493 -0
  86. aas_core_codegen/golang/transpilation.py +1191 -0
  87. aas_core_codegen/golang/unrolling.py +159 -0
  88. aas_core_codegen/golang/verification/__init__.py +6 -0
  89. aas_core_codegen/golang/verification/_generate.py +1513 -0
  90. aas_core_codegen/golang/xmlization/__init__.py +4 -0
  91. aas_core_codegen/golang/xmlization/_generate.py +2507 -0
  92. aas_core_codegen/infer_for_schema/__init__.py +21 -0
  93. aas_core_codegen/infer_for_schema/_inline.py +693 -0
  94. aas_core_codegen/infer_for_schema/_len.py +527 -0
  95. aas_core_codegen/infer_for_schema/_pattern.py +311 -0
  96. aas_core_codegen/infer_for_schema/_set.py +394 -0
  97. aas_core_codegen/infer_for_schema/_stringify.py +201 -0
  98. aas_core_codegen/infer_for_schema/_types.py +135 -0
  99. aas_core_codegen/infer_for_schema/match.py +122 -0
  100. aas_core_codegen/intermediate/__init__.py +78 -0
  101. aas_core_codegen/intermediate/_hierarchy.py +397 -0
  102. aas_core_codegen/intermediate/_stringify.py +989 -0
  103. aas_core_codegen/intermediate/_translate.py +5128 -0
  104. aas_core_codegen/intermediate/_types.py +2901 -0
  105. aas_core_codegen/intermediate/construction.py +750 -0
  106. aas_core_codegen/intermediate/doc.py +344 -0
  107. aas_core_codegen/intermediate/pattern_verification.py +428 -0
  108. aas_core_codegen/intermediate/revm.py +985 -0
  109. aas_core_codegen/intermediate/type_inference.py +2266 -0
  110. aas_core_codegen/java/__init__.py +1 -0
  111. aas_core_codegen/java/common.py +197 -0
  112. aas_core_codegen/java/constants/__init__.py +5 -0
  113. aas_core_codegen/java/constants/_generate.py +334 -0
  114. aas_core_codegen/java/copying/__init__.py +4 -0
  115. aas_core_codegen/java/copying/_generate.py +502 -0
  116. aas_core_codegen/java/description.py +774 -0
  117. aas_core_codegen/java/enhancing/__init__.py +4 -0
  118. aas_core_codegen/java/enhancing/_generate.py +820 -0
  119. aas_core_codegen/java/generation/__init__.py +5 -0
  120. aas_core_codegen/java/generation/_generate.py +285 -0
  121. aas_core_codegen/java/jsonization/__init__.py +4 -0
  122. aas_core_codegen/java/jsonization/_generate.py +1472 -0
  123. aas_core_codegen/java/main.py +438 -0
  124. aas_core_codegen/java/naming.py +187 -0
  125. aas_core_codegen/java/optional.py +514 -0
  126. aas_core_codegen/java/reporting/__init__.py +4 -0
  127. aas_core_codegen/java/reporting/_generate.py +248 -0
  128. aas_core_codegen/java/stringification/__init__.py +4 -0
  129. aas_core_codegen/java/stringification/_generate.py +212 -0
  130. aas_core_codegen/java/structure/__init__.py +6 -0
  131. aas_core_codegen/java/structure/_generate.py +1767 -0
  132. aas_core_codegen/java/transpilation.py +1111 -0
  133. aas_core_codegen/java/verification/__init__.py +6 -0
  134. aas_core_codegen/java/verification/_generate.py +1536 -0
  135. aas_core_codegen/java/visitation/__init__.py +5 -0
  136. aas_core_codegen/java/visitation/_generate.py +689 -0
  137. aas_core_codegen/java/xmlization/__init__.py +4 -0
  138. aas_core_codegen/java/xmlization/_generate.py +2274 -0
  139. aas_core_codegen/jsonld/__init__.py +1 -0
  140. aas_core_codegen/jsonld/main.py +455 -0
  141. aas_core_codegen/jsonschema/__init__.py +1 -0
  142. aas_core_codegen/jsonschema/main.py +982 -0
  143. aas_core_codegen/main.py +245 -0
  144. aas_core_codegen/naming.py +133 -0
  145. aas_core_codegen/opcua/__init__.py +1 -0
  146. aas_core_codegen/opcua/main.py +1525 -0
  147. aas_core_codegen/opcua/naming.py +126 -0
  148. aas_core_codegen/parse/__init__.py +46 -0
  149. aas_core_codegen/parse/_rules.py +796 -0
  150. aas_core_codegen/parse/_stringify.py +532 -0
  151. aas_core_codegen/parse/_translate.py +3940 -0
  152. aas_core_codegen/parse/_types.py +973 -0
  153. aas_core_codegen/parse/retree/__init__.py +46 -0
  154. aas_core_codegen/parse/retree/_fix.py +434 -0
  155. aas_core_codegen/parse/retree/_parse.py +1143 -0
  156. aas_core_codegen/parse/retree/_render.py +298 -0
  157. aas_core_codegen/parse/retree/_stringify.py +199 -0
  158. aas_core_codegen/parse/retree/_types.py +362 -0
  159. aas_core_codegen/parse/retree/_visitor.py +70 -0
  160. aas_core_codegen/parse/tree.py +1303 -0
  161. aas_core_codegen/protobuf/__init__.py +1 -0
  162. aas_core_codegen/protobuf/common.py +225 -0
  163. aas_core_codegen/protobuf/description.py +1102 -0
  164. aas_core_codegen/protobuf/main.py +115 -0
  165. aas_core_codegen/protobuf/naming.py +143 -0
  166. aas_core_codegen/protobuf/structure/__init__.py +6 -0
  167. aas_core_codegen/protobuf/structure/_generate.py +502 -0
  168. aas_core_codegen/py.typed +1 -0
  169. aas_core_codegen/python/__init__.py +1 -0
  170. aas_core_codegen/python/aas_common/__init__.py +4 -0
  171. aas_core_codegen/python/aas_common/_generate.py +63 -0
  172. aas_core_codegen/python/common.py +406 -0
  173. aas_core_codegen/python/constants/__init__.py +5 -0
  174. aas_core_codegen/python/constants/_generate.py +377 -0
  175. aas_core_codegen/python/description.py +508 -0
  176. aas_core_codegen/python/jsonization/__init__.py +4 -0
  177. aas_core_codegen/python/jsonization/_generate.py +1391 -0
  178. aas_core_codegen/python/main.py +323 -0
  179. aas_core_codegen/python/naming.py +255 -0
  180. aas_core_codegen/python/stringification/__init__.py +4 -0
  181. aas_core_codegen/python/stringification/_generate.py +129 -0
  182. aas_core_codegen/python/structure/__init__.py +6 -0
  183. aas_core_codegen/python/structure/_generate.py +1801 -0
  184. aas_core_codegen/python/transpilation.py +958 -0
  185. aas_core_codegen/python/unrolling.py +156 -0
  186. aas_core_codegen/python/verification/__init__.py +6 -0
  187. aas_core_codegen/python/verification/_generate.py +1471 -0
  188. aas_core_codegen/python/xmlization/__init__.py +4 -0
  189. aas_core_codegen/python/xmlization/_generate.py +3003 -0
  190. aas_core_codegen/python_protobuf/__init__.py +1 -0
  191. aas_core_codegen/python_protobuf/main.py +1424 -0
  192. aas_core_codegen/python_protobuf/naming.py +85 -0
  193. aas_core_codegen/rdf_shacl/__init__.py +1 -0
  194. aas_core_codegen/rdf_shacl/_description.py +351 -0
  195. aas_core_codegen/rdf_shacl/common.py +206 -0
  196. aas_core_codegen/rdf_shacl/main.py +114 -0
  197. aas_core_codegen/rdf_shacl/naming.py +145 -0
  198. aas_core_codegen/rdf_shacl/rdf.py +435 -0
  199. aas_core_codegen/rdf_shacl/shacl.py +453 -0
  200. aas_core_codegen/run.py +124 -0
  201. aas_core_codegen/smoke/__init__.py +1 -0
  202. aas_core_codegen/smoke/main.py +219 -0
  203. aas_core_codegen/specific_implementations.py +72 -0
  204. aas_core_codegen/stringify.py +333 -0
  205. aas_core_codegen/typescript/__init__.py +1 -0
  206. aas_core_codegen/typescript/aas_common/__init__.py +4 -0
  207. aas_core_codegen/typescript/aas_common/_generate.py +472 -0
  208. aas_core_codegen/typescript/common.py +340 -0
  209. aas_core_codegen/typescript/constants/__init__.py +5 -0
  210. aas_core_codegen/typescript/constants/_generate.py +347 -0
  211. aas_core_codegen/typescript/description.py +530 -0
  212. aas_core_codegen/typescript/jsonization/__init__.py +4 -0
  213. aas_core_codegen/typescript/jsonization/_generate.py +1510 -0
  214. aas_core_codegen/typescript/main.py +258 -0
  215. aas_core_codegen/typescript/naming.py +189 -0
  216. aas_core_codegen/typescript/stringification/__init__.py +4 -0
  217. aas_core_codegen/typescript/stringification/_generate.py +367 -0
  218. aas_core_codegen/typescript/structure/__init__.py +6 -0
  219. aas_core_codegen/typescript/structure/_generate.py +2500 -0
  220. aas_core_codegen/typescript/transpilation.py +1051 -0
  221. aas_core_codegen/typescript/unrolling.py +159 -0
  222. aas_core_codegen/typescript/verification/__init__.py +6 -0
  223. aas_core_codegen/typescript/verification/_generate.py +1578 -0
  224. aas_core_codegen/xsd/__init__.py +1 -0
  225. aas_core_codegen/xsd/main.py +1187 -0
  226. aas_core_codegen/xsd/naming.py +83 -0
  227. aas_core_codegen/yielding/__init__.py +1 -0
  228. aas_core_codegen/yielding/flow.py +139 -0
  229. aas_core_codegen/yielding/linear.py +754 -0
  230. aas_core_codegen-0.0.16.dist-info/METADATA +211 -0
  231. aas_core_codegen-0.0.16.dist-info/RECORD +604 -0
  232. aas_core_codegen-0.0.16.dist-info/WHEEL +5 -0
  233. aas_core_codegen-0.0.16.dist-info/entry_points.txt +3 -0
  234. aas_core_codegen-0.0.16.dist-info/licenses/AUTHORS +9 -0
  235. aas_core_codegen-0.0.16.dist-info/licenses/LICENSE +23 -0
  236. aas_core_codegen-0.0.16.dist-info/top_level.txt +2 -0
  237. dev/continuous_integration/__init__.py +1 -0
  238. dev/continuous_integration/check_help_in_readme.py +208 -0
  239. dev/continuous_integration/check_init_and_pyproject_consistent.py +154 -0
  240. dev/continuous_integration/precommit.py +400 -0
  241. dev/dev_scripts/__init__.py +1 -0
  242. dev/dev_scripts/compare_rendered_regexes_against_source_py.py +42 -0
  243. dev/dev_scripts/copy_to_aas_core3_cpp.py +100 -0
  244. dev/dev_scripts/copy_to_aas_core3_java.py +90 -0
  245. dev/dev_scripts/download_latest_aas_core_meta_v3.py +114 -0
  246. dev/dev_scripts/draw_bipartite_graph_based_on_lines.py +37 -0
  247. dev/dev_scripts/run_tests_with_rerecord.py +69 -0
  248. dev/dev_scripts/update_to_aas_core_meta.py +174 -0
  249. dev/integration_tests/input/jsonschema/boilerplate/main.py +55 -0
  250. dev/integration_tests/input/meta_model.py +38 -0
  251. dev/integration_tests/input/python/boilerplate/main.py +153 -0
  252. dev/integration_tests/main.py +258 -0
  253. dev/test_data/csharp/test_structure/concrete_class_with_descendants/meta_model.py +15 -0
  254. dev/test_data/csharp/test_structure/constructor_without_arguments/all_properties_optional/meta_model.py +9 -0
  255. dev/test_data/csharp/test_structure/constructor_without_arguments/no_properties/meta_model.py +6 -0
  256. dev/test_data/csharp/test_verification/builtin_functions/len/on_list/meta_model.py +20 -0
  257. dev/test_data/csharp/test_verification/builtin_functions/len/on_str/meta_model.py +16 -0
  258. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_prefix/meta_model.py +8 -0
  259. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/as_suffix/meta_model.py +8 -0
  260. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_group_with_quantifier/meta_model.py +8 -0
  261. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_the_middle/meta_model.py +8 -0
  262. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/in_union/meta_model.py +8 -0
  263. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/single_utf32_literal/meta_model.py +8 -0
  264. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_within_group/meta_model.py +8 -0
  265. dev/test_data/csharp/test_verification/pattern_verification/utf32_as_literal/with_quantifier_without_group/meta_model.py +8 -0
  266. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_beginning/meta_model.py +8 -0
  267. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/at_the_end/meta_model.py +8 -0
  268. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/in_the_middle/meta_model.py +8 -0
  269. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/multiple/meta_model.py +8 -0
  270. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single/meta_model.py +8 -0
  271. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/literal/single_with_quantifier/meta_model.py +8 -0
  272. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/mixed_with_non_utf32/meta_model.py +8 -0
  273. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/more_than_two_high_surrogates/meta_model.py +8 -0
  274. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges/meta_model.py +8 -0
  275. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/multiple_utf32_ranges_mixed_with_non_utf32/meta_model.py +8 -0
  276. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate/meta_model.py +8 -0
  277. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/same_high_surrogate_with_quantifier/meta_model.py +8 -0
  278. dev/test_data/csharp/test_verification/pattern_verification/utf32_in_character_set/range/two_high_surrogates/meta_model.py +8 -0
  279. dev/test_data/intermediate/expected/class/empty/meta_model.py +6 -0
  280. dev/test_data/intermediate/expected/class/implementation_specific_method/meta_model.py +8 -0
  281. dev/test_data/intermediate/expected/class/inheritance/meta_model.py +41 -0
  282. dev/test_data/intermediate/expected/class/methods_with_contracts/meta_model.py +15 -0
  283. dev/test_data/intermediate/expected/class/only_method_no_property/meta_model.py +7 -0
  284. dev/test_data/intermediate/expected/class/only_property_no_method/meta_model.py +9 -0
  285. dev/test_data/intermediate/expected/constant/constant_set/of_enum/meta_model.py +12 -0
  286. dev/test_data/intermediate/expected/constant/constant_set/of_str/meta_model.py +4 -0
  287. dev/test_data/intermediate/expected/constant/constant_set/with_description/meta_model.py +6 -0
  288. dev/test_data/intermediate/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
  289. dev/test_data/intermediate/expected/constant/constant_str/only_value/meta_model.py +7 -0
  290. dev/test_data/intermediate/expected/constant/constant_str/with_description/meta_model.py +5 -0
  291. dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_in_literal/meta_model.py +20 -0
  292. dev/test_data/intermediate/expected/documentation/docstring_with_special_characters_outside_literal/meta_model.py +20 -0
  293. dev/test_data/intermediate/expected/empty/meta_model.py +2 -0
  294. dev/test_data/intermediate/expected/enumeration/meta_model.py +9 -0
  295. dev/test_data/intermediate/expected/interface/basic/meta_model.py +14 -0
  296. dev/test_data/intermediate/expected/interface/empty/meta_model.py +7 -0
  297. dev/test_data/intermediate/expected/interface/inheritance/meta_model.py +27 -0
  298. dev/test_data/intermediate/expected/interface/method_signature/meta_model.py +10 -0
  299. dev/test_data/intermediate/expected/interface/only_constructor/meta_model.py +11 -0
  300. dev/test_data/intermediate/expected/method/non_mutating/implementation_specific/meta_model.py +12 -0
  301. dev/test_data/intermediate/expected/method/non_mutating/understood/meta_model.py +11 -0
  302. dev/test_data/intermediate/expected/type_annotation/atomic/meta_model.py +9 -0
  303. dev/test_data/intermediate/expected/type_annotation/subscripted/class/meta_model.py +13 -0
  304. dev/test_data/intermediate/expected/type_annotation/subscripted/primitive/meta_model.py +9 -0
  305. dev/test_data/intermediate/unexpected/constant_set/of_enum/enumeration_literals_in_subset_outside_of_superset/meta_model.py +20 -0
  306. dev/test_data/intermediate/unexpected/constant_set/of_enum/invalid_literal/meta_model.py +11 -0
  307. dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_between_enumeration_and_literal/meta_model.py +30 -0
  308. dev/test_data/intermediate/unexpected/constant_set/of_enum/mismatch_in_enumerations_between_subset_and_superset/meta_model.py +21 -0
  309. dev/test_data/intermediate/unexpected/constant_set/of_str/literals_in_subset_outside_of_superset/meta_model.py +18 -0
  310. dev/test_data/intermediate/unexpected/constant_set/of_str/mismatch_between_type_annotation_and_literals/meta_model.py +10 -0
  311. dev/test_data/intermediate/unexpected/constant_set/of_str/superset_and_subset_mismatch_in_type/meta_model.py +12 -0
  312. dev/test_data/intermediate/unexpected/constraints/dangling_constraintref/meta_model.py +18 -0
  313. dev/test_data/intermediate/unexpected/constraints/duplicate_constraints/meta_model.py +20 -0
  314. dev/test_data/intermediate/unexpected/documentation/unexpected_documentation_elements/meta_model.py +34 -0
  315. dev/test_data/intermediate/unexpected/invariant/class_invariant_uses_re/meta_model.py +10 -0
  316. dev/test_data/intermediate/unexpected/invariant/invariant_of_constrained_primitive_uses_re/meta_model.py +7 -0
  317. dev/test_data/intermediate/unexpected/invariant/unexpected_argument_count_to_len/meta_model.py +20 -0
  318. dev/test_data/intermediate/unexpected/invariant/unhandled_built_in_function/meta_model.py +16 -0
  319. dev/test_data/intermediate/unexpected/method_definitions/non_constant_default/meta_model.py +7 -0
  320. dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/default_non_none/meta_model.py +16 -0
  321. dev/test_data/intermediate/unexpected/optional_constructor_arguments_wo_default/no_default/meta_model.py +16 -0
  322. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/after_inheritance/meta_model.py +58 -0
  323. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/type_missmatch/meta_model.py +9 -0
  324. dev/test_data/intermediate/unexpected/properties_and_constructor_arguments_do_not_match/within_class/meta_model.py +22 -0
  325. dev/test_data/jsonschema/test_main/regression_when_len_constraints_on_inherited_property/meta_model.py +28 -0
  326. dev/test_data/opcua/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
  327. dev/test_data/opcua/test_main/classes_with_invariants/meta_model.py +21 -0
  328. dev/test_data/opcua/test_main/concrete_class_with_descendant/meta_model.py +27 -0
  329. dev/test_data/opcua/test_main/concrete_class_with_enum/meta_model.py +21 -0
  330. dev/test_data/opcua/test_main/concrete_class_with_list_of_instances/meta_model.py +21 -0
  331. dev/test_data/opcua/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  332. dev/test_data/opcua/test_main/concrete_class_with_string/meta_model.py +13 -0
  333. dev/test_data/opcua/test_main/constrained_primitive/meta_model.py +20 -0
  334. dev/test_data/opcua/test_main/multiple_inheritance/meta_model.py +25 -0
  335. dev/test_data/parse/expected/constant/constant_set/of_enum/meta_model.py +12 -0
  336. dev/test_data/parse/expected/constant/constant_set/of_str/meta_model.py +4 -0
  337. dev/test_data/parse/expected/constant/constant_set/with_description/meta_model.py +6 -0
  338. dev/test_data/parse/expected/constant/constant_set/with_superset_of/meta_model.py +14 -0
  339. dev/test_data/parse/expected/constant/constant_str/only_value/meta_model.py +7 -0
  340. dev/test_data/parse/expected/constant/constant_str/with_description/meta_model.py +5 -0
  341. dev/test_data/parse/expected/enum/ok/meta_model.py +15 -0
  342. dev/test_data/parse/expected/implementation_specific_class/properties_and_methods_in_implementation_specific_class/meta_model.py +17 -0
  343. dev/test_data/parse/expected/inheritance/basic/meta_model.py +11 -0
  344. dev/test_data/parse/expected/inheritance/diamond/meta_model.py +26 -0
  345. dev/test_data/parse/expected/inheritance/inheritance_from_concrete_class/meta_model.py +10 -0
  346. dev/test_data/parse/expected/invariants/in_relation/meta_model.py +16 -0
  347. dev/test_data/parse/expected/method/arguments/meta_model.py +7 -0
  348. dev/test_data/parse/expected/method/basic/meta_model.py +7 -0
  349. dev/test_data/parse/expected/method/contracts/condition_as_keyword_argument/meta_model.py +8 -0
  350. dev/test_data/parse/expected/method/contracts/condition_as_positional_argument/meta_model.py +8 -0
  351. dev/test_data/parse/expected/method/contracts/description_as_keyword_argument/meta_model.py +8 -0
  352. dev/test_data/parse/expected/method/contracts/description_as_positional_argument/meta_model.py +8 -0
  353. dev/test_data/parse/expected/method/contracts/multiple_contracts_in_order/meta_model.py +17 -0
  354. dev/test_data/parse/expected/method/contracts/postcondition/basic/meta_model.py +10 -0
  355. dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_keyword_arguments/meta_model.py +9 -0
  356. dev/test_data/parse/expected/method/contracts/postcondition/snapshot/with_positional_arguments/meta_model.py +9 -0
  357. dev/test_data/parse/expected/method/default/meta_model.py +9 -0
  358. dev/test_data/parse/expected/method/description/meta_model.py +8 -0
  359. dev/test_data/parse/expected/method/is_implementation_specific/meta_model.py +8 -0
  360. dev/test_data/parse/expected/method/non_mutating/meta_model.py +11 -0
  361. dev/test_data/parse/expected/method/returns_none/meta_model.py +7 -0
  362. dev/test_data/parse/expected/method/returns_something/meta_model.py +7 -0
  363. dev/test_data/parse/expected/single_class/description/meta_model.py +12 -0
  364. dev/test_data/parse/expected/single_class/empty/meta_model.py +6 -0
  365. dev/test_data/parse/expected/single_class/property/description/meta_model.py +14 -0
  366. dev/test_data/parse/expected/single_class/property/mandatory/meta_model.py +6 -0
  367. dev/test_data/parse/expected/single_class/property/optional/meta_model.py +6 -0
  368. dev/test_data/parse/expected/single_class/property/recursion_to_entity/meta_model.py +6 -0
  369. dev/test_data/parse/unexpected/class_decorators/non_name_decorator/meta_model.py +7 -0
  370. dev/test_data/parse/unexpected/class_decorators/unknown_decorator/meta_model.py +7 -0
  371. dev/test_data/parse/unexpected/class_definitions/is_abstract_and_implementation_specific/meta_model.py +8 -0
  372. dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_before_a_method/meta_model.py +11 -0
  373. dev/test_data/parse/unexpected/class_definitions/unexpected_docstring_for_a_pass/meta_model.py +9 -0
  374. dev/test_data/parse/unexpected/class_definitions/unexpected_double_description_for_a_property/meta_model.py +10 -0
  375. dev/test_data/parse/unexpected/class_inheritances/inheriting_from_implementation_specific_parent/meta_model.py +20 -0
  376. dev/test_data/parse/unexpected/class_inheritances/non_name_super_class/meta_model.py +6 -0
  377. dev/test_data/parse/unexpected/enum/expression_as_assignment_value/meta_model.py +6 -0
  378. dev/test_data/parse/unexpected/enum/non_assignment/meta_model.py +8 -0
  379. dev/test_data/parse/unexpected/enum/non_string_literal/meta_model.py +6 -0
  380. dev/test_data/parse/unexpected/enum/unexpected_inheritance/meta_model.py +6 -0
  381. dev/test_data/parse/unexpected/method_contracts/contract/non_lambda_condition/meta_model.py +8 -0
  382. dev/test_data/parse/unexpected/method_contracts/contract/non_string_literal_description/meta_model.py +8 -0
  383. dev/test_data/parse/unexpected/method_contracts/contract/without_any_arguments/meta_model.py +8 -0
  384. dev/test_data/parse/unexpected/method_contracts/contract/without_condition/meta_model.py +8 -0
  385. dev/test_data/parse/unexpected/method_contracts/postcondition/OLD_in_postcondition_without_snapshot/meta_model.py +8 -0
  386. dev/test_data/parse/unexpected/method_contracts/postcondition/argument_missing_in_function/meta_model.py +8 -0
  387. dev/test_data/parse/unexpected/method_contracts/precondition/argument_missing_in_function/meta_model.py +8 -0
  388. dev/test_data/parse/unexpected/method_contracts/snapshot/argument_missing_in_function/meta_model.py +8 -0
  389. dev/test_data/parse/unexpected/method_contracts/snapshot/capture_not_a_lambda/meta_model.py +8 -0
  390. dev/test_data/parse/unexpected/method_contracts/snapshot/invalid_name/meta_model.py +8 -0
  391. dev/test_data/parse/unexpected/method_contracts/snapshot/name_not_a_string_literal/meta_model.py +8 -0
  392. dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_capture/meta_model.py +8 -0
  393. dev/test_data/parse/unexpected/method_contracts/snapshot/without_a_name/meta_model.py +8 -0
  394. dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_constructor/meta_model.py +8 -0
  395. dev/test_data/parse/unexpected/method_decorators/non_mutating/non_mutating_verification_function/meta_model.py +8 -0
  396. dev/test_data/parse/unexpected/method_decorators/non_name_decorator/meta_model.py +8 -0
  397. dev/test_data/parse/unexpected/method_decorators/unknown_call_decorator/meta_model.py +8 -0
  398. dev/test_data/parse/unexpected/method_decorators/unknown_name_decorator/meta_model.py +8 -0
  399. dev/test_data/parse/unexpected/method_definitions/argument_with_final/meta_model.py +7 -0
  400. dev/test_data/parse/unexpected/method_definitions/argument_without_a_type_annotation/meta_model.py +7 -0
  401. dev/test_data/parse/unexpected/method_definitions/default_for_self/meta_model.py +7 -0
  402. dev/test_data/parse/unexpected/method_definitions/dunder/meta_model.py +7 -0
  403. dev/test_data/parse/unexpected/method_definitions/init_with_return_type/meta_model.py +7 -0
  404. dev/test_data/parse/unexpected/method_definitions/with_keyword_only_arguments/meta_model.py +7 -0
  405. dev/test_data/parse/unexpected/method_definitions/with_positional_arguments/meta_model.py +7 -0
  406. dev/test_data/parse/unexpected/method_definitions/with_type_annotation_for_self/meta_model.py +7 -0
  407. dev/test_data/parse/unexpected/method_definitions/with_variable_arguments/meta_model.py +7 -0
  408. dev/test_data/parse/unexpected/method_definitions/with_variable_keyword_arguments/meta_model.py +7 -0
  409. dev/test_data/parse/unexpected/method_definitions/without_arguments/meta_model.py +7 -0
  410. dev/test_data/parse/unexpected/method_definitions/without_self/meta_model.py +7 -0
  411. dev/test_data/parse/unexpected/method_definitions/without_type_annotation_for_result/meta_model.py +7 -0
  412. dev/test_data/parse/unexpected/property_definitions/final_without_subscript/meta_model.py +6 -0
  413. dev/test_data/parse/unexpected/property_definitions/nested_final/meta_model.py +6 -0
  414. dev/test_data/parse/unexpected/property_definitions/non_simple/meta_model.py +6 -0
  415. dev/test_data/parse/unexpected/property_definitions/unexpected_assignment/meta_model.py +6 -0
  416. dev/test_data/parse/unexpected/property_definitions/unexpected_non_name_property/meta_model.py +6 -0
  417. dev/test_data/parse/unexpected/property_definitions/without_type_annotation/meta_model.py +6 -0
  418. dev/test_data/parse/unexpected/symbol_table/constant_set_with_a_non_set_subset/meta_model.py +6 -0
  419. dev/test_data/parse/unexpected/symbol_table/dangling_inheritance/meta_model.py +6 -0
  420. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_a_property/meta_model.py +6 -0
  421. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_an_argument/meta_model.py +7 -0
  422. dev/test_data/parse/unexpected/symbol_table/dangling_reference_in_type_annotation_of_constant_set/meta_model.py +6 -0
  423. dev/test_data/parse/unexpected/symbol_table/dangling_subset_in_constant_set/meta_model.py +4 -0
  424. dev/test_data/parse/unexpected/symbol_table/inheritance_from_non_class/meta_model.py +10 -0
  425. dev/test_data/parse_retree/expected/character_set/common_escaping/source.py +1 -0
  426. dev/test_data/parse_retree/expected/character_set/complementing/double_caret/source.py +1 -0
  427. dev/test_data/parse_retree/expected/character_set/complementing/multiple_ranges/source.py +1 -0
  428. dev/test_data/parse_retree/expected/character_set/complementing/suffix_dash/source.py +1 -0
  429. dev/test_data/parse_retree/expected/character_set/escape_first_caret/source.py +1 -0
  430. dev/test_data/parse_retree/expected/character_set/literals_which_need_no_escaping_in_characters_set_but_need_escaping_outside/source.py +1 -0
  431. dev/test_data/parse_retree/expected/character_set/multiple_ranges/source.py +1 -0
  432. dev/test_data/parse_retree/expected/character_set/single_literal/source.py +1 -0
  433. dev/test_data/parse_retree/expected/character_set/single_range/source.py +1 -0
  434. dev/test_data/parse_retree/expected/character_set/unescaped_dash/only_dash/source.py +1 -0
  435. dev/test_data/parse_retree/expected/character_set/unescaped_dash/prefix_dash/source.py +1 -0
  436. dev/test_data/parse_retree/expected/character_set/unescaped_dash/suffix_dash/source.py +1 -0
  437. dev/test_data/parse_retree/expected/dot/source.py +1 -0
  438. dev/test_data/parse_retree/expected/empty/group/source.py +1 -0
  439. dev/test_data/parse_retree/expected/empty/group_in_a_group/source.py +1 -0
  440. dev/test_data/parse_retree/expected/empty/group_of_union_of_empty_concatenations/source.py +1 -0
  441. dev/test_data/parse_retree/expected/empty/regex/source.py +1 -0
  442. dev/test_data/parse_retree/expected/empty/union_of_empty_concatenations/source.py +1 -0
  443. dev/test_data/parse_retree/expected/escaped_literals/source.py +1 -0
  444. dev/test_data/parse_retree/expected/formatted_value/at_the_beginning/source.py +1 -0
  445. dev/test_data/parse_retree/expected/formatted_value/at_the_end/source.py +1 -0
  446. dev/test_data/parse_retree/expected/formatted_value/in_the_middle/source.py +1 -0
  447. dev/test_data/parse_retree/expected/formatted_value/single_formatted_value/source.py +1 -0
  448. dev/test_data/parse_retree/expected/literal/source.py +1 -0
  449. dev/test_data/parse_retree/expected/quantifier/greedy/at_least_3/source.py +1 -0
  450. dev/test_data/parse_retree/expected/quantifier/greedy/at_least_one/source.py +1 -0
  451. dev/test_data/parse_retree/expected/quantifier/greedy/at_most_3/source.py +1 -0
  452. dev/test_data/parse_retree/expected/quantifier/greedy/exactly_3/source.py +1 -0
  453. dev/test_data/parse_retree/expected/quantifier/greedy/maybe/source.py +1 -0
  454. dev/test_data/parse_retree/expected/quantifier/greedy/zero_or_more/source.py +1 -0
  455. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_3/source.py +1 -0
  456. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_least_one/source.py +1 -0
  457. dev/test_data/parse_retree/expected/quantifier/non_greedy/at_most_3/source.py +1 -0
  458. dev/test_data/parse_retree/expected/quantifier/non_greedy/exactly_3/source.py +1 -0
  459. dev/test_data/parse_retree/expected/quantifier/non_greedy/maybe/source.py +1 -0
  460. dev/test_data/parse_retree/expected/quantifier/non_greedy/zero_or_more/source.py +1 -0
  461. dev/test_data/parse_retree/expected/quantifier/on_a_character_set/source.py +1 -0
  462. dev/test_data/parse_retree/expected/quantifier/on_a_formatted_value/source.py +1 -0
  463. dev/test_data/parse_retree/expected/quantifier/on_a_group/source.py +1 -0
  464. dev/test_data/parse_retree/expected/quantifier/on_a_literal/source.py +1 -0
  465. dev/test_data/parse_retree/expected/start_and_stop_symbols/double_end_symbol/source.py +1 -0
  466. dev/test_data/parse_retree/expected/start_and_stop_symbols/double_start_symbol/source.py +1 -0
  467. dev/test_data/parse_retree/expected/start_and_stop_symbols/end_symbol_in_the_middle/source.py +1 -0
  468. dev/test_data/parse_retree/expected/start_and_stop_symbols/only_start_symbol/source.py +1 -0
  469. dev/test_data/parse_retree/expected/start_and_stop_symbols/only_stop_symbol/source.py +1 -0
  470. dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_at_the_beginning/source.py +1 -0
  471. dev/test_data/parse_retree/expected/start_and_stop_symbols/start_symbol_in_the_middle/source.py +1 -0
  472. dev/test_data/parse_retree/expected/start_and_stop_symbols/stop_symbol_at_the_end/source.py +1 -0
  473. dev/test_data/parse_retree/expected/union/of_character_sets/source.py +1 -0
  474. dev/test_data/parse_retree/expected/union/of_groups/source.py +1 -0
  475. dev/test_data/parse_retree/expected/union/of_string_literals/source.py +1 -0
  476. dev/test_data/parse_retree/expected/union/within_group/source.py +1 -0
  477. dev/test_data/parse_retree/expected/whitespace/source.py +1 -0
  478. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/Uxxxxxxxx_out_of_range/source.py +1 -0
  479. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/only_backslash/source.py +1 -0
  480. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_Uxxxxxxxx/source.py +1 -0
  481. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_uxxxx/source.py +1 -0
  482. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/short_x/source.py +1 -0
  483. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unexpected_escaping/source.py +1 -0
  484. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/digit/source.py +1 -0
  485. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_digit/source.py +1 -0
  486. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_whitespace/source.py +1 -0
  487. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/not_word/source.py +1 -0
  488. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/whitespace/source.py +1 -0
  489. dev/test_data/parse_retree/unexpected/improper_escaping/character_literal/unhandled/word/source.py +1 -0
  490. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/Uxxxxxxxx_out_of_range/source.py +1 -0
  491. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/only_backslash/source.py +1 -0
  492. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_Uxxxxxxxx/source.py +1 -0
  493. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_uxxxx/source.py +1 -0
  494. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/short_x/source.py +1 -0
  495. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unexpected_escaping/source.py +1 -0
  496. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/digit/source.py +1 -0
  497. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_digit/source.py +1 -0
  498. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_whitespace/source.py +1 -0
  499. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/not_word/source.py +1 -0
  500. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/whitespace/source.py +1 -0
  501. dev/test_data/parse_retree/unexpected/improper_escaping/range_character/unhandled/word/source.py +1 -0
  502. dev/test_data/parse_retree/unexpected/invalid_character_range/source.py +1 -0
  503. dev/test_data/parse_retree/unexpected/invalid_quantifier/at_least_x/source.py +1 -0
  504. dev/test_data/parse_retree/unexpected/invalid_quantifier/between_3_and_x/source.py +1 -0
  505. dev/test_data/parse_retree/unexpected/invalid_quantifier/exactly_x/source.py +1 -0
  506. dev/test_data/parse_retree/unexpected/unhandled_group_directives/source.py +1 -0
  507. dev/test_data/parse_retree/unexpected/unterminated/character_set/source.py +1 -0
  508. dev/test_data/parse_retree/unexpected/unterminated/group/source.py +1 -0
  509. dev/test_data/parse_retree/unexpected/unterminated/group_of_union_of_empty_concatenations/source.py +1 -0
  510. dev/test_data/parse_retree/unexpected/unterminated/quantifier/source.py +1 -0
  511. dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_comma/source.py +1 -0
  512. dev/test_data/parse_retree/unexpected/unterminated/quantifier_with_number_and_comma/source.py +1 -0
  513. dev/test_data/proto/test_main/expected/abstract_and_concrete_classes/meta_model.py +37 -0
  514. dev/test_data/proto/test_main/expected/concrete_class_with_descendants/meta_model.py +30 -0
  515. dev/test_data/proto/test_main/expected/concrete_class_with_enum/meta_model.py +21 -0
  516. dev/test_data/proto/test_main/expected/concrete_class_with_list_of_instances/meta_model.py +21 -0
  517. dev/test_data/proto/test_main/expected/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  518. dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/expected_output/pbization.py +532 -0
  519. dev/test_data/python_protobuf/test_main/abstract_and_concrete_classes/meta_model.py +37 -0
  520. dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/expected_output/pbization.py +527 -0
  521. dev/test_data/python_protobuf/test_main/concrete_class_with_descendant/meta_model.py +27 -0
  522. dev/test_data/python_protobuf/test_main/concrete_class_with_enum/expected_output/pbization.py +290 -0
  523. dev/test_data/python_protobuf/test_main/concrete_class_with_enum/meta_model.py +21 -0
  524. dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/expected_output/pbization.py +328 -0
  525. dev/test_data/python_protobuf/test_main/concrete_class_with_list_of_instances/meta_model.py +23 -0
  526. dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/expected_output/pbization.py +274 -0
  527. dev/test_data/python_protobuf/test_main/concrete_class_with_primitive_attributes/meta_model.py +41 -0
  528. dev/test_data/rdf_shacl/test_main/expected/regression_when_lang_string_class_is_missing/meta_model.py +29 -0
  529. dev/test_data/rdf_shacl/test_main/expected/regression_when_len_constraints_on_inherited_property/meta_model.py +27 -0
  530. dev/test_data/rdf_shacl/test_main/unexpected/regression_len_constraint_on_class_property/meta_model.py +61 -0
  531. dev/test_data/real_meta_models/aas_core_meta.v3.py +5721 -0
  532. dev/test_data/smoke/test_main/unexpected/infer_for_schema_error/meta_model.py +12 -0
  533. dev/test_data/smoke/test_main/unexpected/intermediate_error/meta_model.py +18 -0
  534. dev/test_data/smoke/test_main/unexpected/parse_error/meta_model.py +5 -0
  535. dev/test_data/smoke/test_main/unexpected/pattern_verification_unparsable_regex/direct_match/meta_model.py +8 -0
  536. dev/test_data/smoke/test_main/unexpected/type_error/meta_model.py +18 -0
  537. dev/tests/__init__.py +1 -0
  538. dev/tests/common.py +197 -0
  539. dev/tests/cpp/__init__.py +0 -0
  540. dev/tests/cpp/test_common.py +32 -0
  541. dev/tests/cpp/test_main.py +144 -0
  542. dev/tests/cpp/test_pattern.py +188 -0
  543. dev/tests/cpp/test_verification.py +189 -0
  544. dev/tests/cpp/test_yielding.py +225 -0
  545. dev/tests/csharp/__init__.py +0 -0
  546. dev/tests/csharp/live_test_main.py +109 -0
  547. dev/tests/csharp/test_common.py +28 -0
  548. dev/tests/csharp/test_description.py +684 -0
  549. dev/tests/csharp/test_main.py +129 -0
  550. dev/tests/csharp/test_structure.py +93 -0
  551. dev/tests/csharp/test_verification.py +82 -0
  552. dev/tests/description.py +29 -0
  553. dev/tests/golang/__init__.py +0 -0
  554. dev/tests/golang/test_common.py +78 -0
  555. dev/tests/golang/test_main.py +128 -0
  556. dev/tests/infer_for_schema/__init__.py +0 -0
  557. dev/tests/infer_for_schema/common.py +47 -0
  558. dev/tests/infer_for_schema/test_len_on_properties.py +955 -0
  559. dev/tests/infer_for_schema/test_len_on_self.py +580 -0
  560. dev/tests/infer_for_schema/test_patterns_on_properties.py +686 -0
  561. dev/tests/infer_for_schema/test_patterns_on_self.py +258 -0
  562. dev/tests/infer_for_schema/test_property_in_set_of_enumeration_literals.py +600 -0
  563. dev/tests/infer_for_schema/test_property_in_set_of_primitives.py +549 -0
  564. dev/tests/intermediate/__init__.py +0 -0
  565. dev/tests/intermediate/test_constructor.py +719 -0
  566. dev/tests/intermediate/test_hierarchy.py +221 -0
  567. dev/tests/intermediate/test_revm.py +134 -0
  568. dev/tests/intermediate/test_translate.py +337 -0
  569. dev/tests/intermediate/test_type_inference.py +333 -0
  570. dev/tests/intermediate/test_types.py +169 -0
  571. dev/tests/java/__init__.py +0 -0
  572. dev/tests/java/test_common.py +20 -0
  573. dev/tests/java/test_description.py +128 -0
  574. dev/tests/java/test_main.py +234 -0
  575. dev/tests/jsonld_context/test_main.py +79 -0
  576. dev/tests/opcua/__init__.py +3 -0
  577. dev/tests/opcua/test_main.py +110 -0
  578. dev/tests/our_jsonschema/__init__.py +3 -0
  579. dev/tests/our_jsonschema/test_main.py +232 -0
  580. dev/tests/parse/__init__.py +0 -0
  581. dev/tests/parse/test_parse.py +503 -0
  582. dev/tests/parse/test_retree.py +272 -0
  583. dev/tests/proto/__init__.py +0 -0
  584. dev/tests/proto/test_main.py +112 -0
  585. dev/tests/python/__init__.py +0 -0
  586. dev/tests/python/test_common.py +124 -0
  587. dev/tests/python/test_main.py +126 -0
  588. dev/tests/python/test_xml_playground.py +254 -0
  589. dev/tests/python_protobuf/__init__.py +0 -0
  590. dev/tests/python_protobuf/test_main.py +111 -0
  591. dev/tests/rdf_shacl/__init__.py +0 -0
  592. dev/tests/rdf_shacl/test_common.py +32 -0
  593. dev/tests/rdf_shacl/test_description.py +223 -0
  594. dev/tests/rdf_shacl/test_main.py +194 -0
  595. dev/tests/smoke/__init__.py +0 -0
  596. dev/tests/smoke/test_main.py +83 -0
  597. dev/tests/test_common.py +94 -0
  598. dev/tests/typescript/__init__.py +0 -0
  599. dev/tests/typescript/test_common.py +108 -0
  600. dev/tests/typescript/test_main.py +125 -0
  601. dev/tests/xsd/__init__.py +0 -0
  602. dev/tests/xsd/test_main.py +227 -0
  603. dev/tests/yielding/__init__.py +0 -0
  604. dev/tests/yielding/test_linear.py +558 -0
@@ -0,0 +1,955 @@
1
+ """Generate C++ code to de/stringify enumerations and primitives."""
2
+
3
+ import io
4
+ from typing import List
5
+
6
+ from icontract import ensure
7
+
8
+ import aas_core_codegen.naming
9
+ from aas_core_codegen import intermediate
10
+ from aas_core_codegen.common import Stripped, Identifier, indent_but_first_line
11
+ from aas_core_codegen.cpp import (
12
+ common as cpp_common,
13
+ naming as cpp_naming,
14
+ )
15
+ from aas_core_codegen.cpp.common import (
16
+ INDENT as I,
17
+ INDENT2 as II,
18
+ INDENT3 as III,
19
+ INDENT4 as IIII,
20
+ INDENT5 as IIIII,
21
+ )
22
+
23
+
24
+ def _generate_model_type_from_string_definition() -> List[Stripped]:
25
+ """Generate the definition of translation of a model type from string."""
26
+ enum_name = cpp_naming.enum_name(Identifier("Model_type"))
27
+ from_string = cpp_naming.function_name(Identifier("model_type_from_string"))
28
+ must_from_string = cpp_naming.function_name(
29
+ Identifier("must_model_type_from_string")
30
+ )
31
+
32
+ return [
33
+ Stripped(
34
+ f"""\
35
+ /**
36
+ * Try to parse the \\p text as a model type literal.
37
+ *
38
+ * \\param text to be parsed
39
+ * \\return literal, or nothing, if \\p text invalid
40
+ */
41
+ common::optional<types::{enum_name}> {from_string}(
42
+ {I}const std::string& text
43
+ );"""
44
+ ),
45
+ Stripped(
46
+ f"""\
47
+ /**
48
+ * Parse the \\p text as a model type literal.
49
+ *
50
+ * \\param text to be parsed
51
+ * \\return literal
52
+ * \\throw std::invalid_argument if \\p text invalid
53
+ */
54
+ types::{enum_name} {must_from_string}(
55
+ {I}const std::string& text
56
+ );"""
57
+ ),
58
+ ]
59
+
60
+
61
+ def _generate_model_type_from_string_implementation(
62
+ symbol_table: intermediate.SymbolTable,
63
+ ) -> List[Stripped]:
64
+ """Generate the implementation of translation of a model type from string."""
65
+ blocks = [] # type: List[Stripped]
66
+
67
+ # region Map
68
+
69
+ enum_name = cpp_naming.enum_name(Identifier("Model_type"))
70
+
71
+ items = [] # type: List[str]
72
+ for cls in symbol_table.concrete_classes:
73
+ literal_name = cpp_naming.enum_literal_name(cls.name)
74
+
75
+ literal_value = cpp_common.string_literal(
76
+ aas_core_codegen.naming.json_model_type(cls.name)
77
+ )
78
+
79
+ items.append(
80
+ Stripped(
81
+ f"""\
82
+ {{
83
+ {I}{literal_value},
84
+ {I}types::{enum_name}::{literal_name}
85
+ }}"""
86
+ )
87
+ )
88
+
89
+ map_name = cpp_naming.constant_name(Identifier("model_type_from_string_map"))
90
+
91
+ items_joined = ",\n".join(items)
92
+
93
+ blocks.append(
94
+ Stripped(
95
+ f"""\
96
+ const std::unordered_map<
97
+ {I}std::string,
98
+ {I}types::{enum_name}
99
+ > {map_name} = {{
100
+ {I}{indent_but_first_line(items_joined, I)}
101
+ }};"""
102
+ )
103
+ )
104
+
105
+ # endregion
106
+
107
+ # region From function
108
+
109
+ from_string = cpp_naming.function_name(Identifier("model_type_from_string"))
110
+
111
+ blocks.append(
112
+ Stripped(
113
+ f"""\
114
+ common::optional<types::{enum_name}> {from_string}(
115
+ {I}const std::string& text
116
+ ) {{
117
+ {I}const auto it = {map_name}.find(
118
+ {II}text
119
+ {I});
120
+ {I}if (it == {map_name}.end()) {{
121
+ {II}return {{}};
122
+ {I}}}
123
+ {I}return it->second;
124
+ }}"""
125
+ )
126
+ )
127
+
128
+ # endregion
129
+
130
+ # region Must-from function
131
+
132
+ must_from_string = cpp_naming.function_name(
133
+ Identifier("must_model_type_from_string")
134
+ )
135
+
136
+ blocks.append(
137
+ Stripped(
138
+ f"""\
139
+ types::{enum_name} {must_from_string}(
140
+ {I}const std::string& text
141
+ ) {{
142
+ {I}const auto it = {map_name}.find(
143
+ {II}text
144
+ {I});
145
+ {I}if (it == {map_name}.end()) {{
146
+ {II}throw std::invalid_argument(
147
+ {III}common::Concat(
148
+ {IIII}"Unexpected {enum_name} literal: ",
149
+ {IIII}text
150
+ {III})
151
+ {II});
152
+ {I}}}
153
+ {I}return it->second;
154
+ }}"""
155
+ )
156
+ )
157
+
158
+ # endregion
159
+
160
+ return blocks
161
+
162
+
163
+ def _generate_model_type_to_string_definition() -> Stripped:
164
+ """Generate the definition for translating a string to a model type."""
165
+ enum_name = cpp_naming.enum_name(Identifier("Model_type"))
166
+
167
+ model_type_arg = cpp_naming.argument_name(Identifier("model_type"))
168
+
169
+ # NOTE (mristin, 2023-07-12):
170
+ # We use ``to_string`` naming to resemble the functions in standard library.
171
+ return Stripped(
172
+ f"""\
173
+ /**
174
+ * Translate the enumeration literal \\p {model_type_arg} to text.
175
+ *
176
+ * \\param {model_type_arg} to be converted into text
177
+ * \\return text representation of \\p {model_type_arg}
178
+ * \\throw std::invalid_argument if \\p {model_type_arg} invalid
179
+ */
180
+ std::string to_string(
181
+ {I}types::{enum_name} {model_type_arg}
182
+ );"""
183
+ )
184
+
185
+
186
+ def _generate_model_type_to_string_implementation(
187
+ symbol_table: intermediate.SymbolTable,
188
+ ) -> Stripped:
189
+ """Generate the implementation for translating a string to a model type."""
190
+ enum_name = cpp_naming.enum_name(Identifier("Model_type"))
191
+
192
+ case_blocks = [] # type: List[Stripped]
193
+ for cls in symbol_table.concrete_classes:
194
+ literal_name = cpp_naming.enum_literal_name(cls.name)
195
+ literal_value = cpp_common.string_literal(
196
+ aas_core_codegen.naming.json_model_type(cls.name)
197
+ )
198
+
199
+ case_blocks.append(
200
+ Stripped(
201
+ f"""\
202
+ case types::{enum_name}::{literal_name}:
203
+ return {literal_value};"""
204
+ )
205
+ )
206
+
207
+ model_type_arg = cpp_naming.argument_name(Identifier("model_type"))
208
+
209
+ case_blocks.append(
210
+ Stripped(
211
+ f"""\
212
+ default:
213
+ {I}throw std::invalid_argument(
214
+ {II}common::Concat(
215
+ {III}"Unexpected model type: ",
216
+ {III}std::to_string(
217
+ {IIII}static_cast<std::uint32_t>(
218
+ {IIIII}{model_type_arg}
219
+ {IIII})
220
+ {III})
221
+ {II})
222
+ {I});"""
223
+ )
224
+ )
225
+
226
+ case_blocks_joined = "\n".join(case_blocks)
227
+
228
+ # NOTE (mristin, 2023-07-12):
229
+ # We use ``to_string`` naming to resemble the functions in standard library.
230
+ return Stripped(
231
+ f"""\
232
+ std::string to_string(
233
+ {I}types::{enum_name} {model_type_arg}
234
+ ) {{
235
+ {I}switch ({model_type_arg}) {{
236
+ {II}{indent_but_first_line(case_blocks_joined, II)}
237
+ {I}}}
238
+ }}"""
239
+ )
240
+
241
+
242
+ def _generate_enum_from_string_definition(
243
+ enum: intermediate.Enumeration,
244
+ ) -> List[Stripped]:
245
+ """Generate the definition of translation of an enum from string."""
246
+ enum_name = cpp_naming.enum_name(enum.name)
247
+ from_string = cpp_naming.function_name(Identifier(f"{enum.name}_from_string"))
248
+ must_from_string = cpp_naming.function_name(
249
+ Identifier(f"must_{enum.name}_from_string")
250
+ )
251
+
252
+ return [
253
+ Stripped(
254
+ f"""\
255
+ /**
256
+ * Try to parse the \\p text as a literal of
257
+ * types::{enum_name}.
258
+ *
259
+ * \\param text to be parsed
260
+ * \\return literal, or nothing, if \\p text invalid
261
+ */
262
+ common::optional<types::{enum_name}> {from_string}(
263
+ {I}const std::string& text
264
+ );"""
265
+ ),
266
+ Stripped(
267
+ f"""\
268
+ /**
269
+ * Parse the \\p text as a literal of
270
+ * types::{enum_name}.
271
+ *
272
+ * \\param text to be parsed
273
+ * \\return literal
274
+ * \\throw std::invalid_argument if \\p text invalid
275
+ */
276
+ types::{enum_name} {must_from_string}(
277
+ {I}const std::string& text
278
+ );"""
279
+ ),
280
+ ]
281
+
282
+
283
+ def _generate_enum_from_string_implementation(
284
+ enum: intermediate.Enumeration,
285
+ ) -> List[Stripped]:
286
+ """Generate the implementation of translation of an enum from string."""
287
+ blocks = [] # type: List[Stripped]
288
+
289
+ # region Map
290
+
291
+ enum_name = cpp_naming.enum_name(enum.name)
292
+
293
+ items = [] # type: List[str]
294
+ for literal in enum.literals:
295
+ literal_name = cpp_naming.enum_literal_name(literal.name)
296
+ literal_value = cpp_common.string_literal(literal.value)
297
+
298
+ items.append(
299
+ Stripped(
300
+ f"""\
301
+ {{
302
+ {I}{literal_value},
303
+ {I}types::{enum_name}::{literal_name}
304
+ }}"""
305
+ )
306
+ )
307
+
308
+ map_name = cpp_naming.constant_name(Identifier(f"{enum.name}_from_string_map"))
309
+
310
+ items_joined = ",\n".join(items)
311
+
312
+ blocks.append(
313
+ Stripped(
314
+ f"""\
315
+ const std::unordered_map<
316
+ {I}std::string,
317
+ {I}types::{enum_name}
318
+ > {map_name} = {{
319
+ {I}{indent_but_first_line(items_joined, I)}
320
+ }};"""
321
+ )
322
+ )
323
+
324
+ # endregion
325
+
326
+ # region From function
327
+
328
+ from_string = cpp_naming.function_name(Identifier(f"{enum.name}_from_string"))
329
+
330
+ blocks.append(
331
+ Stripped(
332
+ f"""\
333
+ common::optional<types::{enum_name}> {from_string}(
334
+ {I}const std::string& text
335
+ ) {{
336
+ {I}const auto it = {map_name}.find(
337
+ {II}text
338
+ {I});
339
+ {I}if (it == {map_name}.end()) {{
340
+ {II}return {{}};
341
+ {I}}}
342
+ {I}return it->second;
343
+ }}"""
344
+ )
345
+ )
346
+
347
+ # endregion
348
+
349
+ # region Must-from function
350
+
351
+ must_from_string = cpp_naming.function_name(
352
+ Identifier(f"must_{enum.name}_from_string")
353
+ )
354
+
355
+ blocks.append(
356
+ Stripped(
357
+ f"""\
358
+ types::{enum_name} {must_from_string}(
359
+ {I}const std::string& text
360
+ ) {{
361
+ {I}const auto it = {map_name}.find(
362
+ {II}text
363
+ {I});
364
+ {I}if (it == {map_name}.end()) {{
365
+ {II}throw std::invalid_argument(
366
+ {III}common::Concat(
367
+ {IIII}"Unexpected {enum_name} literal: ",
368
+ {IIII}text
369
+ {III})
370
+ {II});
371
+ {I}}}
372
+ {I}return it->second;
373
+ }}"""
374
+ )
375
+ )
376
+
377
+ # endregion
378
+
379
+ return blocks
380
+
381
+
382
+ def _generate_enum_to_string_definition(enum: intermediate.Enumeration) -> Stripped:
383
+ """Generate the definition for translating a string to an enum literal."""
384
+ enum_name = cpp_naming.enum_name(enum.name)
385
+
386
+ literal_arg = cpp_naming.argument_name(Identifier("literal"))
387
+
388
+ # NOTE (mristin, 2023-07-12):
389
+ # We use ``to_string`` naming to resemble the functions in standard library.
390
+ return Stripped(
391
+ f"""\
392
+ /**
393
+ * Translate the enumeration literal \\p {literal_arg}
394
+ * of types::{enum_name} to text.
395
+ *
396
+ * \\param {literal_arg} to be converted into text
397
+ * \\return text representation of \\p {literal_arg}
398
+ * \\throw std::invalid_argument if \\p {literal_arg} invalid
399
+ */
400
+ std::string to_string(
401
+ {I}types::{enum_name} {literal_arg}
402
+ );"""
403
+ )
404
+
405
+
406
+ def _generate_enum_to_string_implementation(enum: intermediate.Enumeration) -> Stripped:
407
+ """Generate the implementation for translating a string to an enum literal."""
408
+ enum_name = cpp_naming.enum_name(enum.name)
409
+
410
+ case_blocks = [] # type: List[Stripped]
411
+ for literal in enum.literals:
412
+ literal_name = cpp_naming.enum_literal_name(literal.name)
413
+ literal_value = cpp_common.string_literal(literal.value)
414
+
415
+ case_blocks.append(
416
+ Stripped(
417
+ f"""\
418
+ case types::{enum_name}::{literal_name}:
419
+ {I}return {literal_value};"""
420
+ )
421
+ )
422
+
423
+ literal_arg = cpp_naming.argument_name(Identifier("literal"))
424
+
425
+ case_blocks.append(
426
+ Stripped(
427
+ f"""\
428
+ default:
429
+ {I}throw std::invalid_argument(
430
+ {II}common::Concat(
431
+ {III}"Unexpected literal: ",
432
+ {III}std::to_string(
433
+ {IIII}static_cast<std::uint32_t>(
434
+ {IIIII}{literal_arg}
435
+ {IIII})
436
+ {III})
437
+ {II})
438
+ {I});"""
439
+ )
440
+ )
441
+
442
+ case_blocks_joined = "\n".join(case_blocks)
443
+
444
+ # NOTE (mristin, 2023-07-12):
445
+ # We use ``to_string`` naming to resemble the functions in standard library.
446
+ return Stripped(
447
+ f"""\
448
+ std::string to_string(
449
+ {I}types::{enum_name} {literal_arg}
450
+ ) {{
451
+ {I}switch ({literal_arg}) {{
452
+ {II}{indent_but_first_line(case_blocks_joined, II)}
453
+ {I}}}
454
+ }}"""
455
+ )
456
+
457
+
458
+ def _generate_base64_encode_definition() -> Stripped:
459
+ """Generate the definition of the base64 encoding of bytes to a string."""
460
+ function_name = cpp_naming.function_name(Identifier("base64_encode"))
461
+ return Stripped(
462
+ f"""\
463
+ /**
464
+ * Encode the \\p bytes with base64 to a std::string.
465
+ *
466
+ * \\param bytes to be encoded
467
+ * \\return base64-encoding of \\p bytes
468
+ */
469
+ std::string {function_name}(
470
+ {I}const std::vector<std::uint8_t>& bytes
471
+ );"""
472
+ )
473
+
474
+
475
+ def _generate_base64_encode_implementation() -> List[Stripped]:
476
+ """Generate the implementation of the base64 encoding of bytes to a string."""
477
+ char_base64_table = cpp_naming.constant_name(Identifier("char_base64_table"))
478
+ char_base64_table_len = cpp_naming.constant_name(
479
+ Identifier("char_base64_table_len")
480
+ )
481
+
482
+ function_name = cpp_naming.function_name(Identifier("base64_encode"))
483
+ # noinspection SpellCheckingInspection
484
+ return [
485
+ Stripped(
486
+ """\
487
+ // The following encoder has been adapted from Jouni Malinen <j@w1.fi> to work with
488
+ // std::string. The original source code is available at:
489
+ // https://web.mit.edu/freebsd/head/contrib/wpa/src/utils/base64.c
490
+ //
491
+ // See also the following StackOverflow question for a benchmark:
492
+ // https://stackoverflow.com/questions/342409/how-do-i-base64-encode-decode-in-c/41094722#41094722"""
493
+ ),
494
+ Stripped(
495
+ f"""\
496
+ constexpr std::size_t {char_base64_table_len} = 65;
497
+ static const unsigned char {char_base64_table}[{char_base64_table_len}](
498
+ {I}"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
499
+ );"""
500
+ ),
501
+ Stripped(
502
+ f"""\
503
+ std::string {function_name}(
504
+ {I}const std::vector<std::uint8_t>& bytes
505
+ ) {{
506
+ {I}// See: https://cplusplus.com/reference/vector/vector/data/.
507
+ {I}// The data is guaranteed to be a continuous block in memory.
508
+ {I}const unsigned char* const src(
509
+ {II}bytes.data()
510
+ {I});
511
+
512
+ {I}const std::size_t len = bytes.size();
513
+
514
+ {I}// 3-byte blocks to 4-byte
515
+ {I}const std::size_t olen = 4 * ((len + 2) / 3);
516
+
517
+ {I}// Integer overflow?
518
+ {I}if (olen < len) {{
519
+ {II}throw std::invalid_argument(
520
+ {III}common::Concat(
521
+ {IIII}"The calculation of the output length overflowed. "
522
+ {IIII}"The length was: ",
523
+ {IIII}std::to_string(len),
524
+ {IIII}", but the output length was calculated as: ",
525
+ {IIII}std::to_string(olen)
526
+ {III})
527
+ {II});
528
+ {I}}}
529
+
530
+ {I}std::string out_string;
531
+ {I}out_string.resize(olen);
532
+
533
+ {I}unsigned char* out(
534
+ {II}reinterpret_cast<unsigned char*>(
535
+ {III}&out_string[0]
536
+ {II})
537
+ {I});
538
+
539
+ {I}const unsigned char* const end = src + len;
540
+
541
+ {I}const unsigned char* in = src;
542
+ {I}unsigned char* pos = out;
543
+
544
+ {I}while (end - in >= 3) {{
545
+ {II}*pos++ = {char_base64_table}[in[0] >> 2];
546
+ {II}*pos++ = {char_base64_table}[((in[0] & 0x03) << 4) | (in[1] >> 4)];
547
+ {II}*pos++ = {char_base64_table}[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
548
+ {II}*pos++ = {char_base64_table}[in[2] & 0x3f];
549
+ {II}in += 3;
550
+ {I}}}
551
+
552
+ {I}if (end - in) {{
553
+ {II}*pos++ = {char_base64_table}[in[0] >> 2];
554
+
555
+ {II}if (end - in == 1) {{
556
+ {III}*pos++ = {char_base64_table}[(in[0] & 0x03) << 4];
557
+ {III}*pos++ = '=';
558
+ {II}}} else {{
559
+ {III}*pos++ = {char_base64_table}[
560
+ {IIII}((in[0] & 0x03) << 4) | (in[1] >> 4)
561
+ {III}];
562
+ {III}*pos++ = {char_base64_table}[(in[1] & 0x0f) << 2];
563
+ {II}}}
564
+ {II}*pos++ = '=';
565
+ {I}}}
566
+
567
+ {I}return out_string;
568
+ }}"""
569
+ ),
570
+ ]
571
+
572
+
573
+ def _generate_base64_decode_definition() -> Stripped:
574
+ """Generate the definition of the base64 decoding of a string to bytes."""
575
+ # NOTE (mristin, 2023-07-12):
576
+ # We decode intentionally from ``std::string``, and
577
+ function_name = cpp_naming.function_name(Identifier("base64_decode"))
578
+ return Stripped(
579
+ f"""\
580
+ /**
581
+ * Decode the \\p the text with base64 to bytes.
582
+ *
583
+ * \\remark \\parblock
584
+ * We intentionally decode from std::string and *not* from std::wstring as
585
+ * the de/serialization libraries currently work only with UTF-8 encoded strings.
586
+ * \\endparblock
587
+ *
588
+ * \\param text to be decoded
589
+ * \\return decoded bytes, or error message, if any.
590
+ */
591
+ common::expected<
592
+ {I}std::vector<std::uint8_t>,
593
+ {I}std::string
594
+ > {function_name}(
595
+ {I}const std::string& text
596
+ );"""
597
+ )
598
+
599
+
600
+ def _generate_base64_decode_implementation() -> List[Stripped]:
601
+ """Generate the implementation of the base64 decoding of a string to bytes."""
602
+ function_name = cpp_naming.function_name(Identifier("base64_decode"))
603
+ base64_lookup = cpp_naming.constant_name(Identifier("base64_lookup"))
604
+
605
+ char_base64_table = cpp_naming.constant_name(Identifier("char_base64_table"))
606
+ char_base64_table_len = cpp_naming.constant_name(
607
+ Identifier("char_base64_table_len")
608
+ )
609
+
610
+ construct_base64_lookup = cpp_naming.function_name(
611
+ Identifier("construct_base64_lookup")
612
+ )
613
+
614
+ return [
615
+ Stripped(
616
+ """\
617
+ // The following decoder is vaguely based on:
618
+ // https://github.com/danguer/blog-examples/blob/master/js/base64-binary.js,
619
+ // https://github.com/niklasvh/base64-arraybuffer/blob/master/src/index.ts and
620
+ // https://github.com/beatgammit/base64-js/blob/master/index.js."""
621
+ ),
622
+ Stripped(
623
+ f"""\
624
+ std::vector<std::uint8_t> {construct_base64_lookup}() {{
625
+ {I}std::vector<std::uint8_t> lookup(256, 255);
626
+ {I}for (std::uint8_t i = 0; i < {char_base64_table_len}; ++i) {{
627
+ {II}lookup.at({char_base64_table}[i]) = i;
628
+ {I}}}
629
+ {I}return lookup;
630
+ }}
631
+ const std::vector<std::uint8_t> {base64_lookup} = {construct_base64_lookup}();"""
632
+ ),
633
+ Stripped(
634
+ f"""\
635
+ common::expected<
636
+ {I}std::vector<std::uint8_t>,
637
+ {I}std::string
638
+ > {function_name}(
639
+ {I}const std::string& text
640
+ ) {{
641
+ {I}if (text.empty()) {{
642
+ {II}return std::vector<std::uint8_t>();
643
+ {I}}}
644
+
645
+ {I}const std::size_t len = text.size();
646
+ {I}std::size_t len_wo_pad = len;
647
+
648
+ {I}// NOTE (mristin):
649
+ {I}// Some implementations forget the padding, so we try to be robust and check
650
+ {I}// for the padding manually.
651
+ {I}std::size_t bytes_length = (len * 3) / 4;
652
+ {I}if (text[len - 1] == '=') {{
653
+ {II}bytes_length--;
654
+ {II}len_wo_pad--;
655
+
656
+ {II}if (text[len - 2] == '=') {{
657
+ {III}bytes_length--;
658
+ {III}len_wo_pad--;
659
+ {II}}}
660
+ {I}}}
661
+
662
+ {I}std::vector<std::uint8_t> bytes(bytes_length);
663
+
664
+ {I}const std::size_t base64_lookup_len = {base64_lookup}.size();
665
+
666
+ {I}std::size_t pointer = 0;
667
+
668
+ {I}for (std::size_t i = 0; i < len; i += 4) {{
669
+ {II}// NOTE (mristin):
670
+ {II}// Admittedly, this is very verbose code, but we want to be efficient, so we
671
+ {II}// opted for performance over readability here.
672
+
673
+ {II}const unsigned char code0 = text[i];
674
+ {II}if (code0 >= base64_lookup_len) {{
675
+ {III}std::string message = common::Concat(
676
+ {IIII}"Expected a valid character from base64-encoded string, "
677
+ {IIII}"but got at index ",
678
+ {IIII}std::to_string(i),
679
+ {IIII}": ",
680
+ {IIII}std::to_string(code0),
681
+ {IIII}" (code: ",
682
+ {IIII}std::to_string(static_cast<int>(code0)),
683
+ {IIII}")"
684
+ {III});
685
+
686
+ {III}return common::make_unexpected(message);
687
+ {II}}}
688
+ {II}const std::uint8_t encoded0 = {base64_lookup}[code0];
689
+ {II}if (encoded0 == 255) {{
690
+ {III}std::string message = common::Concat(
691
+ {IIII}"Expected a valid character from base64-encoded string, "
692
+ {IIII}"but got at index ",
693
+ {IIII}std::to_string(i),
694
+ {IIII}": ",
695
+ {IIII}std::to_string(code0),
696
+ {IIII}" (code: ",
697
+ {IIII}std::to_string(static_cast<int>(code0)),
698
+ {IIII}")"
699
+ {III});
700
+
701
+ {III}return common::make_unexpected(message);
702
+ {II}}}
703
+
704
+ {II}const unsigned char code1 = text[i + 1];
705
+ {II}if (code1 >= base64_lookup_len) {{
706
+ {III}std::string message = common::Concat(
707
+ {IIII}"Expected a valid character from base64-encoded string, "
708
+ {IIII}"but got at index ",
709
+ {IIII}std::to_string(i + 1),
710
+ {IIII}": ",
711
+ {IIII}std::to_string(code1),
712
+ {IIII}" (code: ",
713
+ {IIII}std::to_string(static_cast<int>(code1)),
714
+ {IIII}")"
715
+ {III});
716
+
717
+ {III}return common::make_unexpected(message);
718
+ {II}}}
719
+ {II}const std::uint8_t encoded1 = {base64_lookup}[code1];
720
+ {II}if (encoded1 == 255) {{
721
+ {III}std::string message = common::Concat(
722
+ {IIII}"Expected a valid character from base64-encoded string, "
723
+ {IIII}"but got at index ",
724
+ {IIII}std::to_string(i + 1),
725
+ {IIII}": ",
726
+ {IIII}std::to_string(code1),
727
+ {IIII}" (code: ",
728
+ {IIII}std::to_string(static_cast<int>(code1)),
729
+ {IIII}")"
730
+ {III});
731
+
732
+ {III}return common::make_unexpected(message);
733
+ {II}}}
734
+
735
+ {II}// We map padding to 65, which is the value of "A".
736
+ {II}const unsigned char code2 = i + 2 < len_wo_pad ? text[i + 2] : 65;
737
+ {II}if (code2 >= base64_lookup_len) {{
738
+ {III}std::string message = common::Concat(
739
+ {IIII}"Expected a valid character from base64-encoded string, "
740
+ {IIII}"but got at index ",
741
+ {IIII}std::to_string(i + 2),
742
+ {IIII}": ",
743
+ {IIII}std::to_string(code2),
744
+ {IIII}" (code: ",
745
+ {IIII}std::to_string(static_cast<int>(code2)),
746
+ {IIII}")"
747
+ {III});
748
+
749
+ {III}return common::make_unexpected(message);
750
+ {II}}}
751
+ {II}const std::uint8_t encoded2 = {base64_lookup}[code2];
752
+ {II}if (encoded2 == 255) {{
753
+ {III}std::string message = common::Concat(
754
+ {IIII}"Expected a valid character from base64-encoded string, "
755
+ {IIII}"but got at index ",
756
+ {IIII}std::to_string(i + 2),
757
+ {IIII}": ",
758
+ {IIII}std::to_string(code2),
759
+ {IIII}" (code: ",
760
+ {IIII}std::to_string(static_cast<int>(code2)),
761
+ {IIII}")"
762
+ {III});
763
+
764
+ {III}return common::make_unexpected(message);
765
+ {II}}}
766
+
767
+ {II}// We map padding to 65, which is the value of 'A'.
768
+ {II}const unsigned char code3 = i + 3 < len_wo_pad ? text[i + 3] : 65;
769
+ {II}if (code3 >= base64_lookup_len) {{
770
+ {III}std::string message = common::Concat(
771
+ {IIII}"Expected a valid character from base64-encoded string, "
772
+ {IIII}"but got at index ",
773
+ {IIII}std::to_string(i + 3),
774
+ {IIII}": ",
775
+ {IIII}std::to_string(code3),
776
+ {IIII}" (code: ",
777
+ {IIII}std::to_string(static_cast<int>(code3)),
778
+ {IIII}")"
779
+ {III});
780
+
781
+ {III}return common::make_unexpected(message);
782
+ {II}}}
783
+ {II}const std::uint8_t encoded3 = {base64_lookup}[code3];
784
+ {II}if (encoded3 == 255) {{
785
+ {III}std::string message = common::Concat(
786
+ {IIII}"Expected a valid character from base64-encoded string, "
787
+ {IIII}"but got at index ",
788
+ {IIII}std::to_string(i + 3),
789
+ {IIII}": ",
790
+ {IIII}std::to_string(code3),
791
+ {IIII}" (code: ",
792
+ {IIII}std::to_string(static_cast<int>(code3)),
793
+ {IIII}")"
794
+ {III});
795
+
796
+ {III}return common::make_unexpected(message);
797
+ {II}}}
798
+
799
+ {II}if (pointer >= bytes_length) {{
800
+ {III}break;
801
+ {II}}}
802
+ {II}bytes[pointer] = (encoded0 << 2) | (encoded1 >> 4);
803
+ {II}pointer++;
804
+
805
+ {II}if (pointer >= bytes_length) {{
806
+ {III}break;
807
+ {II}}}
808
+ {II}bytes[pointer] = ((encoded1 & 15) << 4) | (encoded2 >> 2);
809
+ {II}pointer++;
810
+
811
+ {II}if (pointer >= bytes_length) {{
812
+ {III}break;
813
+ {II}}}
814
+ {II}bytes[pointer] = ((encoded2 & 3) << 6) | (encoded3 & 63);
815
+ {II}pointer++;
816
+ {I}}}
817
+
818
+ {I}return bytes;
819
+ }}"""
820
+ ),
821
+ ]
822
+
823
+
824
+ # fmt: off
825
+ @ensure(
826
+ lambda result:
827
+ result.endswith('\n'),
828
+ "Trailing newline mandatory for valid end-of-files"
829
+ )
830
+ # fmt: on
831
+ def generate_header(
832
+ symbol_table: intermediate.SymbolTable, library_namespace: Stripped
833
+ ) -> str:
834
+ """Generate the C++ header code for stringification."""
835
+ namespace = Stripped(f"{library_namespace}::stringification")
836
+
837
+ include_guard_var = cpp_common.include_guard_var(namespace)
838
+
839
+ include_prefix_path = cpp_common.generate_include_prefix_path(library_namespace)
840
+
841
+ blocks = [
842
+ Stripped(
843
+ f"""\
844
+ #ifndef {include_guard_var}
845
+ #define {include_guard_var}"""
846
+ ),
847
+ cpp_common.WARNING,
848
+ Stripped(
849
+ f"""\
850
+ #include "{include_prefix_path}/common.hpp"
851
+ #include "{include_prefix_path}/types.hpp"
852
+
853
+ #pragma warning(push, 0)
854
+ #include <string>
855
+ #include <vector>
856
+ #pragma warning(pop)"""
857
+ ),
858
+ cpp_common.generate_namespace_opening(library_namespace),
859
+ Stripped(
860
+ """\
861
+ /**
862
+ * \\defgroup stringification Translate to strings, and, where applicable, from strings.
863
+ * @{
864
+ */
865
+ namespace stringification {"""
866
+ ),
867
+ *_generate_model_type_from_string_definition(),
868
+ _generate_model_type_to_string_definition(),
869
+ ]
870
+
871
+ for enum in symbol_table.enumerations:
872
+ blocks.extend(_generate_enum_from_string_definition(enum=enum))
873
+ blocks.append(_generate_enum_to_string_definition(enum=enum))
874
+
875
+ blocks.extend(
876
+ [
877
+ _generate_base64_encode_definition(),
878
+ _generate_base64_decode_definition(),
879
+ cpp_common.generate_namespace_closing(namespace),
880
+ Stripped("/**@}*/"),
881
+ cpp_common.WARNING,
882
+ Stripped(f"#endif // {include_guard_var}"),
883
+ ]
884
+ )
885
+
886
+ writer = io.StringIO()
887
+ for i, block in enumerate(blocks):
888
+ if i > 0:
889
+ writer.write("\n\n")
890
+
891
+ writer.write(block)
892
+
893
+ writer.write("\n")
894
+
895
+ return writer.getvalue()
896
+
897
+
898
+ # fmt: off
899
+ @ensure(
900
+ lambda result:
901
+ result.endswith('\n'),
902
+ "Trailing newline mandatory for valid end-of-files"
903
+ )
904
+ # fmt: on
905
+ def generate_implementation(
906
+ symbol_table: intermediate.SymbolTable, library_namespace: Stripped
907
+ ) -> str:
908
+ """Generate the C++ code for stringification."""
909
+ namespace = Stripped(f"{library_namespace}::stringification")
910
+
911
+ include_prefix_path = cpp_common.generate_include_prefix_path(library_namespace)
912
+
913
+ blocks = [
914
+ cpp_common.WARNING,
915
+ Stripped(
916
+ f"""\
917
+ #include "{include_prefix_path}/stringification.hpp"
918
+
919
+ #pragma warning(push, 0)
920
+ #include <unordered_map>
921
+ #pragma warning(pop)"""
922
+ ),
923
+ cpp_common.generate_namespace_opening(namespace),
924
+ *_generate_model_type_from_string_implementation(symbol_table=symbol_table),
925
+ _generate_model_type_to_string_implementation(symbol_table=symbol_table),
926
+ ] # type: List[Stripped]
927
+
928
+ for enum in symbol_table.enumerations:
929
+ blocks.extend(_generate_enum_from_string_implementation(enum=enum))
930
+ blocks.append(_generate_enum_to_string_implementation(enum=enum))
931
+
932
+ blocks.extend(
933
+ [
934
+ *_generate_base64_encode_implementation(),
935
+ *_generate_base64_decode_implementation(),
936
+ Stripped(
937
+ """\
938
+ } // namespace stringification
939
+ /**@}*/"""
940
+ ),
941
+ cpp_common.generate_namespace_closing(library_namespace),
942
+ cpp_common.WARNING,
943
+ ]
944
+ )
945
+
946
+ writer = io.StringIO()
947
+ for i, block in enumerate(blocks):
948
+ if i > 0:
949
+ writer.write("\n\n")
950
+
951
+ writer.write(block)
952
+
953
+ writer.write("\n")
954
+
955
+ return writer.getvalue()