Skip to content

Commit 8cad6ec

Browse files
committed
Improvements in SELECT and ENUMERATION support
1 parent 5f345c7 commit 8cad6ec

19 files changed

Lines changed: 538 additions & 253 deletions

src/fedex_python/examples/unitary_schemas/generate_shemas_modules.py renamed to src/fedex_python/examples/unitary_schemas/generate_schemas_modules.py

File renamed without changes.

src/fedex_python/examples/unitary_schemas/index_attribute.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@
77
from SCL.AggregationDataTypes import *
88
from SCL.TypeChecker import check_type
99
from SCL.Expr import *
10-
common_datum_list = 'LIST TYPE Not implemented'
10+
common_datum_list = LIST(1,None,'datum_reference_element')
1111
label = STRING
12+
# SELECT TYPE datum_or_common_datum_
13+
if (not 'common_datum_list' in globals().keys()):
14+
common_datum_list = 'common_datum_list'
15+
if (not 'datum' in globals().keys()):
16+
datum = 'datum'
17+
datum_or_common_datum = SELECT(
18+
'common_datum_list',
19+
'datum')
1220

1321
####################
1422
# ENTITY shape_aspect #
@@ -34,8 +42,10 @@ def fset( self, value ):
3442
# Mandatory argument
3543
if value==None:
3644
raise AssertionError('Argument name is mantatory and can not be set to None')
37-
check_type(value,STRING)
38-
self._name = value
45+
if not check_type(value,STRING):
46+
self._name = STRING(value)
47+
else:
48+
self._name = value
3949
return property(**locals())
4050

4151
@apply
@@ -46,8 +56,10 @@ def fset( self, value ):
4656
# Mandatory argument
4757
if value==None:
4858
raise AssertionError('Argument of_shape is mantatory and can not be set to None')
49-
check_type(value,product_definition_shape)
50-
self._of_shape = value
59+
if not check_type(value,product_definition_shape):
60+
self._of_shape = product_definition_shape(value)
61+
else:
62+
self._of_shape = value
5163
return property(**locals())
5264

5365
####################
@@ -71,8 +83,10 @@ def fset( self, value ):
7183
# Mandatory argument
7284
if value==None:
7385
raise AssertionError('Argument base is mantatory and can not be set to None')
74-
check_type(value,datum_or_common_datum)
75-
self._base = value
86+
if not check_type(value,datum_or_common_datum):
87+
self._base = datum_or_common_datum(value)
88+
else:
89+
self._base = value
7690
return property(**locals())
7791

7892
####################
@@ -101,5 +115,3 @@ class datum(shape_aspect):
101115
'''
102116
def __init__( self , shape_aspect__name , shape_aspect__of_shape , ):
103117
shape_aspect.__init__(self , shape_aspect__name , shape_aspect__of_shape , )
104-
# SELECT TYPE datum_or_common_datum
105-
datum_or_common_datum=SELECT([common_datum_list,datum])

src/fedex_python/examples/unitary_schemas/test_array.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class point(BaseEntityClass):
1515
'''Entity point definition.
1616
1717
:param coords
18-
:type coords:(null)
18+
:type coords:ARRAY(1,3,'REAL')
1919
'''
2020
def __init__( self , coords, ):
2121
self.coords = coords
@@ -28,6 +28,8 @@ def fset( self, value ):
2828
# Mandatory argument
2929
if value==None:
3030
raise AssertionError('Argument coords is mantatory and can not be set to None')
31-
check_type(value,ARRAY(1,3,REAL))
32-
self._coords = value
31+
if not check_type(value,ARRAY(1,3,'REAL')):
32+
self._coords = ARRAY(value)
33+
else:
34+
self._coords = value
3335
return property(**locals())

src/fedex_python/examples/unitary_schemas/test_array_of_simple_types.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class point(BaseEntityClass):
1515
'''Entity point definition.
1616
1717
:param arr_real
18-
:type arr_real:(null)
18+
:type arr_real:ARRAY(1,3,'REAL')
1919
2020
:param arr_string
21-
:type arr_string:(null)
21+
:type arr_string:ARRAY(1,3,'STRING')
2222
2323
:param arr_integer
24-
:type arr_integer:(null)
24+
:type arr_integer:ARRAY(1,None,'INTEGER')
2525
'''
2626
def __init__( self , arr_real,arr_string,arr_integer, ):
2727
self.arr_real = arr_real
@@ -36,8 +36,10 @@ def fset( self, value ):
3636
# Mandatory argument
3737
if value==None:
3838
raise AssertionError('Argument arr_real is mantatory and can not be set to None')
39-
check_type(value,ARRAY(1,3,REAL))
40-
self._arr_real = value
39+
if not check_type(value,ARRAY(1,3,'REAL')):
40+
self._arr_real = ARRAY(value)
41+
else:
42+
self._arr_real = value
4143
return property(**locals())
4244

4345
@apply
@@ -48,8 +50,10 @@ def fset( self, value ):
4850
# Mandatory argument
4951
if value==None:
5052
raise AssertionError('Argument arr_string is mantatory and can not be set to None')
51-
check_type(value,ARRAY(1,3,STRING))
52-
self._arr_string = value
53+
if not check_type(value,ARRAY(1,3,'STRING')):
54+
self._arr_string = ARRAY(value)
55+
else:
56+
self._arr_string = value
5357
return property(**locals())
5458

5559
@apply
@@ -60,6 +64,8 @@ def fset( self, value ):
6064
# Mandatory argument
6165
if value==None:
6266
raise AssertionError('Argument arr_integer is mantatory and can not be set to None')
63-
check_type(value,ARRAY(1,None,INTEGER))
64-
self._arr_integer = value
67+
if not check_type(value,ARRAY(1,None,'INTEGER')):
68+
self._arr_integer = ARRAY(value)
69+
else:
70+
self._arr_integer = value
6571
return property(**locals())

src/fedex_python/examples/unitary_schemas/test_derived_attribute.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ def fset( self, value ):
5151
# Mandatory argument
5252
if value==None:
5353
raise AssertionError('Argument centre is mantatory and can not be set to None')
54-
check_type(value,point)
55-
self._centre = value
54+
if not check_type(value,point):
55+
self._centre = point(value)
56+
else:
57+
self._centre = value
5658
return property(**locals())
5759

5860
@apply
@@ -63,8 +65,10 @@ def fset( self, value ):
6365
# Mandatory argument
6466
if value==None:
6567
raise AssertionError('Argument radius is mantatory and can not be set to None')
66-
check_type(value,REAL)
67-
self._radius = value
68+
if not check_type(value,REAL):
69+
self._radius = REAL(value)
70+
else:
71+
self._radius = value
6872
return property(**locals())
6973

7074
@apply
@@ -75,8 +79,10 @@ def fset( self, value ):
7579
# Mandatory argument
7680
if value==None:
7781
raise AssertionError('Argument axis is mantatory and can not be set to None')
78-
check_type(value,vector)
79-
self._axis = value
82+
if not check_type(value,vector):
83+
self._axis = vector(value)
84+
else:
85+
self._axis = value
8086
return property(**locals())
8187

8288
@apply

src/fedex_python/examples/unitary_schemas/test_enum_entity_name.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
from SCL.AggregationDataTypes import *
88
from SCL.TypeChecker import check_type
99
from SCL.Expr import *
10+
1011
# ENUMERATION TYPE simple_datum_reference_modifier
11-
simple_datum_reference_modifier = ENUMERATION([
12+
if (not 'line' in globals().keys()):
13+
line = 'line'
14+
if (not 'translation' in globals().keys()):
15+
translation = 'translation'
16+
simple_datum_reference_modifier = ENUMERATION(
1217
'line',
1318
'translation',
14-
])
19+
)
1520

1621
####################
1722
# ENTITY line #

src/fedex_python/examples/unitary_schemas/test_enums_same_name.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@
77
from SCL.AggregationDataTypes import *
88
from SCL.TypeChecker import check_type
99
from SCL.Expr import *
10+
1011
# ENUMERATION TYPE hair_color
11-
hair_color = ENUMERATION([
12+
if (not 'bald' in globals().keys()):
13+
bald = 'bald'
14+
if (not 'red' in globals().keys()):
15+
red = 'red'
16+
hair_color = ENUMERATION(
1217
'bald',
1318
'red',
14-
])
19+
)
20+
1521
# ENUMERATION TYPE favorite_color
16-
favorite_color = ENUMERATION([
22+
if (not 'clear' in globals().keys()):
23+
clear = 'clear'
24+
if (not 'red' in globals().keys()):
25+
red = 'red'
26+
favorite_color = ENUMERATION(
1727
'clear',
1828
'red',
19-
])
29+
)

0 commit comments

Comments
 (0)