idl-parser 0.6.0__tar.gz → 0.6.2__tar.gz
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.
- {idl_parser-0.6.0 → idl_parser-0.6.2}/PKG-INFO +2 -1
- {idl_parser-0.6.0 → idl_parser-0.6.2}/README.md +1 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/README.rst +1 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/docs/api/index.rst +1 -0
- idl_parser-0.6.2/examples/repository_id_example.py +62 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/union_example.py +2 -2
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/bitmask.py +2 -1
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/bitset.py +9 -1
- idl_parser-0.6.2/idl_parser/const.py +271 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/const_expr.py +167 -5
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/definitions.py +141 -49
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/enum.py +23 -1
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/interface.py +101 -14
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/module.py +114 -30
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/node.py +118 -7
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/parser.py +93 -25
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/pragma.py +74 -9
- idl_parser-0.6.2/idl_parser/repository_id.py +264 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/struct.py +25 -2
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/token_buffer.py +90 -5
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/type.py +34 -1
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/union.py +177 -13
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/valuetype.py +19 -5
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser.egg-info/PKG-INFO +2 -1
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser.egg-info/SOURCES.txt +15 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser.egg-info/scm_file_list.json +15 -0
- idl_parser-0.6.2/idl_parser.egg-info/scm_version.json +8 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/examples/examples_test.py +23 -2
- idl_parser-0.6.2/tests/include/filepath_absolute_test.py +89 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/interface/interface_body_test.py +14 -14
- idl_parser-0.6.2/tests/interface/multiword_return_type_test.py +125 -0
- idl_parser-0.6.2/tests/interface/self_reference_test.py +116 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/bracket_spacing_test.py +1 -1
- idl_parser-0.6.2/tests/lexing/file_encoding_test.py +101 -0
- idl_parser-0.6.2/tests/lexing/node_line_number_test.py +144 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/preprocessor_test.py +3 -3
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/string_literal_comment_test.py +1 -1
- idl_parser-0.6.2/tests/pragma_key/repository_id_test.py +365 -0
- idl_parser-0.6.2/tests/primitive_const/builtin_corba_type_test.py +135 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/primitive_const/const_expr_test.py +6 -6
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/primitive_const/const_test.py +1 -1
- idl_parser-0.6.2/tests/primitive_const/const_typed_value_test.py +175 -0
- idl_parser-0.6.2/tests/scope/declaration_order_test.py +123 -0
- idl_parser-0.6.2/tests/scope/escaped_identifier_test.py +124 -0
- idl_parser-0.6.2/tests/scope/semantic_check_test.py +273 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/unknown_word_test.py +3 -2
- idl_parser-0.6.2/tests/struct_enum_union/member_type_definition_test.py +152 -0
- idl_parser-0.6.2/tests/struct_enum_union/union_discriminator_test.py +186 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/valuetype/valuetype_test.py +3 -3
- idl_parser-0.6.0/idl_parser/const.py +0 -119
- idl_parser-0.6.0/idl_parser.egg-info/scm_version.json +0 -8
- {idl_parser-0.6.0 → idl_parser-0.6.2}/.github/workflows/release.yml +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/.github/workflows/test.yml +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/.gitignore +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/.readthedocs.yaml +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/.vscode/extensions.json +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/.vscode/launch.json +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/.vscode/settings.json +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/LICENSE +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/docs/conf.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/docs/index.rst +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/docs/requirements.txt +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/_path.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/annotation_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/any_fixed_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/argument_direction_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/conditional_include/platform_a.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/conditional_include/platform_b.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/conditional_include/platform_default.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/conditional_include/robot.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/conditional_include_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/const_expr_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/enum_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/enum_value_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/include_dirs/common/time.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/include_dirs/geometry/geometry.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/include_dirs/geometry/path.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/include_dirs/navigation/navigator.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/include_dirs_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/preprocessor_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/scoped_name_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/struct_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/struct_inheritance_map_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/typedef_template_module_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/examples/valuetype_example.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/exception.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/native.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/preprocessor.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser/typedef.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser.egg-info/dependency_links.txt +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/idl_parser.egg-info/top_level.txt +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/pyproject.toml +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/setup.cfg +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/README.md +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/annotation/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/annotation/annotation_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/annotation/bit_bound_scope_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/annotation/string_argument_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/bitmask_bitset/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/bitmask_bitset/bitmask_bitset_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/examples/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/forward_declaration/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/forward_declaration/element_type_forward_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/forward_declaration/interface_forward_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/forward_declaration/struct_union_forward_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/basic_module_test.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/circular/circular_a.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/circular/circular_b.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/circular/diamond.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/forward_declaration.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/generalization.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/generalization_extended.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/included_idl.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/including_idl.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/invalid_idl.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue12_subpath/relative_include.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue12_subpath/sensor_msgs/msg/Imu.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue12_subpath/std/msg/Header.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue18_idl42_int_types.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue28_pragma_keylist.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue9_const_pragma.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue9_tabs_bounded_string.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/issue9_whitespace_variants.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/multi_include_dirs/common/time.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/multi_include_dirs/geometry/geometry.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/multi_include_dirs/geometry/path.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/multi_include_dirs/navigation/navigator.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/idls/multi_module_test.idl +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/circular_include_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/conditional_include_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/filepath_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/include_dirs_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/missing_include_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/multi_include_dirs_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/parse_dirs_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/include/subpath_include_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/interface/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/interface/argument_direction_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/interface/basic_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/interface/inheritance_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/interface/local_abstract_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/interface/raises_context_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/basic_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/error_line_number_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/exception_message_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/opensplice_idl_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/reserved_word_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/lexing/token_split_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/output/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/output/constructor_python_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/output/simple_dic_enum_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/output/simple_dic_inherits_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/output/simple_dic_member_only_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/output/simple_dic_member_type_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/pragma_key/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/pragma_key/key_annotation_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/pragma_key/keylist_validation_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/pragma_key/pragma_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/primitive_const/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/primitive_const/any_object_fixed_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/primitive_const/basic_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/primitive_const/int_types_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/primitive_const/native_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/basename_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/basic_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/leading_scope_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/multi_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/pathname_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/same_name_resolution_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/template_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/scope/unsupported_block_scope_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/sequence_array/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/sequence_array/basic_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/sequence_array/element_type_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/sequence_array/map_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/sequence_array/nested_bounded_sequence_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/sequence_array/syntax_error_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/__init__.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/basic_module_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/enum_value_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/exception_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/multiple_declarators_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/struct_inheritance_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/syntax_error_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/typedef_constr_type_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/union_char_label_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/struct_enum_union/union_default_label_test.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/support.py +0 -0
- {idl_parser-0.6.0 → idl_parser-0.6.2}/tests/valuetype/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: idl_parser
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Very simple OMG IDL (Interface Definition Language) parser. This parses IDL files and outputs intermediate class objects.
|
|
5
5
|
Author-email: ysuga <ysuga@ysuga.net>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -112,6 +112,7 @@ More examples are in the ``examples`` folder of the repository:
|
|
|
112
112
|
- ``typedef_template_module_example.py``: types declared inside a typedef (``typedef enum E { ... } EE;``), and template modules, which are skipped with a warning
|
|
113
113
|
- ``union_example.py``: unions (discriminator kinds, case and ``default`` labels, member types)
|
|
114
114
|
- ``annotation_example.py``: IDL 4 annotations (``@key``, ``@range``, ...) and struct keys
|
|
115
|
+
- ``repository_id_example.py``: repository IDs (``IDL:omg.org/CosNaming/NamingContext:1.0``) from ``#pragma prefix`` / ``ID`` / ``version``, ``typeid`` and ``typeprefix``
|
|
115
116
|
- ``scoped_name_example.py``: same-named types in several modules (relative ``X``, ``C::X`` and absolute ``::B::X`` names)
|
|
116
117
|
|
|
117
118
|
https://github.com/sugarsweetrobotics/idl_parser/tree/main/examples
|
|
@@ -90,6 +90,7 @@ More examples are in the [examples](examples/) folder:
|
|
|
90
90
|
| [`valuetype_example.py`](examples/valuetype_example.py) | value types and event types: state members, `factory`, inheritance, `supports`, boxed value types |
|
|
91
91
|
| [`include_dirs_example.py`](examples/include_dirs_example.py) | IDL files that `#include` each other across several include directories |
|
|
92
92
|
| [`conditional_include_example.py`](examples/conditional_include_example.py) | `#include` in `#if` / `#elif` / `#else` branches: only the files of the kept branch are read |
|
|
93
|
+
| [`repository_id_example.py`](examples/repository_id_example.py) | repository IDs (`IDL:omg.org/CosNaming/NamingContext:1.0`) from `#pragma prefix` / `ID` / `version`, `typeid` and `typeprefix` |
|
|
93
94
|
| [`scoped_name_example.py`](examples/scoped_name_example.py) | same-named types in several modules: relative (`X`, `C::X`) and absolute (`::B::X`) names |
|
|
94
95
|
|
|
95
96
|
Run them with e.g. `python examples/union_example.py` (in a source checkout no install is needed).
|
|
@@ -89,6 +89,7 @@ More examples are in the ``examples`` folder of the repository:
|
|
|
89
89
|
- ``typedef_template_module_example.py``: types declared inside a typedef (``typedef enum E { ... } EE;``), and template modules, which are skipped with a warning
|
|
90
90
|
- ``union_example.py``: unions (discriminator kinds, case and ``default`` labels, member types)
|
|
91
91
|
- ``annotation_example.py``: IDL 4 annotations (``@key``, ``@range``, ...) and struct keys
|
|
92
|
+
- ``repository_id_example.py``: repository IDs (``IDL:omg.org/CosNaming/NamingContext:1.0``) from ``#pragma prefix`` / ``ID`` / ``version``, ``typeid`` and ``typeprefix``
|
|
92
93
|
- ``scoped_name_example.py``: same-named types in several modules (relative ``X``, ``C::X`` and absolute ``::B::X`` names)
|
|
93
94
|
|
|
94
95
|
https://github.com/sugarsweetrobotics/idl_parser/tree/main/examples
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Example: repository IDs (``IDL:omg.org/CosNaming/NamingContext:1.0``).
|
|
2
|
+
|
|
3
|
+
Shows that
|
|
4
|
+
- each definition has ``repository_id``,
|
|
5
|
+
- ``#pragma prefix`` adds a prefix to the definitions after it, up to the
|
|
6
|
+
end of its scope,
|
|
7
|
+
- ``#pragma version`` changes the version, and ``#pragma ID`` / ``typeid``
|
|
8
|
+
give the whole ID,
|
|
9
|
+
- ``typeprefix`` adds a prefix to a scope and everything in it.
|
|
10
|
+
|
|
11
|
+
Run::
|
|
12
|
+
|
|
13
|
+
python examples/repository_id_example.py
|
|
14
|
+
"""
|
|
15
|
+
import _path # noqa: F401 (use the idl_parser of this checkout)
|
|
16
|
+
|
|
17
|
+
from idl_parser import parser
|
|
18
|
+
|
|
19
|
+
IDL = '''
|
|
20
|
+
#pragma prefix "omg.org"
|
|
21
|
+
module CosNaming {
|
|
22
|
+
typedef string Istring;
|
|
23
|
+
interface NamingContext {
|
|
24
|
+
exception NotFound { long why; };
|
|
25
|
+
void unbind(in Istring n) raises (NotFound);
|
|
26
|
+
};
|
|
27
|
+
#pragma version NamingContext 1.1
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
module Legacy {
|
|
31
|
+
struct Point { long x; long y; };
|
|
32
|
+
typeid Point "DCE:9e2f5c1a-0001:1";
|
|
33
|
+
struct Size { long w; long h; };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
module Robot {
|
|
37
|
+
typeprefix Robot "example.com";
|
|
38
|
+
interface Arm { void move(in long x); };
|
|
39
|
+
};
|
|
40
|
+
'''
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main():
|
|
44
|
+
g = parser.IDLParser().load(IDL)
|
|
45
|
+
naming = g.module_by_name('CosNaming')
|
|
46
|
+
nc = naming.interface_by_name('NamingContext')
|
|
47
|
+
legacy = g.module_by_name('Legacy')
|
|
48
|
+
arm = g.module_by_name('Robot').interface_by_name('Arm')
|
|
49
|
+
for node, label in [(naming, 'CosNaming'),
|
|
50
|
+
(naming.typedef_by_name('Istring'), 'CosNaming::Istring'),
|
|
51
|
+
(nc, 'CosNaming::NamingContext'),
|
|
52
|
+
(nc.exceptions[0], 'CosNaming::NamingContext::NotFound'),
|
|
53
|
+
(nc.method_by_name('unbind'), 'CosNaming::NamingContext::unbind'),
|
|
54
|
+
(legacy.struct_by_name('Point'), 'Legacy::Point'),
|
|
55
|
+
(legacy.struct_by_name('Size'), 'Legacy::Size'),
|
|
56
|
+
(arm, 'Robot::Arm'),
|
|
57
|
+
(arm.method_by_name('move'), 'Robot::Arm::move')]:
|
|
58
|
+
print('%-36s %s' % (label, node.repository_id))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if __name__ == '__main__':
|
|
62
|
+
main()
|
|
@@ -29,7 +29,7 @@ module shapes {
|
|
|
29
29
|
|
|
30
30
|
typedef sequence<Point2D> PointSeq;
|
|
31
31
|
|
|
32
|
-
struct
|
|
32
|
+
struct Rect {
|
|
33
33
|
Point2D top_left;
|
|
34
34
|
double width;
|
|
35
35
|
double height;
|
|
@@ -40,7 +40,7 @@ module shapes {
|
|
|
40
40
|
case CIRCLE:
|
|
41
41
|
double radius;
|
|
42
42
|
case RECTANGLE:
|
|
43
|
-
|
|
43
|
+
Rect rect;
|
|
44
44
|
case POLYGON:
|
|
45
45
|
PointSeq vertices;
|
|
46
46
|
case POINT:
|
|
@@ -107,7 +107,7 @@ class IDLBitmask(node.IDLNode):
|
|
|
107
107
|
def value_by_name(self, name):
|
|
108
108
|
"""The value named ``name`` (an :class:`IDLBitValue`), or None."""
|
|
109
109
|
for v in self._values:
|
|
110
|
-
if v.name == name:
|
|
110
|
+
if v.name == node.unescape(name):
|
|
111
111
|
return v
|
|
112
112
|
return None
|
|
113
113
|
|
|
@@ -198,4 +198,5 @@ class IDLBitmask(node.IDLNode):
|
|
|
198
198
|
v._filepath = self.filepath
|
|
199
199
|
v._add_annotations(annotations)
|
|
200
200
|
self._values.append(v)
|
|
201
|
+
node.check_unique_names([b.name for b in self._values], 'bitmask "%s"' % self.name, ln, fn)
|
|
201
202
|
|
|
@@ -137,7 +137,7 @@ class IDLBitset(node.IDLNode):
|
|
|
137
137
|
def bitfield_by_name(self, name):
|
|
138
138
|
"""The named bitfield ``name`` (an :class:`IDLBitfield`; the base bitset is searched too), or None."""
|
|
139
139
|
for b in self.members:
|
|
140
|
-
if b.name == name:
|
|
140
|
+
if b.name == node.unescape(name):
|
|
141
141
|
return b
|
|
142
142
|
return None
|
|
143
143
|
|
|
@@ -229,6 +229,14 @@ class IDLBitset(node.IDLNode):
|
|
|
229
229
|
self._bitfields.append(b)
|
|
230
230
|
self._own_bits += bits
|
|
231
231
|
|
|
232
|
+
# Bitfield names are unique, also with the base bitfields, and
|
|
233
|
+
# ignoring case (issue #143); unnamed bitfields have no name
|
|
234
|
+
names, b = [], self
|
|
235
|
+
while b is not None:
|
|
236
|
+
names = [f.name for f in b.bitfields] + names
|
|
237
|
+
b = b._base
|
|
238
|
+
node.check_unique_names([n for n in names if n], 'bitset "%s"' % self.name, ln, fn)
|
|
239
|
+
|
|
232
240
|
if self.bit_size > MAX_BITS:
|
|
233
241
|
raise exception.InvalidIDLSyntaxError(
|
|
234
242
|
ln, fn, 'Bitset "%s" has %d bits (must be %d or less)' % (self.name, self.bit_size, MAX_BITS))
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"""IDL constants."""
|
|
2
|
+
import decimal
|
|
3
|
+
import os, sys, traceback
|
|
4
|
+
|
|
5
|
+
from . import node
|
|
6
|
+
from . import const_expr
|
|
7
|
+
from . import type as idl_type
|
|
8
|
+
from .token_buffer import split_tokens
|
|
9
|
+
from .exception import InvalidConstExpressionError
|
|
10
|
+
sep = '::'
|
|
11
|
+
|
|
12
|
+
# Floating-point types and the largest finite value of each (issue #137)
|
|
13
|
+
_float_types = {'float': 3.4028234663852886e38, 'double': None, 'long double': None}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class IDLConst(node.IDLNode):
|
|
17
|
+
"""A ``const`` definition, such as ``const long MAX = 10;``.
|
|
18
|
+
|
|
19
|
+
:param name: Constant name.
|
|
20
|
+
:param typename: Type name as written (``'long'``, ``'string'``, ...).
|
|
21
|
+
:param value: Value as written, which may be an expression (``'1 + 2'``).
|
|
22
|
+
The value of a constant of an integer type is evaluated
|
|
23
|
+
(:attr:`value`, issue #130).
|
|
24
|
+
:param parent: Enclosing :class:`~idl_parser.module.IDLModule`.
|
|
25
|
+
:param filepath: File the constant was defined in.
|
|
26
|
+
"""
|
|
27
|
+
def __init__(self, name, typename, value, parent, filepath=None):
|
|
28
|
+
super(IDLConst, self).__init__('IDLConst', name, parent)
|
|
29
|
+
self._typename = typename
|
|
30
|
+
self._verbose = True
|
|
31
|
+
self._value = value
|
|
32
|
+
self._filepath= filepath
|
|
33
|
+
self._int_value = None
|
|
34
|
+
self._typed_value = None
|
|
35
|
+
self._evaluated = False
|
|
36
|
+
self._base_type = None
|
|
37
|
+
|
|
38
|
+
def _evaluate(self, line_number=None, file_name=None):
|
|
39
|
+
"""Evaluate the value with the type of the constant (issues #130, #137).
|
|
40
|
+
|
|
41
|
+
:raises ~idl_parser.exception.InvalidConstExpressionError: The value
|
|
42
|
+
is not a valid value of the type, or is out of its range.
|
|
43
|
+
"""
|
|
44
|
+
base = self._resolve_base_type()
|
|
45
|
+
self._base_type = base
|
|
46
|
+
if base is None:
|
|
47
|
+
return # a type that has no values (or is not defined)
|
|
48
|
+
def error(reason):
|
|
49
|
+
return InvalidConstExpressionError(
|
|
50
|
+
line_number, file_name, 'Invalid value "%s" of const "%s": %s'
|
|
51
|
+
% (self._value, self.name, reason))
|
|
52
|
+
try:
|
|
53
|
+
value = self._evaluate_as(base, error)
|
|
54
|
+
except const_expr.ConstExprError as e:
|
|
55
|
+
raise error(e)
|
|
56
|
+
self._typed_value = value
|
|
57
|
+
self._evaluated = True
|
|
58
|
+
if base in const_expr.integer_types:
|
|
59
|
+
self._int_value = value
|
|
60
|
+
|
|
61
|
+
def _resolve_base_type(self):
|
|
62
|
+
"""The type the constant's type stands for, typedefs followed: a
|
|
63
|
+
primitive type name (``'long'``, ``'double'``, ``'string'``, ...),
|
|
64
|
+
``'fixed'``, or an :class:`~idl_parser.enum.IDLEnum`. None for any
|
|
65
|
+
other type."""
|
|
66
|
+
name = ' '.join(self.typename.split())
|
|
67
|
+
scope = self.parent
|
|
68
|
+
self._string_bound = None
|
|
69
|
+
for _ in range(32): # a typedef of a typedef of ...
|
|
70
|
+
if name in const_expr.integer_types or name in _float_types or \
|
|
71
|
+
name in ('char', 'wchar', 'boolean', 'string', 'wstring'):
|
|
72
|
+
return name
|
|
73
|
+
bounded = idl_type.parse_bounded_string(name)
|
|
74
|
+
if bounded is not None:
|
|
75
|
+
self._string_bound = const_expr.evaluate_positive(
|
|
76
|
+
bounded[1], scope, 'bound of "%s"' % name)
|
|
77
|
+
return bounded[0]
|
|
78
|
+
if name == 'fixed' or idl_type.parse_fixed(name) is not None:
|
|
79
|
+
return 'fixed'
|
|
80
|
+
typs = self.root_node.find_types(name, scope=scope)
|
|
81
|
+
if not typs:
|
|
82
|
+
return None
|
|
83
|
+
if typs[0].is_enum:
|
|
84
|
+
return typs[0]
|
|
85
|
+
if not typs[0].is_typedef:
|
|
86
|
+
return None
|
|
87
|
+
scope = typs[0].parent
|
|
88
|
+
name = ' '.join(str(typs[0].type).split())
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def _evaluate_as(self, base, error):
|
|
92
|
+
"""The value of the constant for the type ``base`` (see
|
|
93
|
+
:meth:`_resolve_base_type`)."""
|
|
94
|
+
text = self._value
|
|
95
|
+
if not isinstance(base, str): # an enum
|
|
96
|
+
value = base.find_enumerator(text)
|
|
97
|
+
if value is None:
|
|
98
|
+
value = self._const_of(text, lambda v: getattr(v, 'parent', None) is base)
|
|
99
|
+
if value is None:
|
|
100
|
+
raise error('not an enumerator of %s' % base.full_path.lstrip(':'))
|
|
101
|
+
return value
|
|
102
|
+
if base in const_expr.integer_types:
|
|
103
|
+
value = const_expr.evaluate(text, self.parent)
|
|
104
|
+
low, high = const_expr.integer_ranges[base]
|
|
105
|
+
if not low <= value <= high:
|
|
106
|
+
raise error('%d is out of the range of %s' % (value, base))
|
|
107
|
+
return value
|
|
108
|
+
if base in _float_types:
|
|
109
|
+
value = const_expr.evaluate_real(text, self.parent, 'float')
|
|
110
|
+
limit = _float_types[base]
|
|
111
|
+
if value != value or value in (float('inf'), float('-inf')) or \
|
|
112
|
+
(limit is not None and abs(value) > limit):
|
|
113
|
+
raise error('%r is out of the range of %s' % (value, base))
|
|
114
|
+
return value
|
|
115
|
+
if base == 'fixed':
|
|
116
|
+
value = const_expr.evaluate_real(text, self.parent, 'fixed')
|
|
117
|
+
if len(value.as_tuple().digits) > 31:
|
|
118
|
+
raise error('a fixed-point value has at most 31 digits')
|
|
119
|
+
return value
|
|
120
|
+
if base == 'boolean':
|
|
121
|
+
value = const_expr.parse_boolean_literal(text)
|
|
122
|
+
if value is None:
|
|
123
|
+
value = self._const_of(text, lambda v: isinstance(v, bool))
|
|
124
|
+
if value is None:
|
|
125
|
+
raise error('not TRUE or FALSE')
|
|
126
|
+
return value
|
|
127
|
+
if base in ('char', 'wchar'):
|
|
128
|
+
value = const_expr.parse_char_literal(text, wide=base == 'wchar')
|
|
129
|
+
if value is None:
|
|
130
|
+
value = self._const_of(text, lambda v: isinstance(v, str) and len(v) == 1)
|
|
131
|
+
if value is None:
|
|
132
|
+
raise error('not a character literal')
|
|
133
|
+
if base == 'char' and ord(value) > 255:
|
|
134
|
+
raise error('%r is not a char' % value)
|
|
135
|
+
return value
|
|
136
|
+
# string / wstring: adjacent literals are joined ("a" "b" -> "ab")
|
|
137
|
+
parts = []
|
|
138
|
+
for token in split_tokens(text):
|
|
139
|
+
literal = token[1:] if base == 'wstring' and token.startswith('L"') else token
|
|
140
|
+
if len(literal) >= 2 and literal[0] == '"' and literal[-1] == '"':
|
|
141
|
+
parts.append(const_expr.unescape(literal[1:-1]))
|
|
142
|
+
continue
|
|
143
|
+
value = self._const_of(token, lambda v: isinstance(v, str))
|
|
144
|
+
if value is None:
|
|
145
|
+
raise error('not a string literal')
|
|
146
|
+
parts.append(value)
|
|
147
|
+
value = ''.join(parts)
|
|
148
|
+
if base == 'string' and any(ord(c) > 255 for c in value):
|
|
149
|
+
raise error('a string holds only 8-bit characters; use wstring')
|
|
150
|
+
if self._string_bound is not None and len(value) > self._string_bound:
|
|
151
|
+
raise error('%d characters are more than the bound %d' % (len(value), self._string_bound))
|
|
152
|
+
return value
|
|
153
|
+
|
|
154
|
+
def _const_of(self, name, accept):
|
|
155
|
+
"""The value of the constant named ``name`` if ``accept(value)``,
|
|
156
|
+
otherwise None."""
|
|
157
|
+
try:
|
|
158
|
+
c = const_expr.find_const(name, self.parent)
|
|
159
|
+
except Exception:
|
|
160
|
+
return None
|
|
161
|
+
if c is None or c is self or not c._evaluated or not accept(c._typed_value):
|
|
162
|
+
return None
|
|
163
|
+
return c._typed_value
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def is_integer(self):
|
|
167
|
+
"""True if the type is an integer type (``long``, ``unsigned short``,
|
|
168
|
+
``int32``, ``octet``, ..., or a typedef of one)."""
|
|
169
|
+
return self._base_type in const_expr.integer_types
|
|
170
|
+
|
|
171
|
+
@property
|
|
172
|
+
def int_value(self):
|
|
173
|
+
"""The value of a constant of an integer type as an int
|
|
174
|
+
(``const long M = N * 2;`` -> ``6`` when ``N`` is 3), otherwise None."""
|
|
175
|
+
return self._int_value
|
|
176
|
+
|
|
177
|
+
def to_simple_dic(self, quiet=False, full_path=False, recursive=False, member_only=False):
|
|
178
|
+
"""A compact summary: ``{'const NAME': {'type': ..., 'value': ...}}``.
|
|
179
|
+
|
|
180
|
+
:param quiet: Return ``'const TYPE NAME = VALUE'`` instead.
|
|
181
|
+
:param full_path: Use :attr:`full_path` as the name.
|
|
182
|
+
"""
|
|
183
|
+
name = self.full_path if full_path else self.name
|
|
184
|
+
if quiet:
|
|
185
|
+
value = self._plain_value()
|
|
186
|
+
if isinstance(value, str) or not self._evaluated:
|
|
187
|
+
value = self.value_string # keep the quotes of a literal
|
|
188
|
+
return 'const %s %s = %s' % (self.typename, name, value)
|
|
189
|
+
dic = { 'const %s' % name : { 'type' : self.typename,
|
|
190
|
+
'value' : self._plain_value() } }
|
|
191
|
+
return dic
|
|
192
|
+
|
|
193
|
+
def to_dic(self):
|
|
194
|
+
"""The constant as a plain dict (for JSON or YAML output).
|
|
195
|
+
|
|
196
|
+
``'value'`` is :attr:`value`, except that a fixed-point value is a
|
|
197
|
+
string (``'1.25'``) and an enumerator its scoped name (``'M::RED'``).
|
|
198
|
+
"""
|
|
199
|
+
dic = { 'name' : self.name,
|
|
200
|
+
'filepath' : self.filepath,
|
|
201
|
+
'classname' : self.classname,
|
|
202
|
+
'typename' : self.typename,
|
|
203
|
+
'value' : self._plain_value() }
|
|
204
|
+
return self._with_annotations(dic)
|
|
205
|
+
|
|
206
|
+
def _plain_value(self):
|
|
207
|
+
""":attr:`value` as a str, int, float or bool (for JSON)."""
|
|
208
|
+
value = self.value
|
|
209
|
+
if isinstance(value, decimal.Decimal):
|
|
210
|
+
return str(value)
|
|
211
|
+
if isinstance(value, node.IDLNode):
|
|
212
|
+
return value.full_path.lstrip(':')
|
|
213
|
+
return value
|
|
214
|
+
|
|
215
|
+
@property
|
|
216
|
+
def typename(self):
|
|
217
|
+
"""Type name as written."""
|
|
218
|
+
return self._typename
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def type(self):
|
|
222
|
+
"""The type of the constant, looked up from the scope of the constant.
|
|
223
|
+
|
|
224
|
+
For ``const fixed F = 1.25d;`` it is an
|
|
225
|
+
:class:`~idl_parser.type.IDLFixed` whose digits and scale are those
|
|
226
|
+
of the value (``fixed<3, 2>``, issue #137).
|
|
227
|
+
"""
|
|
228
|
+
if ' '.join(self.typename.split()) == 'fixed':
|
|
229
|
+
digits, scale = _fixed_digits(self.value) if self._evaluated else (1, 0)
|
|
230
|
+
return idl_type.IDLFixed(idl_type.fixed_name(digits, scale), self)
|
|
231
|
+
return self.root_node.find_types(self.typename, scope=self)[0]
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def value(self):
|
|
235
|
+
"""Value of the constant, evaluated with its type (issues #130, #137):
|
|
236
|
+
|
|
237
|
+
- integer types: an int (``const long X = 1 + 2;`` -> ``3``)
|
|
238
|
+
- ``float`` / ``double`` / ``long double``: a float
|
|
239
|
+
(``const double D = 1.0 / 4;`` -> ``0.25``)
|
|
240
|
+
- ``fixed``: a :class:`decimal.Decimal` (``1.25d`` -> ``Decimal('1.25')``)
|
|
241
|
+
- ``string`` / ``wstring``: a str without the quotes, escapes
|
|
242
|
+
replaced and adjacent literals joined (``"a" "b"`` -> ``'ab'``)
|
|
243
|
+
- ``char`` / ``wchar``: a str of one character
|
|
244
|
+
- ``boolean``: a bool
|
|
245
|
+
- an enum: the :class:`~idl_parser.enum.IDLEnumValue`
|
|
246
|
+
|
|
247
|
+
Typedefs of these types are followed, and the names of other
|
|
248
|
+
constants can be used. For other types the value is the text as
|
|
249
|
+
written (see :attr:`value_string`).
|
|
250
|
+
"""
|
|
251
|
+
if self._evaluated:
|
|
252
|
+
return self._typed_value
|
|
253
|
+
return self._value
|
|
254
|
+
|
|
255
|
+
@property
|
|
256
|
+
def value_string(self):
|
|
257
|
+
"""Value as written (a string; ``'1 + 2'`` is kept whole)."""
|
|
258
|
+
return self._value
|
|
259
|
+
|
|
260
|
+
@property
|
|
261
|
+
def full_path(self):
|
|
262
|
+
"""Scoped name (``'M::MAX'``; ``'::MAX'`` at the global scope)."""
|
|
263
|
+
return self.parent.full_path + sep + self.name
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def _fixed_digits(value):
|
|
267
|
+
"""(digits, scale) of a fixed-point value: ``Decimal('1.25')`` -> ``(3, 2)``."""
|
|
268
|
+
t = value.as_tuple()
|
|
269
|
+
scale = max(0, -t.exponent)
|
|
270
|
+
digits = len(t.digits) + max(0, t.exponent)
|
|
271
|
+
return max(digits, scale, 1), scale
|