idl-parser 0.3.2__tar.gz → 0.4.1__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.3.2/idl_parser.egg-info → idl_parser-0.4.1}/PKG-INFO +1 -1
- {idl_parser-0.3.2 → idl_parser-0.4.1}/README.md +1 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/docs/api/index.rst +3 -0
- idl_parser-0.4.1/examples/valuetype_example.py +149 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/bitset.py +4 -8
- idl_parser-0.4.1/idl_parser/definitions.py +416 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/exception.py +10 -9
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/interface.py +256 -17
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/module.py +176 -312
- idl_parser-0.4.1/idl_parser/native.py +42 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/node.py +39 -16
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/parser.py +10 -3
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/struct.py +52 -1
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/type.py +14 -3
- idl_parser-0.4.1/idl_parser/valuetype.py +416 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1/idl_parser.egg-info}/PKG-INFO +1 -1
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser.egg-info/SOURCES.txt +12 -1
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser.egg-info/scm_file_list.json +12 -1
- idl_parser-0.4.1/idl_parser.egg-info/scm_version.json +8 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/README.md +4 -3
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/examples/examples_test.py +59 -3
- idl_parser-0.4.1/tests/interface/interface_body_test.py +188 -0
- idl_parser-0.4.1/tests/interface/local_abstract_test.py +109 -0
- idl_parser-0.4.1/tests/primitive_const/native_test.py +134 -0
- idl_parser-0.4.1/tests/scope/pathname_test.py +39 -0
- idl_parser-0.4.1/tests/scope/unknown_word_test.py +151 -0
- idl_parser-0.4.1/tests/struct_enum_union/exception_test.py +178 -0
- idl_parser-0.4.1/tests/valuetype/__init__.py +0 -0
- idl_parser-0.4.1/tests/valuetype/valuetype_test.py +327 -0
- idl_parser-0.3.2/idl_parser.egg-info/scm_version.json +0 -8
- idl_parser-0.3.2/tests/scope/unknown_word_test.py +0 -165
- {idl_parser-0.3.2 → idl_parser-0.4.1}/.github/workflows/release.yml +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/.github/workflows/test.yml +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/.gitignore +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/.readthedocs.yaml +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/.vscode/extensions.json +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/.vscode/launch.json +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/.vscode/settings.json +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/LICENSE +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/README.rst +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/docs/conf.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/docs/index.rst +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/docs/requirements.txt +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/_path.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/annotation_example.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/argument_direction_example.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/enum_example.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/example.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/scoped_name_example.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/struct_example.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/examples/union_example.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/bitmask.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/const.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/enum.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/pragma.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/token_buffer.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/typedef.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser/union.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser.egg-info/dependency_links.txt +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/idl_parser.egg-info/top_level.txt +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/pyproject.toml +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/setup.cfg +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/annotation/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/annotation/annotation_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/annotation/bit_bound_scope_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/annotation/string_argument_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/bitmask_bitset/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/bitmask_bitset/bitmask_bitset_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/examples/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/forward_declaration/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/forward_declaration/element_type_forward_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/forward_declaration/interface_forward_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/forward_declaration/struct_union_forward_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/basic_module_test.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/circular/circular_a.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/circular/circular_b.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/circular/diamond.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/forward_declaration.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/generalization.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/generalization_extended.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/included_idl.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/including_idl.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/invalid_idl.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue12_subpath/relative_include.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue12_subpath/sensor_msgs/msg/Imu.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue12_subpath/std/msg/Header.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue18_idl42_int_types.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue28_pragma_keylist.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue9_const_pragma.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue9_tabs_bounded_string.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/issue9_whitespace_variants.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/idls/multi_module_test.idl +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/include/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/include/circular_include_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/include/include_dirs_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/include/subpath_include_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/interface/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/interface/argument_direction_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/interface/basic_module_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/interface/inheritance_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/interface/raises_context_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/basic_module_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/bracket_spacing_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/error_line_number_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/exception_message_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/opensplice_idl_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/string_literal_comment_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/lexing/token_split_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/output/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/output/constructor_python_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/output/simple_dic_enum_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/output/simple_dic_inherits_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/output/simple_dic_member_only_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/output/simple_dic_member_type_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/pragma_key/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/pragma_key/key_annotation_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/pragma_key/keylist_validation_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/pragma_key/pragma_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/primitive_const/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/primitive_const/basic_module_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/primitive_const/const_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/primitive_const/int_types_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/scope/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/scope/basename_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/scope/basic_module_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/scope/leading_scope_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/scope/multi_module_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/scope/same_name_resolution_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/scope/unsupported_block_scope_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/sequence_array/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/sequence_array/basic_module_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/sequence_array/element_type_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/sequence_array/nested_bounded_sequence_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/sequence_array/syntax_error_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/struct_enum_union/__init__.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/struct_enum_union/basic_module_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/struct_enum_union/syntax_error_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/struct_enum_union/union_char_label_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/struct_enum_union/union_default_label_test.py +0 -0
- {idl_parser-0.3.2 → idl_parser-0.4.1}/tests/support.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: idl_parser
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
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
|
|
@@ -81,6 +81,7 @@ More examples are in the [examples](examples/) folder:
|
|
|
81
81
|
| [`enum_example.py`](examples/enum_example.py) | enums and their values |
|
|
82
82
|
| [`union_example.py`](examples/union_example.py) | unions: discriminator kinds, case and `default` labels, member types |
|
|
83
83
|
| [`annotation_example.py`](examples/annotation_example.py) | IDL 4 annotations (`@key`, `@range`, ...) and struct keys |
|
|
84
|
+
| [`valuetype_example.py`](examples/valuetype_example.py) | value types and event types: state members, `factory`, inheritance, `supports`, boxed value types |
|
|
84
85
|
| [`scoped_name_example.py`](examples/scoped_name_example.py) | same-named types in several modules: relative (`X`, `C::X`) and absolute (`::B::X`) names |
|
|
85
86
|
|
|
86
87
|
Run them with e.g. `python examples/union_example.py` (in a source checkout no install is needed).
|
|
@@ -8,6 +8,7 @@ API Reference
|
|
|
8
8
|
idl_parser.parser
|
|
9
9
|
idl_parser.module
|
|
10
10
|
idl_parser.interface
|
|
11
|
+
idl_parser.valuetype
|
|
11
12
|
idl_parser.struct
|
|
12
13
|
idl_parser.enum
|
|
13
14
|
idl_parser.bitmask
|
|
@@ -15,6 +16,8 @@ API Reference
|
|
|
15
16
|
idl_parser.union
|
|
16
17
|
idl_parser.typedef
|
|
17
18
|
idl_parser.const
|
|
19
|
+
idl_parser.native
|
|
20
|
+
idl_parser.definitions
|
|
18
21
|
idl_parser.pragma
|
|
19
22
|
idl_parser.type
|
|
20
23
|
idl_parser.node
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""Example: read IDL value types (``valuetype``) and event types (``eventtype``).
|
|
2
|
+
|
|
3
|
+
Shows how to get
|
|
4
|
+
- the state members of a value type, with ``public`` / ``private``,
|
|
5
|
+
- its initializers (``factory``), operations and attributes,
|
|
6
|
+
- base value types (``: truncatable B``) and supported interfaces (``supports I``),
|
|
7
|
+
- the ``abstract`` / ``custom`` modifiers,
|
|
8
|
+
- a boxed value type (``valuetype V long;``) and the type it wraps,
|
|
9
|
+
- an event type, read the same way as a value type,
|
|
10
|
+
- value types and event types used as member and argument types,
|
|
11
|
+
- a value type as a plain dict (``to_dic``).
|
|
12
|
+
|
|
13
|
+
Run::
|
|
14
|
+
|
|
15
|
+
python examples/valuetype_example.py
|
|
16
|
+
"""
|
|
17
|
+
import json
|
|
18
|
+
|
|
19
|
+
import _path # noqa: F401 (use the idl_parser of this checkout)
|
|
20
|
+
|
|
21
|
+
from idl_parser import parser
|
|
22
|
+
|
|
23
|
+
IDL = '''
|
|
24
|
+
module sensors {
|
|
25
|
+
exception InvalidRange { string reason; };
|
|
26
|
+
|
|
27
|
+
interface Resettable {
|
|
28
|
+
void reset();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// An abstract value type has operations only (no state).
|
|
32
|
+
abstract valuetype Describable {
|
|
33
|
+
string describe();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
valuetype Reading : Describable {
|
|
37
|
+
public double value;
|
|
38
|
+
public string unit;
|
|
39
|
+
private long long raw;
|
|
40
|
+
factory create(in double value, in string unit) raises (InvalidRange);
|
|
41
|
+
double scaled(in double factor);
|
|
42
|
+
readonly attribute boolean valid;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Inherits Reading; "truncatable" lets a receiver that does not know
|
|
46
|
+
// RangedReading use it as a Reading.
|
|
47
|
+
valuetype RangedReading : truncatable Reading supports Resettable {
|
|
48
|
+
public double min, max;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// A custom value type marshals itself.
|
|
52
|
+
custom valuetype Calibration {
|
|
53
|
+
public sequence<double> coefficients;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// A value type can refer to itself (a linked list).
|
|
57
|
+
valuetype ReadingNode {
|
|
58
|
+
public Reading item;
|
|
59
|
+
public ReadingNode next;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Boxed value types wrap a single type; the value may be null.
|
|
63
|
+
valuetype OptionalName string;
|
|
64
|
+
valuetype OptionalValues sequence<double>;
|
|
65
|
+
|
|
66
|
+
// An event type has the same form as a value type.
|
|
67
|
+
eventtype Alarm {
|
|
68
|
+
public string message;
|
|
69
|
+
public long level;
|
|
70
|
+
};
|
|
71
|
+
eventtype CriticalAlarm : Alarm { };
|
|
72
|
+
|
|
73
|
+
struct Snapshot {
|
|
74
|
+
Reading latest;
|
|
75
|
+
OptionalName label;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
interface Monitor {
|
|
79
|
+
Reading read();
|
|
80
|
+
void notify(in Alarm alarm);
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
'''
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def print_valuetype(v):
|
|
87
|
+
modifiers = [m for m in ('abstract', 'custom') if getattr(v, 'is_' + m)]
|
|
88
|
+
kind = 'eventtype' if v.is_eventtype else 'valuetype'
|
|
89
|
+
print(' '.join(modifiers + [kind, v.full_path]))
|
|
90
|
+
if v.is_boxed:
|
|
91
|
+
print(' boxed type:', v.boxed_type.name)
|
|
92
|
+
return
|
|
93
|
+
if v.inheritances:
|
|
94
|
+
print(' inherits: %s%s' % ('truncatable ' if v.is_truncatable else '',
|
|
95
|
+
', '.join(b.full_path for b in v.inheritances)))
|
|
96
|
+
if v.supports:
|
|
97
|
+
print(' supports:', ', '.join(i.full_path for i in v.supports))
|
|
98
|
+
for m in v.state_members:
|
|
99
|
+
print(' %s %s %s' % (m.visibility, m.type, m.name))
|
|
100
|
+
for f in v.factories:
|
|
101
|
+
params = ', '.join(a.to_simple_dic() for a in f.arguments)
|
|
102
|
+
print(' factory %s(%s) raises %s' % (f.name, params, f.raises))
|
|
103
|
+
for op in v.methods:
|
|
104
|
+
params = ', '.join(a.to_simple_dic() for a in op.arguments)
|
|
105
|
+
print(' operation %s %s(%s)' % (op.returns.name, op.name, params))
|
|
106
|
+
for a in v.attributes:
|
|
107
|
+
print(' %sattribute %s %s' % ('readonly ' if a.readonly else '', a.type, a.name))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def main():
|
|
111
|
+
global_module = parser.IDLParser().load(IDL)
|
|
112
|
+
sensors = global_module.module_by_name('sensors')
|
|
113
|
+
|
|
114
|
+
# All value types and event types in a module
|
|
115
|
+
print('valuetypes in module sensors:', [v.name for v in sensors.valuetypes])
|
|
116
|
+
print('eventtypes in module sensors:', [e.name for e in sensors.eventtypes])
|
|
117
|
+
print()
|
|
118
|
+
|
|
119
|
+
for v in sensors.valuetypes + sensors.eventtypes:
|
|
120
|
+
print_valuetype(v)
|
|
121
|
+
print()
|
|
122
|
+
|
|
123
|
+
# Look up by name; the exceptions of a factory are resolved like those of an operation.
|
|
124
|
+
reading = sensors.valuetype_by_name('Reading')
|
|
125
|
+
create = reading.factory_by_name('create')
|
|
126
|
+
print('Reading.create raises:', [x.full_path for x in create.exceptions])
|
|
127
|
+
print('Reading.raw is public:', reading.state_member_by_name('raw').is_public)
|
|
128
|
+
|
|
129
|
+
# A self-referencing member resolves to the value type itself.
|
|
130
|
+
node = sensors.valuetype_by_name('ReadingNode')
|
|
131
|
+
print('ReadingNode.next type is ReadingNode:', node.state_member_by_name('next').type is node)
|
|
132
|
+
print()
|
|
133
|
+
|
|
134
|
+
# Value types and event types can be member, return and argument types.
|
|
135
|
+
snapshot = sensors.struct_by_name('Snapshot')
|
|
136
|
+
for m in snapshot.members:
|
|
137
|
+
print('Snapshot.%s: %s %s' % (m.name, m.type.classname, m.type.full_path))
|
|
138
|
+
monitor = sensors.interface_by_name('Monitor')
|
|
139
|
+
print('Monitor.read returns:', monitor.method_by_name('read').returns.obj.full_path)
|
|
140
|
+
alarm = monitor.method_by_name('notify').argument_by_name('alarm')
|
|
141
|
+
print('Monitor.notify(alarm) is an eventtype:', alarm.type.obj.is_eventtype)
|
|
142
|
+
print()
|
|
143
|
+
|
|
144
|
+
# The whole value type as a dict (handy for JSON or code generators)
|
|
145
|
+
print(json.dumps(sensors.valuetype_by_name('RangedReading').to_dic(), indent=2))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
if __name__ == '__main__':
|
|
149
|
+
main()
|
|
@@ -245,13 +245,11 @@ class IDLBitset(node.IDLNode):
|
|
|
245
245
|
return candidates
|
|
246
246
|
|
|
247
247
|
def _find_base(self, name, ln, fn):
|
|
248
|
+
from .module import definition_scopes
|
|
248
249
|
bitsets = {}
|
|
249
|
-
|
|
250
|
+
for m in definition_scopes(self.root_node, self):
|
|
250
251
|
for b in m.bitsets:
|
|
251
252
|
bitsets[b.full_path.lstrip(':')] = b
|
|
252
|
-
for sub in m.modules:
|
|
253
|
-
collect(sub)
|
|
254
|
-
collect(self.root_node)
|
|
255
253
|
for c in self._scopes(name):
|
|
256
254
|
if c in bitsets:
|
|
257
255
|
return bitsets[c]
|
|
@@ -259,13 +257,11 @@ class IDLBitset(node.IDLNode):
|
|
|
259
257
|
ln, fn, 'Can not find "%s" bitset which is the base of "%s"' % (name, self.name))
|
|
260
258
|
|
|
261
259
|
def _find_const(self, name):
|
|
260
|
+
from .module import definition_scopes
|
|
262
261
|
consts = {}
|
|
263
|
-
|
|
262
|
+
for m in definition_scopes(self.root_node, self):
|
|
264
263
|
for c in m.consts:
|
|
265
264
|
consts[(m.full_path.lstrip(':') + sep + c.name).lstrip(':')] = c
|
|
266
|
-
for sub in m.modules:
|
|
267
|
-
collect(sub)
|
|
268
|
-
collect(self.root_node)
|
|
269
265
|
for c in self._scopes(name):
|
|
270
266
|
if c in consts:
|
|
271
267
|
return consts[c]
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"""Type and constant definitions shared by modules and interfaces.
|
|
2
|
+
|
|
3
|
+
A ``module`` and an ``interface`` can both hold ``struct``, ``union``,
|
|
4
|
+
``enum``, ``typedef``, ``const``, ``exception``, ``native``, ``bitmask`` and
|
|
5
|
+
``bitset`` definitions (issue #101). :class:`IDLDefinitionScope` keeps them
|
|
6
|
+
and parses them for both.
|
|
7
|
+
"""
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
from . import node
|
|
11
|
+
from . import struct, typedef, enum, const, union, bitmask, bitset, native
|
|
12
|
+
from .exception import InvalidIDLSyntaxError
|
|
13
|
+
|
|
14
|
+
# Keywords that start a definition handled by IDLDefinitionScope.parse_definition().
|
|
15
|
+
definition_keywords = ('typedef', 'struct', 'exception', 'enum', 'bitmask',
|
|
16
|
+
'bitset', 'union', 'native', 'const')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class IDLDefinitionScope(object):
|
|
20
|
+
"""Mixin for a scope that holds type and constant definitions.
|
|
21
|
+
|
|
22
|
+
Used by :class:`~idl_parser.module.IDLModule` and
|
|
23
|
+
:class:`~idl_parser.interface.IDLInterface`.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def _init_definitions(self):
|
|
27
|
+
self._typedefs = []
|
|
28
|
+
self._structs = []
|
|
29
|
+
self._forward_structs = []
|
|
30
|
+
self._exceptions = []
|
|
31
|
+
self._enums = []
|
|
32
|
+
self._bitmasks = []
|
|
33
|
+
self._bitsets = []
|
|
34
|
+
self._unions = []
|
|
35
|
+
self._forward_unions = []
|
|
36
|
+
self._consts = []
|
|
37
|
+
self._natives = []
|
|
38
|
+
|
|
39
|
+
def parse_definition(self, token, token_buf, filepath=None, annotations=()):
|
|
40
|
+
"""Parse a definition whose keyword ``token`` is already consumed.
|
|
41
|
+
|
|
42
|
+
:param token: The keyword (one of :data:`definition_keywords`).
|
|
43
|
+
:param token_buf: :class:`~idl_parser.token_buffer.TokenBuffer` to read from.
|
|
44
|
+
:param filepath: File name recorded in the parsed nodes.
|
|
45
|
+
:param annotations: Annotations written before the keyword.
|
|
46
|
+
:return: False if ``token`` does not start a definition (nothing is read).
|
|
47
|
+
:raises ~idl_parser.exception.InvalidIDLSyntaxError: The definition is
|
|
48
|
+
not valid IDL.
|
|
49
|
+
"""
|
|
50
|
+
pending_annotations = list(annotations)
|
|
51
|
+
if token == 'typedef':
|
|
52
|
+
blocks = []
|
|
53
|
+
while True:
|
|
54
|
+
ln, fn, t = token_buf.pop()
|
|
55
|
+
if t == None:
|
|
56
|
+
raise InvalidIDLSyntaxError()
|
|
57
|
+
elif t == ';':
|
|
58
|
+
break
|
|
59
|
+
else:
|
|
60
|
+
blocks.append(t)
|
|
61
|
+
t = typedef.IDLTypedef(self)
|
|
62
|
+
anns, blocks = node.parse_annotations(blocks)
|
|
63
|
+
t._add_annotations(pending_annotations + anns)
|
|
64
|
+
t.parse_blocks(blocks, filepath=filepath)
|
|
65
|
+
t_ = self.typedef_by_name(t.name)
|
|
66
|
+
if t_:
|
|
67
|
+
if self._verbose: sys.stdout.write('# Error. Same Typedef Defined (%s)\n' % t.name)
|
|
68
|
+
else:
|
|
69
|
+
self._typedefs.append(t)
|
|
70
|
+
|
|
71
|
+
elif token == 'struct':
|
|
72
|
+
ln, fn, name_ = token_buf.pop()
|
|
73
|
+
s_ = self.struct_by_name(name_)
|
|
74
|
+
s = struct.IDLStruct(name_, self)
|
|
75
|
+
s._add_annotations(pending_annotations)
|
|
76
|
+
s.parse_tokens(token_buf, filepath=filepath)
|
|
77
|
+
if s.is_forward:
|
|
78
|
+
# Forward declaration ("struct A;"): remember the name only.
|
|
79
|
+
# The definition, if any, is added to structs when it appears.
|
|
80
|
+
if name_ not in self._forward_structs:
|
|
81
|
+
self._forward_structs.append(name_)
|
|
82
|
+
elif s_:
|
|
83
|
+
if self._verbose: sys.stdout.write('# Error. Same Struct Defined (%s)\n' % name_)
|
|
84
|
+
# raise InvalidIDLSyntaxError
|
|
85
|
+
else:
|
|
86
|
+
self._structs.append(s)
|
|
87
|
+
|
|
88
|
+
elif token == 'exception':
|
|
89
|
+
ln, fn, name_ = token_buf.pop()
|
|
90
|
+
s = struct.IDLException(name_, self)
|
|
91
|
+
s._add_annotations(pending_annotations)
|
|
92
|
+
s.parse_tokens(token_buf, filepath=filepath)
|
|
93
|
+
if self.exception_by_name(name_):
|
|
94
|
+
if self._verbose: sys.stdout.write('# Error. Same Exception Defined (%s)\n' % name_)
|
|
95
|
+
else:
|
|
96
|
+
self._exceptions.append(s)
|
|
97
|
+
|
|
98
|
+
elif token == 'enum':
|
|
99
|
+
ln, fn, name_ = token_buf.pop()
|
|
100
|
+
s = enum.IDLEnum(name_, self)
|
|
101
|
+
s._add_annotations(pending_annotations)
|
|
102
|
+
s.parse_tokens(token_buf, filepath)
|
|
103
|
+
s_ = self.enum_by_name(name_)
|
|
104
|
+
if s_:
|
|
105
|
+
if self._verbose: sys.stdout.write('# Error. Same Enum Defined (%s)\n' % name_)
|
|
106
|
+
# raise InvalidIDLSyntaxError
|
|
107
|
+
else:
|
|
108
|
+
self._enums.append(s)
|
|
109
|
+
|
|
110
|
+
elif token == 'bitmask':
|
|
111
|
+
ln, fn, name_ = token_buf.pop()
|
|
112
|
+
s = bitmask.IDLBitmask(name_, self, pending_annotations)
|
|
113
|
+
s.parse_tokens(token_buf, filepath)
|
|
114
|
+
if self.bitmask_by_name(name_):
|
|
115
|
+
if self._verbose: sys.stdout.write('# Error. Same Bitmask Defined (%s)\n' % name_)
|
|
116
|
+
else:
|
|
117
|
+
self._bitmasks.append(s)
|
|
118
|
+
|
|
119
|
+
elif token == 'bitset':
|
|
120
|
+
ln, fn, name_ = token_buf.pop()
|
|
121
|
+
s = bitset.IDLBitset(name_, self)
|
|
122
|
+
s._add_annotations(pending_annotations)
|
|
123
|
+
s.parse_tokens(token_buf, filepath)
|
|
124
|
+
if self.bitset_by_name(name_):
|
|
125
|
+
if self._verbose: sys.stdout.write('# Error. Same Bitset Defined (%s)\n' % name_)
|
|
126
|
+
else:
|
|
127
|
+
self._bitsets.append(s)
|
|
128
|
+
|
|
129
|
+
elif token == 'union':
|
|
130
|
+
ln, fn, name_ = token_buf.pop()
|
|
131
|
+
s = union.IDLUnion(name_, self)
|
|
132
|
+
s._add_annotations(pending_annotations)
|
|
133
|
+
s.parse_tokens(token_buf, filepath)
|
|
134
|
+
if s.is_forward:
|
|
135
|
+
# Forward declaration ("union A;"): remember the name only.
|
|
136
|
+
if name_ not in self._forward_unions:
|
|
137
|
+
self._forward_unions.append(name_)
|
|
138
|
+
elif self.union_by_name(name_):
|
|
139
|
+
if self._verbose: sys.stdout.write('# Error. Same Union Defined (%s)\n' % name_)
|
|
140
|
+
# raise InvalidIDLSyntaxError
|
|
141
|
+
else:
|
|
142
|
+
self._unions.append(s)
|
|
143
|
+
|
|
144
|
+
elif token == 'native':
|
|
145
|
+
# "native N;": a type with a name only (issue #93).
|
|
146
|
+
ln, fn, name_ = token_buf.pop()
|
|
147
|
+
if name_ is None or name_ in (';', '{', '}'):
|
|
148
|
+
raise InvalidIDLSyntaxError(ln, fn, 'No name after "native"')
|
|
149
|
+
ln2, fn2, t = token_buf.pop()
|
|
150
|
+
if t != ';':
|
|
151
|
+
raise InvalidIDLSyntaxError(ln, fn, 'No ";" after "native %s"' % name_)
|
|
152
|
+
n = native.IDLNative(name_, self, filepath=filepath)
|
|
153
|
+
n._add_annotations(pending_annotations)
|
|
154
|
+
if self.native_by_name(name_):
|
|
155
|
+
if self._verbose: sys.stdout.write('# Error. Same Native Defined (%s)\n' % name_)
|
|
156
|
+
else:
|
|
157
|
+
self._natives.append(n)
|
|
158
|
+
|
|
159
|
+
elif token == 'const':
|
|
160
|
+
values = []
|
|
161
|
+
while True:
|
|
162
|
+
ln, fn, t = token_buf.pop()
|
|
163
|
+
if t is None:
|
|
164
|
+
if self._verbose: sys.stdout.write('# Error. No ";" after const.\n')
|
|
165
|
+
raise InvalidIDLSyntaxError(message='No ";" after const definition')
|
|
166
|
+
if t == ';':
|
|
167
|
+
break
|
|
168
|
+
values.append(t)
|
|
169
|
+
|
|
170
|
+
# Split at '=': "<type> <name> = <value>" (issue #52).
|
|
171
|
+
# The value is every token after '=', so that an
|
|
172
|
+
# expression such as "1 + 2" is kept whole.
|
|
173
|
+
if '=' not in values:
|
|
174
|
+
raise InvalidIDLSyntaxError(ln, fn, 'No "=" in const definition "%s"' % ' '.join(values))
|
|
175
|
+
eq = values.index('=')
|
|
176
|
+
if eq < 2:
|
|
177
|
+
raise InvalidIDLSyntaxError(ln, fn, 'No type or name in const definition "%s"' % ' '.join(values))
|
|
178
|
+
if eq == len(values) - 1:
|
|
179
|
+
raise InvalidIDLSyntaxError(ln, fn, 'No value in const definition "%s"' % ' '.join(values))
|
|
180
|
+
value_ = ' '.join(values[eq+1:])
|
|
181
|
+
name_ = values[eq-1]
|
|
182
|
+
typename = ' '.join(values[:eq-1])
|
|
183
|
+
s = const.IDLConst(name_, typename, value_, self, filepath=filepath)
|
|
184
|
+
s._add_annotations(pending_annotations)
|
|
185
|
+
s_ = self.const_by_name(name_)
|
|
186
|
+
if s_:
|
|
187
|
+
if self._verbose: sys.stdout.write('# Error. Same Const Defined (%s)\n' % name_)
|
|
188
|
+
else:
|
|
189
|
+
self._consts.append(s)
|
|
190
|
+
|
|
191
|
+
else:
|
|
192
|
+
return False
|
|
193
|
+
return True
|
|
194
|
+
|
|
195
|
+
@property
|
|
196
|
+
def has_definitions(self):
|
|
197
|
+
"""True if any type or constant is defined in this scope."""
|
|
198
|
+
return any((self._typedefs, self._structs, self._exceptions, self._enums,
|
|
199
|
+
self._bitmasks, self._bitsets, self._unions, self._consts,
|
|
200
|
+
self._natives))
|
|
201
|
+
|
|
202
|
+
@property
|
|
203
|
+
def structs(self):
|
|
204
|
+
"""Structs defined directly in this scope (list of :class:`~idl_parser.struct.IDLStruct`)."""
|
|
205
|
+
return self._structs
|
|
206
|
+
|
|
207
|
+
def struct_by_name(self, name):
|
|
208
|
+
"""The struct named ``name`` (not scoped) in this scope, or None."""
|
|
209
|
+
for s in self.structs:
|
|
210
|
+
if s.name == name:
|
|
211
|
+
return s
|
|
212
|
+
return None
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def forward_structs(self):
|
|
216
|
+
"""Names of structs forward-declared ("struct A;") in this scope,
|
|
217
|
+
in declaration order, whether or not they are defined later."""
|
|
218
|
+
return list(self._forward_structs)
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def undefined_forward_structs(self):
|
|
222
|
+
"""Forward-declared struct names that have no definition in this scope."""
|
|
223
|
+
return [n for n in self._forward_structs if self.struct_by_name(n) is None]
|
|
224
|
+
|
|
225
|
+
def for_each_struct(self, func, filter=None):
|
|
226
|
+
"""Call ``func`` with each struct and return the results as a list.
|
|
227
|
+
|
|
228
|
+
:param filter: If given, only the structs for which ``filter(struct)`` is
|
|
229
|
+
true are passed to ``func``.
|
|
230
|
+
"""
|
|
231
|
+
retval = []
|
|
232
|
+
for m in self.structs:
|
|
233
|
+
if filter:
|
|
234
|
+
if filter(m):
|
|
235
|
+
retval.append(func(m))
|
|
236
|
+
pass
|
|
237
|
+
else:
|
|
238
|
+
retval.append(func(m))
|
|
239
|
+
return retval
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def exceptions(self):
|
|
243
|
+
"""Exceptions defined directly in this scope (list of :class:`~idl_parser.struct.IDLException`)."""
|
|
244
|
+
return self._exceptions
|
|
245
|
+
|
|
246
|
+
def exception_by_name(self, name):
|
|
247
|
+
"""The exception named ``name`` (not scoped) in this scope, or None."""
|
|
248
|
+
for x in self.exceptions:
|
|
249
|
+
if x.name == name:
|
|
250
|
+
return x
|
|
251
|
+
return None
|
|
252
|
+
|
|
253
|
+
def for_each_exception(self, func):
|
|
254
|
+
"""Call ``func`` with each exception and return the results as a list."""
|
|
255
|
+
return [func(x) for x in self.exceptions]
|
|
256
|
+
|
|
257
|
+
@property
|
|
258
|
+
def enums(self):
|
|
259
|
+
"""Enums defined directly in this scope (list of :class:`~idl_parser.enum.IDLEnum`)."""
|
|
260
|
+
return self._enums
|
|
261
|
+
|
|
262
|
+
def enum_by_name(self, name):
|
|
263
|
+
"""The enum named ``name`` (not scoped) in this scope, or None."""
|
|
264
|
+
for e in self.enums:
|
|
265
|
+
if e.name == name:
|
|
266
|
+
return e
|
|
267
|
+
return None
|
|
268
|
+
|
|
269
|
+
def for_each_enum(self, func):
|
|
270
|
+
"""Call ``func`` with each enum and return the results as a list."""
|
|
271
|
+
retval = []
|
|
272
|
+
for m in self.enums:
|
|
273
|
+
retval.append(func(m))
|
|
274
|
+
return retval
|
|
275
|
+
|
|
276
|
+
@property
|
|
277
|
+
def bitmasks(self):
|
|
278
|
+
"""Bitmasks defined directly in this scope (list of :class:`~idl_parser.bitmask.IDLBitmask`)."""
|
|
279
|
+
return self._bitmasks
|
|
280
|
+
|
|
281
|
+
def bitmask_by_name(self, name):
|
|
282
|
+
"""The bitmask named ``name`` (not scoped) in this scope, or None."""
|
|
283
|
+
for b in self.bitmasks:
|
|
284
|
+
if b.name == name:
|
|
285
|
+
return b
|
|
286
|
+
return None
|
|
287
|
+
|
|
288
|
+
def for_each_bitmask(self, func):
|
|
289
|
+
"""Call ``func`` with each bitmask and return the results as a list."""
|
|
290
|
+
return [func(b) for b in self.bitmasks]
|
|
291
|
+
|
|
292
|
+
@property
|
|
293
|
+
def bitsets(self):
|
|
294
|
+
"""Bitsets defined directly in this scope (list of :class:`~idl_parser.bitset.IDLBitset`)."""
|
|
295
|
+
return self._bitsets
|
|
296
|
+
|
|
297
|
+
def bitset_by_name(self, name):
|
|
298
|
+
"""The bitset named ``name`` (not scoped) in this scope, or None."""
|
|
299
|
+
for b in self.bitsets:
|
|
300
|
+
if b.name == name:
|
|
301
|
+
return b
|
|
302
|
+
return None
|
|
303
|
+
|
|
304
|
+
def for_each_bitset(self, func):
|
|
305
|
+
"""Call ``func`` with each bitset and return the results as a list."""
|
|
306
|
+
return [func(b) for b in self.bitsets]
|
|
307
|
+
|
|
308
|
+
@property
|
|
309
|
+
def unions(self):
|
|
310
|
+
"""Unions defined directly in this scope (list of :class:`~idl_parser.union.IDLUnion`)."""
|
|
311
|
+
return self._unions
|
|
312
|
+
|
|
313
|
+
def union_by_name(self, name):
|
|
314
|
+
"""The union named ``name`` (not scoped) in this scope, or None."""
|
|
315
|
+
for u in self.unions:
|
|
316
|
+
if u.name == name:
|
|
317
|
+
return u
|
|
318
|
+
return None
|
|
319
|
+
|
|
320
|
+
@property
|
|
321
|
+
def forward_unions(self):
|
|
322
|
+
"""Names of unions forward-declared ("union A;") in this scope,
|
|
323
|
+
in declaration order, whether or not they are defined later."""
|
|
324
|
+
return list(self._forward_unions)
|
|
325
|
+
|
|
326
|
+
@property
|
|
327
|
+
def undefined_forward_unions(self):
|
|
328
|
+
"""Forward-declared union names that have no definition in this scope."""
|
|
329
|
+
return [n for n in self._forward_unions if self.union_by_name(n) is None]
|
|
330
|
+
|
|
331
|
+
def for_each_union(self, func):
|
|
332
|
+
"""Call ``func`` with each union and return the results as a list."""
|
|
333
|
+
retval = []
|
|
334
|
+
for m in self.unions:
|
|
335
|
+
retval.append(func(m))
|
|
336
|
+
return retval
|
|
337
|
+
|
|
338
|
+
@property
|
|
339
|
+
def consts(self):
|
|
340
|
+
"""Constants defined directly in this scope (list of :class:`~idl_parser.const.IDLConst`)."""
|
|
341
|
+
return self._consts
|
|
342
|
+
|
|
343
|
+
def const_by_name(self, name):
|
|
344
|
+
"""The constant named ``name`` (not scoped) in this scope, or None."""
|
|
345
|
+
for c in self.consts:
|
|
346
|
+
if c.name == name:
|
|
347
|
+
return c
|
|
348
|
+
return None
|
|
349
|
+
|
|
350
|
+
def for_each_const(self, func):
|
|
351
|
+
"""Call ``func`` with each constant and return the results as a list."""
|
|
352
|
+
retval = []
|
|
353
|
+
for m in self.consts:
|
|
354
|
+
retval.append(func(m))
|
|
355
|
+
return retval
|
|
356
|
+
|
|
357
|
+
@property
|
|
358
|
+
def natives(self):
|
|
359
|
+
"""Native types declared directly in this scope (list of :class:`~idl_parser.native.IDLNative`)."""
|
|
360
|
+
return self._natives
|
|
361
|
+
|
|
362
|
+
def native_by_name(self, name):
|
|
363
|
+
"""The native type named ``name`` (not scoped) in this scope, or None."""
|
|
364
|
+
for n in self.natives:
|
|
365
|
+
if n.name == name:
|
|
366
|
+
return n
|
|
367
|
+
return None
|
|
368
|
+
|
|
369
|
+
def for_each_native(self, func):
|
|
370
|
+
"""Call ``func`` with each native type and return the results as a list."""
|
|
371
|
+
return [func(n) for n in self.natives]
|
|
372
|
+
|
|
373
|
+
@property
|
|
374
|
+
def typedefs(self):
|
|
375
|
+
"""Typedefs defined directly in this scope (list of :class:`~idl_parser.typedef.IDLTypedef`)."""
|
|
376
|
+
return self._typedefs
|
|
377
|
+
|
|
378
|
+
def typedef_by_name(self, name):
|
|
379
|
+
"""The typedef named ``name`` (not scoped) in this scope, or None."""
|
|
380
|
+
for t in self.typedefs:
|
|
381
|
+
if t.name == name:
|
|
382
|
+
return t
|
|
383
|
+
return None
|
|
384
|
+
|
|
385
|
+
def for_each_typedef(self, func):
|
|
386
|
+
"""Call ``func`` with each typedef.
|
|
387
|
+
|
|
388
|
+
Unlike the other ``for_each_*`` methods, it returns None.
|
|
389
|
+
"""
|
|
390
|
+
retval = []
|
|
391
|
+
for m in self.typedefs:
|
|
392
|
+
retval.append(func(m))
|
|
393
|
+
|
|
394
|
+
def _definitions_simple_dic(self, quiet=False):
|
|
395
|
+
"""``to_simple_dic()`` of the definitions in this scope, grouped by kind."""
|
|
396
|
+
return ([s.to_simple_dic(quiet) for s in self.structs] +
|
|
397
|
+
[x.to_simple_dic(quiet) for x in self.exceptions] +
|
|
398
|
+
[e.to_simple_dic(quiet) for e in self.enums] +
|
|
399
|
+
[b.to_simple_dic(quiet) for b in self.bitmasks] +
|
|
400
|
+
[b.to_simple_dic(quiet) for b in self.bitsets] +
|
|
401
|
+
[u.to_simple_dic(quiet) for u in self.unions] +
|
|
402
|
+
[t.to_simple_dic(quiet) for t in self.typedefs] +
|
|
403
|
+
[n.to_simple_dic(quiet) for n in self.natives] +
|
|
404
|
+
[c.to_simple_dic(quiet) for c in self.consts])
|
|
405
|
+
|
|
406
|
+
def _definitions_dic(self):
|
|
407
|
+
"""``to_dic()`` of the definitions in this scope, keyed by kind."""
|
|
408
|
+
return { 'typedefs' : [t.to_dic() for t in self.typedefs],
|
|
409
|
+
'natives' : [n.to_dic() for n in self.natives],
|
|
410
|
+
'structs' : [s.to_dic() for s in self.structs],
|
|
411
|
+
'exceptions' : [x.to_dic() for x in self.exceptions],
|
|
412
|
+
'enums' : [e.to_dic() for e in self.enums],
|
|
413
|
+
'bitmasks' : [b.to_dic() for b in self.bitmasks],
|
|
414
|
+
'bitsets' : [b.to_dic() for b in self.bitsets],
|
|
415
|
+
'unions' : [u.to_dic() for u in self.unions],
|
|
416
|
+
'consts' : [c.to_dic() for c in self.consts] }
|
|
@@ -54,7 +54,8 @@ class InvalidDataTypeException(IDLParserException):
|
|
|
54
54
|
pass
|
|
55
55
|
|
|
56
56
|
class IDLCanNotFindException(IDLParserException):
|
|
57
|
-
"""An ``#include`` file
|
|
57
|
+
"""An ``#include`` file, a base interface / bitset or an exception in
|
|
58
|
+
``raises (...)`` can not be found."""
|
|
58
59
|
pass
|
|
59
60
|
|
|
60
61
|
|
|
@@ -63,18 +64,18 @@ class IDLParserWarning(UserWarning):
|
|
|
63
64
|
pass
|
|
64
65
|
|
|
65
66
|
class UnknownIDLSyntaxWarning(IDLParserWarning):
|
|
66
|
-
"""
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
"""No longer issued: an unknown word in a module or the global scope (a
|
|
68
|
+
misspelled keyword such as ``strcut``) is an :class:`InvalidIDLSyntaxError`
|
|
69
|
+
since 0.4.0 (issue #94).
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
warnings.simplefilter('error', UnknownIDLSyntaxWarning)
|
|
71
|
+
It was issued from 0.3.2 (issue #76), and is kept so that code referring
|
|
72
|
+
to it (``warnings.simplefilter('error', UnknownIDLSyntaxWarning)``) still
|
|
73
|
+
works.
|
|
74
74
|
"""
|
|
75
75
|
pass
|
|
76
76
|
|
|
77
77
|
class UnsupportedIDLSyntaxWarning(IDLParserWarning):
|
|
78
78
|
"""A valid IDL definition that idl_parser does not support yet
|
|
79
|
-
(``
|
|
79
|
+
(``component``, ``home``, ...) was skipped (issue #76). ``valuetype``
|
|
80
|
+
and ``eventtype`` are parsed since issue #99."""
|
|
80
81
|
pass
|