Repository navigation
Expand file tree
/
Copy pathtest_classes.py
More file actions
156 lines (112 loc) · 2.35 KB
/
Copy pathtest_classes.py
File metadata and controls
156 lines (112 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
from cyclonedds.idl import IdlStruct, IdlUnion, IdlEnum
from cyclonedds.idl.annotations import keylist, key
import cyclonedds.idl.types as pt
from enum import auto
from dataclasses import dataclass
@dataclass
class SingleInt(IdlStruct):
value: int
key("value")
@dataclass
class SingleString(IdlStruct):
value: str
key("value")
@dataclass
class SingleFloat(IdlStruct):
value: float
key("value")
@dataclass
class SingleBool(IdlStruct):
value: bool
key("value")
@dataclass
class SingleSequence(IdlStruct):
value: pt.sequence[int]
key("value")
@dataclass
class SingleArray(IdlStruct):
value: pt.array[pt.uint16, 3]
key("value")
@dataclass
class SingleUint16(IdlStruct):
value: pt.uint16
key("value")
@dataclass
class SingleBoundedSequence(IdlStruct):
value: pt.sequence[int, 3]
key("value")
@dataclass
class SingleBoundedString(IdlStruct):
value: pt.bounded_str[10]
key("value")
class BasicEnum(IdlEnum):
One = auto()
Two = auto()
Three = auto()
@dataclass
class SingleEnum(IdlStruct):
value: BasicEnum
key("value")
@dataclass
class SingleNested(IdlStruct):
value: SingleInt
key("value")
@dataclass
@keylist(['a'])
class Keyed(IdlStruct):
a: int
b: int
@dataclass
class Keyed2(IdlStruct):
a: int
key("a")
b: int
@dataclass
@keylist([])
class Keyless(IdlStruct):
a: int
b: int
@dataclass
class AllPrimitives(IdlStruct):
a: pt.int8 = 123
b: pt.uint8 = 212
c: pt.int16 = 7834
d: pt.uint16 = 2817
e: pt.int32 = 12987421
f: pt.uint32 = 328732
g: pt.int64 = 84987349873
h: pt.uint64 = 12987181827
i: pt.float32 = 1.0
j: pt.float64 = 1287.1878
class EasyUnion(IdlUnion, discriminator=int):
a: pt.case[1, int]
b: pt.case[2, bool]
@dataclass
class SingleUnion(IdlStruct):
value: EasyUnion
key("value")
typedef_a = pt.typedef['typedef_a', pt.uint32]
typedef_b = pt.typedef['typedef_b', pt.uint32]
class ContainSameTypes(IdlStruct):
a: typedef_a
b: typedef_b
alltypes = [
SingleInt,
SingleString,
SingleFloat,
SingleBool,
SingleSequence,
SingleArray,
SingleUint16,
SingleBoundedSequence,
SingleBoundedString,
SingleEnum,
SingleNested,
Keyed,
Keyed2,
Keyless,
AllPrimitives,
EasyUnion,
SingleUnion,
ContainSameTypes
]