Skip to content

Commit 10999e7

Browse files
committed
First draft for a SCL python generator
1 parent becb840 commit 10999e7

32 files changed

Lines changed: 11231 additions & 0 deletions

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON)
5858
# build static libs by default
5959
OPTION(BUILD_STATIC_LIBS "Build static libraries" OFF)
6060

61+
OPTION(PYTHON_GENERATOR "Compile fedex_plus_python" ON)
62+
OPTION(CPP_GENERATOR "Compile fedex_plus" ON)
63+
6164
# Set version
6265
SET(SCL_VERSION_MAJOR "3")
6366
SET(SCL_VERSION_MINOR "2")
@@ -258,6 +261,7 @@ include_directories(
258261
ADD_SUBDIRECTORY(src/express)
259262
ADD_SUBDIRECTORY(src/exppp)
260263
ADD_SUBDIRECTORY(src/fedex_plus)
264+
ADD_SUBDIRECTORY(src/fedex_python)
261265
ADD_SUBDIRECTORY(src/clstepcore)
262266
ADD_SUBDIRECTORY(src/cleditor)
263267
ADD_SUBDIRECTORY(src/cldai)

include/express/type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ GLOBAL SCL_EXPRESS_EXPORT Error ERROR_corrupted_type INITIALLY( ERROR_none );
235235
#define TYPEis_identifier(t) ((t)->u.type->body->type == identifier_)
236236
#define TYPEis_logical(t) ((t)->u.type->body->type == logical_)
237237
#define TYPEis_boolean(t) ((t)->u.type->body->type == boolean_)
238+
#define TYPEis_real(t) ((t)->u.type->body->type == real_)
239+
#define TYPEis_integer(t) ((t)->u.type->body->type == integer_)
238240
#define TYPEis_string(t) ((t)->u.type->body->type == string_)
239241
#define TYPEis_expression(t) ((t)->u.type->body->type == op_)
240242
#define TYPEis_oneof(t) ((t)->u.type->body->type == oneof_)

src/fedex_python/CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
if(PYTHON_GENERATOR)
2+
3+
include_directories(
4+
${SCL_SOURCE_DIR}/include
5+
${SCL_SOURCE_DIR}/include/exppp
6+
${SCL_SOURCE_DIR}/include/express
7+
${SCL_SOURCE_DIR}/src/fedex_plus
8+
)
9+
10+
add_definitions( -DHAVE_CONFIG_H )
11+
12+
IF(MSVC)
13+
set(fedex_plus_MSVC_SOURCES
14+
${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc
15+
)
16+
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
17+
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
18+
ENDIF(MSVC)
19+
20+
set(fedex_python_SOURCES
21+
src/classes_misc_python.c
22+
${SCL_SOURCE_DIR}/src/express/fedex.c
23+
src/fedex_main_python.c
24+
src/classes_wrapper_python.cc
25+
src/classes_python.c
26+
src/selects_python.c
27+
src/multpass_python.c
28+
${SCL_SOURCE_DIR}/src/fedex_plus/collect.cc
29+
${SCL_SOURCE_DIR}/src/fedex_plus/complexlist.cc
30+
${SCL_SOURCE_DIR}/src/fedex_plus/entlist.cc
31+
${SCL_SOURCE_DIR}/src/fedex_plus/multlist.cc
32+
${SCL_SOURCE_DIR}/src/fedex_plus/orlist.cc
33+
${SCL_SOURCE_DIR}/src/fedex_plus/entnode.cc
34+
${SCL_SOURCE_DIR}/src/fedex_plus/expressbuild.cc
35+
${SCL_SOURCE_DIR}/src/fedex_plus/non-ors.cc
36+
${SCL_SOURCE_DIR}/src/fedex_plus/match-ors.cc
37+
${SCL_SOURCE_DIR}/src/fedex_plus/trynext.cc
38+
${SCL_SOURCE_DIR}/src/fedex_plus/write.cc
39+
${SCL_SOURCE_DIR}/src/fedex_plus/print.cc
40+
)
41+
SCL_ADDEXEC(fedex_python "${fedex_python_SOURCES} ${fedex_plus_MSVC_SOURCES}" "libexppp express")
42+
43+
add_dependencies( fedex_python version_string )
44+
endif(PYTHON_GENERATOR)

src/fedex_python/REAMDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Howto
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__doc__= ''' This script runs fedex_python over each EXPRESS schema in the test/unitary_schemas folder'''
2+
3+
unitary_schemas_path = '../../../../test/unitary_schemas'
4+
fedex_python_path = '../../../../cmake-build/bin/fedex_python'
5+
6+
import subprocess
7+
import glob
8+
import os
9+
10+
unitary_schemas = glob.glob(os.path.join(unitary_schemas_path,'*.exp'))
11+
12+
for unitary_schema in unitary_schemas:
13+
subprocess.call([fedex_python_path,unitary_schema])
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# This file was generated by fedex_python. You probably don't want to edit
2+
# it since your modifications will be lost if fedex_plus is used to
3+
# regenerate it.
4+
from SCL.SCLBase import *
5+
from SCL.SimpleDataTypes import *
6+
from SCL.ConstructedDataTypes import *
7+
from SCL.AggregationDataType import *
8+
from SCL.TypeChecker import check_type
9+
from SCL.Expr import *
10+
common_datum_list = 'LIST TYPE Not implemented'
11+
label = STRING
12+
13+
####################
14+
# ENTITY shape_aspect #
15+
####################
16+
class shape_aspect(BaseEntityClass):
17+
'''Entity shape_aspect definition.
18+
19+
:param name
20+
:type name:STRING
21+
22+
:param of_shape
23+
:type of_shape:product_definition_shape
24+
'''
25+
def __init__( self , name,of_shape, ):
26+
self.name = name
27+
self.of_shape = of_shape
28+
29+
@apply
30+
def name():
31+
def fget( self ):
32+
return self._name
33+
def fset( self, value ):
34+
# Mandatory argument
35+
if value==None:
36+
raise AssertionError('Argument name is mantatory and can not be set to None')
37+
check_type(value,STRING)
38+
self._name = value
39+
return property(**locals())
40+
41+
@apply
42+
def of_shape():
43+
def fget( self ):
44+
return self._of_shape
45+
def fset( self, value ):
46+
# Mandatory argument
47+
if value==None:
48+
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
51+
return property(**locals())
52+
53+
####################
54+
# ENTITY general_datum_reference #
55+
####################
56+
class general_datum_reference(shape_aspect):
57+
'''Entity general_datum_reference definition.
58+
59+
:param base
60+
:type base:datum_or_common_datum
61+
'''
62+
def __init__( self , shape_aspect__name , shape_aspect__of_shape , base, ):
63+
shape_aspect.__init__(self , shape_aspect__name , shape_aspect__of_shape , )
64+
self.base = base
65+
66+
@apply
67+
def base():
68+
def fget( self ):
69+
return self._base
70+
def fset( self, value ):
71+
# Mandatory argument
72+
if value==None:
73+
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
76+
return property(**locals())
77+
78+
####################
79+
# ENTITY product_definition_shape #
80+
####################
81+
class product_definition_shape(BaseEntityClass):
82+
'''Entity product_definition_shape definition.
83+
'''
84+
# This class does not define any attribute.
85+
pass
86+
87+
####################
88+
# ENTITY datum_reference_element #
89+
####################
90+
class datum_reference_element(general_datum_reference):
91+
'''Entity datum_reference_element definition.
92+
'''
93+
def __init__( self , general_datum_reference__base , ):
94+
general_datum_reference.__init__(self , general_datum_reference__base , )
95+
96+
####################
97+
# ENTITY datum #
98+
####################
99+
class datum(shape_aspect):
100+
'''Entity datum definition.
101+
'''
102+
def __init__( self , shape_aspect__name , shape_aspect__of_shape , ):
103+
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])
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file was generated by fedex_python. You probably don't want to edit
2+
# it since your modifications will be lost if fedex_plus is used to
3+
# regenerate it.
4+
from SCL.SCLBase import *
5+
from SCL.SimpleDataTypes import *
6+
from SCL.ConstructedDataTypes import *
7+
from SCL.AggregationDataType import *
8+
from SCL.TypeChecker import check_type
9+
from SCL.Expr import *
10+
11+
####################
12+
# ENTITY point #
13+
####################
14+
class point(BaseEntityClass):
15+
'''Entity point definition.
16+
17+
:param coords
18+
:type coords:(null)
19+
'''
20+
def __init__( self , coords, ):
21+
self.coords = coords
22+
23+
@apply
24+
def coords():
25+
def fget( self ):
26+
return self._coords
27+
def fset( self, value ):
28+
# Mandatory argument
29+
if value==None:
30+
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
33+
return property(**locals())
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This file was generated by fedex_python. You probably don't want to edit
2+
# it since your modifications will be lost if fedex_plus is used to
3+
# regenerate it.
4+
from SCL.SCLBase import *
5+
from SCL.SimpleDataTypes import *
6+
from SCL.ConstructedDataTypes import *
7+
from SCL.AggregationDataType import *
8+
from SCL.TypeChecker import check_type
9+
from SCL.Expr import *
10+
11+
####################
12+
# ENTITY point #
13+
####################
14+
class point(BaseEntityClass):
15+
'''Entity point definition.
16+
17+
:param arr_real
18+
:type arr_real:(null)
19+
20+
:param arr_string
21+
:type arr_string:(null)
22+
23+
:param arr_integer
24+
:type arr_integer:(null)
25+
'''
26+
def __init__( self , arr_real,arr_string,arr_integer, ):
27+
self.arr_real = arr_real
28+
self.arr_string = arr_string
29+
self.arr_integer = arr_integer
30+
31+
@apply
32+
def arr_real():
33+
def fget( self ):
34+
return self._arr_real
35+
def fset( self, value ):
36+
# Mandatory argument
37+
if value==None:
38+
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
41+
return property(**locals())
42+
43+
@apply
44+
def arr_string():
45+
def fget( self ):
46+
return self._arr_string
47+
def fset( self, value ):
48+
# Mandatory argument
49+
if value==None:
50+
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+
return property(**locals())
54+
55+
@apply
56+
def arr_integer():
57+
def fget( self ):
58+
return self._arr_integer
59+
def fset( self, value ):
60+
# Mandatory argument
61+
if value==None:
62+
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
65+
return property(**locals())

0 commit comments

Comments
 (0)