Skip to content

Commit d0e2c15

Browse files
committed
Merge pull request #145 from mpictor/tp/python-generator-dev
Tp/python generator dev
2 parents becb840 + b84921e commit d0e2c15

37 files changed

+7406
-0
lines changed

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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.AggregationDataTypes import *
8+
from SCL.TypeChecker import check_type
9+
from SCL.Expr import *
10+
maths_number = NUMBER
11+
# SELECT TYPE atom_based_value_
12+
if (not 'maths_number' in globals().keys()):
13+
maths_number = 'maths_number'
14+
if (not 'atom_based_tuple' in globals().keys()):
15+
atom_based_tuple = 'atom_based_tuple'
16+
atom_based_value = SELECT(
17+
'maths_number',
18+
'atom_based_tuple')
19+
atom_based_tuple = LIST(0,None,'atom_based_value')
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: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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.AggregationDataTypes import *
8+
from SCL.TypeChecker import check_type
9+
from SCL.Expr import *
10+
common_datum_list = LIST(1,None,'datum_reference_element')
11+
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')
20+
21+
####################
22+
# ENTITY shape_aspect #
23+
####################
24+
class shape_aspect(BaseEntityClass):
25+
'''Entity shape_aspect definition.
26+
27+
:param name
28+
:type name:STRING
29+
30+
:param of_shape
31+
:type of_shape:product_definition_shape
32+
'''
33+
def __init__( self , name,of_shape, ):
34+
self.name = name
35+
self.of_shape = of_shape
36+
37+
@apply
38+
def name():
39+
def fget( self ):
40+
return self._name
41+
def fset( self, value ):
42+
# Mandatory argument
43+
if value==None:
44+
raise AssertionError('Argument name is mantatory and can not be set to None')
45+
if not check_type(value,STRING):
46+
self._name = STRING(value)
47+
else:
48+
self._name = value
49+
return property(**locals())
50+
51+
@apply
52+
def of_shape():
53+
def fget( self ):
54+
return self._of_shape
55+
def fset( self, value ):
56+
# Mandatory argument
57+
if value==None:
58+
raise AssertionError('Argument of_shape is mantatory and can not be set to None')
59+
if not check_type(value,product_definition_shape):
60+
self._of_shape = product_definition_shape(value)
61+
else:
62+
self._of_shape = value
63+
return property(**locals())
64+
65+
####################
66+
# ENTITY general_datum_reference #
67+
####################
68+
class general_datum_reference(shape_aspect):
69+
'''Entity general_datum_reference definition.
70+
71+
:param base
72+
:type base:datum_or_common_datum
73+
'''
74+
def __init__( self , shape_aspect__name , shape_aspect__of_shape , base, ):
75+
shape_aspect.__init__(self , shape_aspect__name , shape_aspect__of_shape , )
76+
self.base = base
77+
78+
@apply
79+
def base():
80+
def fget( self ):
81+
return self._base
82+
def fset( self, value ):
83+
# Mandatory argument
84+
if value==None:
85+
raise AssertionError('Argument base is mantatory and can not be set to None')
86+
if not check_type(value,datum_or_common_datum):
87+
self._base = datum_or_common_datum(value)
88+
else:
89+
self._base = value
90+
return property(**locals())
91+
92+
####################
93+
# ENTITY product_definition_shape #
94+
####################
95+
class product_definition_shape(BaseEntityClass):
96+
'''Entity product_definition_shape definition.
97+
'''
98+
# This class does not define any attribute.
99+
pass
100+
101+
####################
102+
# ENTITY datum_reference_element #
103+
####################
104+
class datum_reference_element(general_datum_reference):
105+
'''Entity datum_reference_element definition.
106+
'''
107+
def __init__( self , general_datum_reference__base , ):
108+
general_datum_reference.__init__(self , general_datum_reference__base , )
109+
110+
####################
111+
# ENTITY datum #
112+
####################
113+
class datum(shape_aspect):
114+
'''Entity datum definition.
115+
'''
116+
def __init__( self , shape_aspect__name , shape_aspect__of_shape , ):
117+
shape_aspect.__init__(self , shape_aspect__name , shape_aspect__of_shape , )

0 commit comments

Comments
 (0)