EmbeddedProto 4.0.0b1__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 (63) hide show
  1. EmbeddedProto/EmbeddedProto.py +122 -0
  2. EmbeddedProto/Features.py +255 -0
  3. EmbeddedProto/Field.py +1295 -0
  4. EmbeddedProto/Oneof.py +74 -0
  5. EmbeddedProto/ProtoFile.py +210 -0
  6. EmbeddedProto/TypeDefinitions.py +367 -0
  7. EmbeddedProto/__init__.py +0 -0
  8. EmbeddedProto/__main__.py +28 -0
  9. EmbeddedProto/config.py +173 -0
  10. EmbeddedProto/custom_header.py +513 -0
  11. EmbeddedProto/embedded_proto_options.proto +62 -0
  12. EmbeddedProto/embedded_proto_options_pb2.py +37 -0
  13. EmbeddedProto/field_options.py +344 -0
  14. EmbeddedProto/main.py +316 -0
  15. EmbeddedProto/src/EmbeddedProto/BytesStringCallback.h +476 -0
  16. EmbeddedProto/src/EmbeddedProto/Defines.h +118 -0
  17. EmbeddedProto/src/EmbeddedProto/EmptyArray.h +81 -0
  18. EmbeddedProto/src/EmbeddedProto/Errors.h +53 -0
  19. EmbeddedProto/src/EmbeddedProto/FieldStringBytes.h +793 -0
  20. EmbeddedProto/src/EmbeddedProto/Fields.h +832 -0
  21. EmbeddedProto/src/EmbeddedProto/Functional.h +412 -0
  22. EmbeddedProto/src/EmbeddedProto/MessageCallback.h +688 -0
  23. EmbeddedProto/src/EmbeddedProto/MessageInterface.h +792 -0
  24. EmbeddedProto/src/EmbeddedProto/MessageSizeCalculator.h +109 -0
  25. EmbeddedProto/src/EmbeddedProto/MessageState.h +207 -0
  26. EmbeddedProto/src/EmbeddedProto/ReadBufferFixedSize.h +204 -0
  27. EmbeddedProto/src/EmbeddedProto/ReadBufferInterface.h +181 -0
  28. EmbeddedProto/src/EmbeddedProto/ReadBufferSection.h +232 -0
  29. EmbeddedProto/src/EmbeddedProto/RepeatedField.h +1053 -0
  30. EmbeddedProto/src/EmbeddedProto/RepeatedFieldCallback.h +432 -0
  31. EmbeddedProto/src/EmbeddedProto/RepeatedFieldFixedSize.h +367 -0
  32. EmbeddedProto/src/EmbeddedProto/Version.h +39 -0
  33. EmbeddedProto/src/EmbeddedProto/WireFormatter.h +852 -0
  34. EmbeddedProto/src/EmbeddedProto/WriteBufferFixedSize.h +114 -0
  35. EmbeddedProto/src/EmbeddedProto/WriteBufferInterface.h +134 -0
  36. EmbeddedProto/src/EmbeddedProto.h +55 -0
  37. EmbeddedProto/templates/FieldBasic_Deserialize.h.jinja2 +26 -0
  38. EmbeddedProto/templates/FieldBasic_GetSet.h.jinja2 +89 -0
  39. EmbeddedProto/templates/FieldBytes_GetSet.h.jinja2 +86 -0
  40. EmbeddedProto/templates/FieldEnum_Deserialize.h.jinja2 +50 -0
  41. EmbeddedProto/templates/FieldEnum_GetSet.h.jinja2 +93 -0
  42. EmbeddedProto/templates/FieldErrorRecursive_GetSet.h.jinja2 +29 -0
  43. EmbeddedProto/templates/FieldMap_GetSet.h.jinja2 +203 -0
  44. EmbeddedProto/templates/FieldMsg_Deserialize.h.jinja2 +44 -0
  45. EmbeddedProto/templates/FieldMsg_GetSet.h.jinja2 +93 -0
  46. EmbeddedProto/templates/FieldRepeated_GetSet.h.jinja2 +94 -0
  47. EmbeddedProto/templates/FieldString_GetSet.h.jinja2 +86 -0
  48. EmbeddedProto/templates/Field_DeserializePartial.h.jinja2 +33 -0
  49. EmbeddedProto/templates/Field_Serialize.h.jinja2 +112 -0
  50. EmbeddedProto/templates/Field_SerializePartial.h.jinja2 +119 -0
  51. EmbeddedProto/templates/Header.h.jinja2 +108 -0
  52. EmbeddedProto/templates/TypeDefEnum.h.jinja2 +45 -0
  53. EmbeddedProto/templates/TypeDefMsg.h.jinja2 +791 -0
  54. EmbeddedProto/templates/TypeOneof.h.jinja2 +178 -0
  55. EmbeddedProto/version.json +3 -0
  56. embeddedproto-4.0.0b1.dist-info/METADATA +141 -0
  57. embeddedproto-4.0.0b1.dist-info/RECORD +63 -0
  58. embeddedproto-4.0.0b1.dist-info/WHEEL +5 -0
  59. embeddedproto-4.0.0b1.dist-info/entry_points.txt +3 -0
  60. embeddedproto-4.0.0b1.dist-info/licenses/LICENSE +30 -0
  61. embeddedproto-4.0.0b1.dist-info/licenses/LICENSES/GPL-3.0-only.txt +674 -0
  62. embeddedproto-4.0.0b1.dist-info/licenses/LICENSES/LicenseRef-EmbeddedProto-Commercial.txt +12 -0
  63. embeddedproto-4.0.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,119 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ {# Template for partial field serialization.
24
+ This simplified template delegates to library methods instead of inlining
25
+ the state machine logic. See doc/design/partial_serialization_design_v2.md
26
+ #}
27
+
28
+ {% if field.uses_serialize_len() %}
29
+ {# ======================================================================= #}
30
+ {# Field types that use LENGTH_DELIMITED: messages, strings, bytes, repeated #}
31
+ {# ======================================================================= #}
32
+
33
+ {% if field.callback_is_len_expanded() %}
34
+ {# ------------------------------------------------------------------------- #}
35
+ {# Map callback storage: pull each entry from the bound source and emit it #}
36
+ {# length delimited, resuming across a full buffer without pulling any entry #}
37
+ {# twice. Same framing a resident map uses, so a protoc peer can read it. #}
38
+ {# ------------------------------------------------------------------------- #}
39
+ return_value = {{field.get_variable_name()}}.serialize_partial_as_field_expanded_len(
40
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state, false);
41
+
42
+ {% elif field.callback_is_expanded() %}
43
+ {# ------------------------------------------------------------------------- #}
44
+ {# Repeated callback storage: pull each element from the bound source and emit #}
45
+ {# it EXPANDED (one tag+value or one group per element), resuming across a #}
46
+ {# full buffer without pulling any element twice. #}
47
+ {# ------------------------------------------------------------------------- #}
48
+ return_value = {{field.get_variable_name()}}.serialize_partial_as_field_expanded(
49
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state, false);
50
+
51
+ {% elif (field.optional or (field.oneof is not none)) %}
52
+ {# ------------------------------------------------------------------------- #}
53
+ {# Optional or oneof LENGTH_DELIMITED field #}
54
+ {# ------------------------------------------------------------------------- #}
55
+ if(has_{{field.get_name()}}())
56
+ {
57
+ {% if field.is_delimited() %}
58
+ return_value = {{field.get_variable_name()}}.serialize_partial_as_group(
59
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state);
60
+ {% else %}
61
+ return_value = {{field.get_variable_name()}}.serialize_partial_as_field(
62
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state, true);
63
+ {% endif %}
64
+ }
65
+ else
66
+ {
67
+ state.phase = ::EmbeddedProto::FieldProcessingPhase::COMPLETE;
68
+ }
69
+
70
+ {% elif field.is_delimited() %}
71
+ {# ------------------------------------------------------------------------- #}
72
+ {# Implicit / LEGACY_REQUIRED DELIMITED message field. #}
73
+ {# ------------------------------------------------------------------------- #}
74
+ return_value = {{field.get_variable_name()}}.serialize_partial_as_group(
75
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state);
76
+ {% elif (field.is_packed is defined) and (not field.is_packed()) and (not field.element_is_length_delimited()) %}
77
+ {# ------------------------------------------------------------------------- #}
78
+ {# EXPANDED repeated scalar/enum field (editions repeated_field_encoding). #}
79
+ {# Force one-tag-per-element output so partial matches full serialization. #}
80
+ {# ------------------------------------------------------------------------- #}
81
+ return_value = {{field.get_variable_name()}}.serialize_partial_as_field_expanded(
82
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state, false);
83
+ {% else %}
84
+ {# ------------------------------------------------------------------------- #}
85
+ {# Implicit / LEGACY_REQUIRED LENGTH_DELIMITED field. LEGACY_REQUIRED is always #}
86
+ {# serialized (force=true), implicit only when != default (force=false). #}
87
+ {# ------------------------------------------------------------------------- #}
88
+ return_value = {{field.get_variable_name()}}.serialize_partial_as_field(
89
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state, {{ "true" if field.always_serialize else "false" }});
90
+ {% endif %}
91
+
92
+ {% else %}
93
+ {# ======================================================================= #}
94
+ {# Basic scalar types and enums #}
95
+ {# ======================================================================= #}
96
+
97
+ {% if (field.optional or (field.oneof is not none)) %}
98
+ {# ------------------------------------------------------------------------- #}
99
+ {# Optional or oneof scalar field #}
100
+ {# ------------------------------------------------------------------------- #}
101
+ if(has_{{field.get_name()}}())
102
+ {
103
+ return_value = {{field.get_variable_name()}}.serialize_partial_with_id(
104
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state, true);
105
+ }
106
+ else
107
+ {
108
+ state.phase = ::EmbeddedProto::FieldProcessingPhase::COMPLETE;
109
+ }
110
+
111
+ {% else %}
112
+ {# ------------------------------------------------------------------------- #}
113
+ {# Implicit / LEGACY_REQUIRED scalar field. LEGACY_REQUIRED is always #}
114
+ {# serialized (force=true), implicit only when != default (force=false). #}
115
+ {# ------------------------------------------------------------------------- #}
116
+ return_value = {{field.get_variable_name()}}.serialize_partial_with_id(
117
+ static_cast<uint32_t>(FieldNumber::{{field.get_variable_id_name()}}), buffer, state, {{ "true" if field.always_serialize else "false" }});
118
+ {% endif %}
119
+ {% endif %}
@@ -0,0 +1,108 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ {% if custom_header %}
24
+ {{ custom_header }}
25
+ {% else %}
26
+ /*
27
+ * This file contains code based on templates from Embedded Proto,
28
+ * Copyright (C) Embedded AMS B.V.
29
+ *
30
+ * Embedded Proto is dual licensed. Without a commercial license from
31
+ * Embedded AMS B.V. the template code in this file is licensed under the
32
+ * GNU General Public License version 3 (GPLv3), and
33
+ * any product you distribute that includes it must release its source code
34
+ * under the GPLv3. A commercial license removes that obligation.
35
+ * See <https://embeddedproto.com/pricing/>.
36
+ *
37
+ * SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
38
+ */
39
+ {% endif %}
40
+ /*
41
+ * This file is generated with Embedded Proto, PLEASE DO NOT EDIT!
42
+ * source: {{proto_file.descriptor.name}}
43
+ * Generated on: {{ current_date_and_time }}
44
+ */
45
+
46
+ // This file is generated. Please do not edit!
47
+ #ifndef {{proto_file.get_header_guard()}}_H
48
+ #define {{proto_file.get_header_guard()}}_H
49
+
50
+ #include <cstdint>
51
+ #include <EmbeddedProto/Version.h>
52
+
53
+ //! The major version number of the Embedded Proto generator used to create this file.
54
+ #define {{proto_file.filename_without_folder|upper}}_GENERATOR_VERSION_MAJOR {{version_major}}
55
+
56
+ //! The minor version number of the Embedded Proto generator used to create this file.
57
+ #define {{proto_file.filename_without_folder|upper}}_GENERATOR_VERSION_MINOR {{version_minor}}
58
+
59
+ //! The patch version number of the Embedded Proto generator used to create this file.
60
+ #define {{proto_file.filename_without_folder|upper}}_GENERATOR_VERSION_PATCH {{version_patch}}
61
+
62
+ static_assert({{proto_file.filename_without_folder|upper}}_GENERATOR_VERSION_MAJOR == EMBEDDEDPROTO_VERSION_MAJOR,
63
+ "Major version mismatch between generated code and library");
64
+
65
+ #if {{proto_file.filename_without_folder|upper}}_GENERATOR_VERSION_MINOR != EMBEDDEDPROTO_VERSION_MINOR
66
+ #warning "Minor version mismatch between generated code and library"
67
+ #endif
68
+
69
+ {% if proto_file.msg_definitions %}
70
+ #include <EmbeddedProto/MessageInterface.h>
71
+ #include <EmbeddedProto/WireFormatter.h>
72
+ #include <EmbeddedProto/Fields.h>
73
+ #include <EmbeddedProto/MessageSizeCalculator.h>
74
+ #include <EmbeddedProto/ReadBufferSection.h>
75
+ #include <EmbeddedProto/RepeatedFieldFixedSize.h>
76
+ #include <EmbeddedProto/RepeatedFieldCallback.h>
77
+ #include <EmbeddedProto/MessageCallback.h>
78
+ #include <EmbeddedProto/FieldStringBytes.h>
79
+ #include <EmbeddedProto/BytesStringCallback.h>
80
+ #include <EmbeddedProto/Errors.h>
81
+ #include <EmbeddedProto/Defines.h>
82
+ #include <limits>
83
+ #include <type_traits>
84
+
85
+ {% endif %}
86
+ {% if proto_file.get_dependencies() is defined %}
87
+ // Include external proto definitions
88
+ {% for dependency in proto_file.get_dependencies() %}
89
+ #include "{{dependency}}"
90
+ {% endfor %}
91
+
92
+ {% endif %}
93
+ {% for namespace in proto_file.get_namespaces() %}
94
+ namespace {{ namespace }} {
95
+ {% endfor %}
96
+
97
+ {% for enum in proto_file.enum_definitions %}
98
+ {{ enum.render(environment) }}
99
+
100
+ {% endfor %}
101
+ {% for msg in proto_file.msg_definitions %}
102
+ {{ msg.render(environment) }}
103
+
104
+ {% endfor %}
105
+ {% for namespace in proto_file.get_namespaces()|reverse %}
106
+ } // End of namespace {{ namespace }}
107
+ {% endfor %}
108
+ #endif // {{proto_file.get_header_guard()}}_H
@@ -0,0 +1,45 @@
1
+ {#
2
+ Copyright (C) 2020-2026 Embedded AMS B.V. - All Rights Reserved
3
+
4
+ This file is part of Embedded Proto.
5
+
6
+ Embedded Proto is dual licensed. You may use it under the terms of the
7
+ GNU General Public License version 3 (GPLv3) as published by the Free
8
+ Software Foundation, or under a commercial license from Embedded AMS B.V.
9
+
10
+ Under the GPLv3 you must release the source code of
11
+ any product you distribute that includes Embedded Proto or code
12
+ generated by it. A commercial license removes that obligation.
13
+ See <https://embeddedproto.com/pricing/>.
14
+
15
+ Embedded Proto is distributed WITHOUT ANY WARRANTY; without even the
16
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ See the LICENSE file in the root of the repository for details.
18
+
19
+ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-EmbeddedProto-Commercial
20
+
21
+ Embedded AMS B.V., Hoorn, the Netherlands - info at EmbeddedProto dot com
22
+ #}
23
+ enum class {{ typedef.name }} : uint32_t
24
+ {
25
+ {% for value in typedef.values() %}
26
+ {{ value.name }} = {{ value.number }}{{ "," if not loop.last }}
27
+ {% endfor %}
28
+ };
29
+ {%- if typedef.is_closed() %}
30
+
31
+
32
+ // CLOSED enum (editions enum_type feature): returns true only for declared values.
33
+ static inline bool {{ typedef.name }}_is_valid(const uint32_t value)
34
+ {
35
+ switch(value)
36
+ {
37
+ {% for number in typedef.unique_value_numbers() %}
38
+ case {{ number }}U:
39
+ {% endfor %}
40
+ return true;
41
+ default:
42
+ return false;
43
+ }
44
+ }
45
+ {%- endif %}