Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improvements in SELECT and ENUMERATION support
  • Loading branch information
tpaviot committed Feb 22, 2012
commit 8cad6ec2aa73cfaa92a2646a8629a0aa838550f2
30 changes: 21 additions & 9 deletions src/fedex_python/examples/unitary_schemas/index_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
from SCL.AggregationDataTypes import *
from SCL.TypeChecker import check_type
from SCL.Expr import *
common_datum_list = 'LIST TYPE Not implemented'
common_datum_list = LIST(1,None,'datum_reference_element')
label = STRING
# SELECT TYPE datum_or_common_datum_
if (not 'common_datum_list' in globals().keys()):
common_datum_list = 'common_datum_list'
if (not 'datum' in globals().keys()):
datum = 'datum'
datum_or_common_datum = SELECT(
'common_datum_list',
'datum')

####################
# ENTITY shape_aspect #
Expand All @@ -34,8 +42,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument name is mantatory and can not be set to None')
check_type(value,STRING)
self._name = value
if not check_type(value,STRING):
self._name = STRING(value)
else:
self._name = value
return property(**locals())

@apply
Expand All @@ -46,8 +56,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument of_shape is mantatory and can not be set to None')
check_type(value,product_definition_shape)
self._of_shape = value
if not check_type(value,product_definition_shape):
self._of_shape = product_definition_shape(value)
else:
self._of_shape = value
return property(**locals())

####################
Expand All @@ -71,8 +83,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument base is mantatory and can not be set to None')
check_type(value,datum_or_common_datum)
self._base = value
if not check_type(value,datum_or_common_datum):
self._base = datum_or_common_datum(value)
else:
self._base = value
return property(**locals())

####################
Expand Down Expand Up @@ -101,5 +115,3 @@ class datum(shape_aspect):
'''
def __init__( self , shape_aspect__name , shape_aspect__of_shape , ):
shape_aspect.__init__(self , shape_aspect__name , shape_aspect__of_shape , )
# SELECT TYPE datum_or_common_datum
datum_or_common_datum=SELECT([common_datum_list,datum])
8 changes: 5 additions & 3 deletions src/fedex_python/examples/unitary_schemas/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class point(BaseEntityClass):
'''Entity point definition.

:param coords
:type coords:(null)
:type coords:ARRAY(1,3,'REAL')
'''
def __init__( self , coords, ):
self.coords = coords
Expand All @@ -28,6 +28,8 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument coords is mantatory and can not be set to None')
check_type(value,ARRAY(1,3,REAL))
self._coords = value
if not check_type(value,ARRAY(1,3,'REAL')):
self._coords = ARRAY(value)
else:
self._coords = value
return property(**locals())
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class point(BaseEntityClass):
'''Entity point definition.

:param arr_real
:type arr_real:(null)
:type arr_real:ARRAY(1,3,'REAL')

:param arr_string
:type arr_string:(null)
:type arr_string:ARRAY(1,3,'STRING')

:param arr_integer
:type arr_integer:(null)
:type arr_integer:ARRAY(1,None,'INTEGER')
'''
def __init__( self , arr_real,arr_string,arr_integer, ):
self.arr_real = arr_real
Expand All @@ -36,8 +36,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument arr_real is mantatory and can not be set to None')
check_type(value,ARRAY(1,3,REAL))
self._arr_real = value
if not check_type(value,ARRAY(1,3,'REAL')):
self._arr_real = ARRAY(value)
else:
self._arr_real = value
return property(**locals())

@apply
Expand All @@ -48,8 +50,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument arr_string is mantatory and can not be set to None')
check_type(value,ARRAY(1,3,STRING))
self._arr_string = value
if not check_type(value,ARRAY(1,3,'STRING')):
self._arr_string = ARRAY(value)
else:
self._arr_string = value
return property(**locals())

@apply
Expand All @@ -60,6 +64,8 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument arr_integer is mantatory and can not be set to None')
check_type(value,ARRAY(1,None,INTEGER))
self._arr_integer = value
if not check_type(value,ARRAY(1,None,'INTEGER')):
self._arr_integer = ARRAY(value)
else:
self._arr_integer = value
return property(**locals())
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument centre is mantatory and can not be set to None')
check_type(value,point)
self._centre = value
if not check_type(value,point):
self._centre = point(value)
else:
self._centre = value
return property(**locals())

@apply
Expand All @@ -63,8 +65,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument radius is mantatory and can not be set to None')
check_type(value,REAL)
self._radius = value
if not check_type(value,REAL):
self._radius = REAL(value)
else:
self._radius = value
return property(**locals())

@apply
Expand All @@ -75,8 +79,10 @@ def fset( self, value ):
# Mandatory argument
if value==None:
raise AssertionError('Argument axis is mantatory and can not be set to None')
check_type(value,vector)
self._axis = value
if not check_type(value,vector):
self._axis = vector(value)
else:
self._axis = value
return property(**locals())

@apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
from SCL.AggregationDataTypes import *
from SCL.TypeChecker import check_type
from SCL.Expr import *

# ENUMERATION TYPE simple_datum_reference_modifier
simple_datum_reference_modifier = ENUMERATION([
if (not 'line' in globals().keys()):
line = 'line'
if (not 'translation' in globals().keys()):
translation = 'translation'
simple_datum_reference_modifier = ENUMERATION(
'line',
'translation',
])
)

####################
# ENTITY line #
Expand Down
18 changes: 14 additions & 4 deletions src/fedex_python/examples/unitary_schemas/test_enums_same_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
from SCL.AggregationDataTypes import *
from SCL.TypeChecker import check_type
from SCL.Expr import *

# ENUMERATION TYPE hair_color
hair_color = ENUMERATION([
if (not 'bald' in globals().keys()):
bald = 'bald'
if (not 'red' in globals().keys()):
red = 'red'
hair_color = ENUMERATION(
'bald',
'red',
])
)

# ENUMERATION TYPE favorite_color
favorite_color = ENUMERATION([
if (not 'clear' in globals().keys()):
clear = 'clear'
if (not 'red' in globals().keys()):
red = 'red'
favorite_color = ENUMERATION(
'clear',
'red',
])
)
Loading