Compare commits
327
Commits
incomplete_tests
...
v0.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
953021ec9d | ||
|
|
c8f14a0821 | ||
|
|
63049515d1 | ||
|
|
ca7487fa95 | ||
|
|
0f5179e74b | ||
|
|
bfbd8df61e | ||
|
|
dfe69a923d | ||
|
|
50452e8282 | ||
|
|
e74d4dc813 | ||
|
|
653625f56a | ||
|
|
5f702fb702 | ||
|
|
8273ce1866 | ||
|
|
efb82853b7 | ||
|
|
37901afbbb | ||
|
|
6bac26d3c7 | ||
|
|
ff3fd1f5e7 | ||
|
|
9313b8e6ee | ||
|
|
921de860b0 | ||
|
|
5df2f69930 | ||
|
|
31bf315543 | ||
|
|
87c66bb4dc | ||
|
|
c91109b7b4 | ||
|
|
febbb636fc | ||
|
|
7976c8bee5 | ||
|
|
0b42b2fe89 | ||
|
|
d36d12c6d3 | ||
|
|
86bbc327fa | ||
|
|
c8cfac3acc | ||
|
|
9efd75ebc1 | ||
|
|
98283dca34 | ||
|
|
65c703b811 | ||
|
|
2374029ae8 | ||
|
|
c6d841789e | ||
|
|
14689c6db6 | ||
|
|
01db3788a2 | ||
|
|
712d9657e8 | ||
|
|
168e7a93ed | ||
|
|
7ae34348be | ||
|
|
1e95f8f61e | ||
|
|
4df86e5fea | ||
|
|
78427423ab | ||
|
|
c2c0a6443b | ||
|
|
674fa941f6 | ||
|
|
9db1170803 | ||
|
|
7089bdbf5c | ||
|
|
409315841b | ||
|
|
4bde538c65 | ||
|
|
6955a03fca | ||
|
|
b31ffa3968 | ||
|
|
06bfc7d4d1 | ||
|
|
73b3c1b901 | ||
|
|
66deaafb30 | ||
|
|
9e1d078b46 | ||
|
|
31331651df | ||
|
|
6117e532f8 | ||
|
|
b9db4568fe | ||
|
|
ea24200c67 | ||
|
|
acdc338c9d | ||
|
|
9cf54cf374 | ||
|
|
ea339e2ffa | ||
|
|
14d7b32320 | ||
|
|
62ef3c6edd | ||
|
|
521a999af9 | ||
|
|
47d42ad558 | ||
|
|
f63835532b | ||
|
|
cd08570a3f | ||
|
|
4a01038cd0 | ||
|
|
3132089419 | ||
|
|
5c0bea384c | ||
|
|
d64bbc3611 | ||
|
|
236778a5fc | ||
|
|
d6bb20d81b | ||
|
|
6cb750a3eb | ||
|
|
118d8b295b | ||
|
|
64dd1d2a9a | ||
|
|
2ae605d5ae | ||
|
|
23a5a62397 | ||
|
|
aaa1ca04a6 | ||
|
|
d4f13e0179 | ||
|
|
800453e68a | ||
|
|
a74dc1d32c | ||
|
|
d9c89b9e94 | ||
|
|
fdcdd5a966 | ||
|
|
7222c91c01 | ||
|
|
51acb993da | ||
|
|
ebb7a920f2 | ||
|
|
f6078d8b5b | ||
|
|
4b3e433667 | ||
|
|
1fddd17a64 | ||
|
|
647ecbcf99 | ||
|
|
ef2c01d76c | ||
|
|
e17938afe8 | ||
|
|
d5f693a862 | ||
|
|
bd402b2567 | ||
|
|
ca560239ce | ||
|
|
b3b464632b | ||
|
|
0188910a3a | ||
|
|
35ead380af | ||
|
|
b1387b731e | ||
|
|
d1062cddfa | ||
|
|
6e636d1c20 | ||
|
|
f3cd328b24 | ||
|
|
7867505fdc | ||
|
|
57d3d2fe07 | ||
|
|
259750e31e | ||
|
|
9144443d69 | ||
|
|
6004ba458b | ||
|
|
2d060e7cc3 | ||
|
|
6419146cf1 | ||
|
|
ffd0da9ceb | ||
|
|
bf39d90382 | ||
|
|
5b14529f63 | ||
|
|
60141ce6f7 | ||
|
|
f72e01e610 | ||
|
|
7531579d39 | ||
|
|
2ff6f4b434 | ||
|
|
f357ef4c83 | ||
|
|
752f976475 | ||
|
|
03dbb8ee9f | ||
|
|
3e51af51b4 | ||
|
|
87e1f9948c | ||
|
|
b905bec990 | ||
|
|
63298df542 | ||
|
|
319a8ab59d | ||
|
|
607f732671 | ||
|
|
e649757417 | ||
|
|
4515ffca43 | ||
|
|
4e90ff65e8 | ||
|
|
e18b6d5c2a | ||
|
|
ecaa9ba13f | ||
|
|
53fac955ba | ||
|
|
aee532dd14 | ||
|
|
5840883239 | ||
|
|
df100f5764 | ||
|
|
b65af6f982 | ||
|
|
65d3937e72 | ||
|
|
d635ee5ca8 | ||
|
|
bd80de24bc | ||
|
|
44a6abb36e | ||
|
|
cabf5df7ac | ||
|
|
5fc6630b3f | ||
|
|
b7df5a0e6f | ||
|
|
9aa3b4201f | ||
|
|
6d57acff5b | ||
|
|
c3094242c8 | ||
|
|
1c048abd2e | ||
|
|
3e4af5a77e | ||
|
|
a285652f01 | ||
|
|
5abaebb04b | ||
|
|
35b76941bd | ||
|
|
7301b34c27 | ||
|
|
e4426e3a64 | ||
|
|
39d37e9b09 | ||
|
|
a7fc5d1e76 | ||
|
|
f6fde2f1e1 | ||
|
|
d43b52d61e | ||
|
|
9cded87862 | ||
|
|
8de8875cd8 | ||
|
|
7ff99c9564 | ||
|
|
3f0115631b | ||
|
|
bcd9a58abc | ||
|
|
4a0a27cc30 | ||
|
|
5c24152afe | ||
|
|
87fbca7359 | ||
|
|
2338dd11e1 | ||
|
|
f1ee9585d1 | ||
|
|
5d78a327db | ||
|
|
832a6e75b6 | ||
|
|
252f19754f | ||
|
|
1598dee630 | ||
|
|
15993bdd96 | ||
|
|
a8ffbc17d3 | ||
|
|
7f0a0f852f | ||
|
|
cd0d8b496b | ||
|
|
4d945de475 | ||
|
|
bbe607be60 | ||
|
|
38467bdca3 | ||
|
|
78d99f2f4e | ||
|
|
5c021b2b7f | ||
|
|
10fb7419b5 | ||
|
|
f4ac673b71 | ||
|
|
1696fea0c7 | ||
|
|
44e02c957a | ||
|
|
c0e74a9eef | ||
|
|
a7579f0bc9 | ||
|
|
317b40bff0 | ||
|
|
d4d42b7d1c | ||
|
|
492f455598 | ||
|
|
2ccc5ce360 | ||
|
|
05a74dedd8 | ||
|
|
5043c035a3 | ||
|
|
426e2b4ab3 | ||
|
|
2d651bfad4 | ||
|
|
c6f0c44a02 | ||
|
|
6533032fd9 | ||
|
|
26822ef959 | ||
|
|
86f884b399 | ||
|
|
4fd5dd9f74 | ||
|
|
8e08f71fe8 | ||
|
|
b320bfe3f7 | ||
|
|
34d917fb19 | ||
|
|
86bae779b0 | ||
|
|
b15ba38edf | ||
|
|
96bd4520b5 | ||
|
|
5dd996d38d | ||
|
|
5384fe0dbb | ||
|
|
2d4346dd5a | ||
|
|
ce6a37e49a | ||
|
|
0b2f9ee3fc | ||
|
|
a9120d79f7 | ||
|
|
e1fe3e0b9f | ||
|
|
d14e7670c2 | ||
|
|
37a95f5e63 | ||
|
|
207d6c26c2 | ||
|
|
7de64b6bc4 | ||
|
|
a4e96f62ff | ||
|
|
993c40f6ad | ||
|
|
a035292cf0 | ||
|
|
6ca7b04dfd | ||
|
|
427ecaf09f | ||
|
|
b7a8ac4cbb | ||
|
|
2e6ee6695a | ||
|
|
86bf2dff99 | ||
|
|
c4fde8c96f | ||
|
|
3088d3d63f | ||
|
|
99fbadcdfd | ||
|
|
685e95f618 | ||
|
|
b8d35ce517 | ||
|
|
d1f57453dd | ||
|
|
86302fb0f3 | ||
|
|
4efb670ddf | ||
|
|
5bdac5427b | ||
|
|
a01fa5708a | ||
|
|
ec4eed7367 | ||
|
|
c080fbc8dc | ||
|
|
599f51891d | ||
|
|
ce4227c6b5 | ||
|
|
0dd18d246a | ||
|
|
1cc0beec4b | ||
|
|
aa8842ea56 | ||
|
|
2cd5d494f9 | ||
|
|
6092c9b29f | ||
|
|
8f57958813 | ||
|
|
10ef152fc6 | ||
|
|
95d339e2c7 | ||
|
|
25521ee3af | ||
|
|
f7c56d3e5a | ||
|
|
b2b0039d2f | ||
|
|
91e9528afe | ||
|
|
52acad573b | ||
|
|
44ab3e3352 | ||
|
|
30b04d741f | ||
|
|
abf0541ae9 | ||
|
|
bb41fd4863 | ||
|
|
9c5e27590d | ||
|
|
0b16a413f7 | ||
|
|
0d533f55df | ||
|
|
c6cfc06f4f | ||
|
|
d4a21dd654 | ||
|
|
166db7d178 | ||
|
|
0bf73eece7 | ||
|
|
5a6b972e47 | ||
|
|
9e6b419a53 | ||
|
|
33b0629e1e | ||
|
|
05ade5ca60 | ||
|
|
0a46b861a5 | ||
|
|
2c8a05fa0a | ||
|
|
eb9193038c | ||
|
|
d691bdf4d2 | ||
|
|
c686fc163b | ||
|
|
587ce0f16b | ||
|
|
7ccf768adf | ||
|
|
14c854e0df | ||
|
|
9899ad937b | ||
|
|
171671db1f | ||
|
|
d4c7d1bf6f | ||
|
|
d10d955f74 | ||
|
|
626635b644 | ||
|
|
f64d8f75ca | ||
|
|
4c13ff422f | ||
|
|
caf887ed03 | ||
|
|
860d612086 | ||
|
|
2685dbcf31 | ||
|
|
1ec21780c6 | ||
|
|
58dd89044c | ||
|
|
995a8a7fe9 | ||
|
|
e7bbcc0909 | ||
|
|
bc298808dd | ||
|
|
0c0ff74429 | ||
|
|
f3c56ceafc | ||
|
|
ca1a34a698 | ||
|
|
ee86226f5e | ||
|
|
2fd8d1a0be | ||
|
|
98bc5049f7 | ||
|
|
5fa2ebb677 | ||
|
|
f4369ba902 | ||
|
|
e343668210 | ||
|
|
02ef60aee2 | ||
|
|
530c796284 | ||
|
|
f43a106ac3 | ||
|
|
46951e3b32 | ||
|
|
8f72192262 | ||
|
|
3ee5fc0ca8 | ||
|
|
d061b146d5 | ||
|
|
b3a284a59a | ||
|
|
4a4c39fae9 | ||
|
|
29a15c5db9 | ||
|
|
17c518cd12 | ||
|
|
49a6227103 | ||
|
|
a8a7a723c8 | ||
|
|
21e029c362 | ||
|
|
c0e6d32290 | ||
|
|
d68b60fb39 | ||
|
|
a379152c80 | ||
|
|
c56ee55128 | ||
|
|
9eba5b18dd | ||
|
|
701f90025c | ||
|
|
66d6406ed9 | ||
|
|
19e96fa6fa | ||
|
|
0754642e31 | ||
|
|
0c0714260a | ||
|
|
05333b3185 | ||
|
|
6772b3a64e | ||
|
|
31f0644b26 | ||
|
|
b9922e2e0a | ||
|
|
95597e8a71 | ||
|
|
a13481e543 |
@@ -0,0 +1,2 @@
|
||||
/build
|
||||
|
||||
@@ -5,21 +5,26 @@ http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/src/other/step/?vie
|
||||
In alphabetical order:
|
||||
Bertucat, Roch (rbertucat)
|
||||
Bowman, W. Keith (indianlarry)
|
||||
da Costa, Raphael Kubo (rakuco)
|
||||
DeGraw, Jason (jasondegraw)
|
||||
Easterbrook, Zach (lainiwakurax)
|
||||
Greenwald, Erik (erikg, erikgreenwald)
|
||||
Horler, Chris (cshorler)
|
||||
Lanning, Craig (craigl64)
|
||||
Loman, David (davidloman)
|
||||
McDonald, Rob (ramcdona)
|
||||
Mittal, Pulkit (hoiji09)
|
||||
Morrison, Christopher Sean (sean, morrison, brlcad)
|
||||
Paviot, Thomas (tpaviot)
|
||||
Pictor, Mark (mpictor)
|
||||
Reed, Nick (nickreed)
|
||||
Shah, Kesha (kesha)
|
||||
Shah, Kesha (kesha, keshashah)
|
||||
Thomas, Dawn (homovulgaris, madant)
|
||||
Wouters, Dave (davyw)
|
||||
Yapp, Clifford (starseeker)
|
||||
|
||||
Special thanks:
|
||||
Hunten, Keith (Lockheed Martin)
|
||||
Lubbell, Joshua (NIST)
|
||||
Stirk, Charlie (CostVision)
|
||||
Thurman, Tom (TRThurman)
|
||||
|
||||
+87
-386
@@ -32,427 +32,128 @@
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# *******************************************************************
|
||||
# *** SC's CMakeLists.txt ***
|
||||
# *** STEPcode's CMakeLists.txt ***
|
||||
# *******************************************************************
|
||||
|
||||
# This file contains the top level CMakeLists.txt logic for the
|
||||
# SC software package.
|
||||
# STEPcode software package.
|
||||
|
||||
PROJECT(SC)
|
||||
project(SC)
|
||||
|
||||
# SC version
|
||||
SET(SC_VERSION_MAJOR 0)
|
||||
SET(SC_VERSION_MINOR 7-dev)
|
||||
SET(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR})
|
||||
set(SC_VERSION_MAJOR 0)
|
||||
set(SC_VERSION_MINOR 7-dev)
|
||||
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR})
|
||||
|
||||
# SC ABI version. SC_ABI_SOVERSION should be incremented
|
||||
# for each release introducing API incompatibilities
|
||||
SET(SC_ABI_SOVERSION 2)
|
||||
SET(SC_ABI_VERSION ${SC_ABI_SOVERSION}.0.0)
|
||||
set(SC_ABI_SOVERSION 2)
|
||||
set(SC_ABI_VERSION ${SC_ABI_SOVERSION}.0.0)
|
||||
|
||||
# Minimum required version of CMake
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
cmake_minimum_required(VERSION 2.8.7)
|
||||
if(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND CMAKE_POLICY)
|
||||
|
||||
IF( NOT DEFINED INCLUDE_INSTALL_DIR )
|
||||
SET( INCLUDE_INSTALL_DIR include )
|
||||
ENDIF( NOT DEFINED INCLUDE_INSTALL_DIR )
|
||||
|
||||
IF( NOT DEFINED LIB_INSTALL_DIR )
|
||||
SET( LIB_INSTALL_DIR lib )
|
||||
ENDIF( NOT DEFINED LIB_INSTALL_DIR )
|
||||
|
||||
IF( NOT DEFINED BIN_INSTALL_DIR )
|
||||
SET( BIN_INSTALL_DIR bin )
|
||||
ENDIF( NOT DEFINED BIN_INSTALL_DIR )
|
||||
|
||||
IF( NOT DEFINED SC_BUILD_TYPE )
|
||||
SET( SC_BUILD_TYPE "Debug" CACHE STRING "Build type" ) # By default set debug build
|
||||
ENDIF( NOT DEFINED SC_BUILD_TYPE )
|
||||
IF(NOT SC_IS_SUBBUILD)
|
||||
SET(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE} CACHE INTERNAL "Build type, immutable" FORCE )
|
||||
ELSE(NOT SC_IS_SUBBUILD)
|
||||
SET(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE} )
|
||||
ENDIF(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Define helper macro OPTION_WITH_DEFAULT
|
||||
MACRO( OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT )
|
||||
IF( NOT DEFINED ${OPTION_NAME} )
|
||||
SET( ${OPTION_NAME} ${OPTION_DEFAULT} )
|
||||
ENDIF( NOT DEFINED ${OPTION_NAME} )
|
||||
OPTION( ${OPTION_NAME} "${OPTION_STRING}" ${${OPTION_NAME}} )
|
||||
ENDMACRO( OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT )
|
||||
|
||||
# build shared libs by default
|
||||
OPTION_WITH_DEFAULT(SC_BUILD_SHARED_LIBS "Build shared libs" ON )
|
||||
|
||||
# don't build static libs by default
|
||||
OPTION_WITH_DEFAULT(SC_BUILD_STATIC_LIBS "Build static libs" OFF)
|
||||
|
||||
OPTION_WITH_DEFAULT(SC_PYTHON_GENERATOR "Compile exp2python" ON)
|
||||
OPTION_WITH_DEFAULT(SC_CPP_GENERATOR "Compile exp2cxx" ON)
|
||||
|
||||
OPTION_WITH_DEFAULT(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF)
|
||||
OPTION_WITH_DEFAULT(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF)
|
||||
|
||||
if(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS )
|
||||
set( SC_SDAI_ADDITIONAL_EXES_SRCS "" CACHE STRING "Source files for additional executables to be linked with SDAI libs" )
|
||||
endif(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS )
|
||||
|
||||
if( NOT DEFINED SC_BUILD_SCHEMAS )
|
||||
set( SCHEMAS_WARNING TRUE )
|
||||
#this makes SC_BUILD_SCHEMAS show up in cmake-gui
|
||||
SET(SC_BUILD_SCHEMAS "ALL" CACHE string "Semicolon-separated list of paths to EXPRESS schemas to be built" )
|
||||
endif( NOT DEFINED SC_BUILD_SCHEMAS )
|
||||
if ("${CMAKE_VERSION}" VERSION_GREATER 2.99)
|
||||
CMAKE_POLICY(SET CMP0026 OLD)
|
||||
endif ("${CMAKE_VERSION}" VERSION_GREATER 2.99)
|
||||
endif(COMMAND CMAKE_POLICY)
|
||||
|
||||
# CMake derives much of its functionality from modules, typically
|
||||
# stored in one directory - let CMake know where to find them.
|
||||
SET(SC_CMAKE_DIR "${SC_SOURCE_DIR}/cmake")
|
||||
set(SC_CMAKE_DIR "${SC_SOURCE_DIR}/cmake")
|
||||
if(NOT IS_SUBBUILD)
|
||||
SET(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}")
|
||||
set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}")
|
||||
else(NOT IS_SUBBUILD)
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}")
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}")
|
||||
endif(NOT IS_SUBBUILD)
|
||||
|
||||
INCLUDE(${SC_CMAKE_DIR}/SC_Utils.cmake)
|
||||
# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc
|
||||
include(${SC_CMAKE_DIR}/SC_Build_opts.cmake)
|
||||
|
||||
# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables and set them
|
||||
# to "C" so things like date output are as expected
|
||||
SET(_orig_lc_all $ENV{LC_ALL})
|
||||
SET(_orig_lc_messages $ENV{LC_MESSAGES})
|
||||
SET(_orig_lang $ENV{LANG})
|
||||
IF(_orig_lc_all)
|
||||
SET(ENV{LC_ALL} C)
|
||||
ENDIF(_orig_lc_all)
|
||||
IF(_orig_lc_messages)
|
||||
SET(ENV{LC_MESSAGES} C)
|
||||
ENDIF(_orig_lc_messages)
|
||||
IF(_orig_lang)
|
||||
SET(ENV{LANG} C)
|
||||
ENDIF(_orig_lang)
|
||||
# SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc
|
||||
include(${SC_CMAKE_DIR}/SC_Targets.cmake)
|
||||
|
||||
# Macros related to paths
|
||||
include(${SC_CMAKE_DIR}/SC_Paths.cmake)
|
||||
|
||||
# locale stuff
|
||||
include(${SC_CMAKE_DIR}/SC_Locale.cmake)
|
||||
|
||||
# logic related to regenerating the lexer and parser source code
|
||||
include(${SC_CMAKE_DIR}/SC_Regenerate.cmake)
|
||||
|
||||
if(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS)
|
||||
set(SC_SDAI_ADDITIONAL_EXES_SRCS "" CACHE STRING "Source files for additional executables to be linked with SDAI libs")
|
||||
endif(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS)
|
||||
|
||||
if(NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
list(APPEND CONFIG_END_MESSAGES
|
||||
"** CMake variable SC_BUILD_SCHEMAS was not set. Defaults to building ALL schemas, which will take a"
|
||||
" while; see http://stepcode.org/mw/index.php?title=STEPcode_CMake_variables#SC_BUILD_SCHEMAS")
|
||||
#this makes SC_BUILD_SCHEMAS show up in cmake-gui
|
||||
set(SC_BUILD_SCHEMAS "ALL" CACHE string "Semicolon-separated list of paths to EXPRESS schemas to be built")
|
||||
endif(NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
|
||||
list(APPEND CONFIG_END_MESSAGES
|
||||
".. Don't worry about any messages above about missing headers or failed tests, as long as"
|
||||
" you see 'Configuring done' below. Headers and features vary by compiler."
|
||||
".. Generating step can take a while if you are building several schemas.")
|
||||
|
||||
# create config headers sc_cf.h and sc_version_string.h
|
||||
include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Coverage option
|
||||
OPTION_WITH_DEFAULT( SC_ENABLE_COVERAGE "Enable code coverage test" OFF )
|
||||
IF(SC_ENABLE_COVERAGE)
|
||||
SET(SC_ENABLE_TESTING ON CACHE BOOL "Testing enabled by coverage option" FORCE)
|
||||
# build static libs, better coverage report
|
||||
SET(SC_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE )
|
||||
SET(SC_BUILD_STATIC_LIBS ON CACHE BOOL "Build static libs" FORCE )
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE)
|
||||
SET(SC_BUILD_TYPE "Debug" CACHE STRING "Build type required by testing framework" FORCE)
|
||||
SET( SC_PYTHON_GENERATOR OFF ) #won't build with static libs
|
||||
ENDIF(SC_ENABLE_COVERAGE)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Testing option
|
||||
OPTION_WITH_DEFAULT( SC_ENABLE_TESTING "Enable unittesting framework" OFF )
|
||||
IF(SC_ENABLE_TESTING)
|
||||
if( NOT DEFINED SC_BUILD_SCHEMAS )
|
||||
set( SC_BUILD_SCHEMAS "ALL" ) #test all schemas, unless otherwise specified
|
||||
endif()
|
||||
INCLUDE(CTest)
|
||||
ENABLE_TESTING()
|
||||
ENDIF(SC_ENABLE_TESTING)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# The following logic is what allows binaries to run successfully in
|
||||
# the build directory AND install directory. Thanks to plplot for
|
||||
# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
|
||||
# Documentation of these options is available at
|
||||
# http://www.cmake.org/Wiki/CMake_RPATH_handling
|
||||
|
||||
# use, i.e. don't skip the full RPATH for the build tree
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
|
||||
# when building, don't use the install RPATH already
|
||||
# (but later on when installing)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
# the RPATH/INSTALL_NAME_DIR to be used when installing
|
||||
if (NOT APPLE)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib")
|
||||
endif(NOT APPLE)
|
||||
# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH
|
||||
# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
|
||||
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
# add the automatically determined parts of the RPATH which point to
|
||||
# directories outside the build tree to the install RPATH
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Output directories.
|
||||
# When this is a subbuild, assume that the parent project controls these
|
||||
IF( NOT SC_IS_SUBBUILD )
|
||||
IF(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.")
|
||||
ENDIF(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
IF(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.")
|
||||
ENDIF(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
IF(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
|
||||
ENDIF(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
|
||||
FOREACH(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
|
||||
STRING(TOUPPER "${CFG_TYPE}" CFG_TYPE)
|
||||
IF(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.")
|
||||
ENDIF(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
IF(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.")
|
||||
ENDIF(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
IF(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
|
||||
ENDIF(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
ENDFOREACH()
|
||||
ENDIF( NOT SC_IS_SUBBUILD )
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure install locations.
|
||||
|
||||
# The location in which to install SC. Need a good Debug location
|
||||
# for Windows. Only do this if CMAKE_INSTALL_PREFIX hasn't been set
|
||||
# already, to try and allow parent builds (if any) some control.
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
IF(NOT WIN32)
|
||||
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
SET(SC_INSTALL_PREFIX "${SC_SOURCE_DIR}/../sc-install")
|
||||
ELSE()
|
||||
SET(SC_INSTALL_PREFIX "/usr/local")
|
||||
ENDIF()
|
||||
ENDIF(NOT WIN32)
|
||||
SET( SC_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE
|
||||
PATH "Install prefix prepended to target to create install location" )
|
||||
SET( CMAKE_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE INTERNAL "Prefix prepended to install directories if target destination is not absolute, immutable" FORCE )
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
OPTION(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF)
|
||||
MARK_AS_ADVANCED(SC_BUILD_EXPRESS_ONLY)
|
||||
|
||||
# Take the sc config file template as the starting point for
|
||||
# sc_cf.h.in - scripts may need to append to the template, so
|
||||
# it is read into memory initially.
|
||||
SET(CONFIG_H_FILE ${SC_BINARY_DIR}/include/sc_cf.h.in)
|
||||
set_source_files_properties(${CONFIG_H_FILE} PROPERTIES GENERATED TRUE)
|
||||
set(CMAKE_CURRENT_PROJECT SC)
|
||||
define_property(GLOBAL PROPERTY SC_CONFIG_H_CONTENTS BRIEF_DOCS "config.h.in contents" FULL_DOCS "config.h.in contents for SC project")
|
||||
if(NOT COMMAND CONFIG_H_APPEND)
|
||||
macro(CONFIG_H_APPEND PROJECT_NAME NEW_CONTENTS)
|
||||
if(PROJECT_NAME)
|
||||
get_property(${PROJECT_NAME}_CONFIG_H_CONTENTS GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS)
|
||||
set(${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS "${${PROJECT_NAME}_CONFIG_H_CONTENTS}${NEW_CONTENTS}")
|
||||
set_property(GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS "${${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS}")
|
||||
endif(PROJECT_NAME)
|
||||
endmacro(CONFIG_H_APPEND NEW_CONTENTS)
|
||||
endif(NOT COMMAND CONFIG_H_APPEND)
|
||||
file(READ ${SC_SOURCE_DIR}/include/sc_cf_cmake.h.in CONFIG_H_FILE_CONTENTS)
|
||||
CONFIG_H_APPEND(SC "${CONFIG_H_FILE_CONTENTS}")
|
||||
|
||||
# The Express parser uses the tools Perplex, RE2C and Lemon to generate code
|
||||
# from higher level inputs. Depending on available tools and options, the
|
||||
# SC build can either re-generate code as part of the build, or use cached
|
||||
# files that are ready for compilation.
|
||||
#
|
||||
# SC_GENERATE_LEXER_PARSER is the "high level" control a user sets to determine
|
||||
# how the SC build will interact (or not) with these tools. AUTO (the
|
||||
# default) means it will search for the necessary tools, and use them only if
|
||||
# everything is found. If not, it will fall back to the cached versions. If
|
||||
# this option is set to ON and the necessary tools are not found, the
|
||||
# configure step will fail. If it is set to OFF, SC will not even try to use
|
||||
# the generators and will instead use the cached sources.
|
||||
if(NOT SC_GENERATE_LEXER_PARSER)
|
||||
set(SC_GENERATE_LEXER_PARSER "AUTO" CACHE STRING "Use Perplex, RE2C and Lemon to generate C source code.")
|
||||
else(NOT SC_GENERATE_LEXER_PARSER)
|
||||
string(TOUPPER "${SC_GENERATE_LEXER_PARSER}" SC_GENERATE_LEXER_PARSER)
|
||||
endif(NOT SC_GENERATE_LEXER_PARSER)
|
||||
set_property(CACHE SC_GENERATE_LEXER_PARSER PROPERTY STRINGS AUTO ON OFF)
|
||||
if (NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "AUTO" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
message(WARNING "Unknown value ${SC_GENERATE_LEXER_PARSER} supplied for BRLCAD_WORD_SIZE - defaulting to AUTO")
|
||||
message(WARNING "Valid options are AUTO, ON and OFF")
|
||||
set(SC_GENERATE_LEXER_PARSER "AUTO" CACHE STRING "Use Perplex, RE2C and Lemon to generate C source code.")
|
||||
endif (NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "AUTO" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
|
||||
# If the generators have not been turned off, we need to check for them
|
||||
if(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
find_package(LEMON)
|
||||
find_package(RE2C)
|
||||
find_package(PERPLEX)
|
||||
if(LEMON_EXECUTABLE AND LEMON_TEMPLATE AND PERPLEX_EXECUTABLE AND PERPLEX_TEMPLATE AND RE2C_EXECUTABLE)
|
||||
# Templates may be anywhere - make sure we have a stable path if a relative
|
||||
# path was specified at CMake time
|
||||
get_filename_component(lemon_template_fpath "${LEMON_TEMPLATE}" ABSOLUTE)
|
||||
if(NOT "${lemon_template_fpath}" STREQUAL "${LEMON_TEMPLATE}")
|
||||
get_filename_component(LEMON_TEMPLATE "${CMAKE_BINARY_DIR}/${LEMON_TEMPLATE}" ABSOLUTE)
|
||||
endif(NOT "${lemon_template_fpath}" STREQUAL "${LEMON_TEMPLATE}")
|
||||
get_filename_component(perplex_template_fpath "${PERPLEX_TEMPLATE}" ABSOLUTE)
|
||||
if(NOT "${perplex_template_fpath}" STREQUAL "${PERPLEX_TEMPLATE}")
|
||||
get_filename_component(PERPLEX_TEMPLATE "${CMAKE_BINARY_DIR}/${PERPLEX_TEMPLATE}" ABSOLUTE)
|
||||
endif(NOT "${perplex_template_fpath}" STREQUAL "${PERPLEX_TEMPLATE}")
|
||||
|
||||
if(NOT COMMAND LEMON_TARGET)
|
||||
include(${SC_CMAKE_DIR}/LEMON_Util.cmake)
|
||||
endif(NOT COMMAND LEMON_TARGET)
|
||||
if(NOT COMMAND PERPLEX_TARGET)
|
||||
include(${SC_CMAKE_DIR}/PERPLEX_Util.cmake)
|
||||
endif(NOT COMMAND PERPLEX_TARGET)
|
||||
set(SC_GENERATE_LP_SOURCES 1)
|
||||
else(LEMON_EXECUTABLE AND LEMON_TEMPLATE AND PERPLEX_EXECUTABLE AND PERPLEX_TEMPLATE AND RE2C_EXECUTABLE)
|
||||
if("${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON")
|
||||
message(FATAL_ERROR "\nSC_GENERATE_LEXER_PARSER set to ON, but one or more components of the Perplex/RE2C/Lemon toolchain were not found.\n")
|
||||
else("${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON")
|
||||
set(SC_GENERATE_LP_SOURCES 0)
|
||||
endif("${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON")
|
||||
endif(LEMON_EXECUTABLE AND LEMON_TEMPLATE AND PERPLEX_EXECUTABLE AND PERPLEX_TEMPLATE AND RE2C_EXECUTABLE)
|
||||
else(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
set(SC_GENERATE_LP_SOURCES 0)
|
||||
endif(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
|
||||
INCLUDE(CheckLibraryExists)
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CMakePushCheckState)
|
||||
INCLUDE(CheckCXXSourceRuns)
|
||||
|
||||
CHECK_INCLUDE_FILE(ndir.h HAVE_NDIR_H)
|
||||
CHECK_INCLUDE_FILE(stdarg.h HAVE_STDARG_H)
|
||||
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILE(sys/param.h HAVE_SYS_PARAM_H)
|
||||
CHECK_INCLUDE_FILE(sysent.h HAVE_SYSENT_H)
|
||||
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
|
||||
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
|
||||
CHECK_INCLUDE_FILE(process.h HAVE_PROCESS_H)
|
||||
CHECK_INCLUDE_FILE(io.h HAVE_IO_H)
|
||||
|
||||
CHECK_FUNCTION_EXISTS(abs HAVE_ABS)
|
||||
CHECK_FUNCTION_EXISTS(memcpy HAVE_MEMCPY)
|
||||
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
|
||||
CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT)
|
||||
|
||||
CHECK_TYPE_SIZE("ssize_t" SSIZE_T)
|
||||
|
||||
set( TEST_STD_THREAD "
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
void do_work() {
|
||||
std::cout << \"thread\" << std::endl;
|
||||
}
|
||||
int main() {
|
||||
std::thread t(do_work);
|
||||
t.join();
|
||||
}
|
||||
" )
|
||||
cmake_push_check_state()
|
||||
if( UNIX )
|
||||
set( CMAKE_REQUIRED_FLAGS "-pthread -std=c++0x" )
|
||||
else( UNIX )
|
||||
# vars probably need set for MSVC11, embarcadero, etc
|
||||
endif( UNIX )
|
||||
CHECK_CXX_SOURCE_RUNS( "${TEST_STD_THREAD}" HAVE_STD_THREAD ) #quotes are *required*!
|
||||
cmake_pop_check_state()
|
||||
|
||||
# Now that all the tests are done, configure the sc_cf.h file:
|
||||
get_property(CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS)
|
||||
file(WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS}")
|
||||
configure_file(${CONFIG_H_FILE} ${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_cf.h)
|
||||
|
||||
################ create sc_version_string.h, http://stackoverflow.com/questions/3780667
|
||||
# Using 'ver_string' instead of 'sc_version_string.h' is a trick to force the
|
||||
# command to always execute when the custom target is built. It works because
|
||||
# a file by that name never exists.
|
||||
configure_file(${SC_CMAKE_DIR}/sc_version_string.cmake ${SC_BINARY_DIR}/sc_version_string.cmake @ONLY)
|
||||
add_custom_target(version_string ALL DEPENDS ver_string )
|
||||
# creates sc_version_string.h using cmake script
|
||||
add_custom_command(OUTPUT ver_string ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${SC_SOURCE_DIR}
|
||||
-DBINARY_DIR=${SC_BINARY_DIR}
|
||||
-P ${SC_BINARY_DIR}/sc_version_string.cmake)
|
||||
# sc_version_string.h is a generated file
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
PROPERTIES GENERATED TRUE
|
||||
HEADER_FILE_ONLY TRUE )
|
||||
################
|
||||
|
||||
if(MSVC)
|
||||
# add_definitions( -Wall )
|
||||
add_definitions( -D__MSVC__ -D__WIN32__ )
|
||||
add_definitions(-D__MSVC__ -D__WIN32__)
|
||||
# Disable warning for preferred usage of secure functions (example strcpy should be strcpy_s, ...)
|
||||
add_definitions( -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS )
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
|
||||
elseif(BORLAND)
|
||||
add_definitions( -D__BORLAND__ -D__WIN32__ )
|
||||
add_definitions(-D__BORLAND__ -D__WIN32__)
|
||||
else()
|
||||
add_definitions( -pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long )
|
||||
add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${SC_SOURCE_DIR}/include
|
||||
${SC_BINARY_DIR}/include
|
||||
)
|
||||
)
|
||||
|
||||
ADD_SUBDIRECTORY(src/base)
|
||||
ADD_SUBDIRECTORY(src/express)
|
||||
ADD_SUBDIRECTORY(src/exppp)
|
||||
ADD_SUBDIRECTORY(src/exp2cxx)
|
||||
ADD_SUBDIRECTORY(src/exp2python)
|
||||
ADD_SUBDIRECTORY(src/clstepcore)
|
||||
ADD_SUBDIRECTORY(src/cleditor)
|
||||
ADD_SUBDIRECTORY(src/cldai)
|
||||
ADD_SUBDIRECTORY(src/clutils)
|
||||
if( NOT WIN32 ) # don't build cllazyfile on windows until export/import macros are in place
|
||||
ADD_SUBDIRECTORY( src/cllazyfile )
|
||||
endif( NOT WIN32 )
|
||||
ADD_SUBDIRECTORY(include)
|
||||
ADD_SUBDIRECTORY(data)
|
||||
IF(SC_ENABLE_TESTING)
|
||||
ADD_SUBDIRECTORY( test )
|
||||
ENDIF(SC_ENABLE_TESTING)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
add_subdirectory(src/base)
|
||||
add_subdirectory(src/express)
|
||||
add_subdirectory(src/exppp)
|
||||
add_subdirectory(src/exp2cxx)
|
||||
add_subdirectory(src/exp2python)
|
||||
add_subdirectory(src/clstepcore)
|
||||
add_subdirectory(src/cleditor)
|
||||
add_subdirectory(src/cldai)
|
||||
add_subdirectory(src/clutils)
|
||||
if(NOT WIN32) # don't build cllazyfile on windows until export/import macros are in place
|
||||
add_subdirectory(src/cllazyfile)
|
||||
endif(NOT WIN32)
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(data)
|
||||
if(SC_ENABLE_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif(SC_ENABLE_TESTING)
|
||||
add_subdirectory(doc)
|
||||
|
||||
if( SCHEMAS_WARNING )
|
||||
message( "** CMake variable SC_BUILD_SCHEMAS was not set. Defaults to building ALL schemas, which will take a")
|
||||
message(" while; see http://stepcode.org/mw/index.php?title=STEPcode_CMake_variables#SC_BUILD_SCHEMAS" )
|
||||
endif( SCHEMAS_WARNING )
|
||||
message( ".. Don't worry about any messages above about missing headers or failed tests, as long as\n you see '-- Configuring done' below. Headers and features vary by compiler." )
|
||||
# 'make core' builds everything that isn't generated. for devs.
|
||||
add_custom_target(core)
|
||||
add_dependencies(core stepdai check-express stepeditor exp2cxx)
|
||||
|
||||
# this is for testing - 'make core' builds everything that isn't generated
|
||||
add_custom_target( core )
|
||||
add_dependencies( core stepdai check-express stepeditor exp2cxx )
|
||||
# CONFIG_END_MESSAGES - list of messages to be printed after everything else is done.
|
||||
# THIS MUST BE LAST to ensure that they are visible to the user without scrolling.
|
||||
foreach(_msg ${CONFIG_END_MESSAGES})
|
||||
message("${_msg}")
|
||||
endforeach(_msg ${CONFIG_END_MESSAGES})
|
||||
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
###############################################################################
|
||||
# SC Packaging #
|
||||
# $make package #
|
||||
###############################################################################
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode")
|
||||
SET(CPACK_SET_DESTDIR "ON")
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${SC_VERSION_MAJOR})
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR ${SC_VERSION_MINOR})
|
||||
SET(CPACK_PACKAGE_NAME SC )
|
||||
|
||||
SET(CPACK_PACKAGE_CONTACT "SC Developers <scl-dev@googlegroups.com>")
|
||||
INCLUDE(CPack)
|
||||
|
||||
########################################################################################
|
||||
# Uninstall code #
|
||||
# From http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F #
|
||||
# ######################################################################################
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
@@ -8,3 +8,11 @@ set(CTEST_DROP_METHOD "http")
|
||||
set(CTEST_DROP_SITE "my.cdash.org")
|
||||
set(CTEST_DROP_LOCATION "/submit.php?project=StepClassLibrary")
|
||||
set(CTEST_DROP_SITE_CDASH TRUE)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
STEPcode -- http://github.com/stepcode/stepcode -- http://stepcode.org
|
||||
************************************************************************
|
||||
Release 0.8 (December, 2014)
|
||||
|
||||
New since v0.7:
|
||||
* handle diamond inheritance, derived Attributes
|
||||
* rename fedex_python, fedex_plus to exp2py, exp2cxx
|
||||
* many changes to the pretty printer, due to use in reformatting draft
|
||||
and IS schemas (Thanks Tom!)
|
||||
* parser was also changed due to errors caught while pretty printing
|
||||
- we can be much more confident that the parser is correct now
|
||||
* fix incorrect quoting of timestamp in p21 header
|
||||
* fix various copy constructors and ShallowCopy() members
|
||||
* split generated code into many small files
|
||||
- far easier to open generated code in editors
|
||||
- support more compilers
|
||||
- small files are combined (via #include statements) into a few
|
||||
large files for faster "unitary" builds, if the compiler can handle it
|
||||
- unitary builds are faster than the previous builds
|
||||
* most compiler warnings fixed
|
||||
* finally, all tests pass!
|
||||
|
||||
************************************************************************
|
||||
Release 0.7 (April, 2013)
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
Travis-CI build status:
|
||||
[](https://travis-ci.org/stepcode/stepcode)
|
||||
|
||||
***********************************************************************
|
||||
STEPcode v0.7 -- stepcode.org, github.com/stepcode/stepcode
|
||||
STEPcode v0.8 -- stepcode.org, github.com/stepcode/stepcode
|
||||
|
||||
* What is STEPcode? SC reads ISO10303-11 EXPRESS schemas and generates
|
||||
C++ source code that can read and write Part 21 files conforming
|
||||
@@ -54,4 +57,4 @@ Download astyle from http://sourceforge.net/projects/astyle/files/astyle/
|
||||
|
||||
***********************************************************************
|
||||
|
||||
For more info, see the wiki.
|
||||
For more info, see the wiki.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0.7
|
||||
0.8
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
(from BRL-CAD)
|
||||
|
||||
* rewrite express parser to not require lex/yacc
|
||||
|
||||
* verify/fix step parser generation with newer AP schemas, seems to be
|
||||
outputting invalid syntax.
|
||||
+51
-44
@@ -24,61 +24,68 @@
|
||||
# (To distributed this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
MACRO(CHECK_C_FILE_RUNS SOURCE VAR)
|
||||
IF("${VAR}" MATCHES "^${VAR}$")
|
||||
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||
macro(CHECK_C_FILE_RUNS SOURCE VAR)
|
||||
if("${VAR}" MATCHES "^${VAR}$")
|
||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||
IF(CMAKE_REQUIRED_LIBRARIES)
|
||||
SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||
ELSE(CMAKE_REQUIRED_LIBRARIES)
|
||||
SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||
ENDIF(CMAKE_REQUIRED_LIBRARIES)
|
||||
IF(CMAKE_REQUIRED_INCLUDES)
|
||||
SET(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||
ELSE(CMAKE_REQUIRED_INCLUDES)
|
||||
SET(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
|
||||
ENDIF(CMAKE_REQUIRED_INCLUDES)
|
||||
if(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
|
||||
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||
else(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
|
||||
endif(CMAKE_REQUIRED_LIBRARIES)
|
||||
if(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||
else(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
|
||||
endif(CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
MESSAGE(STATUS "Performing Test ${VAR}")
|
||||
TRY_RUN(${VAR}_EXITCODE ${VAR}_COMPILED
|
||||
message(STATUS "Performing Test ${VAR}")
|
||||
try_run(${VAR}_EXITCODE ${VAR}_COMPILED
|
||||
${CMAKE_BINARY_DIR}
|
||||
${SOURCE}
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${FILE_RUN_DEFINITIONS}
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${FILE_RUN_DEFINITIONS}
|
||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
|
||||
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
|
||||
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
|
||||
COMPILE_OUTPUT_VARIABLE OUTPUT)
|
||||
# if it did not compile make the return value fail code of 1
|
||||
IF(NOT ${VAR}_COMPILED)
|
||||
SET(${VAR}_EXITCODE 1)
|
||||
ENDIF(NOT ${VAR}_COMPILED)
|
||||
if(NOT ${VAR}_COMPILED)
|
||||
set(${VAR}_EXITCODE 1)
|
||||
endif(NOT ${VAR}_COMPILED)
|
||||
# if the return value was 0 then it worked
|
||||
IF("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
|
||||
MESSAGE(STATUS "Performing Test ${VAR} - Success")
|
||||
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Return value: ${${VAR}}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
ELSE("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
IF(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
SET(${VAR} "${${VAR}_EXITCODE}")
|
||||
ELSE(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
SET(${VAR} "" CACHE INTERNAL "Test ${VAR}")
|
||||
ENDIF(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
if("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
|
||||
message(STATUS "Performing Test ${VAR} - Success")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Return value: ${${VAR}}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
else("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
set(${VAR} "${${VAR}_EXITCODE}")
|
||||
else(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
|
||||
endif(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
|
||||
|
||||
MESSAGE(STATUS "Performing Test ${VAR} - Failed")
|
||||
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Return value: ${${VAR}_EXITCODE}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
message(STATUS "Performing Test ${VAR} - Failed")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Return value: ${${VAR}_EXITCODE}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
|
||||
ENDIF("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
ENDIF("${VAR}" MATCHES "^${VAR}$")
|
||||
ENDMACRO(CHECK_C_FILE_RUNS)
|
||||
endif("${${VAR}_EXITCODE}" EQUAL 0)
|
||||
endif("${VAR}" MATCHES "^${VAR}$")
|
||||
endmacro(CHECK_C_FILE_RUNS)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
# Copyright 2009 Kitware, Inc.
|
||||
# Copyright 2006 Tristan Carel
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
#
|
||||
# * The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
|
||||
@@ -15,18 +15,18 @@
|
||||
# Copyright 2009 Kitware, Inc.
|
||||
# Copyright 2006 Tristan Carel
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
#
|
||||
# * The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
|
||||
@@ -8,3 +8,11 @@ mark_as_advanced(RE2C_EXECUTABLE)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(RE2C DEFAULT_MSG RE2C_EXECUTABLE)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -24,18 +24,18 @@
|
||||
# Copyright 2009 Kitware, Inc.
|
||||
# Copyright 2006 Tristan Carel
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
#
|
||||
# * The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
@@ -106,9 +106,9 @@ macro(LEMON_TARGET Name LemonInput LemonSource LemonHeader)
|
||||
# rename generated outputs
|
||||
if(NOT "${LemonSource}" STREQUAL "${LEMON_GEN_SOURCE}")
|
||||
add_custom_command(
|
||||
OUTPUT ${LemonSource}
|
||||
OUTPUT ${LemonSource}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_SOURCE} ${LemonSource}
|
||||
DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE}
|
||||
DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE}
|
||||
)
|
||||
set(LEMON_${Name}_OUTPUTS ${LemonSource} ${LEMON_${Name}_OUTPUTS})
|
||||
endif(NOT "${LemonSource}" STREQUAL "${LEMON_GEN_SOURCE}")
|
||||
@@ -116,7 +116,7 @@ macro(LEMON_TARGET Name LemonInput LemonSource LemonHeader)
|
||||
add_custom_command(
|
||||
OUTPUT ${LemonHeader}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_HEADER} ${LemonHeader}
|
||||
DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER}
|
||||
DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER}
|
||||
)
|
||||
set(LEMON_${Name}_OUTPUTS ${LemonHeader} ${LEMON_${Name}_OUTPUTS})
|
||||
endif(NOT "${LemonHeader}" STREQUAL "${LEMON_GEN_HEADER}")
|
||||
@@ -125,7 +125,7 @@ macro(LEMON_TARGET Name LemonInput LemonSource LemonHeader)
|
||||
|
||||
# make sure we clean up generated output and copied input
|
||||
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}")
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}")
|
||||
else("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS};${LEMON_BIN_INPUT}")
|
||||
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Defines two macros - PERPLEX_TARGET, which takes perplex inputs and
|
||||
# runs both perplex and re2c to generate C source code/headers, and
|
||||
# runs both perplex and re2c to generate C source code/headers, and
|
||||
# ADD_PERPLEX_LEMON_DEPENDENCY which is used to set up dependencies between
|
||||
# scanner and parser targets when necessary.
|
||||
#
|
||||
@@ -21,7 +21,7 @@
|
||||
# ${PERPLEX_MyScanner_OUTPUTS}
|
||||
# )
|
||||
# ====================================================================
|
||||
#
|
||||
#
|
||||
#=============================================================================
|
||||
#
|
||||
# Originally based off of FindBISON.cmake from Kitware's CMake distribution
|
||||
@@ -31,18 +31,18 @@
|
||||
# Copyright 2009 Kitware, Inc.
|
||||
# Copyright 2006 Tristan Carel
|
||||
# All rights reserved.
|
||||
#
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
#
|
||||
# * The names of the authors may not be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
# testing and compilation options, build output dirs, install dirs, etc
|
||||
# included by root CMakeLists
|
||||
|
||||
if(NOT DEFINED INCLUDE_INSTALL_DIR)
|
||||
set(INCLUDE_INSTALL_DIR include)
|
||||
endif(NOT DEFINED INCLUDE_INSTALL_DIR)
|
||||
|
||||
if(NOT DEFINED LIB_INSTALL_DIR)
|
||||
set(LIB_INSTALL_DIR lib)
|
||||
endif(NOT DEFINED LIB_INSTALL_DIR)
|
||||
|
||||
if(NOT DEFINED BIN_INSTALL_DIR)
|
||||
set(BIN_INSTALL_DIR bin)
|
||||
endif(NOT DEFINED BIN_INSTALL_DIR)
|
||||
|
||||
if(NOT DEFINED SC_BUILD_TYPE)
|
||||
set(SC_BUILD_TYPE "Debug" CACHE STRING "Build type") # By default set debug build
|
||||
endif(NOT DEFINED SC_BUILD_TYPE)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
set(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE} CACHE INTERNAL "Build type, immutable" FORCE)
|
||||
else(NOT SC_IS_SUBBUILD)
|
||||
set(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE})
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Define helper macro OPTION_WITH_DEFAULT
|
||||
macro(OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT)
|
||||
if(NOT DEFINED ${OPTION_NAME})
|
||||
set(${OPTION_NAME} ${OPTION_DEFAULT})
|
||||
endif(NOT DEFINED ${OPTION_NAME})
|
||||
option(${OPTION_NAME} "${OPTION_STRING}" ${${OPTION_NAME}})
|
||||
endmacro(OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT)
|
||||
|
||||
# build shared libs by default
|
||||
OPTION_WITH_DEFAULT(SC_BUILD_SHARED_LIBS "Build shared libs" ON)
|
||||
|
||||
# don't build static libs by default
|
||||
OPTION_WITH_DEFAULT(SC_BUILD_STATIC_LIBS "Build static libs" OFF)
|
||||
|
||||
OPTION_WITH_DEFAULT(SC_PYTHON_GENERATOR "Compile exp2python" ON)
|
||||
OPTION_WITH_DEFAULT(SC_CPP_GENERATOR "Compile exp2cxx" ON)
|
||||
|
||||
OPTION_WITH_DEFAULT(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF)
|
||||
OPTION_WITH_DEFAULT(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF)
|
||||
|
||||
option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF)
|
||||
mark_as_advanced(SC_BUILD_EXPRESS_ONLY)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Coverage option
|
||||
OPTION_WITH_DEFAULT(SC_ENABLE_COVERAGE "Enable code coverage test" OFF)
|
||||
if(SC_ENABLE_COVERAGE)
|
||||
set(SC_ENABLE_TESTING ON CACHE BOOL "Testing enabled by coverage option" FORCE)
|
||||
# build static libs, better coverage report
|
||||
set(SC_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
|
||||
set(SC_BUILD_STATIC_LIBS ON CACHE BOOL "Build static libs" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE)
|
||||
set(SC_BUILD_TYPE "Debug" CACHE STRING "Build type required by testing framework" FORCE)
|
||||
set(SC_PYTHON_GENERATOR OFF) #won't build with static libs
|
||||
endif(SC_ENABLE_COVERAGE)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Testing option
|
||||
OPTION_WITH_DEFAULT(SC_ENABLE_TESTING "Enable unittesting framework" OFF)
|
||||
if(SC_ENABLE_TESTING)
|
||||
if(NOT DEFINED SC_BUILD_SCHEMAS)
|
||||
set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified
|
||||
endif()
|
||||
include(CTest)
|
||||
ENABLE_TESTING()
|
||||
endif(SC_ENABLE_TESTING)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# The following logic is what allows binaries to run successfully in
|
||||
# the build directory AND install directory. Thanks to plplot for
|
||||
# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
|
||||
# Documentation of these options is available at
|
||||
# http://www.cmake.org/Wiki/CMake_RPATH_handling
|
||||
|
||||
# use, i.e. don't skip the full RPATH for the build tree
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
|
||||
# when building, don't use the install RPATH already
|
||||
# (but later on when installing)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
# the RPATH/INSTALL_NAME_DIR to be used when installing
|
||||
if (NOT APPLE)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib")
|
||||
endif(NOT APPLE)
|
||||
# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH
|
||||
# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
|
||||
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
# add the automatically determined parts of the RPATH which point to
|
||||
# directories outside the build tree to the install RPATH
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
# When this is a subbuild, assume that the parent project controls all of the following
|
||||
#======================================================================================
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Output directories. In a separate file so it can be used by the schema scanner CMake as well.
|
||||
include(${SC_CMAKE_DIR}/SC_Outdirs.cmake)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure install locations. Only do this if CMAKE_INSTALL_PREFIX hasn't
|
||||
# been set already, to try and allow parent builds (if any) some control.
|
||||
#
|
||||
# Need a good Debug location for Windows.
|
||||
if(NOT WIN32)
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
set(SC_INSTALL_PREFIX "${SC_SOURCE_DIR}/../sc-install")
|
||||
else()
|
||||
set(SC_INSTALL_PREFIX "/usr/local")
|
||||
endif()
|
||||
endif(NOT WIN32)
|
||||
set(SC_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE
|
||||
PATH "Install prefix prepended to target to create install location")
|
||||
set(CMAKE_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE INTERNAL "Prefix prepended to install directories if target destination is not absolute, immutable" FORCE)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# SC Packaging
|
||||
# $make package
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode")
|
||||
set(CPACK_SET_DESTDIR "ON")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${SC_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${SC_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_NAME SC)
|
||||
set(CPACK_PACKAGE_CONTACT "SC Developers <scl-dev@googlegroups.com>")
|
||||
include(CPack)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Uninstall target
|
||||
# From http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
# macros to be used in the CMakeLists generated by the schema scanner
|
||||
|
||||
# uses SC_GENERATE_CXX_ONESHOT - if true, files will only be generated once. this is useful when debugging and modifying code, not otherwise. TODO: print a warning when set
|
||||
if(NOT DEFINED SC_GENERATE_CXX_ONESHOT)
|
||||
set(SC_GENERATE_CXX_ONESHOT FALSE)
|
||||
endif(NOT DEFINED SC_GENERATE_CXX_ONESHOT)
|
||||
|
||||
# find all part 21 files in schema dir, add a test for each one
|
||||
macro(P21_TESTS sfile)
|
||||
get_filename_component(SCHEMA_DIR ${sfile} PATH)
|
||||
file(GLOB_RECURSE P21_FILES ${SCHEMA_DIR}/*.stp ${SCHEMA_DIR}/*.step ${SCHEMA_DIR}/*.p21 ${SCHEMA_DIR}/*.ifc)
|
||||
foreach(TEST_FILE ${P21_FILES})
|
||||
get_filename_component(FNAME ${TEST_FILE} NAME_WE)
|
||||
add_test(NAME read_write_cpp_${PROJECT_NAME}_${FNAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND p21read_${PROJECT_NAME} ${TEST_FILE})
|
||||
set_tests_properties(read_write_cpp_${PROJECT_NAME}_${FNAME} PROPERTIES DEPENDS build_cpp_${PROJECT_NAME} LABELS cpp_schema_rw)
|
||||
if(NOT WIN32)
|
||||
add_test(NAME read_lazy_cpp_${PROJECT_NAME}_${FNAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND lazy_${PROJECT_NAME} ${TEST_FILE})
|
||||
set_tests_properties(read_lazy_cpp_${PROJECT_NAME}_${FNAME} PROPERTIES DEPENDS build_lazy_cpp_${PROJECT_NAME} LABELS cpp_schema_rw)
|
||||
endif(NOT WIN32)
|
||||
endforeach()
|
||||
endmacro(P21_TESTS sfile)
|
||||
|
||||
# create p21read_sdai_*, lazy_sdai_*, any exes listed in SC_SDAI_ADDITIONAL_EXES_SRCS
|
||||
macro(SCHEMA_EXES)
|
||||
RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT)
|
||||
SC_ADDEXEC(p21read_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" "${PROJECT_NAME};stepdai;stepcore;stepeditor;steputils;base" "TESTABLE")
|
||||
#add_dependencies(p21read_${PROJECT_NAME} version_string)
|
||||
if(NOT WIN32)
|
||||
SC_ADDEXEC(lazy_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" "${PROJECT_NAME};steplazyfile;stepdai;stepcore;stepeditor;steputils;base" "TESTABLE")
|
||||
#add_dependencies(lazy_${PROJECT_NAME} version_string)
|
||||
endif(NOT WIN32)
|
||||
|
||||
#add user-defined executables
|
||||
foreach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
get_filename_component(name ${src} NAME_WE)
|
||||
get_filename_component(path ${src} ABSOLUTE)
|
||||
SC_ADDEXEC(${name}_${PROJECT_NAME} "${src}" "${PROJECT_NAME};stepdai;stepcore;stepeditor;steputils;base" "TESTABLE")
|
||||
add_dependencies(${name}_${PROJECT_NAME} version_string)
|
||||
#set_target_properties(${name}_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${path}")
|
||||
endforeach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
ENDMACRO(SCHEMA_EXES)
|
||||
|
||||
|
||||
# label the tests and set dependencies
|
||||
macro(SCHEMA_TESTS)
|
||||
add_test(NAME generate_cpp_${PROJECT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target generate_cpp_${PROJECT_NAME}
|
||||
--config $<CONFIGURATION>)
|
||||
set_tests_properties(generate_cpp_${PROJECT_NAME} PROPERTIES LABELS cpp_schema_gen)
|
||||
add_test(NAME build_cpp_${PROJECT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target p21read_${PROJECT_NAME}
|
||||
--config $<CONFIGURATION>)
|
||||
set_tests_properties(build_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${PROJECT_NAME} LABELS cpp_schema_build)
|
||||
if(NOT WIN32)
|
||||
add_test(NAME build_lazy_cpp_${PROJECT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target lazy_${PROJECT_NAME}
|
||||
--config $<CONFIGURATION>)
|
||||
set_tests_properties(build_lazy_cpp_${PROJECT_NAME} PROPERTIES DEPENDS build_cpp_${PROJECT_NAME} LABELS cpp_schema_build)
|
||||
endif(NOT WIN32)
|
||||
endmacro(SCHEMA_TESTS)
|
||||
|
||||
# SCHEMA_TARGETS macro -
|
||||
# expFile: path to express file
|
||||
# schemaName: name of the schema
|
||||
# sourceFiles: list of .cc and .h files
|
||||
#
|
||||
# create targets for the schema(s) in expFile
|
||||
# targets include gen_cxx_*, sdai_cxx_*, p21read_*, lazyp21_*, ...
|
||||
macro(SCHEMA_TARGETS expFile schemaName sourceFiles)
|
||||
# schema scanner comes up with a short schema name for PROJECT() (which sets ${PROJECT_NAME})
|
||||
message(STATUS "Will generate ${${PROJECT_NAME}_file_count} C++ files for ${PROJECT_NAME}.")
|
||||
|
||||
add_custom_target(generate_cpp_${PROJECT_NAME} DEPENDS exp2cxx ${expFile} ${sourceFiles} SOURCES ${sourceFiles})
|
||||
# this calls a cmake script because it doesn't seem to be possible
|
||||
# to divert stdout, stderr in cmake except via execute_process
|
||||
add_custom_command(OUTPUT ${sourceFiles}
|
||||
COMMAND ${CMAKE_COMMAND} -DEXE=\"$<TARGET_FILE:exp2cxx>\" -DEXP=\"${expFile}\"
|
||||
-DONESHOT=\"${SC_GENERATE_CXX_ONESHOT}\" -DSDIR=\"${CMAKE_CURRENT_LIST_DIR}\"
|
||||
-P ${SC_CMAKE_DIR}/SC_Run_exp2cxx.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMENT "[exp2cxx] Generating ${${PROJECT_NAME}_file_count} C++ files for ${PROJECT_NAME}."
|
||||
)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR} ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/base/judy/src
|
||||
)
|
||||
# if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
|
||||
SC_ADDLIB(${PROJECT_NAME} "${sourceFiles}" "stepdai;stepcore;stepeditor;steputils;base" "TESTABLE")
|
||||
add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME})
|
||||
|
||||
SCHEMA_EXES()
|
||||
SCHEMA_TESTS()
|
||||
P21_TESTS(${expFile})
|
||||
# TODO add test to verify that schema scanner output matches fedex_plus output
|
||||
|
||||
endmacro(SCHEMA_TARGETS expFile schemaName sourceFiles)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
# create sc_cf.h and sc_version_string.h
|
||||
|
||||
# Take the sc config file template as the starting point for
|
||||
# sc_cf.h.in - scripts may need to append to the template, so
|
||||
# it is read into memory initially.
|
||||
set(CONFIG_H_FILE ${SC_BINARY_DIR}/include/sc_cf.h.in)
|
||||
set_source_files_properties(${CONFIG_H_FILE} PROPERTIES GENERATED TRUE)
|
||||
set(CMAKE_CURRENT_PROJECT SC)
|
||||
define_property(GLOBAL PROPERTY SC_CONFIG_H_CONTENTS BRIEF_DOCS "config.h.in contents" FULL_DOCS "config.h.in contents for SC project")
|
||||
if(NOT COMMAND CONFIG_H_APPEND)
|
||||
macro(CONFIG_H_APPEND PROJECT_NAME NEW_CONTENTS)
|
||||
if(PROJECT_NAME)
|
||||
get_property(${PROJECT_NAME}_CONFIG_H_CONTENTS GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS)
|
||||
set(${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS "${${PROJECT_NAME}_CONFIG_H_CONTENTS}${NEW_CONTENTS}")
|
||||
set_property(GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS "${${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS}")
|
||||
endif(PROJECT_NAME)
|
||||
endmacro(CONFIG_H_APPEND NEW_CONTENTS)
|
||||
endif(NOT COMMAND CONFIG_H_APPEND)
|
||||
file(READ ${SC_SOURCE_DIR}/include/sc_cf_cmake.h.in CONFIG_H_FILE_CONTENTS)
|
||||
CONFIG_H_APPEND(SC "${CONFIG_H_FILE_CONTENTS}")
|
||||
|
||||
include(CheckLibraryExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckTypeSize)
|
||||
include(CMakePushCheckState)
|
||||
include(CheckCXXSourceRuns)
|
||||
|
||||
CHECK_INCLUDE_FILE(ndir.h HAVE_NDIR_H)
|
||||
CHECK_INCLUDE_FILE(stdarg.h HAVE_STDARG_H)
|
||||
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILE(sys/param.h HAVE_SYS_PARAM_H)
|
||||
CHECK_INCLUDE_FILE(sysent.h HAVE_SYSENT_H)
|
||||
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
|
||||
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
|
||||
CHECK_INCLUDE_FILE(process.h HAVE_PROCESS_H)
|
||||
CHECK_INCLUDE_FILE(io.h HAVE_IO_H)
|
||||
|
||||
CHECK_FUNCTION_EXISTS(abs HAVE_ABS)
|
||||
CHECK_FUNCTION_EXISTS(memcpy HAVE_MEMCPY)
|
||||
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
|
||||
CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT)
|
||||
|
||||
CHECK_TYPE_SIZE("ssize_t" SSIZE_T)
|
||||
|
||||
set( TEST_STD_THREAD "
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
void do_work() {
|
||||
std::cout << \"thread\" << std::endl;
|
||||
}
|
||||
int main() {
|
||||
std::thread t(do_work);
|
||||
t.join();
|
||||
}
|
||||
" )
|
||||
cmake_push_check_state()
|
||||
if( UNIX )
|
||||
set( CMAKE_REQUIRED_FLAGS "-pthread -std=c++0x" )
|
||||
else( UNIX )
|
||||
# vars probably need set for MSVC11, embarcadero, etc
|
||||
endif( UNIX )
|
||||
CHECK_CXX_SOURCE_RUNS( "${TEST_STD_THREAD}" HAVE_STD_THREAD ) #quotes are *required*!
|
||||
cmake_pop_check_state()
|
||||
|
||||
# Now that all the tests are done, configure the sc_cf.h file:
|
||||
get_property(CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS)
|
||||
file(WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS}")
|
||||
configure_file(${CONFIG_H_FILE} ${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_cf.h)
|
||||
|
||||
# ------------------------
|
||||
|
||||
# create sc_version_string.h, http://stackoverflow.com/questions/3780667
|
||||
# Using 'ver_string' instead of 'sc_version_string.h' is a trick to force the
|
||||
# command to always execute when the custom target is built. It works because
|
||||
# a file by that name never exists.
|
||||
configure_file(${SC_CMAKE_DIR}/sc_version_string.cmake ${SC_BINARY_DIR}/sc_version_string.cmake @ONLY)
|
||||
add_custom_target(version_string ALL DEPENDS ver_string )
|
||||
# creates sc_version_string.h using cmake script
|
||||
add_custom_command(OUTPUT ver_string ${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${SC_SOURCE_DIR}
|
||||
-DBINARY_DIR=${SC_BINARY_DIR}
|
||||
-P ${SC_BINARY_DIR}/sc_version_string.cmake)
|
||||
# sc_version_string.h is a generated file
|
||||
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
PROPERTIES GENERATED TRUE
|
||||
HEADER_FILE_ONLY TRUE )
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables and set them
|
||||
# to "C" so things like date output are as expected
|
||||
set(_orig_lc_all $ENV{LC_ALL})
|
||||
set(_orig_lc_messages $ENV{LC_MESSAGES})
|
||||
set(_orig_lang $ENV{LANG})
|
||||
if(_orig_lc_all)
|
||||
set(ENV{LC_ALL} C)
|
||||
endif(_orig_lc_all)
|
||||
if(_orig_lc_messages)
|
||||
set(ENV{LC_MESSAGES} C)
|
||||
endif(_orig_lc_messages)
|
||||
if(_orig_lang)
|
||||
set(ENV{LANG} C)
|
||||
endif(_orig_lang)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# in its own file so that it can be used by the schema scanner as well
|
||||
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.")
|
||||
endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.")
|
||||
endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
|
||||
endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER "${CFG_TYPE}" CFG_TYPE)
|
||||
if(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.")
|
||||
endif(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
if(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.")
|
||||
endif(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
if(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.")
|
||||
endif(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}")
|
||||
endforeach()
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
macro(REVERSE_PATH in_path out_path drive_path)
|
||||
set(reversed_path)
|
||||
set(tmp_subpath "${in_path}")
|
||||
while(NOT "${tmp_subpath}" STREQUAL "" AND NOT "${tmp_subpath}" STREQUAL "/")
|
||||
get_filename_component(piece "${tmp_subpath}" NAME)
|
||||
get_filename_component(tmp_subpath "${tmp_subpath}" PATH)
|
||||
if(piece)
|
||||
set(reversed_path "${reversed_path}/${piece}")
|
||||
else(piece)
|
||||
set(${drive_path} ${tmp_subpath})
|
||||
set(tmp_subpath)
|
||||
endif(piece)
|
||||
endwhile(NOT "${tmp_subpath}" STREQUAL "" AND NOT "${tmp_subpath}" STREQUAL "/")
|
||||
set("${out_path}" "${reversed_path}")
|
||||
endmacro(REVERSE_PATH)
|
||||
|
||||
macro(GET_COMMON_ROOT_PATH dir1 dir2 common_subpath)
|
||||
get_filename_component(testpath "${dir1}" REALPATH)
|
||||
set(dir1_rev)
|
||||
set(dir2_rev)
|
||||
REVERSE_PATH("${dir1}" dir1_rev drive_name_1)
|
||||
REVERSE_PATH("${dir2}" dir2_rev drive_name_2)
|
||||
if("${drive_name_1}" STREQUAL "${drive_name_2}")
|
||||
set(component_same 1)
|
||||
set(${common_subpath})
|
||||
while(component_same)
|
||||
get_filename_component(piece1 "${dir1_rev}" NAME)
|
||||
get_filename_component(dir1_rev "${dir1_rev}" PATH)
|
||||
get_filename_component(piece2 "${dir2_rev}" NAME)
|
||||
get_filename_component(dir2_rev "${dir2_rev}" PATH)
|
||||
if("${piece1}" STREQUAL "${piece2}")
|
||||
set(${common_subpath} "${${common_subpath}}/${piece1}")
|
||||
else("${piece1}" STREQUAL "${piece2}")
|
||||
set(component_same 0)
|
||||
endif("${piece1}" STREQUAL "${piece2}")
|
||||
endwhile(component_same)
|
||||
if(drive_name_1)
|
||||
set(${common_subpath} "${drive_name_1}${${common_subpath}}")
|
||||
string(REPLACE "//" "/" ${common_subpath} "${${common_subpath}}")
|
||||
endif(drive_name_1)
|
||||
endif("${drive_name_1}" STREQUAL "${drive_name_2}")
|
||||
endmacro(GET_COMMON_ROOT_PATH)
|
||||
|
||||
|
||||
macro(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path)
|
||||
set(common_root_path)
|
||||
GET_COMMON_ROOT_PATH("${SC_SOURCE_DIR}" "${current_dir}" common_root_path)
|
||||
string(REPLACE "${common_root_path}" "" subpath "${current_dir}")
|
||||
string(REPLACE "${common_root_path}" "" needed_src_path "${SC_SOURCE_DIR}")
|
||||
string(REGEX REPLACE "^/" "" subpath "${subpath}")
|
||||
string(REGEX REPLACE "^/" "" needed_src_path "${needed_src_path}")
|
||||
string(LENGTH "${subpath}" PATH_LENGTH)
|
||||
if(PATH_LENGTH GREATER 0)
|
||||
set(${rel_path} "..")
|
||||
get_filename_component(subpath "${subpath}" PATH)
|
||||
string(LENGTH "${subpath}" PATH_LENGTH)
|
||||
while(PATH_LENGTH GREATER 0)
|
||||
set(${rel_path} "${${rel_path}}/..")
|
||||
get_filename_component(subpath "${subpath}" PATH)
|
||||
string(LENGTH "${subpath}" PATH_LENGTH)
|
||||
endwhile(PATH_LENGTH GREATER 0)
|
||||
endif(PATH_LENGTH GREATER 0)
|
||||
set(${rel_path} "${${rel_path}}/${needed_src_path}")
|
||||
string(REPLACE "//" "/" ${rel_path} "${${rel_path}}")
|
||||
endmacro(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path)
|
||||
|
||||
macro(LOCATE_SCHEMA SCHEMA_FILE _res_var)
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}") #is it a path relative to build dir?
|
||||
set(${_res_var} "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}")
|
||||
elseif(EXISTS "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}") # path relative to STEPcode/data?
|
||||
set(${_res_var} "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}")
|
||||
elseif(EXISTS ${SCHEMA_FILE}) # already an absolute path
|
||||
set(${_res_var} ${SCHEMA_FILE})
|
||||
else()
|
||||
message(FATAL_ERROR "Cannot find ${CMAKE_BINARY_DIR}/${SCHEMA_FILE} or ${SC_SOURCE_DIR}/data/${SCHEMA_FILE}/*.exp or ${SCHEMA_FILE}")
|
||||
endif()
|
||||
|
||||
if(IS_DIRECTORY ${${_res_var}}) #if it is a dir, look for one .exp file inside
|
||||
file(GLOB ${_res_var} ${${_res_var}}/*.exp)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${${_res_var}})
|
||||
message(FATAL_ERROR "Expected one express file. Found '${${_res_var}}' instead.")
|
||||
endif()
|
||||
endmacro(LOCATE_SCHEMA SCHEMA_FILE _res_var)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# The Express parser uses the tools Perplex, RE2C and Lemon to generate code
|
||||
# from higher level inputs. Depending on available tools and options, the
|
||||
# SC build can either re-generate code as part of the build, or use cached
|
||||
# files that are ready for compilation.
|
||||
#
|
||||
# SC_GENERATE_LEXER_PARSER is the "high level" control a user sets to determine
|
||||
# how the SC build will interact (or not) with these tools. AUTO (the
|
||||
# default) means it will search for the necessary tools, and use them only if
|
||||
# everything is found. If not, it will fall back to the cached versions. If
|
||||
# this option is set to ON and the necessary tools are not found, the
|
||||
# configure step will fail. If it is set to OFF, SC will not even try to use
|
||||
# the generators and will instead use the cached sources.
|
||||
if(NOT DEFINED SC_GENERATE_LEXER_PARSER)
|
||||
set(SC_GENERATE_LEXER_PARSER "AUTO" CACHE STRING "Use Perplex, RE2C and Lemon to generate C source code.")
|
||||
set(_verbosity "QUIET")
|
||||
else(NOT DEFINED SC_GENERATE_LEXER_PARSER)
|
||||
string(TOUPPER "${SC_GENERATE_LEXER_PARSER}" SC_GENERATE_LEXER_PARSER)
|
||||
endif(NOT DEFINED SC_GENERATE_LEXER_PARSER)
|
||||
set_property(CACHE SC_GENERATE_LEXER_PARSER PROPERTY STRINGS AUTO ON OFF)
|
||||
if (NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "AUTO" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
message(WARNING "Unknown value ${SC_GENERATE_LEXER_PARSER} supplied for SC_GENERATE_LEXER_PARSER - defaulting to AUTO")
|
||||
message(WARNING "Valid options are AUTO, ON and OFF")
|
||||
set(SC_GENERATE_LEXER_PARSER "AUTO" CACHE STRING "Use Perplex, RE2C and Lemon to generate C source code.")
|
||||
endif (NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "AUTO" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON" AND NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
|
||||
# If the generators have not been turned off, we need to check for them
|
||||
if(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
find_package(LEMON ${_verbosity})
|
||||
find_package(RE2C ${_verbosity})
|
||||
find_package(PERPLEX ${_verbosity})
|
||||
if(LEMON_EXECUTABLE AND LEMON_TEMPLATE AND PERPLEX_EXECUTABLE AND PERPLEX_TEMPLATE AND RE2C_EXECUTABLE)
|
||||
# Templates may be anywhere - make sure we have a stable path if a relative
|
||||
# path was specified at CMake time
|
||||
get_filename_component(lemon_template_fpath "${LEMON_TEMPLATE}" ABSOLUTE)
|
||||
if(NOT "${lemon_template_fpath}" STREQUAL "${LEMON_TEMPLATE}")
|
||||
get_filename_component(LEMON_TEMPLATE "${CMAKE_BINARY_DIR}/${LEMON_TEMPLATE}" ABSOLUTE)
|
||||
endif(NOT "${lemon_template_fpath}" STREQUAL "${LEMON_TEMPLATE}")
|
||||
get_filename_component(perplex_template_fpath "${PERPLEX_TEMPLATE}" ABSOLUTE)
|
||||
if(NOT "${perplex_template_fpath}" STREQUAL "${PERPLEX_TEMPLATE}")
|
||||
get_filename_component(PERPLEX_TEMPLATE "${CMAKE_BINARY_DIR}/${PERPLEX_TEMPLATE}" ABSOLUTE)
|
||||
endif(NOT "${perplex_template_fpath}" STREQUAL "${PERPLEX_TEMPLATE}")
|
||||
|
||||
if(NOT COMMAND LEMON_TARGET)
|
||||
include(${SC_CMAKE_DIR}/LEMON_Util.cmake)
|
||||
endif(NOT COMMAND LEMON_TARGET)
|
||||
if(NOT COMMAND PERPLEX_TARGET)
|
||||
include(${SC_CMAKE_DIR}/PERPLEX_Util.cmake)
|
||||
endif(NOT COMMAND PERPLEX_TARGET)
|
||||
set(SC_GENERATE_LP_SOURCES 1)
|
||||
message(".. Found perplex, re2c, and lemon - can regenerate lexer/parser if necessary")
|
||||
else(LEMON_EXECUTABLE AND LEMON_TEMPLATE AND PERPLEX_EXECUTABLE AND PERPLEX_TEMPLATE AND RE2C_EXECUTABLE)
|
||||
if("${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON")
|
||||
message(FATAL_ERROR "\nSC_GENERATE_LEXER_PARSER set to ON, but one or more components of the Perplex/RE2C/Lemon toolchain were not found.\n")
|
||||
else("${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON")
|
||||
set(SC_GENERATE_LP_SOURCES 0)
|
||||
endif("${SC_GENERATE_LEXER_PARSER}" STREQUAL "ON")
|
||||
endif(LEMON_EXECUTABLE AND LEMON_TEMPLATE AND PERPLEX_EXECUTABLE AND PERPLEX_TEMPLATE AND RE2C_EXECUTABLE)
|
||||
else(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
set(SC_GENERATE_LP_SOURCES 0)
|
||||
endif(NOT "${SC_GENERATE_LEXER_PARSER}" STREQUAL "OFF")
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
# if oneshot is true, don't run exp2cxx if source files exist. if schema.cc exists, assume others do
|
||||
if(ONESHOT AND EXISTS "${SDIR}/schema.cc")
|
||||
message("WARNING: SC_GENERATE_CXX_ONESHOT is enabled. If generated code has been modified, it will NOT be rewritten!")
|
||||
message("This is ONLY for debugging STEPcode internals!")
|
||||
else()
|
||||
execute_process(COMMAND ${EXE} ${EXP}
|
||||
WORKING_DIRECTORY ${SDIR}
|
||||
RESULT_VARIABLE _res
|
||||
OUTPUT_FILE exp2cxx_stdout.txt
|
||||
ERROR_FILE exp2cxx_stderr.txt
|
||||
)
|
||||
if(NOT "${_res}" STREQUAL "0")
|
||||
message(FATAL_ERROR "${EXE} reported an error for ${EXP}.\nsee exp2cxx_stdout.txt and exp2cxx_stderr.txt in ${SDIR} for details.")
|
||||
endif(NOT "${_res}" STREQUAL "0")
|
||||
# TODO count number of lines in stdout/stderr and tell user?
|
||||
endif()
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
|
||||
# set compile definitions for dll exports on windows
|
||||
macro(DEFINE_DLL_EXPORTS libname)
|
||||
if(MSVC OR BORLAND)
|
||||
if(${libname} MATCHES "sdai_.*")
|
||||
set(export "SC_SCHEMA_DLL_EXPORTS")
|
||||
else()
|
||||
string(REGEX REPLACE "lib" "" shortname "${libname}")
|
||||
string(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
|
||||
string(TOUPPER ${LOWERCORE} UPPER_CORE)
|
||||
set(export "SC_${UPPER_CORE}_DLL_EXPORTS")
|
||||
endif()
|
||||
get_target_property(defs ${libname} COMPILE_DEFINITIONS)
|
||||
if(defs) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
|
||||
set(defs "${defs};${export}")
|
||||
else(defs)
|
||||
set(defs "${export}")
|
||||
endif(defs)
|
||||
set_target_properties(${libname} PROPERTIES COMPILE_DEFINITIONS "${defs}")
|
||||
endif(MSVC OR BORLAND)
|
||||
endmacro(DEFINE_DLL_EXPORTS libname)
|
||||
|
||||
# set compile definitions for dll imports on windows
|
||||
macro(DEFINE_DLL_IMPORTS tgt libs)
|
||||
if(MSVC OR BORLAND)
|
||||
get_target_property(defs ${tgt} COMPILE_DEFINITIONS)
|
||||
if(NOT defs) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
|
||||
set(defs "")
|
||||
endif(NOT defs)
|
||||
foreach(lib ${libs})
|
||||
string(REGEX REPLACE "lib" "" shortname "${lib}")
|
||||
string(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
|
||||
string(TOUPPER ${LOWERCORE} UPPER_CORE)
|
||||
list(APPEND defs "SC_${UPPER_CORE}_DLL_IMPORTS")
|
||||
endforeach(lib ${libs})
|
||||
if(DEFINED defs)
|
||||
if(defs)
|
||||
set_target_properties(${tgt} PROPERTIES COMPILE_DEFINITIONS "${defs}")
|
||||
endif(defs)
|
||||
endif(DEFINED defs)
|
||||
endif(MSVC OR BORLAND)
|
||||
endmacro(DEFINE_DLL_IMPORTS tgt libs)
|
||||
|
||||
#EXCLUDE_OR_INSTALL(target destination ARGV3)
|
||||
# installs ${target} in ${destination} unless testing is enabled AND ${arg_3} == "TESTABLE",
|
||||
# in which case the EXCLUDE_FROM_ALL property is set for testing.
|
||||
# EXCLUDE_FROM_ALL cannot be set on targets that are to be installed,
|
||||
# so either test the target or install it - but not both
|
||||
macro(EXCLUDE_OR_INSTALL target dest arg_3)
|
||||
if(NOT ((SC_ENABLE_TESTING) AND ("${arg_3}" STREQUAL "TESTABLE")))
|
||||
INSTALL(TARGETS ${target} DESTINATION ${dest})
|
||||
else(NOT ((SC_ENABLE_TESTING) AND ("${arg_3}" STREQUAL "TESTABLE")))
|
||||
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL ON)
|
||||
endif(NOT ((SC_ENABLE_TESTING) AND ("${arg_3}" STREQUAL "TESTABLE")))
|
||||
endmacro(EXCLUDE_OR_INSTALL target dest arg_3)
|
||||
|
||||
#SC_ADDEXEC(execname "source files" "linked libs" ["TESTABLE"] ["MSVC flag" ...])
|
||||
# optional 4th argument of "TESTABLE", passed to EXCLUDE_OR_INSTALL macro
|
||||
# optional args can also be used by MSVC-specific code, but it looks like these two uses
|
||||
# will not conflict because the MSVC args must contain "STRICT"
|
||||
macro(SC_ADDEXEC execname srcslist libslist)
|
||||
if(SC_BUILD_SHARED_LIBS)
|
||||
add_executable(${execname} ${srcslist})
|
||||
target_link_libraries(${execname} ${libslist})
|
||||
DEFINE_DLL_IMPORTS(${execname} "${libslist}") #add import definitions for all libs that the executable is linked to
|
||||
EXCLUDE_OR_INSTALL(${execname} "bin" "${ARGV3}")
|
||||
# Enable extra compiler flags if local executables and/or global options dictate
|
||||
set(LOCAL_COMPILE_FLAGS "")
|
||||
foreach(extraarg ${ARGN})
|
||||
if(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
set(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
endif(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
endforeach(extraarg ${ARGN})
|
||||
if(LOCAL_COMPILE_FLAGS)
|
||||
set_target_properties(${execname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
endif(LOCAL_COMPILE_FLAGS)
|
||||
endif(SC_BUILD_SHARED_LIBS)
|
||||
if(SC_BUILD_STATIC_LIBS)
|
||||
if(NOT SC_BUILD_SHARED_LIBS)
|
||||
set(staticexecname "${execname}")
|
||||
else()
|
||||
set(staticexecname "${execname}-static")
|
||||
endif(NOT SC_BUILD_SHARED_LIBS)
|
||||
add_executable(${staticexecname} ${srcslist})
|
||||
target_link_libraries(${staticexecname} ${libslist})
|
||||
EXCLUDE_OR_INSTALL(${staticexecname} "bin" "${ARGV3}")
|
||||
# Enable extra compiler flags if local executables and/or global options dictate
|
||||
set(LOCAL_COMPILE_FLAGS "")
|
||||
foreach(extraarg ${ARGN})
|
||||
if(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
set(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
endif(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
endforeach(extraarg ${ARGN})
|
||||
if(LOCAL_COMPILE_FLAGS)
|
||||
set_target_properties(${staticexecname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
endif(LOCAL_COMPILE_FLAGS)
|
||||
endif(SC_BUILD_STATIC_LIBS)
|
||||
endmacro(SC_ADDEXEC execname srcslist libslist)
|
||||
|
||||
#SC_ADDLIB(libname "source files" "linked libs" ["TESTABLE"] ["MSVC flag" ...])
|
||||
# optional 4th argument of "TESTABLE", passed to EXCLUDE_OR_INSTALL macro
|
||||
# optional args can also be used by MSVC-specific code, but it looks like these two uses
|
||||
# will not conflict because the MSVC args must contain "STRICT"
|
||||
macro(SC_ADDLIB libname srcslist libslist)
|
||||
string(REGEX REPLACE "-framework;" "-framework " libslist "${libslist1}")
|
||||
if(SC_BUILD_SHARED_LIBS)
|
||||
add_library(${libname} SHARED ${srcslist})
|
||||
DEFINE_DLL_EXPORTS(${libname})
|
||||
if(NOT "${libs}" MATCHES "NONE")
|
||||
target_link_libraries(${libname} ${libslist})
|
||||
DEFINE_DLL_IMPORTS(${libname} "${libslist}")
|
||||
endif(NOT "${libs}" MATCHES "NONE")
|
||||
set_target_properties(${libname} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION})
|
||||
EXCLUDE_OR_INSTALL(${libname} "lib" "${ARGV3}")
|
||||
if(APPLE)
|
||||
set_target_properties(${libname} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
endif(SC_BUILD_SHARED_LIBS)
|
||||
if(SC_BUILD_STATIC_LIBS)
|
||||
if(NOT SC_BUILD_SHARED_LIBS)
|
||||
set(staticlibname "${libname}")
|
||||
else()
|
||||
set(staticlibname "${libname}-static")
|
||||
endif(NOT SC_BUILD_SHARED_LIBS)
|
||||
add_library(${staticlibname} STATIC ${srcslist})
|
||||
DEFINE_DLL_EXPORTS(${staticlibname})
|
||||
if(NOT ${libs} MATCHES "NONE")
|
||||
target_link_libraries(${staticlibname} "${libslist}")
|
||||
DEFINE_DLL_IMPORTS(${staticlibname} ${libslist})
|
||||
endif(NOT ${libs} MATCHES "NONE")
|
||||
if(NOT WIN32)
|
||||
set_target_properties(${staticlibname} PROPERTIES OUTPUT_NAME "${libname}")
|
||||
endif(NOT WIN32)
|
||||
if(WIN32)
|
||||
# We need the lib prefix on win32, so add it even if our add_library
|
||||
# wrapper function has removed it due to the target name - see
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
|
||||
set_target_properties(${staticlibname} PROPERTIES PREFIX "lib")
|
||||
endif(WIN32)
|
||||
EXCLUDE_OR_INSTALL(${staticlibname} "lib" "${ARGV3}")
|
||||
if(APPLE)
|
||||
set_target_properties(${staticlibname} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
endif(SC_BUILD_STATIC_LIBS)
|
||||
# Enable extra compiler flags if local libraries and/or global options dictate
|
||||
set(LOCAL_COMPILE_FLAGS "")
|
||||
foreach(extraarg ${ARGN})
|
||||
if(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
set(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
endif(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
endforeach(extraarg ${ARGN})
|
||||
if(LOCAL_COMPILE_FLAGS)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(${libname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
endif(BUILD_SHARED_LIBS)
|
||||
if(BUILD_STATIC_LIBS)
|
||||
set_target_properties(${staticlibname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
endif(BUILD_STATIC_LIBS)
|
||||
endif(LOCAL_COMPILE_FLAGS)
|
||||
endmacro(SC_ADDLIB libname srcslist libslist)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
|
||||
# set compile definitions for dll exports on windows
|
||||
MACRO(DEFINE_DLL_EXPORTS libname)
|
||||
IF( MSVC OR BORLAND )
|
||||
if( ${libname} MATCHES "sdai_.*" )
|
||||
set( export "SC_SCHEMA_DLL_EXPORTS" )
|
||||
else()
|
||||
STRING(REGEX REPLACE "lib" "" shortname "${libname}")
|
||||
STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
|
||||
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
|
||||
set( export "SC_${UPPER_CORE}_DLL_EXPORTS" )
|
||||
endif()
|
||||
get_target_property(defs ${libname} COMPILE_DEFINITIONS )
|
||||
if( defs ) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
|
||||
set( defs "${defs};${export}")
|
||||
else( defs )
|
||||
set( defs "${export}")
|
||||
endif( defs )
|
||||
set_target_properties(${libname} PROPERTIES COMPILE_DEFINITIONS "${defs}" )
|
||||
ENDIF( MSVC OR BORLAND )
|
||||
ENDMACRO(DEFINE_DLL_EXPORTS libname)
|
||||
|
||||
# set compile definitions for dll imports on windows
|
||||
MACRO( DEFINE_DLL_IMPORTS tgt libs )
|
||||
IF( MSVC OR BORLAND )
|
||||
get_target_property(defs ${tgt} COMPILE_DEFINITIONS )
|
||||
if( NOT defs ) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false
|
||||
set( defs "")
|
||||
endif( NOT defs )
|
||||
foreach( lib ${libs} )
|
||||
STRING(REGEX REPLACE "lib" "" shortname "${lib}")
|
||||
STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}")
|
||||
STRING(TOUPPER ${LOWERCORE} UPPER_CORE)
|
||||
list( APPEND defs "SC_${UPPER_CORE}_DLL_IMPORTS" )
|
||||
endforeach( lib ${libs} )
|
||||
if( DEFINED defs )
|
||||
if( defs )
|
||||
set_target_properties( ${tgt} PROPERTIES COMPILE_DEFINITIONS "${defs}" )
|
||||
endif( defs )
|
||||
endif( DEFINED defs )
|
||||
ENDIF( MSVC OR BORLAND )
|
||||
ENDMACRO( DEFINE_DLL_IMPORTS tgt libs )
|
||||
|
||||
#EXCLUDE_OR_INSTALL(target destination ARGV3)
|
||||
# installs ${target} in ${destination} unless testing is enabled AND ${arg_3} == "TESTABLE",
|
||||
# in which case the EXCLUDE_FROM_ALL property is set for testing.
|
||||
# EXCLUDE_FROM_ALL cannot be set on targets that are to be installed,
|
||||
# so either test the target or install it - but not both
|
||||
MACRO(EXCLUDE_OR_INSTALL target dest arg_3 )
|
||||
if( NOT ( ( SC_ENABLE_TESTING ) AND ( "${arg_3}" STREQUAL "TESTABLE" ) ) )
|
||||
INSTALL(TARGETS ${target} DESTINATION ${dest})
|
||||
else( NOT ( ( SC_ENABLE_TESTING ) AND ( "${arg_3}" STREQUAL "TESTABLE" ) ) )
|
||||
set_target_properties( ${target} PROPERTIES EXCLUDE_FROM_ALL ON )
|
||||
endif( NOT ( ( SC_ENABLE_TESTING ) AND ( "${arg_3}" STREQUAL "TESTABLE" ) ) )
|
||||
ENDMACRO(EXCLUDE_OR_INSTALL target dest arg_3 )
|
||||
|
||||
#SC_ADDEXEC( execname "source files" "linked libs" ["TESTABLE"] ["MSVC flag" ...])
|
||||
# optional 4th argument of "TESTABLE", passed to EXCLUDE_OR_INSTALL macro
|
||||
# optional args can also be used by MSVC-specific code, but it looks like these two uses
|
||||
# will not conflict because the MSVC args must contain "STRICT"
|
||||
MACRO(SC_ADDEXEC execname srcslist libslist)
|
||||
add_executable(${execname} ${srcslist})
|
||||
target_link_libraries(${execname} ${libslist})
|
||||
DEFINE_DLL_IMPORTS(${execname} "${libslist}") #add import definitions for all libs that the executable is linked to
|
||||
EXCLUDE_OR_INSTALL( ${execname} "bin" "${ARGV3}" )
|
||||
# Enable extra compiler flags if local executables and/or global options dictate
|
||||
SET(LOCAL_COMPILE_FLAGS "")
|
||||
FOREACH(extraarg ${ARGN})
|
||||
IF(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
ENDIF(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
ENDFOREACH(extraarg ${ARGN})
|
||||
IF(LOCAL_COMPILE_FLAGS)
|
||||
SET_TARGET_PROPERTIES(${execname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(LOCAL_COMPILE_FLAGS)
|
||||
ENDMACRO(SC_ADDEXEC execname srcslist libslist)
|
||||
|
||||
#SC_ADDLIB( libname "source files" "linked libs" ["TESTABLE"] ["MSVC flag" ...])
|
||||
# optional 4th argument of "TESTABLE", passed to EXCLUDE_OR_INSTALL macro
|
||||
# optional args can also be used by MSVC-specific code, but it looks like these two uses
|
||||
# will not conflict because the MSVC args must contain "STRICT"
|
||||
MACRO(SC_ADDLIB libname srcslist libslist)
|
||||
STRING(REGEX REPLACE "-framework;" "-framework " libslist "${libslist1}")
|
||||
IF(SC_BUILD_SHARED_LIBS)
|
||||
add_library(${libname} SHARED ${srcslist})
|
||||
DEFINE_DLL_EXPORTS(${libname})
|
||||
if(NOT "${libs}" MATCHES "NONE")
|
||||
target_link_libraries(${libname} ${libslist})
|
||||
DEFINE_DLL_IMPORTS(${libname} "${libslist}" )
|
||||
endif(NOT "${libs}" MATCHES "NONE")
|
||||
SET_TARGET_PROPERTIES(${libname} PROPERTIES VERSION ${SC_ABI_VERSION} SOVERSION ${SC_ABI_SOVERSION} )
|
||||
EXCLUDE_OR_INSTALL( ${libname} "lib" "${ARGV3}" )
|
||||
if(APPLE)
|
||||
set_target_properties(${libname} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
ENDIF(SC_BUILD_SHARED_LIBS)
|
||||
IF(SC_BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
if( NOT SC_BUILD_SHARED_LIBS )
|
||||
set( staticlibname "${libname}" )
|
||||
else()
|
||||
set( staticlibname "${libname}-static" )
|
||||
endif( NOT SC_BUILD_SHARED_LIBS )
|
||||
add_library(${staticlibname} STATIC ${srcslist})
|
||||
DEFINE_DLL_EXPORTS(${staticlibname})
|
||||
if(NOT ${libs} MATCHES "NONE")
|
||||
target_link_libraries(${staticlibname} "${libslist}")
|
||||
DEFINE_DLL_IMPORTS(${staticlibname} ${libslist} )
|
||||
endif(NOT ${libs} MATCHES "NONE")
|
||||
IF(NOT WIN32)
|
||||
SET_TARGET_PROPERTIES(${staticlibname} PROPERTIES OUTPUT_NAME "${libname}")
|
||||
ENDIF(NOT WIN32)
|
||||
IF(WIN32)
|
||||
# We need the lib prefix on win32, so add it even if our add_library
|
||||
# wrapper function has removed it due to the target name - see
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F
|
||||
SET_TARGET_PROPERTIES(${staticlibname} PROPERTIES PREFIX "lib")
|
||||
ENDIF(WIN32)
|
||||
EXCLUDE_OR_INSTALL( ${staticlibname} "lib" "${ARGV3}" )
|
||||
if(APPLE)
|
||||
set_target_properties(${staticlibname} PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
|
||||
endif(APPLE)
|
||||
ENDIF(SC_BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
# Enable extra compiler flags if local libraries and/or global options dictate
|
||||
SET(LOCAL_COMPILE_FLAGS "")
|
||||
FOREACH(extraarg ${ARGN})
|
||||
IF(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
SET(LOCAL_COMPILE_FLAGS "${LOCAL_COMPILE_FLAGS} ${STRICT_FLAGS}")
|
||||
ENDIF(${extraarg} MATCHES "STRICT" AND SC-ENABLE_STRICT)
|
||||
ENDFOREACH(extraarg ${ARGN})
|
||||
IF(LOCAL_COMPILE_FLAGS)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
SET_TARGET_PROPERTIES(${libname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
IF(BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
SET_TARGET_PROPERTIES(${staticlibname} PROPERTIES COMPILE_FLAGS ${LOCAL_COMPILE_FLAGS})
|
||||
ENDIF(BUILD_STATIC_LIBS AND NOT MSVC)
|
||||
ENDIF(LOCAL_COMPILE_FLAGS)
|
||||
ENDMACRO(SC_ADDLIB libname srcslist libslist)
|
||||
@@ -1,22 +1,30 @@
|
||||
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
list(REVERSE files)
|
||||
foreach (file ${files})
|
||||
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
if (EXISTS "$ENV{DESTDIR}${file}")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E remove "$ENV{DESTDIR}${file}"
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RESULT_VARIABLE rm_retval
|
||||
)
|
||||
if(NOT ${rm_retval} EQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
endif (NOT ${rm_retval} EQUAL 0)
|
||||
else (EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
endif (EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
||||
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
if (EXISTS "$ENV{DESTDIR}${file}")
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E remove "$ENV{DESTDIR}${file}"
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RESULT_VARIABLE rm_retval
|
||||
)
|
||||
if(NOT ${rm_retval} EQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
endif (NOT ${rm_retval} EQUAL 0)
|
||||
else (EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
endif (EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# http://stackoverflow.com/questions/3780667
|
||||
# http://www.cmake.org/pipermail/cmake/2009-February/027014.html
|
||||
|
||||
|
||||
set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@")
|
||||
|
||||
#---------- find commit id ------------------
|
||||
@@ -13,68 +12,76 @@ set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@")
|
||||
#create a tag with 'git tag <name>' and 'git push --tags'
|
||||
#if git can't be found, uses contents of SC_VERSION.txt
|
||||
|
||||
set(VERS_FILE ${SOURCE_DIR}/SC_VERSION.txt )
|
||||
if( EXISTS ${SOURCE_DIR}/.git )
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags WORKING_DIRECTORY ${SOURCE_DIR}
|
||||
RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COMMIT_ID )
|
||||
if( NOT ${res_var} EQUAL 0 )
|
||||
file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 )
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message( WARNING "Git failed (probably no tags in repo). Build will contain revision info from ${VERS_FILE}." )
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif()
|
||||
else(GIT_FOUND)
|
||||
file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 )
|
||||
set(VERS_FILE ${SOURCE_DIR}/SC_VERSION.txt)
|
||||
if(EXISTS ${SOURCE_DIR}/.git)
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags WORKING_DIRECTORY ${SOURCE_DIR}
|
||||
RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COMMIT_ID)
|
||||
if(NOT ${res_var} EQUAL 0)
|
||||
file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message(WARNING "Git failed (probably no tags in repo). Build will contain revision info from ${VERS_FILE}.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif()
|
||||
else(GIT_FOUND)
|
||||
file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message( WARNING "Git not found. Build will contain revision info from ${VERS_FILE}." )
|
||||
message(WARNING "Git not found. Build will contain revision info from ${VERS_FILE}.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif(GIT_FOUND)
|
||||
endif(GIT_FOUND)
|
||||
else()
|
||||
file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 )
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message( WARNING "Git failed ('.git' not found). Build will contain revision info from ${VERS_FILE}." )
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message(WARNING "Git failed ('.git' not found). Build will contain revision info from ${VERS_FILE}.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif()
|
||||
string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID} )
|
||||
string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID})
|
||||
|
||||
#-------------- date and time ---------------
|
||||
#once cmake_minimum_required is >= 2.8.11, we can use TIMESTAMP:
|
||||
#string( TIMESTAMP date_time_string )
|
||||
#string(TIMESTAMP date_time_string)
|
||||
|
||||
if( UNIX )
|
||||
execute_process( COMMAND date "+%d %b %Y %H:%M" OUTPUT_VARIABLE date_time_string OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
elseif( WIN32 )
|
||||
execute_process( COMMAND cmd /c date /t OUTPUT_VARIABLE currentDate OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
execute_process( COMMAND cmd /c time /t OUTPUT_VARIABLE currentTime OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
set ( date_time_string "${currentDate} ${currentTime}" )
|
||||
if(UNIX)
|
||||
execute_process(COMMAND date "+%d %b %Y %H:%M" OUTPUT_VARIABLE date_time_string OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
elseif(WIN32)
|
||||
execute_process(COMMAND cmd /c date /t OUTPUT_VARIABLE currentDate OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND cmd /c time /t OUTPUT_VARIABLE currentTime OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set (date_time_string "${currentDate} ${currentTime}")
|
||||
else()
|
||||
set( date_time_string "\" __DATE__ \" \" __TIME__ \" " )
|
||||
if( NOT SC_IS_SUBBUILD )
|
||||
message( STATUS "Unknown platform - using date from preprocessor" )
|
||||
endif( NOT SC_IS_SUBBUILD )
|
||||
set(date_time_string "\" __DATE__ \" \" __TIME__ \" ")
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message(STATUS "Unknown platform - using date from preprocessor")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
endif()
|
||||
|
||||
set( header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n"
|
||||
"#ifndef SC_VERSION_STRING\n"
|
||||
"#define SC_VERSION_STRING\n\n"
|
||||
"/*\n** The git commit id looks like \"test-1-g5e1fb47\", where test is the\n"
|
||||
"** name of the last tagged git revision, 1 is the number of commits since that tag,\n"
|
||||
"** 'g' is unknown, and 5e1fb47 is the first 7 chars of the git sha1 commit id.\n"
|
||||
"** timestamp is created from date/time commands on known platforms, and uses\n"
|
||||
"** preprocessor macros elsewhere.\n*/\n\n"
|
||||
"static char sc_version[512] = {\n"
|
||||
" \"git commit id: ${GIT_COMMIT_ID}, build timestamp ${date_time_string}\"\n"
|
||||
"}\;\n\n"
|
||||
"#endif\n"
|
||||
)
|
||||
set(header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n"
|
||||
"#ifndef SC_VERSION_STRING\n"
|
||||
"#define SC_VERSION_STRING\n\n"
|
||||
"/*\n** The git commit id looks like \"test-1-g5e1fb47\", where test is the\n"
|
||||
"** name of the last tagged git revision, 1 is the number of commits since that tag,\n"
|
||||
"** 'g' is unknown, and 5e1fb47 is the first 7 chars of the git sha1 commit id.\n"
|
||||
"** timestamp is created from date/time commands on known platforms, and uses\n"
|
||||
"** preprocessor macros elsewhere.\n*/\n\n"
|
||||
"static char sc_version[512] = {\n"
|
||||
" \"git commit id: ${GIT_COMMIT_ID}, build timestamp ${date_time_string}\"\n"
|
||||
"}\;\n\n"
|
||||
"#endif\n"
|
||||
)
|
||||
|
||||
file(WRITE sc_version_string.h.txt ${header_string} )
|
||||
file(WRITE sc_version_string.h.txt ${header_string})
|
||||
# copy the file to the final header only if the version changes
|
||||
# reduces needless rebuilds
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
sc_version_string.h.txt ${BINARY_DIR}/include/sc_version_string.h)
|
||||
sc_version_string.h.txt ${BINARY_DIR}/include/sc_version_string.h)
|
||||
if(NOT SC_IS_SUBBUILD)
|
||||
message("-- sc_version_string.h is up-to-date.")
|
||||
endif(NOT SC_IS_SUBBUILD)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
project(SC_SUBPROJECT_SCHEMA_SCANNER)
|
||||
cmake_minimum_required(VERSION 2.8.7)
|
||||
|
||||
if(NOT ("${CALLED_FROM}" STREQUAL "STEPCODE_CMAKELISTS" AND DEFINED SC_ROOT AND DEFINED SC_BUILDDIR))
|
||||
message(" ${CALLED_FROM} ${SC_ROOT} ${SC_BUILDDIR}")
|
||||
message(FATAL_ERROR "This is not a truly independent project; it should be built during the STEPcode configuration stage.")
|
||||
endif()
|
||||
|
||||
# SC_ROOT: SC root dir
|
||||
# SC_BUILDDIR: SC build dir, so generated headers can be found
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
# set all target location variables so that MSVC will put the executable the same place as other compilers
|
||||
set(SC_BINARY_DIR ${SC_BUILDDIR})
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../SC_Outdirs.cmake)
|
||||
|
||||
set(schema_scanner_src
|
||||
${SC_ROOT}/src/base/sc_mkdir.c
|
||||
${SC_ROOT}/src/exp2cxx/genCxxFilenames.c
|
||||
${SC_ROOT}/src/exp2cxx/class_strings.c
|
||||
${SC_ROOT}/src/express/generated/expparse.c
|
||||
${SC_ROOT}/src/express/generated/expscan.c
|
||||
${SC_ROOT}/src/express/alg.c
|
||||
${SC_ROOT}/src/express/caseitem.c
|
||||
${SC_ROOT}/src/express/dict.c
|
||||
${SC_ROOT}/src/express/entity.c
|
||||
${SC_ROOT}/src/express/error.c
|
||||
${SC_ROOT}/src/express/exp_kw.c
|
||||
${SC_ROOT}/src/express/expr.c
|
||||
${SC_ROOT}/src/express/express.c
|
||||
${SC_ROOT}/src/express/hash.c
|
||||
${SC_ROOT}/src/express/lexact.c
|
||||
${SC_ROOT}/src/express/linklist.c
|
||||
${SC_ROOT}/src/express/memory.c
|
||||
${SC_ROOT}/src/express/object.c
|
||||
${SC_ROOT}/src/express/info.c
|
||||
${SC_ROOT}/src/express/resolve.c
|
||||
${SC_ROOT}/src/express/schema.c
|
||||
${SC_ROOT}/src/express/scope.c
|
||||
${SC_ROOT}/src/express/stmt.c
|
||||
${SC_ROOT}/src/express/symbol.c
|
||||
${SC_ROOT}/src/express/type.c
|
||||
${SC_ROOT}/src/express/variable.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/schemaScanner.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SC_ROOT}/include/
|
||||
${SC_ROOT}/src/express/
|
||||
${SC_ROOT}/src/express/generated
|
||||
${SC_ROOT}/src/base
|
||||
${SC_ROOT}/src/exp2cxx
|
||||
${SC_BUILDDIR}/include
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D__MSVC__ -D__WIN32__)
|
||||
# Disable warning for preferred usage of secure functions (example strcpy should be strcpy_s, ...)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
|
||||
elseif(BORLAND)
|
||||
add_definitions(-D__BORLAND__ -D__WIN32__)
|
||||
else()
|
||||
add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long)
|
||||
endif()
|
||||
|
||||
add_definitions(-DSCHEMA_SCANNER)
|
||||
|
||||
add_executable(schema_scanner ${schema_scanner_src})
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
README for STEPcode schema scanner
|
||||
--------------
|
||||
|
||||
The files in this directory are for a schema scanner executable, built by CMake during the configuration stage.
|
||||
|
||||
This scanner is used to determine the file names that exp2cxx will use. In CMake, all file names must be known before
|
||||
configuration finishes - so it is necessary to parse the schemas early.
|
||||
|
||||
This appears to be a standalone project to CMake, but it is intended to be built only as part of STEPcode. It is configured,
|
||||
built, and executed during the configuration stage of STEPcode.
|
||||
@@ -0,0 +1,336 @@
|
||||
|
||||
/** \file schemaScanner.cc
|
||||
* This file, along with part of libexpress, are compiled (at configure time)
|
||||
* into a static executable. This executable is a schema scanner that is used
|
||||
* by CMake to determine what files exp2cxx will create. Otherwise, we'd need
|
||||
* to use a few huge files - there is no other way to tell CMake what the
|
||||
* generated files will be called.
|
||||
*/
|
||||
|
||||
/* WARNING
|
||||
* If you modify this file, you must re-run cmake. It doesn't seem to be possible
|
||||
* to re-run cmake automatically, as CMake's configure_file() gets confused by
|
||||
* the '${' and '}' in writeLists() below.
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
# include "expparse.h"
|
||||
# include "expscan.h"
|
||||
# include "express/scope.h"
|
||||
# include "genCxxFilenames.h"
|
||||
# include "sc_mkdir.h"
|
||||
|
||||
# include <string.h>
|
||||
|
||||
# if defined( _WIN32 ) || defined ( __WIN32__ )
|
||||
# include <direct.h>
|
||||
# define getcwd _getcwd
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
}
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
int multiple_inheritance = 0;
|
||||
|
||||
using std::string;
|
||||
using std::stringstream;
|
||||
using std::endl;
|
||||
using std::ofstream;
|
||||
using std::cerr;
|
||||
using std::cout;
|
||||
|
||||
/** \return true for types that exp2cxx won't generate code for */
|
||||
bool notGenerated( const Type t ) {
|
||||
switch( TYPEget_body( t )->type ) {
|
||||
case integer_:
|
||||
case real_:
|
||||
case string_:
|
||||
case binary_:
|
||||
case boolean_:
|
||||
case number_:
|
||||
case logical_:
|
||||
case aggregate_:
|
||||
case bag_:
|
||||
case set_:
|
||||
case list_:
|
||||
case array_:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* from addRenameTypedefs() in multpass.c - check for renamed
|
||||
* enums and selects - exp2cxx prints typedefs for them */
|
||||
if( ( TYPEis_enumeration( t ) || TYPEis_select( t ) ) && ( TYPEget_head( t ) ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** \return a short name for the schema
|
||||
* this name is intended to be unique, but no special care is put into its generation
|
||||
* the official schema name seems most likely to not be unique, but it is generally the longest
|
||||
*
|
||||
* picks the shortest of:
|
||||
* * the name of the dir containing the file (if in sc/data),
|
||||
* * the name of the file containing the schema (minus extension),
|
||||
* * the official name of the schema, passed in arg 'longName'
|
||||
*
|
||||
* TODO: maybe also consider an acronym, such that 'test_array_bounds_expr' becomes 'tabe', 'TABE', 'T_A_B_E', or similar
|
||||
*/
|
||||
string makeShortName( const char * longName ) {
|
||||
//input_filename is path to file. we will extract dir name and file name from it.
|
||||
string dirname = input_filename, filename = input_filename, schname = longName;
|
||||
const char slash = '/';
|
||||
|
||||
//for filename, get rid of dir name(s), if any, as well as the extension
|
||||
size_t sl = filename.rfind( slash );
|
||||
if( sl != string::npos ) {
|
||||
filename.erase( 0, sl + 1 );
|
||||
}
|
||||
size_t dot = filename.rfind( '.' );
|
||||
if( dot != string::npos ) {
|
||||
filename.erase( dot );
|
||||
}
|
||||
|
||||
//for dirname, get rid of the filename and ensure it's in data/
|
||||
sl = dirname.rfind( slash );
|
||||
if( sl != string::npos ) {
|
||||
dirname.erase( sl );
|
||||
}
|
||||
const char * dat = "data";
|
||||
size_t data = dirname.find( dat );
|
||||
if( ( data == string::npos ) || ( dirname[ data + strlen( dat ) ] != slash ) ) {
|
||||
//doesn't contain 'data/'. clear it so it'll be ignored.
|
||||
dirname.clear();
|
||||
} else {
|
||||
//get rid of all but last dir name
|
||||
dirname.erase( 0, dirname.rfind( slash ) + 1 );
|
||||
}
|
||||
|
||||
//use dir name if it's at least 3 chars and shorter than file name
|
||||
//length requirement gets rid of short, undescriptive dir names - including '.' and '..'
|
||||
if( ( dirname.size() > 2 ) && ( dirname.size() < filename.size() ) ) {
|
||||
filename = dirname;
|
||||
}
|
||||
if( strlen( longName ) < filename.size() ) {
|
||||
filename = longName;
|
||||
}
|
||||
filename.insert( 0, "sdai_" );
|
||||
return filename;
|
||||
}
|
||||
|
||||
/** write a CMakeLists.txt file for the schema; print its directory to stdout for CMake's add_subdirectory() command */
|
||||
void writeLists( const char * schemaName, stringstream & eh, stringstream & ei, int ecount,
|
||||
stringstream & th, stringstream & ti, int tcount ) {
|
||||
string shortName = makeShortName( schemaName );
|
||||
if( mkDirIfNone( shortName.c_str() ) < 0 ) {
|
||||
cerr << "Error creating directory " << shortName << " at " << __FILE__ << ":" << __LINE__;
|
||||
perror( 0 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
size_t nameLen = strlen( schemaName );
|
||||
string schema_upper( nameLen, char() );
|
||||
for( size_t i = 0; i < nameLen; ++i) {
|
||||
schema_upper[i] = toupper(schemaName[i]);
|
||||
}
|
||||
string cmListsPath = shortName;
|
||||
cmListsPath += "/CMakeLists.txt";
|
||||
ofstream cmLists;
|
||||
cmLists.open( cmListsPath.c_str() );
|
||||
if( !cmLists.good() ) {
|
||||
cerr << "error opening file " << cmListsPath << " - exiting." << endl;
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
cmLists << "# ----- GENERATED FILE -----" << endl;
|
||||
cmLists << "# ----- Do not edit! -----" << endl << endl;
|
||||
|
||||
cmLists << "# schema name: " << schemaName << endl;
|
||||
cmLists << "# (short name: " << shortName << ")" << endl;
|
||||
cmLists << "# " << ecount << " entities, " << tcount << " types" << endl << endl;
|
||||
|
||||
cmLists << "# targets, logic, etc are within a set of macros shared by all schemas" << endl;
|
||||
cmLists << "include(${SC_CMAKE_DIR}/SC_CXX_schema_macros.cmake)" << endl;
|
||||
|
||||
// * 2 for headers, + 10 other files
|
||||
cmLists << "set(" << shortName << "_file_count " << ( ( ecount + tcount ) * 2 ) + 10 << ")" << endl << endl;
|
||||
|
||||
|
||||
cmLists << "PROJECT(" << shortName << ")" << endl;
|
||||
cmLists << "# list headers so they can be installed - entity, type, misc" << endl;
|
||||
|
||||
cmLists << "set(" << shortName << "_entity_hdrs" << endl;
|
||||
cmLists << eh.str();
|
||||
cmLists << " )" << endl << endl;
|
||||
|
||||
cmLists << "set(" << shortName << "_type_hdrs" << endl;
|
||||
cmLists << th.str();
|
||||
cmLists << " )" << endl << endl;
|
||||
|
||||
cmLists << "set(" << shortName << "_misc_hdrs" << endl;
|
||||
cmLists << " Sdaiclasses.h schema.h" << endl;
|
||||
cmLists << " Sdai" << schema_upper << "Names.h" << endl;
|
||||
cmLists << " Sdai" << schema_upper << ".h" << endl;
|
||||
cmLists << " )" << endl << endl;
|
||||
|
||||
cmLists << "# install all headers" << endl;
|
||||
cmLists << "set(all_headers ${" << shortName << "_entity_hdrs} ${" << shortName << "_type_hdrs} ${" << shortName << "_misc_hdrs})" << endl;
|
||||
cmLists << "foreach( header_file ${all_headers} )" << endl;
|
||||
cmLists << " set(curr_dir)" << endl;
|
||||
cmLists << " get_filename_component(curr_dir ${header_file} PATH)" << endl;
|
||||
cmLists << " get_filename_component(curr_name ${header_file} NAME)" << endl;
|
||||
cmLists << " if (curr_dir)" << endl;
|
||||
cmLists << " install( FILES ${header_file} DESTINATION \"include/schemas/" << shortName << "/${curr_dir}\" )" << endl;
|
||||
cmLists << " else (curr_dir)" << endl;
|
||||
cmLists << " install( FILES ${header_file} DESTINATION \"include/schemas/" << shortName << "\" )" << endl;
|
||||
cmLists << " endif (curr_dir)" << endl;
|
||||
cmLists << "endforeach()" << endl;
|
||||
|
||||
cmLists << "# implementation files - 3 lists" << endl << endl;
|
||||
|
||||
cmLists << "# unity build: #include small .cc files to reduce the number" << endl;
|
||||
cmLists << "# of translation units that must be compiled" << endl;
|
||||
cmLists << "if(SC_UNITY_BUILD)" << endl << " # turns off include statements within type and entity .cc's - the unity T.U.'s include a unity header" << endl;
|
||||
cmLists << " add_definitions( -DSC_SDAI_UNITY_BUILD)" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_impls Sdai" << schema_upper << "_unity_entities.cc)" << endl;
|
||||
cmLists << " set(" << shortName << "_type_impls Sdai" << schema_upper << "_unity_types.cc)" << endl;
|
||||
cmLists << "else(SC_UNITY_BUILD)" << endl;
|
||||
cmLists << " set(" << shortName << "_entity_impls" << endl;
|
||||
cmLists << ei.str();
|
||||
cmLists << " )" << endl << endl;
|
||||
|
||||
cmLists << " set(" << shortName << "_type_impls" << endl;
|
||||
cmLists << ti.str();
|
||||
cmLists << " )" << endl;
|
||||
cmLists << "endif(SC_UNITY_BUILD)" << endl << endl;
|
||||
|
||||
cmLists << "set( " << shortName << "_misc_impls" << endl;
|
||||
cmLists << " SdaiAll.cc compstructs.cc schema.cc" << endl;
|
||||
cmLists << " Sdai" << schema_upper << ".cc" << endl;
|
||||
cmLists << " Sdai" << schema_upper << ".init.cc )" << endl << endl;
|
||||
|
||||
cmLists << "set(schema_target_files ${" << shortName << "_entity_impls} " << "${" << shortName << "_type_impls} " << "${" << shortName << "_misc_impls})" << endl;
|
||||
cmLists << "SCHEMA_TARGETS(\"" << input_filename << "\" \"" << schemaName << "\"" << endl;
|
||||
cmLists << " \"${schema_target_files}\")" << endl;
|
||||
|
||||
cmLists.close();
|
||||
|
||||
char pwd[BUFSIZ] = {0};
|
||||
if( getcwd( pwd, BUFSIZ ) ) {
|
||||
cout << pwd << "/" << shortName << endl;
|
||||
} else {
|
||||
cerr << "Error encountered by getcwd() for " << shortName << " - exiting. Error was ";
|
||||
perror( 0 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
void printSchemaFilenames( Schema sch ){
|
||||
const int numColumns = 2;
|
||||
const int colWidth = 75;
|
||||
const char * tab = " ";
|
||||
|
||||
stringstream typeHeaders, typeImpls, entityHeaders, entityImpls;
|
||||
typeHeaders << tab;
|
||||
typeImpls << tab;
|
||||
entityHeaders << tab;
|
||||
entityImpls << tab;
|
||||
|
||||
int ecount = 0, tcount = 0;
|
||||
|
||||
DictionaryEntry de;
|
||||
Generic x;
|
||||
filenames_t fn;
|
||||
DICTdo_init( sch->symbol_table, &de );
|
||||
while( 0 != ( x = DICTdo( &de ) ) ) {
|
||||
switch( DICT_type ) {
|
||||
case OBJ_ENTITY:
|
||||
fn = getEntityFilenames( ( Entity ) x );
|
||||
entityHeaders << std::left << std::setw( colWidth ) << fn.header << " ";
|
||||
entityImpls << std::left << std::setw( colWidth ) << fn.impl << " ";
|
||||
++ecount;
|
||||
if( ( ecount % numColumns ) == 0 ) {
|
||||
// columns
|
||||
entityHeaders << endl << tab;
|
||||
entityImpls << endl << tab;
|
||||
}
|
||||
break;
|
||||
case OBJ_TYPE: {
|
||||
Type t = ( Type ) x;
|
||||
if( TYPEis_enumeration( t ) && ( TYPEget_head( t ) ) ) {
|
||||
/* t is a renamed enum type, for which exp2cxx
|
||||
* will print a typedef in an existing file */
|
||||
break;
|
||||
}
|
||||
if( notGenerated( t ) ) {
|
||||
/* skip builtin types */
|
||||
break;
|
||||
}
|
||||
fn = getTypeFilenames( t );
|
||||
typeHeaders << std::left << std::setw( colWidth ) << fn.header << " ";
|
||||
typeImpls << std::left << std::setw( colWidth ) << fn.impl << " ";
|
||||
++tcount;
|
||||
if( ( tcount % numColumns ) == 0 ) {
|
||||
typeHeaders << endl << tab;
|
||||
typeImpls << endl << tab;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* case OBJ_FUNCTION:
|
||||
* case OBJ_PROCEDURE:
|
||||
* case OBJ_RULE: */
|
||||
default:
|
||||
/* ignore everything else */
|
||||
/* TODO: if DEBUG is defined, print the names of these to stderr */
|
||||
break;
|
||||
}
|
||||
}
|
||||
//write the CMakeLists.txt
|
||||
writeLists( sch->symbol.name, entityHeaders, entityImpls, ecount, typeHeaders, typeImpls, tcount );
|
||||
}
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
/* TODO init globals! */
|
||||
|
||||
Schema schema;
|
||||
DictionaryEntry de;
|
||||
/* copied from fedex.c */
|
||||
Express model;
|
||||
if( ( argc != 2 ) || ( strlen( argv[1] ) < 1 ) ) {
|
||||
fprintf( stderr, "\nUsage: %s file.exp\nOutput: a CMakeLists.txt to build the schema,", argv[0] );
|
||||
fprintf( stderr, " containing file names for entities, types, etc\n" );
|
||||
fprintf( stderr, "also prints (to stdout) the absolute path to the directory CMakeLists.txt was created in\n" );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
EXPRESSprogram_name = argv[0];
|
||||
input_filename = argv[1];
|
||||
|
||||
EXPRESSinitialize();
|
||||
|
||||
model = EXPRESScreate();
|
||||
EXPRESSparse( model, ( FILE * )0, input_filename );
|
||||
if( ERRORoccurred ) {
|
||||
EXPRESSdestroy( model );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
EXPRESSresolve( model );
|
||||
if( ERRORoccurred ) {
|
||||
int result = EXPRESS_fail( model );
|
||||
EXPRESScleanup();
|
||||
EXPRESSdestroy( model );
|
||||
exit( result );
|
||||
}
|
||||
|
||||
DICTdo_type_init( model->symbol_table, &de, OBJ_SCHEMA );
|
||||
while( 0 != ( schema = ( Schema )DICTdo( &de ) ) ) {
|
||||
printSchemaFilenames( schema );
|
||||
}
|
||||
|
||||
EXPRESSdestroy( model );
|
||||
exit( EXIT_SUCCESS );
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
# this file should be included from data/CMakeLists.txt
|
||||
#
|
||||
# at configure time, this builds a small program
|
||||
# which will parse express schemas to determine
|
||||
# what files exp2cxx will create for that schema.
|
||||
#
|
||||
# The SCHEMA_CMLIST macro is to be used to run this
|
||||
# program. It will set variables for schema name(s),
|
||||
# headers, and implementation files.
|
||||
|
||||
# in a unity build, many small .cc files are #included to create a few large translation units
|
||||
# this makes compilation faster, but sometimes runs into compiler limitations
|
||||
if(NOT DEFINED SC_UNITY_BUILD)
|
||||
if(BORLAND)
|
||||
message(".. Will not do unity build for this compiler.")
|
||||
set(SC_UNITY_BUILD FALSE)
|
||||
else()
|
||||
message(".. Assuming compiler is capable of unity build.")
|
||||
set(SC_UNITY_BUILD TRUE)
|
||||
endif(BORLAND)
|
||||
message(".. Override by setting SC_UNITY_BUILD; TRUE will result in *huge* translation units, higher memory use in compilation, and faster build times.")
|
||||
else(NOT DEFINED SC_UNITY_BUILD)
|
||||
message(".. Respecting user-defined SC_UNITY_BUILD value of ${SC_UNITY_BUILD}.")
|
||||
endif(NOT DEFINED SC_UNITY_BUILD)
|
||||
|
||||
|
||||
# --- variables ---
|
||||
# SC_ROOT: SC root dir
|
||||
# SC_BUILDDIR: SC build dir, so generated headers can be found
|
||||
# SCANNER_SRC_DIR: dir this file is in
|
||||
# SCANNER_OUT_DIR: location of binary, same dir as SC uses
|
||||
# SCANNER_BUILD_DIR: location scanner is built
|
||||
|
||||
set(SCANNER_SRC_DIR ${SC_CMAKE_DIR}/schema_scanner)
|
||||
set(SCANNER_BUILD_DIR ${SC_BINARY_DIR}/schema_scanner CACHE INTERNAL "location for scanner build, config files (copied schemas)")
|
||||
set(SCANNER_OUT_DIR ${SC_BINARY_DIR}/bin CACHE INTERNAL "location for schema_scanner executable")
|
||||
|
||||
#write a cmake file for the cache. the alternative is a very long
|
||||
# command line - and the command line can't have newlines in it
|
||||
set(initial_scanner_cache ${SCANNER_BUILD_DIR}/initial_scanner_cache.cmake)
|
||||
file(WRITE ${initial_scanner_cache} "
|
||||
set(SC_ROOT \"${SC_SOURCE_DIR}\" CACHE STRING \"root dir\")
|
||||
set(SC_BUILDDIR \"${SC_BINARY_DIR}\" CACHE PATH \"build dir\")
|
||||
set(CALLED_FROM \"STEPCODE_CMAKELISTS\" CACHE STRING \"verification\")
|
||||
set(CMAKE_BUILD_TYPE \"Debug\" CACHE STRING \"build type\")
|
||||
set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\" CACHE STRING \"compiler\")
|
||||
set(CMAKE_CXX_COMPILER \"${CMAKE_CXX_COMPILER}\" CACHE STRING \"compiler\")
|
||||
")
|
||||
|
||||
message("-- Compiling schema scanner...")
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${SC_BINARY_DIR}/schemas)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${SCANNER_BUILD_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -C ${initial_scanner_cache} ${SCANNER_SRC_DIR} -G ${CMAKE_GENERATOR}
|
||||
WORKING_DIRECTORY ${SCANNER_BUILD_DIR}
|
||||
TIMEOUT 60
|
||||
OUTPUT_VARIABLE _ss_config_out
|
||||
RESULT_VARIABLE _ss_config_stat
|
||||
ERROR_VARIABLE _ss_config_err
|
||||
)
|
||||
if(NOT ${_ss_config_stat} STREQUAL "0")
|
||||
message(FATAL_ERROR "Scanner config status: ${_ss_config_stat}. stdout:\n${_ss_config_out}\nstderr:\n${_ss_config_err}")
|
||||
endif(NOT ${_ss_config_stat} STREQUAL "0")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build ${SCANNER_BUILD_DIR} --config Debug --clean-first
|
||||
WORKING_DIRECTORY ${SCANNER_BUILD_DIR}
|
||||
TIMEOUT 120 # should take far less than 2m
|
||||
OUTPUT_VARIABLE _ss_build_out
|
||||
RESULT_VARIABLE _ss_build_stat
|
||||
ERROR_VARIABLE _ss_build_err
|
||||
)
|
||||
if(NOT ${_ss_build_stat} STREQUAL "0")
|
||||
message(FATAL_ERROR "Scanner build status: ${_ss_build_stat}. stdout:\n${_ss_build_out}\nstderr:\n${_ss_build_err}")
|
||||
endif(NOT ${_ss_build_stat} STREQUAL "0")
|
||||
|
||||
message("-- Schema scanner built. Running it...")
|
||||
|
||||
# not sure if it makes sense to install this or not...
|
||||
if(WIN32)
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner.exe DESTINATION ${BIN_INSTALL_DIR})
|
||||
else(WIN32)
|
||||
install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR})
|
||||
endif(WIN32)
|
||||
|
||||
# macro SCHEMA_CMLIST
|
||||
# runs the schema scanner on one express file, creating a CMakeLists.txt file for each schema found. Those files are added via add_subdirectory().
|
||||
#
|
||||
# SCHEMA_FILE - path to the schema
|
||||
# TODO should we have a result variable to return schema name(s) found?
|
||||
macro(SCHEMA_CMLIST SCHEMA_FILE)
|
||||
execute_process(COMMAND ${SCANNER_OUT_DIR}/schema_scanner ${SCHEMA_FILE}
|
||||
WORKING_DIRECTORY ${SC_BINARY_DIR}/schemas
|
||||
RESULT_VARIABLE _ss_stat
|
||||
OUTPUT_VARIABLE _ss_out
|
||||
ERROR_VARIABLE _ss_err
|
||||
)
|
||||
if(NOT "${_ss_stat}" STREQUAL "0")
|
||||
#check size of output, put in file if large?
|
||||
message(FATAL_ERROR "Schema scan for '${SCHEMA_FILE}'\nexited with error code '${_ss_stat}'\nstdout:\n${_ss_out}\nstderr:\n${_ss_err}\n")
|
||||
endif(NOT "${_ss_stat}" STREQUAL "0")
|
||||
# scanner output format: each line contains an absolute path. each path is a dir containing a CMakeLists for one schema
|
||||
# there will usually be a single line of output, but it is not illegal for multiple schemas to exist in one .exp file
|
||||
string(STRIP "${_ss_out}" _ss_stripped)
|
||||
string(REGEX REPLACE "\\\n" ";" _list ${_ss_stripped})
|
||||
foreach(_dir ${_list})
|
||||
add_subdirectory(${_dir} ${_dir}) #specify source and binary dirs as the same
|
||||
endforeach(_dir ${_ss_out})
|
||||
# configure_file forces cmake to run again if the schema has been modified
|
||||
#if multiple schemas in one file, _schema is the last one printed.
|
||||
configure_file(${SCHEMA_FILE} ${SCANNER_BUILD_DIR}/${_schema})
|
||||
endmacro(SCHEMA_CMLIST SCHEMA_FILE)
|
||||
@@ -69,8 +69,8 @@ if(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
endforeach(outf ${output_files})
|
||||
endif(NOT LOCKED_SOURCE_DIR)
|
||||
|
||||
else (NOT DEBUGGING_GENERATED_SOURCES)
|
||||
|
||||
else(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
|
||||
message("\nNote: DEBUGGING_GENERATED_SOURCES is enabled - generated outputs will contain configuration-specific debugging information, so syncing cached output files is not possible. To restore normal behavior, disable DEBUGGING_GENERATED_SOURCES.\n")
|
||||
|
||||
endif(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Inherit the parent CMake setting
|
||||
set(DEBUGGING_GENERATED_SOURCES @DEBUGGING_GENERATED_SOURCES@)
|
||||
set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@)
|
||||
set(CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
|
||||
|
||||
# Include the file the provides the baseline against which
|
||||
# current files will be compared
|
||||
if(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
|
||||
include(@BASELINE_INFORMATION_FILE@)
|
||||
include("@BASELINE_INFORMATION_FILE@")
|
||||
|
||||
# Define a variety of convenience routines
|
||||
include(@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake)
|
||||
include("@PROJECT_CMAKE_DIR@/Generated_Source_Utils.cmake")
|
||||
|
||||
# Individually verify all of the files in question.
|
||||
set(filelist "@CACHED_FILELIST@")
|
||||
@@ -20,7 +20,7 @@ if(NOT DEBUGGING_GENERATED_SOURCES)
|
||||
message(FATAL_ERROR "Generated sources have been modified. These files should never be modified directly except when debugging faulty output from the generators - changes to lexer and parser logic should be made to the generator input files. If this is a debugging situation, set the variable DEBUGGING_GENERATED_SOURCES to ON during the CMake configure.")
|
||||
endif(srcs_pass)
|
||||
|
||||
# If we got by that test, see if it looks like these
|
||||
# If we got by that test, see if it looks like these
|
||||
# sources came from the current input files. It's not
|
||||
# a failure condition if they didn't, but warn about it.
|
||||
set(filelist "@INPUT_FILELIST@")
|
||||
|
||||
+18
-10
@@ -1,11 +1,11 @@
|
||||
# run_ctest.cmake
|
||||
# `ctest -S run_ctest.cmake`
|
||||
|
||||
set( CTEST_SOURCE_DIRECTORY . )
|
||||
set( CTEST_BINARY_DIRECTORY build_matrix )
|
||||
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
|
||||
set( CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind )
|
||||
set( CTEST_INITIAL_CACHE "
|
||||
set(CTEST_SOURCE_DIRECTORY .)
|
||||
set(CTEST_BINARY_DIRECTORY build_matrix)
|
||||
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
|
||||
set(CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind)
|
||||
set(CTEST_INITIAL_CACHE "
|
||||
SITE:STRING=${CTEST_SITE}
|
||||
BUILDNAME:STRING=${CTEST_BUILD_NAME}
|
||||
SC_ENABLE_TESTING:BOOL=ON
|
||||
@@ -15,11 +15,19 @@ SC_BUILD_TYPE:STRING=Debug
|
||||
|
||||
ctest_start(matrix)
|
||||
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
|
||||
ctest_configure( BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS -DSC_ENABLE_TESTING=ON )
|
||||
ctest_build( BUILD "${CTEST_BINARY_DIRECTORY}" )
|
||||
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS -DSC_ENABLE_TESTING=ON)
|
||||
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}")
|
||||
message("running tests")
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" INCLUDE_LABEL "cpp_schema_....*" )
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" INCLUDE_LABEL "cpp_schema_....*")
|
||||
|
||||
message("running python script")
|
||||
execute_process( COMMAND python ../misc/wiki-scripts/update-matrix.py
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} )
|
||||
execute_process(COMMAND python ../misc/wiki-scripts/update-matrix.py
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY})
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
+30
-175
@@ -1,181 +1,36 @@
|
||||
# To build one or more schemas, configure with
|
||||
# 'cmake -DSC_BUILD_SCHEMAS="path/to/schema.exp;path/to/schema2.exp"
|
||||
# you can specify a schema in 3 ways:
|
||||
# * path relative to build dir
|
||||
# * path relative to sc/data (this dir)
|
||||
# * absolute path
|
||||
#
|
||||
# cmake goes through the above options in order until it finds one
|
||||
# that exists. if ${path} is a dir, cmake expects to find a single
|
||||
# .exp file inside, which it uses. otherwise, ${path} is assumed to
|
||||
# be an express file.
|
||||
|
||||
MACRO(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path)
|
||||
string(REPLACE "${SC_SOURCE_DIR}" "" subpath "${current_dir}")
|
||||
string(REGEX REPLACE "^/" "" subpath "${subpath}")
|
||||
string(LENGTH "${subpath}" PATH_LENGTH)
|
||||
if(PATH_LENGTH GREATER 0)
|
||||
set(${rel_path} "..")
|
||||
get_filename_component(subpath "${subpath}" PATH)
|
||||
string(LENGTH "${subpath}" PATH_LENGTH)
|
||||
while(PATH_LENGTH GREATER 0)
|
||||
set(${rel_path} "${${rel_path}}/..")
|
||||
get_filename_component(subpath "${subpath}" PATH)
|
||||
string(LENGTH "${subpath}" PATH_LENGTH)
|
||||
endwhile(PATH_LENGTH GREATER 0)
|
||||
endif(PATH_LENGTH GREATER 0)
|
||||
ENDMACRO(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path)
|
||||
if(NOT "${SC_BUILD_SCHEMAS}" STREQUAL "")
|
||||
include(${SC_CMAKE_DIR}/schema_scanner/schemaScanner.cmake)
|
||||
foreach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
get_filename_component(name ${src} NAME_WE)
|
||||
message(STATUS "Additional SDAI executable: ${name}")
|
||||
endforeach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS})
|
||||
|
||||
# This function runs fedex on one express file. The generated source goes in a dir
|
||||
# in the build dir, and it is compiled into a library. A p21read executable is
|
||||
# compiled and linked to the lib. p21read is used to test the lib.
|
||||
FUNCTION(BUILD_A_SCHEMA SCHEMA_FILE)
|
||||
if( EXISTS "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}" ) #is it a path relative to build dir?
|
||||
set( SCHEMA_FILE "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}" )
|
||||
elseif( EXISTS "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}" ) # path relative to STEPcode/data?
|
||||
set( SCHEMA_FILE "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}" )
|
||||
elseif( NOT EXISTS ${SCHEMA_FILE} ) # absolute path
|
||||
message( FATAL_ERROR "Cannot find ${CMAKE_BINARY_DIR}/${SCHEMA_FILE} or ${SC_SOURCE_DIR}/data/${SCHEMA_FILE} or ${SCHEMA_FILE}" )
|
||||
endif()
|
||||
if(SC_BUILD_SCHEMAS STREQUAL "ALL")
|
||||
file(GLOB_RECURSE SC_BUILD_SCHEMAS ${SC_SOURCE_DIR}/data/*.exp)
|
||||
endif()
|
||||
foreach(FILE ${SC_BUILD_SCHEMAS})
|
||||
# figure out an absolute path to the file
|
||||
LOCATE_SCHEMA(${FILE} abspath)
|
||||
SCHEMA_CMLIST(${abspath})
|
||||
endforeach()
|
||||
endif(NOT "${SC_BUILD_SCHEMAS}" STREQUAL "")
|
||||
|
||||
if( IS_DIRECTORY ${SCHEMA_FILE} ) #if it is a dir, look for one .exp file inside
|
||||
file(GLOB SCHEMA_FILE ${SCHEMA_FILE}/*.exp )
|
||||
endif()
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
if( NOT EXISTS ${SCHEMA_FILE} )
|
||||
message(FATAL_ERROR "Expected one express file. Found '${SCHEMA_FILE}' instead.")
|
||||
endif()
|
||||
|
||||
# read the schema name from a line like 'SCHEMA AUTOMOTIVE_DESIGN;'
|
||||
file(STRINGS ${SCHEMA_FILE} SCHEMA_STATEMENT LIMIT_COUNT 1 REGEX "^SCHEMA .*")
|
||||
string(REGEX REPLACE "^SCHEMA \(.*\)\;$" "\\1" SCHEMA_N ${SCHEMA_STATEMENT} )
|
||||
string(TOUPPER ${SCHEMA_N} SCHEMA_LONG_NAME) #exp2cxx always uses upper case for file names
|
||||
get_filename_component( SCHEMA_SN ${SCHEMA_FILE} NAME )
|
||||
string( REGEX REPLACE "\(.*\).[Ee][Xx][Pp]" "\\1" SCHEMA_SHORT_NAME ${SCHEMA_SN} )
|
||||
|
||||
project( sdai_${SCHEMA_SHORT_NAME} )
|
||||
message( STATUS "Generating code for ${SCHEMA_SHORT_NAME}.")
|
||||
set( SCHEMA_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_SHORT_NAME} )
|
||||
|
||||
#the names of the files that will be generated
|
||||
set( FEDEX_HEADERS ${SCHEMA_OUTPUT_DIR}/Sdaiclasses.h ${SCHEMA_OUTPUT_DIR}/schema.h
|
||||
${SCHEMA_OUTPUT_DIR}/Sdai${SCHEMA_LONG_NAME}.h )
|
||||
set( FEDEX_OUT ${SCHEMA_OUTPUT_DIR}/compstructs.cc ${SCHEMA_OUTPUT_DIR}/schema.cc
|
||||
${SCHEMA_OUTPUT_DIR}/Sdai${SCHEMA_LONG_NAME}.cc ${SCHEMA_OUTPUT_DIR}/SdaiAll.cc
|
||||
${SCHEMA_OUTPUT_DIR}/Sdai${SCHEMA_LONG_NAME}.init.cc ${FEDEX_HEADERS} )
|
||||
|
||||
install( FILES ${FEDEX_HEADERS} DESTINATION include/${SCHEMA_SHORT_NAME} )
|
||||
|
||||
# *cannot* use include_directories() because the includes keep piling up - if building
|
||||
# multiple schemas, each one will use the include dirs from all previous schemas. Since
|
||||
# one header (schema.h) is always named the same, this will not work. only workaround
|
||||
# seems to be set_target_properties( <target> PROPERTIES COMPILE_FLAGS <flags> )
|
||||
set( ${PROJECT_NAME}_COMPILE_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR} -I${SC_SOURCE_DIR}/src/cldai -I${SC_SOURCE_DIR}/src/cleditor -I${SC_SOURCE_DIR}/src/clutils -I${SCHEMA_OUTPUT_DIR} -I${SC_SOURCE_DIR}/src/clstepcore -I${SC_SOURCE_DIR}/src/base" )
|
||||
|
||||
add_custom_command( OUTPUT ${SCHEMA_OUTPUT_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${SCHEMA_OUTPUT_DIR}
|
||||
COMMENT "Creating ${SCHEMA_OUTPUT_DIR} for schema ${SCHEMA_SHORT_NAME}")
|
||||
add_custom_command( OUTPUT ${FEDEX_OUT}
|
||||
COMMAND exp2cxx ARGS ${SCHEMA_FILE}
|
||||
DEPENDS ${SCHEMA_FILE} ${SCHEMA_OUTPUT_DIR}
|
||||
WORKING_DIRECTORY ${SCHEMA_OUTPUT_DIR}
|
||||
COMMENT "Running exp2cxx for ${SCHEMA_SHORT_NAME}..."
|
||||
VERBATIM )
|
||||
add_custom_target( generate_cpp_${SCHEMA_SHORT_NAME} DEPENDS ${FEDEX_OUT} SOURCES ${FEDEX_OUT} )
|
||||
|
||||
if( SC_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
|
||||
# Coverage will always be sparse on schema libs. Compiling the libs with the -fprofile-arcs and
|
||||
# -ftest-coverage is extremely slow. We can avoid that by temporarily changing build type to release.
|
||||
set( PREV_BUILD_TYPE ${CMAKE_BUILD_TYPE} )
|
||||
set( CMAKE_BUILD_TYPE "Release" )
|
||||
endif( SC_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
|
||||
|
||||
# if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
|
||||
SC_ADDLIB( ${PROJECT_NAME} "${FEDEX_OUT}" "stepdai;stepcore;stepeditor;steputils;base" "TESTABLE" )
|
||||
add_dependencies( ${PROJECT_NAME} generate_cpp_${SCHEMA_SHORT_NAME} )
|
||||
set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
|
||||
${${PROJECT_NAME}_COMPILE_FLAGS} )
|
||||
if( TARGET ${PROJECT_NAME}-static )
|
||||
set_target_properties( ${PROJECT_NAME}-static PROPERTIES COMPILE_FLAGS
|
||||
${${PROJECT_NAME}_COMPILE_FLAGS} )
|
||||
endif( TARGET ${PROJECT_NAME}-static )
|
||||
|
||||
if( SC_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
|
||||
set( CMAKE_BUILD_TYPE ${PREV_BUILD_TYPE} )
|
||||
endif( SC_ENABLE_COVERAGE AND NOT SC_COVER_SCHEMAS )
|
||||
|
||||
add_test( NAME generate_cpp_${SCHEMA_SHORT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target generate_cpp_${SCHEMA_SHORT_NAME}
|
||||
--config $<CONFIGURATION> )
|
||||
add_test( NAME build_cpp_${PROJECT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target p21read_${PROJECT_NAME}
|
||||
--config $<CONFIGURATION> )
|
||||
if(NOT WIN32)
|
||||
add_test( NAME build_lazy_cpp_${PROJECT_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target lazy_${PROJECT_NAME}
|
||||
--config $<CONFIGURATION> )
|
||||
endif(NOT WIN32)
|
||||
|
||||
# label the tests and set dependencies
|
||||
set_tests_properties( generate_cpp_${SCHEMA_SHORT_NAME} PROPERTIES LABELS cpp_schema_gen )
|
||||
if(NOT WIN32)
|
||||
set_tests_properties( build_lazy_cpp_${PROJECT_NAME} build_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${SCHEMA_SHORT_NAME} LABELS cpp_schema_build )
|
||||
endif(NOT WIN32)
|
||||
|
||||
RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT)
|
||||
SC_ADDEXEC( p21read_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" "${PROJECT_NAME};base" "TESTABLE" )
|
||||
if(NOT WIN32)
|
||||
SC_ADDEXEC( lazy_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" "${PROJECT_NAME};steplazyfile;stepeditor" "TESTABLE" )
|
||||
endif(NOT WIN32)
|
||||
add_dependencies( p21read_${PROJECT_NAME} version_string )
|
||||
if(NOT WIN32)
|
||||
add_dependencies( lazy_${PROJECT_NAME} version_string )
|
||||
endif(NOT WIN32)
|
||||
set_target_properties( p21read_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
|
||||
${${PROJECT_NAME}_COMPILE_FLAGS} )
|
||||
if(NOT WIN32)
|
||||
set_target_properties( lazy_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${SC_SOURCE_DIR}/src/base/judy/src" )
|
||||
endif(NOT WIN32)
|
||||
|
||||
|
||||
#add user-defined executables
|
||||
foreach( src ${SC_SDAI_ADDITIONAL_EXES_SRCS} )
|
||||
get_filename_component( name ${src} NAME_WE )
|
||||
get_filename_component( path ${src} ABSOLUTE )
|
||||
SC_ADDEXEC( ${name}_${PROJECT_NAME} "${src}" "${PROJECT_NAME};base" "TESTABLE" )
|
||||
add_dependencies( ${name}_${PROJECT_NAME} version_string )
|
||||
set_target_properties( ${name}_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
|
||||
"${${PROJECT_NAME}_COMPILE_FLAGS} -I${path}" )
|
||||
endforeach( src ${SC_SDAI_ADDITIONAL_EXES_SRCS} )
|
||||
|
||||
#find all part 21 files in schema dir, add a test for each one
|
||||
get_filename_component( SCHEMA_DIR ${SCHEMA_FILE} PATH )
|
||||
file( GLOB_RECURSE P21_FILES ${SCHEMA_DIR}/*.stp ${SCHEMA_DIR}/*.step ${SCHEMA_DIR}/*.p21 ${SCHEMA_DIR}/*.ifc )
|
||||
foreach( TEST_FILE ${P21_FILES} )
|
||||
get_filename_component( FNAME ${TEST_FILE} NAME_WE )
|
||||
add_test( NAME read_write_cpp_${SCHEMA_SHORT_NAME}_${FNAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND p21read_${PROJECT_NAME} ${TEST_FILE} )
|
||||
set_tests_properties( read_write_cpp_${SCHEMA_SHORT_NAME}_${FNAME} PROPERTIES DEPENDS build_cpp_${PROJECT_NAME} LABELS cpp_schema_rw )
|
||||
if(NOT WIN32)
|
||||
add_test( NAME read_lazy_cpp_${SCHEMA_SHORT_NAME}_${FNAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND lazy_${PROJECT_NAME} ${TEST_FILE} )
|
||||
set_tests_properties( read_lazy_cpp_${SCHEMA_SHORT_NAME}_${FNAME} PROPERTIES DEPENDS build_lazy_cpp_${PROJECT_NAME} LABELS cpp_schema_rw )
|
||||
endif(NOT WIN32)
|
||||
endforeach()
|
||||
|
||||
ENDFUNCTION(BUILD_A_SCHEMA)
|
||||
|
||||
#----------------------------------------------------------------------------------------------------
|
||||
|
||||
if( DEFINED SC_BUILD_SCHEMAS )
|
||||
foreach( src ${SC_SDAI_ADDITIONAL_EXES_SRCS} )
|
||||
get_filename_component( name ${src} NAME_WE )
|
||||
message( STATUS "Additional SDAI executable: ${name}" )
|
||||
endforeach( src ${SC_SDAI_ADDITIONAL_EXES_SRCS} )
|
||||
|
||||
if( SC_BUILD_SCHEMAS STREQUAL "ALL" )
|
||||
file( GLOB_RECURSE SC_BUILD_SCHEMAS ${SC_SOURCE_DIR}/data/*.exp )
|
||||
endif()
|
||||
foreach( ap ${SC_BUILD_SCHEMAS} )
|
||||
BUILD_A_SCHEMA( ${ap} )
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(* This is a MODIFIED version of AP203 Amd. 1.
|
||||
The change was to remove a useless IF...ELSE...ENDIF statement that always evaluated
|
||||
the same way. Statements in the branch that was never executed caused problems with
|
||||
the same way. Statements in the branch that were never executed caused problems with
|
||||
libexpress, and it was easier to modify the schema than to come up with a generic
|
||||
fix for libexpress. This change does *not* affect the behavior of the schema.
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
SCHEMA config_control_design;
|
||||
|
||||
CONSTANT
|
||||
(* FIXME: gcc error on next statement with c99/POSIX:
|
||||
Syntax error: "(" unexpected
|
||||
*)
|
||||
dummy_gri : geometric_representation_item := representation_item('') ||
|
||||
geometric_representation_item();
|
||||
dummy_tri : topological_representation_item := representation_item('')
|
||||
|
||||
+33007
-38333
File diff suppressed because it is too large
Load Diff
+15
-7
@@ -1,12 +1,20 @@
|
||||
SET(sc_MANS
|
||||
man/man1/fedex.1
|
||||
man/man1/exp2cxx.1
|
||||
)
|
||||
set(sc_MANS
|
||||
man/man1/fedex.1
|
||||
man/man1/exp2cxx.1
|
||||
)
|
||||
|
||||
if(NOT DEFINED MAN_DIR)
|
||||
set(MAN_DIR share/man)
|
||||
endif(NOT DEFINED MAN_DIR)
|
||||
|
||||
IF(NOT WIN32)
|
||||
INSTALL(FILES ${sc_MANS} DESTINATION ${MAN_DIR}/man1)
|
||||
ENDIF(NOT WIN32)
|
||||
if(NOT WIN32)
|
||||
install(FILES ${sc_MANS} DESTINATION ${MAN_DIR}/man1)
|
||||
endif(NOT WIN32)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -5,87 +5,91 @@
|
||||
# freely copied in part or in full for any purpose. No acknowledgment is required
|
||||
# for the use of this file.
|
||||
#
|
||||
PROJECT( AP203Minimum )
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
project(AP203Minimum)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Set STEPCODE_ROOT_DIR to point to the root of the STEPcode source tree.
|
||||
if( NOT DEFINED STEPCODE_ROOT_DIR )
|
||||
message( FATAL_ERROR "STEPCODE_ROOT_DIR is not defined! Set via cmake-gui or on command line:\n cmake .. -DSTEPCODE_ROOT_DIR=/path/to/sc" )
|
||||
endif( NOT DEFINED STEPCODE_ROOT_DIR )
|
||||
if(NOT DEFINED STEPCODE_ROOT_DIR)
|
||||
message(FATAL_ERROR "STEPCODE_ROOT_DIR is not defined! Set via cmake-gui or on command line:\n cmake .. -DSTEPCODE_ROOT_DIR=/path/to/sc")
|
||||
endif(NOT DEFINED STEPCODE_ROOT_DIR)
|
||||
|
||||
# STEPCODE_ROOT_DIR is relative or absolute path?
|
||||
if( EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/SC_VERSION.txt" )
|
||||
set( STEPCODE_ROOT_DIR "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}" )
|
||||
message( "** STEPCODE_ROOT_DIR is a relative path; converted to absolute path: ${STEPCODE_ROOT_DIR}." )
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
set(STEPCODE_ROOT_DIR "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}")
|
||||
message("** STEPCODE_ROOT_DIR is a relative path; converted to absolute path: ${STEPCODE_ROOT_DIR}.")
|
||||
else()
|
||||
if( NOT EXISTS "${STEPCODE_ROOT_DIR}/SC_VERSION.txt" )
|
||||
message( FATAL_ERROR "**** Cannot locate STEPCODE_ROOT_DIR - try an absolute path." )
|
||||
endif( NOT EXISTS "${STEPCODE_ROOT_DIR}/SC_VERSION.txt" )
|
||||
endif( EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/SC_VERSION.txt" )
|
||||
if(NOT EXISTS "${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
message(FATAL_ERROR "**** Cannot locate STEPCODE_ROOT_DIR - try an absolute path.")
|
||||
endif(NOT EXISTS "${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
endif(EXISTS "${CMAKE_BINARY_DIR}/${STEPCODE_ROOT_DIR}/SC_VERSION.txt")
|
||||
|
||||
|
||||
# Use STEPcode as library, but build from this build process.
|
||||
set( SC_IS_SUBBUILD TRUE )
|
||||
set(SC_IS_SUBBUILD TRUE)
|
||||
|
||||
# Build type, DEBUG or RELEASE
|
||||
if( NOT DEFINED CMAKE_BUILD_TYPE )
|
||||
set( CMAKE_BUILD_TYPE Debug )
|
||||
endif( NOT DEFINED CMAKE_BUILD_TYPE )
|
||||
set( SC_BUILD_TYPE ${CMAKE_BUILD_TYPE} )
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
set(SC_BUILD_TYPE ${CMAKE_BUILD_TYPE})
|
||||
|
||||
# Path to STEPcode
|
||||
set( STEPCODE_BUILD_DIR ${CMAKE_BINARY_DIR}/sc CACHE PATH "STEPcode build subdir" )
|
||||
set(STEPCODE_BUILD_DIR ${CMAKE_BINARY_DIR}/sc CACHE PATH "STEPcode build subdir")
|
||||
|
||||
# STEP schema to build and link against.
|
||||
set( SCHEMA ap203 )
|
||||
set( SC_BUILD_SCHEMAS ${SCHEMA} CACHE INTERNAL "Schema, internal, immutable" FORCE )
|
||||
set(SCHEMA ap203)
|
||||
set(SC_BUILD_SCHEMAS ${SCHEMA} CACHE INTERNAL "Schema, internal, immutable" FORCE)
|
||||
|
||||
# Parse out schema name and library.
|
||||
set( SCHEMA_PATH "${STEPCODE_ROOT_DIR}/data/${SCHEMA}/*.exp" )
|
||||
file( GLOB SCHEMA_FILE "${SCHEMA_PATH}" )
|
||||
set(SCHEMA_PATH "${STEPCODE_ROOT_DIR}/data/${SCHEMA}/*.exp")
|
||||
file(GLOB SCHEMA_FILE "${SCHEMA_PATH}")
|
||||
|
||||
if( NOT EXISTS ${SCHEMA_FILE} )
|
||||
message( FATAL_ERROR "Cannot find the schema; cannot continue. Looked for ${SCHEMA_PATH} from ${CMAKE_CURRENT_LIST_DIR}" )
|
||||
endif( NOT EXISTS ${SCHEMA_FILE} )
|
||||
if(NOT EXISTS ${SCHEMA_FILE})
|
||||
message(FATAL_ERROR "Cannot find the schema; cannot continue. Looked for ${SCHEMA_PATH} from ${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif(NOT EXISTS ${SCHEMA_FILE})
|
||||
|
||||
|
||||
get_filename_component( SCHEMA_SN ${SCHEMA_FILE} NAME )
|
||||
string( REGEX REPLACE "\(.*\).[Ee][Xx][Pp]" "\\1" SCHEMA_LINK_NAME ${SCHEMA_SN} )
|
||||
set( STEPCODE_LIBRARIES base stepcore stepeditor stepdai steputils sdai_${SCHEMA_LINK_NAME} )
|
||||
get_filename_component(SCHEMA_SN ${SCHEMA_FILE} NAME)
|
||||
string(REGEX REPLACE "\(.*\).[Ee][Xx][Pp]" "sdai_\\1" SCHEMA_LINK_NAME ${SCHEMA_SN})
|
||||
set(STEPCODE_LIBRARIES base stepcore stepeditor stepdai steputils ${SCHEMA_LINK_NAME})
|
||||
|
||||
# Add STEPCode project to CMake build.
|
||||
add_subdirectory( ${STEPCODE_ROOT_DIR} "${CMAKE_CURRENT_BINARY_DIR}/sc" EXCLUDE_FROM_ALL )
|
||||
add_subdirectory(${STEPCODE_ROOT_DIR} "${CMAKE_CURRENT_BINARY_DIR}/sc" EXCLUDE_FROM_ALL)
|
||||
|
||||
# Set up STEPcode include directories.
|
||||
set( STEPCODE_INCLUDE_DIR
|
||||
${STEPCODE_ROOT_DIR}/src/base
|
||||
${STEPCODE_ROOT_DIR}/src/clstepcore
|
||||
${STEPCODE_ROOT_DIR}/src/cldai
|
||||
${STEPCODE_ROOT_DIR}/src/clutils
|
||||
${STEPCODE_ROOT_DIR}/src/cleditor
|
||||
${STEPCODE_BUILD_DIR}/include
|
||||
${STEPCODE_ROOT_DIR}/include
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
set(STEPCODE_INCLUDE_DIR
|
||||
${STEPCODE_ROOT_DIR}/src/base
|
||||
${STEPCODE_ROOT_DIR}/src/clstepcore
|
||||
${STEPCODE_ROOT_DIR}/src/cldai
|
||||
${STEPCODE_ROOT_DIR}/src/clutils
|
||||
${STEPCODE_ROOT_DIR}/src/cleditor
|
||||
${STEPCODE_BUILD_DIR}/include
|
||||
${STEPCODE_ROOT_DIR}/include
|
||||
${CMAKE_BINARY_DIR}
|
||||
${STEPCODE_BUILD_DIR}/schemas/${SCHEMA_LINK_NAME}
|
||||
)
|
||||
|
||||
# Reset sane values for build destination. Otherwise, everything ends up in ${CMAKE_BINARY_DIR}/sc
|
||||
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
||||
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
include_directories(
|
||||
${STEPCODE_INCLUDE_DIR}
|
||||
)
|
||||
${STEPCODE_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Application sources and headers
|
||||
set( SRCS
|
||||
ap203min.cpp
|
||||
)
|
||||
set(SRCS ap203min.cpp)
|
||||
|
||||
set( HDRS
|
||||
)
|
||||
set(HDRS )
|
||||
|
||||
add_executable( ${PROJECT_NAME} ${SRCS} ${HDRS} )
|
||||
add_executable(${PROJECT_NAME} ${SRCS} ${HDRS})
|
||||
|
||||
target_link_libraries( ${PROJECT_NAME} ${STEPCODE_LIBRARIES} )
|
||||
target_link_libraries(${PROJECT_NAME} ${STEPCODE_LIBRARIES})
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
set_target_properties( ${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-I${STEPCODE_BUILD_DIR}/data/${SCHEMA_LINK_NAME}" )
|
||||
|
||||
@@ -49,10 +49,6 @@
|
||||
// $./AP203Minimum
|
||||
// AP203Minimum outfile.stp
|
||||
|
||||
|
||||
extern void
|
||||
SchemaInit( class Registry & );
|
||||
|
||||
#include <STEPfile.h>
|
||||
#include <sdai.h>
|
||||
#include <STEPattribute.h>
|
||||
|
||||
+19
-11
@@ -1,4 +1,4 @@
|
||||
SET(express_HDRS
|
||||
set(express_HDRS
|
||||
express/alg.h
|
||||
express/basic.h
|
||||
express/caseitem.h
|
||||
@@ -20,21 +20,29 @@ SET(express_HDRS
|
||||
express/symbol.h
|
||||
express/type.h
|
||||
express/variable.h
|
||||
)
|
||||
)
|
||||
install(FILES ${express_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/express)
|
||||
|
||||
SET(exppp_HDRS
|
||||
set(exppp_HDRS
|
||||
exppp/exppp.h
|
||||
)
|
||||
)
|
||||
install(FILES ${exppp_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/exppp)
|
||||
|
||||
install(FILES ordered_attrs.h
|
||||
sc_export.h
|
||||
sc_stdbool.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode)
|
||||
sc_export.h
|
||||
sc_stdbool.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode)
|
||||
|
||||
install(FILES ${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_cf.h
|
||||
${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode)
|
||||
${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_version_string.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ struct tag {
|
||||
|
||||
/** location of fulltext of algorithm in source file */
|
||||
struct FullText {
|
||||
char * filename;
|
||||
const char * filename;
|
||||
unsigned int start, end;
|
||||
};
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ typedef struct Error_Warning_ {
|
||||
/********************/
|
||||
|
||||
extern SC_EXPRESS_EXPORT bool __ERROR_buffer_errors;
|
||||
extern SC_EXPRESS_EXPORT char * current_filename;
|
||||
extern SC_EXPRESS_EXPORT const char * current_filename;
|
||||
|
||||
/* flag to remember whether non-warning errors have occurred */
|
||||
extern SC_EXPRESS_EXPORT bool ERRORoccurred;
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
#ifndef EXP_KW_H
|
||||
#define EXP_KW_H
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
extern SC_EXPRESS_EXPORT char * KW_ABS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ABSTRACT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ACOS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_AGGREGATE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ALIAS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_AND;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ANDOR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ARRAY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_AS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ASIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ATAN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BAG;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BEGIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BINARY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BLENGTH;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BOOLEAN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CASE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CONST_E;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CONSTANT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CONTEXT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_COS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_DERIVE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_DIV;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ELSE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_ALIAS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_CASE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_CONSTANT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_CONTEXT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_ENTITY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_FUNCTION;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_IF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_LOCAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_MODEL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_PROCEDURE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_REPEAT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_RULE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_SCHEMA;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_TYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ENTITY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ENUMERATION;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ESCAPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_EXISTS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_EXP;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FALSE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FIXED;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FOR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FORMAT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FROM;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FUNCTION;
|
||||
extern SC_EXPRESS_EXPORT char * KW_GENERIC;
|
||||
extern SC_EXPRESS_EXPORT char * KW_HIBOUND;
|
||||
extern SC_EXPRESS_EXPORT char * KW_HIINDEX;
|
||||
extern SC_EXPRESS_EXPORT char * KW_IF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_IN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INCLUDE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INSERT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INTEGER;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INVERSE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LENGTH;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LIKE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LIST;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOBOUND;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOCAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOG;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOG10;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOG2;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOGICAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOINDEX;
|
||||
extern SC_EXPRESS_EXPORT char * KW_MOD;
|
||||
extern SC_EXPRESS_EXPORT char * KW_MODEL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_NOT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_NUMBER;
|
||||
extern SC_EXPRESS_EXPORT char * KW_NVL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ODD;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ONEOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OPTIONAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OTHERWISE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_PI;
|
||||
extern SC_EXPRESS_EXPORT char * KW_PROCEDURE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_QUERY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REFERENCE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REMOVE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REPEAT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_RETURN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ROLESOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_RULE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SCHEMA;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SELECT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SELF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SET;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SIZEOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SKIP;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SQRT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_STRING;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SUBTYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SUPERTYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TAN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_THEN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TO;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TRUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TYPEOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_UNIQUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_UNKNOWN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_UNTIL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_USE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_USEDIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VALUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VALUE_IN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VALUE_UNIQUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VAR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_WHERE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_WHILE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_XOR;
|
||||
|
||||
#endif /* EXP_KW_H */
|
||||
+2
-125
@@ -115,127 +115,6 @@ extern SC_EXPRESS_EXPORT Error ERROR_warn_small_real;
|
||||
extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_NVL;
|
||||
extern SC_EXPRESS_EXPORT struct Scope_ * FUNC_USEDIN;
|
||||
|
||||
extern SC_EXPRESS_EXPORT char * KW_ABS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ABSTRACT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ACOS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_AGGREGATE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ALIAS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_AND;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ANDOR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ARRAY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_AS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ASIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ATAN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BAG;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BEGIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BINARY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BLENGTH;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BOOLEAN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_BY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CASE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CONST_E;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CONSTANT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_CONTEXT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_COS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_DERIVE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_DIV;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ELSE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_ALIAS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_CASE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_CONSTANT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_CONTEXT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_ENTITY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_FUNCTION;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_IF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_LOCAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_MODEL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_PROCEDURE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_REPEAT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_RULE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_SCHEMA;
|
||||
extern SC_EXPRESS_EXPORT char * KW_END_TYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ENTITY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ENUMERATION;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ESCAPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_EXISTS;
|
||||
extern SC_EXPRESS_EXPORT char * KW_EXP;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FALSE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FIXED;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FOR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FORMAT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FROM;
|
||||
extern SC_EXPRESS_EXPORT char * KW_FUNCTION;
|
||||
extern SC_EXPRESS_EXPORT char * KW_GENERIC;
|
||||
extern SC_EXPRESS_EXPORT char * KW_HIBOUND;
|
||||
extern SC_EXPRESS_EXPORT char * KW_HIINDEX;
|
||||
extern SC_EXPRESS_EXPORT char * KW_IF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_IN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INCLUDE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INSERT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INTEGER;
|
||||
extern SC_EXPRESS_EXPORT char * KW_INVERSE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LENGTH;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LIKE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LIST;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOBOUND;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOCAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOG;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOG10;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOG2;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOGICAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_LOINDEX;
|
||||
extern SC_EXPRESS_EXPORT char * KW_MOD;
|
||||
extern SC_EXPRESS_EXPORT char * KW_MODEL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_NOT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_NUMBER;
|
||||
extern SC_EXPRESS_EXPORT char * KW_NVL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ODD;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ONEOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OPTIONAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_OTHERWISE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_PI;
|
||||
extern SC_EXPRESS_EXPORT char * KW_PROCEDURE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_QUERY;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REAL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REFERENCE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REMOVE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_REPEAT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_RETURN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_ROLESOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_RULE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SCHEMA;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SELECT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SELF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SET;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SIZEOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SKIP;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SQRT;
|
||||
extern SC_EXPRESS_EXPORT char * KW_STRING;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SUBTYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_SUPERTYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TAN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_THEN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TO;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TRUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TYPE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_TYPEOF;
|
||||
extern SC_EXPRESS_EXPORT char * KW_UNIQUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_UNKNOWN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_UNTIL;
|
||||
extern SC_EXPRESS_EXPORT char * KW_USE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_USEDIN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VALUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VALUE_IN;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VALUE_UNIQUE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_VAR;
|
||||
extern SC_EXPRESS_EXPORT char * KW_WHERE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_WHILE;
|
||||
extern SC_EXPRESS_EXPORT char * KW_XOR;
|
||||
|
||||
/******************************/
|
||||
/* macro function definitions */
|
||||
/******************************/
|
||||
@@ -255,11 +134,9 @@ extern SC_EXPRESS_EXPORT void EXPRESSparse PROTO( ( Express, FILE *, ch
|
||||
extern SC_EXPRESS_EXPORT void EXPRESSinitialize PROTO( ( void ) );
|
||||
extern SC_EXPRESS_EXPORT void EXPRESScleanup PROTO( ( void ) );
|
||||
extern SC_EXPRESS_EXPORT void EXPRESSresolve PROTO( ( Express ) );
|
||||
extern SC_EXPRESS_EXPORT char * EXPRESSversion PROTO( ( void ) );
|
||||
extern SC_EXPRESS_EXPORT int EXPRESS_fail PROTO( ( Express ) );
|
||||
extern SC_EXPRESS_EXPORT int EXPRESS_succeed PROTO( ( Express ) );
|
||||
extern SC_EXPRESS_EXPORT int EXPRESS_fail( Express model );
|
||||
extern SC_EXPRESS_EXPORT int EXPRESS_succeed( Express model );
|
||||
extern void EXPRESSinit_init PROTO( ( void ) );
|
||||
extern SC_EXPRESS_EXPORT void EXPRESSusage( int _exit ); /**< exit unless _exit is non-zero */
|
||||
extern SC_EXPRESS_EXPORT void build_complex( Express );
|
||||
|
||||
#endif /*EXPRESS_H*/
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef INFO_H
|
||||
#define INFO_H
|
||||
|
||||
#include "sc_export.h"
|
||||
/** \file info.h
|
||||
* informative functions that were in express.c/express.h
|
||||
*/
|
||||
|
||||
extern SC_EXPRESS_EXPORT char * EXPRESSversion( void );
|
||||
|
||||
/** print usage message, then exit if _exit is non-zero */
|
||||
extern SC_EXPRESS_EXPORT void EXPRESSusage( int _exit );
|
||||
|
||||
#endif /* INFO_H */
|
||||
@@ -58,7 +58,7 @@ typedef struct Scan_Buffer {
|
||||
#endif
|
||||
char * savedPos;
|
||||
FILE * file;
|
||||
char * filename;
|
||||
const char * filename;
|
||||
bool readEof;
|
||||
int lineno;
|
||||
int bol;
|
||||
|
||||
@@ -129,6 +129,8 @@ extern SC_EXPRESS_EXPORT void LISTinitialize PROTO( ( void ) );
|
||||
extern SC_EXPRESS_EXPORT void LISTcleanup PROTO( ( void ) );
|
||||
extern SC_EXPRESS_EXPORT Linked_List LISTcreate PROTO( ( void ) );
|
||||
extern SC_EXPRESS_EXPORT Linked_List LISTcopy PROTO( ( Linked_List ) );
|
||||
extern SC_EXPRESS_EXPORT void LISTsort PROTO( ( Linked_List, int (*comp)(void*, void*) ) );
|
||||
extern SC_EXPRESS_EXPORT void LISTswap PROTO( ( Link, Link ) );
|
||||
extern SC_EXPRESS_EXPORT Generic LISTadd_first PROTO( ( Linked_List, Generic ) );
|
||||
extern SC_EXPRESS_EXPORT Generic LISTadd_last PROTO( ( Linked_List, Generic ) );
|
||||
extern SC_EXPRESS_EXPORT Generic LISTadd_after PROTO( ( Linked_List, Link, Generic ) );
|
||||
|
||||
@@ -59,7 +59,7 @@ typedef struct Symbol_ Symbol;
|
||||
|
||||
struct Symbol_ {
|
||||
char * name;
|
||||
char * filename;
|
||||
const char * filename;
|
||||
int line;
|
||||
char resolved;
|
||||
};
|
||||
@@ -89,6 +89,6 @@ extern SC_EXPRESS_EXPORT struct freelist_head SYMBOL_fl;
|
||||
/***********************/
|
||||
|
||||
extern SC_EXPRESS_EXPORT void SYMBOLinitialize PROTO( ( void ) );
|
||||
SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, char * filename );
|
||||
SC_EXPRESS_EXPORT Symbol * SYMBOLcreate( char * name, int line, const char * filename );
|
||||
|
||||
#endif /* SYMBOL_H */
|
||||
|
||||
@@ -164,6 +164,7 @@ struct TypeBody_ {
|
||||
* element = expression [ ':' repetition ] .
|
||||
* TODO exp2cxx and exp2py do not use this! Are all use cases handled by libexppp?
|
||||
*/
|
||||
unsigned var : 1; /** denotes variable marked 'VAR' - i.e. one where changes are propagated back to the caller */
|
||||
unsigned encoded : 1; /**< encoded string */
|
||||
} flags;
|
||||
Type base; /**< underlying base type if any can also contain true type if this type is a type reference */
|
||||
|
||||
@@ -76,10 +76,11 @@ typedef struct Variable_ * Variable;
|
||||
/***************************/
|
||||
|
||||
struct Variable_ {
|
||||
Expression name; /**< Symbol is inside of 'name' */
|
||||
Expression name; /**< Symbol is inside of 'name' */
|
||||
Type type;
|
||||
Expression initializer; /**< or 'derived' */
|
||||
int offset;
|
||||
int offset; /**< used for attr order in Entitys, and for decl order in LOCAL vars. these two uses should never conflict! */
|
||||
int idx; /**< used in exp2cxx to simplify calculation of attrDescriptor names in generated code */
|
||||
|
||||
struct {
|
||||
unsigned int optional : 1; /**< OPTIONAL keyword */
|
||||
|
||||
+37
-29
@@ -1,15 +1,15 @@
|
||||
# lcov.cmake
|
||||
# `ctest -S lcov.cmake`
|
||||
|
||||
if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
|
||||
message( FATAL_ERROR "LCOV is Linux-only" )
|
||||
endif( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
message(FATAL_ERROR "LCOV is Linux-only")
|
||||
endif(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
|
||||
set( CTEST_SOURCE_DIRECTORY . )
|
||||
set( CTEST_BINARY_DIRECTORY build_lcov )
|
||||
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
|
||||
set( CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind )
|
||||
set( CTEST_INITIAL_CACHE "
|
||||
set(CTEST_SOURCE_DIRECTORY .)
|
||||
set(CTEST_BINARY_DIRECTORY build_lcov)
|
||||
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
|
||||
set(CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind)
|
||||
set(CTEST_INITIAL_CACHE "
|
||||
SITE:STRING=${CTEST_SITE}
|
||||
BUILDNAME:STRING=${CTEST_BUILD_NAME}
|
||||
SC_ENABLE_TESTING:BOOL=ON
|
||||
@@ -18,42 +18,50 @@ SC_BUILD_SCHEMAS:STRING=ALL
|
||||
SC_BUILD_TYPE:STRING=Debug
|
||||
")
|
||||
|
||||
set( LCOV_OUT "${CTEST_BINARY_DIRECTORY}/lcov_html" )
|
||||
set(LCOV_OUT "${CTEST_BINARY_DIRECTORY}/lcov_html")
|
||||
|
||||
ctest_start(lcov)
|
||||
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
|
||||
message("configuring...")
|
||||
ctest_configure( BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "-DSC_BUILD_SCHEMAS=ALL;-DSC_ENABLE_COVERAGE=ON;-SC_PYTHON_GENERATOR=OFF" )
|
||||
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "-DSC_BUILD_SCHEMAS=ALL;-DSC_ENABLE_COVERAGE=ON;-SC_PYTHON_GENERATOR=OFF")
|
||||
message("lcov: resetting counters...")
|
||||
execute_process( COMMAND lcov -z -d .
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET )
|
||||
execute_process(COMMAND lcov -z -d .
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET)
|
||||
|
||||
# copy files so lcov won't complain
|
||||
execute_process( COMMAND ${CMAKE_COMMAND} -E copy src/express/expparse.y ${CTEST_BINARY_DIRECTORY}/src/express/CMakeFiles/express.dir )
|
||||
execute_process( COMMAND ${CMAKE_COMMAND} -E copy src/express/expscan.l ${CTEST_BINARY_DIRECTORY}/src/express/CMakeFiles/express.dir )
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy src/express/expparse.y ${CTEST_BINARY_DIRECTORY}/src/express/CMakeFiles/express.dir)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy src/express/expscan.l ${CTEST_BINARY_DIRECTORY}/src/express/CMakeFiles/express.dir)
|
||||
|
||||
message("building...")
|
||||
ctest_build( BUILD "${CTEST_BINARY_DIRECTORY}" )
|
||||
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}")
|
||||
|
||||
message("running tests...")
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL 1 )
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL 1)
|
||||
|
||||
message( "analyzing profiling data using lcov..." )
|
||||
execute_process( COMMAND lcov -c -d . -o stepcode.lcov
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET ERROR_QUIET )
|
||||
message("analyzing profiling data using lcov...")
|
||||
execute_process(COMMAND lcov -c -d . -o stepcode.lcov
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET ERROR_QUIET)
|
||||
|
||||
message("removing system headers...")
|
||||
execute_process( COMMAND lcov -r stepcode.lcov "/usr/include/*" -o stepcode_no_usr.lcov
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET ERROR_QUIET )
|
||||
execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${LCOV_OUT} )
|
||||
execute_process(COMMAND lcov -r stepcode.lcov "/usr/include/*" -o stepcode_no_usr.lcov
|
||||
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} OUTPUT_QUIET ERROR_QUIET)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${LCOV_OUT})
|
||||
|
||||
message( "creating html files..." )
|
||||
execute_process( COMMAND genhtml ../stepcode_no_usr.lcov
|
||||
WORKING_DIRECTORY ${LCOV_OUT} OUTPUT_QUIET ERROR_QUIET )
|
||||
message("creating html files...")
|
||||
execute_process(COMMAND genhtml ../stepcode_no_usr.lcov
|
||||
WORKING_DIRECTORY ${LCOV_OUT} OUTPUT_QUIET ERROR_QUIET)
|
||||
|
||||
message( "html files are located in ${LCOV_OUT}" )
|
||||
execute_process( COMMAND ${CMAKE_COMMAND} -E tar czf ${LCOV_OUT}.tgz ${LCOV_OUT} WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY} )
|
||||
message("html files are located in ${LCOV_OUT}")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar czf ${LCOV_OUT}.tgz ${LCOV_OUT} WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY})
|
||||
|
||||
message( "tarball at ${LCOV_OUT}.tgz" )
|
||||
message("tarball at ${LCOV_OUT}.tgz")
|
||||
|
||||
message("================================================ Success! ================================================")
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
message( "================================================ Success! ================================================" )
|
||||
|
||||
+66
-58
@@ -1,11 +1,11 @@
|
||||
# run_ctest.cmake
|
||||
# `ctest -S run_ctest.cmake`
|
||||
|
||||
set( CTEST_SOURCE_DIRECTORY . )
|
||||
set( CTEST_BINARY_DIRECTORY build_ctest )
|
||||
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
|
||||
set( CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind )
|
||||
set( CTEST_INITIAL_CACHE "
|
||||
set(CTEST_SOURCE_DIRECTORY .)
|
||||
set(CTEST_BINARY_DIRECTORY build_ctest)
|
||||
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
|
||||
set(CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind)
|
||||
set(CTEST_INITIAL_CACHE "
|
||||
SITE:STRING=${CTEST_SITE}
|
||||
BUILDNAME:STRING=${CTEST_BUILD_NAME}
|
||||
SC_ENABLE_TESTING:BOOL=ON
|
||||
@@ -14,11 +14,11 @@ SC_BUILD_TYPE:STRING=Debug
|
||||
|
||||
|
||||
|
||||
if( EXISTS "../.SC_CTEST_PREFS.cmake" )
|
||||
include( "../.SC_CTEST_PREFS.cmake" )
|
||||
if(EXISTS "../.SC_CTEST_PREFS.cmake")
|
||||
include("../.SC_CTEST_PREFS.cmake")
|
||||
else()
|
||||
message( WARNING "Did not find ../.SC_CTEST_PREFS.cmake, containing config variables - result submission disabled" )
|
||||
set( SKIP_SUBMISSION TRUE )
|
||||
message(WARNING "Did not find ../.SC_CTEST_PREFS.cmake, containing config variables - result submission disabled")
|
||||
set(SKIP_SUBMISSION TRUE)
|
||||
endif()
|
||||
|
||||
######################################################
|
||||
@@ -26,8 +26,8 @@ endif()
|
||||
# use config variables such as these in
|
||||
# ../.SC_CTEST_PREFS.cmake
|
||||
#
|
||||
#set( CTEST_SITE "username")
|
||||
#set( CTEST_BUILD_NAME "build type, os, arch")
|
||||
#set(CTEST_SITE "username")
|
||||
#set(CTEST_BUILD_NAME "build type, os, arch")
|
||||
#
|
||||
#
|
||||
# setting any of these to true causes that set of tests
|
||||
@@ -44,11 +44,11 @@ endif()
|
||||
######################################################
|
||||
|
||||
|
||||
function( SUBMIT_TEST part )
|
||||
if( NOT SKIP_SUBMISSION )
|
||||
ctest_submit( PARTS ${part} )
|
||||
endif()
|
||||
endfunction( SUBMIT_TEST part )
|
||||
function(SUBMIT_TEST part)
|
||||
if(NOT SKIP_SUBMISSION)
|
||||
ctest_submit(PARTS ${part})
|
||||
endif()
|
||||
endfunction(SUBMIT_TEST part)
|
||||
|
||||
######################################################
|
||||
##### To disable reporting of a set of tests, comment
|
||||
@@ -56,65 +56,73 @@ endfunction( SUBMIT_TEST part )
|
||||
##### the set you wish to disable.
|
||||
#####
|
||||
##### To do this for all tests:
|
||||
##### set( SKIP_SUBMISSION TRUE )
|
||||
##### set(SKIP_SUBMISSION TRUE)
|
||||
######################################################
|
||||
|
||||
ctest_start(Experimental)
|
||||
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
|
||||
|
||||
file(WRITE "${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake" "
|
||||
set( CTEST_CUSTOM_ERROR_EXCEPTION \"{standard input}:[0-9][0-9]*: WARNING: \")
|
||||
set(CTEST_CUSTOM_ERROR_EXCEPTION \"{standard input}:[0-9][0-9]*: WARNING: \")
|
||||
")
|
||||
|
||||
ctest_configure( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND OPTIONS -DSC_ENABLE_TESTING=ON )
|
||||
SUBMIT_TEST( Configure )
|
||||
ctest_build( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND )
|
||||
SUBMIT_TEST( Build )
|
||||
# ctest_memcheck( BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res )
|
||||
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND OPTIONS -DSC_ENABLE_TESTING=ON)
|
||||
SUBMIT_TEST(Configure)
|
||||
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
|
||||
SUBMIT_TEST(Build)
|
||||
# ctest_memcheck(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
|
||||
|
||||
if(NOT SKIP_TEST_UNITARY_SCHEMAS )
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "unitary_schemas" )
|
||||
SUBMIT_TEST( Test )
|
||||
if(NOT SKIP_TEST_UNITARY_SCHEMAS)
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "unitary_schemas")
|
||||
SUBMIT_TEST(Test)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_CPP_TEST_SCHEMA_GEN )
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_gen" )
|
||||
SUBMIT_TEST( Test )
|
||||
if(NOT SKIP_CPP_TEST_SCHEMA_BUILD )
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_build" )
|
||||
SUBMIT_TEST( Test )
|
||||
if(NOT SKIP_CPP_TEST_SCHEMA_RW )
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_rw" )
|
||||
SUBMIT_TEST( Test )
|
||||
endif()
|
||||
if(NOT SKIP_CPP_TEST_SCHEMA_GEN)
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_gen")
|
||||
SUBMIT_TEST(Test)
|
||||
if(NOT SKIP_CPP_TEST_SCHEMA_BUILD)
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_build")
|
||||
SUBMIT_TEST(Test)
|
||||
if(NOT SKIP_CPP_TEST_SCHEMA_RW)
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_rw")
|
||||
SUBMIT_TEST(Test)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_TEST_EXCHANGE_FILE )
|
||||
if( SKIP_CPP_TEST_SCHEMA_BUILD )
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE "build_cpp_sdai_AP214E3_2010" )
|
||||
SUBMIT_TEST( Test )
|
||||
endif()
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "exchange_file" )
|
||||
SUBMIT_TEST( Test )
|
||||
if(NOT SKIP_TEST_EXCHANGE_FILE)
|
||||
if(SKIP_CPP_TEST_SCHEMA_BUILD)
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE "build_cpp_sdai_AP214E3_2010")
|
||||
SUBMIT_TEST(Test)
|
||||
endif()
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "exchange_file")
|
||||
SUBMIT_TEST(Test)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_TEST_CPP_SCHEMA_SPECIFIC )
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_specific" )
|
||||
SUBMIT_TEST( Test )
|
||||
if(NOT SKIP_TEST_CPP_SCHEMA_SPECIFIC)
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_schema_specific")
|
||||
SUBMIT_TEST(Test)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_TEST_CPP_UNIT )
|
||||
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_unit_....*" )
|
||||
SUBMIT_TEST( Test )
|
||||
if(NOT SKIP_TEST_CPP_UNIT)
|
||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND
|
||||
INCLUDE_LABEL "cpp_unit_....*")
|
||||
SUBMIT_TEST(Test)
|
||||
endif()
|
||||
|
||||
# ctest_coverage( )
|
||||
# ctest_coverage()
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
+37
-27
@@ -1,45 +1,55 @@
|
||||
|
||||
set(SC_BASE_SOURCES
|
||||
sc_memmgr.cc
|
||||
sc_trace_fprintf.c
|
||||
sc_getopt.cc
|
||||
sc_benchmark.cc
|
||||
)
|
||||
sc_memmgr.cc
|
||||
sc_trace_fprintf.c
|
||||
sc_getopt.cc
|
||||
sc_benchmark.cc
|
||||
sc_mkdir.c
|
||||
)
|
||||
|
||||
set(SC_BASE_HDRS
|
||||
sc_benchmark.h
|
||||
sc_memmgr.h
|
||||
sc_getopt.h
|
||||
sc_trace_fprintf.h
|
||||
sc_stdbool.h
|
||||
)
|
||||
sc_benchmark.h
|
||||
sc_memmgr.h
|
||||
sc_getopt.h
|
||||
sc_trace_fprintf.h
|
||||
sc_stdbool.h
|
||||
sc_mkdir.h
|
||||
)
|
||||
|
||||
if(MINGW OR MSVC OR BORLAND)
|
||||
add_definitions( -DSC_BASE_DLL_EXPORTS )
|
||||
add_definitions(-DSC_BASE_DLL_EXPORTS)
|
||||
endif()
|
||||
|
||||
if (${SC_MEMMGR_ENABLE_CHECKS})
|
||||
add_definitions( -DSC_MEMMGR_ENABLE_CHECKS )
|
||||
add_definitions(-DSC_MEMMGR_ENABLE_CHECKS)
|
||||
endif()
|
||||
|
||||
SC_ADDLIB(base "${SC_BASE_SOURCES}" "")
|
||||
|
||||
if(MINGW OR MSVC OR BORLAND)
|
||||
target_link_libraries(base psapi.lib)
|
||||
target_link_libraries(base psapi.lib)
|
||||
endif()
|
||||
|
||||
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src" )
|
||||
message( "Judy array source code not found. Downloading (don't sweat, it's public domain)..." )
|
||||
file( DOWNLOAD "http://github.com/mpictor/judy-template/archive/master.tar.gz"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz" SHOW_PROGRESS )
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
)
|
||||
file( RENAME judy-template-master judy )
|
||||
file( REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz" )
|
||||
message( "Judy array source code extracted." )
|
||||
endif(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src" )
|
||||
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src")
|
||||
message("Judy array source code not found. Downloading (don't sweat, it's public domain)...")
|
||||
file(DOWNLOAD "http://github.com/mpictor/judy-template/archive/master.tar.gz"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz" SHOW_PROGRESS)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
|
||||
)
|
||||
file(RENAME judy-template-master judy)
|
||||
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/judy.tar.gz")
|
||||
message("Judy array source code extracted.")
|
||||
endif(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/judy/src")
|
||||
|
||||
install(FILES ${SC_BASE_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/base)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/base)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 2.8)
|
||||
project( JudyTemplates )
|
||||
|
||||
if( NOT DEFINED CMAKE_BUILD_TYPE )
|
||||
# set( CMAKE_BUILD_TYPE "RelWithDebInfo" ) #optimize, but include debug info
|
||||
set( CMAKE_BUILD_TYPE "Release" )
|
||||
# set( CMAKE_BUILD_TYPE "RelWithDebInfo" ) #optimize, but include debug info
|
||||
set( CMAKE_BUILD_TYPE "Release" )
|
||||
endif( NOT DEFINED CMAKE_BUILD_TYPE )
|
||||
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
||||
@@ -12,29 +12,29 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
|
||||
|
||||
if( NOT DEFINED JUDY_OPTIMIZE_FLAGS )
|
||||
if( CMAKE_COMPILER_IS_GNUCC )
|
||||
set( JUDY_OPTIMIZE_FLAGS "-march=native" )
|
||||
if( CMAKE_COMPILER_IS_GNUCC )
|
||||
set( JUDY_OPTIMIZE_FLAGS "-march=native" )
|
||||
|
||||
#test for LTO; this uses an internal variable so it may break
|
||||
if( DEFINED CMAKE_C_COMPILER_VERSION )
|
||||
if( ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 4.7.0 )
|
||||
set( JUDY_OPTIMIZE_FLAGS "${JUDY_OPTIMIZE_FLAGS} -flto" )
|
||||
message( " -- GCC version: ${CMAKE_C_COMPILER_VERSION}. Enabling link-time optimization." )
|
||||
endif( ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 4.7.0 )
|
||||
endif( DEFINED CMAKE_C_COMPILER_VERSION )
|
||||
#test for LTO; this uses an internal variable so it may break
|
||||
if( DEFINED CMAKE_C_COMPILER_VERSION )
|
||||
if( ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 4.7.0 )
|
||||
set( JUDY_OPTIMIZE_FLAGS "${JUDY_OPTIMIZE_FLAGS} -flto" )
|
||||
message( " -- GCC version: ${CMAKE_C_COMPILER_VERSION}. Enabling link-time optimization." )
|
||||
endif( ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 4.7.0 )
|
||||
endif( DEFINED CMAKE_C_COMPILER_VERSION )
|
||||
#elseif( MSVC )
|
||||
# set( JUDY_OPTIMIZE_FLAGS "..." ) # <--- set MSVC flags here <---
|
||||
else()
|
||||
message( "Unrecognized compiler - no optimization flags set. Edit CMakeLists.txt or set JUDY_OPTIMIZE_FLAGS." )
|
||||
set( JUDY_OPTIMIZE_FLAGS "" )
|
||||
endif( CMAKE_COMPILER_IS_GNUCC )
|
||||
else()
|
||||
message( "Unrecognized compiler - no optimization flags set. Edit CMakeLists.txt or set JUDY_OPTIMIZE_FLAGS." )
|
||||
set( JUDY_OPTIMIZE_FLAGS "" )
|
||||
endif( CMAKE_COMPILER_IS_GNUCC )
|
||||
endif( NOT DEFINED JUDY_OPTIMIZE_FLAGS )
|
||||
add_definitions( ${JUDY_OPTIMIZE_FLAGS} )
|
||||
|
||||
set( JUDYS_SOURCES src/judy.c src/judy.h )
|
||||
|
||||
if( CMAKE_COMPILER_IS_GNUCC )
|
||||
add_definitions( -pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long )
|
||||
add_definitions( -pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long )
|
||||
endif( CMAKE_COMPILER_IS_GNUCC )
|
||||
|
||||
add_library( judy_lib STATIC ${JUDYS_SOURCES} )
|
||||
@@ -42,29 +42,37 @@ add_library( judy_lib STATIC ${JUDYS_SOURCES} )
|
||||
include_directories( src )
|
||||
|
||||
if( ENABLE_TESTING )
|
||||
include( CTest )
|
||||
include_directories( test )
|
||||
enable_testing()
|
||||
include( CTest )
|
||||
include_directories( test )
|
||||
enable_testing()
|
||||
|
||||
add_executable( pennysort test/pennySort.c test/sort.c ${JUDYS_SOURCES} )
|
||||
add_executable( hexsort test/hexSort.c test/sort.c ${JUDYS_SOURCES} )
|
||||
set_target_properties( pennysort hexsort PROPERTIES COMPILE_FLAGS "-DSTANDALONE" )
|
||||
add_executable( pennysort test/pennySort.c test/sort.c ${JUDYS_SOURCES} )
|
||||
add_executable( hexsort test/hexSort.c test/sort.c ${JUDYS_SOURCES} )
|
||||
set_target_properties( pennysort hexsort PROPERTIES COMPILE_FLAGS "-DSTANDALONE" )
|
||||
|
||||
|
||||
add_executable( judyLtest test/judyLtest.cc )
|
||||
target_link_libraries( judyLtest judy_lib )
|
||||
add_test( judyLtest judyLtest )
|
||||
add_executable( judyLtest test/judyLtest.cc )
|
||||
target_link_libraries( judyLtest judy_lib )
|
||||
add_test( judyLtest judyLtest )
|
||||
|
||||
add_executable( judyL2test test/judyL2test.cc )
|
||||
target_link_libraries( judyL2test judy_lib )
|
||||
add_test( judyL2test judyL2test )
|
||||
add_executable( judyL2test test/judyL2test.cc )
|
||||
target_link_libraries( judyL2test judy_lib )
|
||||
add_test( judyL2test judyL2test )
|
||||
|
||||
add_executable( judyStest test/judyStest.cc )
|
||||
target_link_libraries( judyStest judy_lib )
|
||||
add_test( judyStest judyStest )
|
||||
add_executable( judyStest test/judyStest.cc )
|
||||
target_link_libraries( judyStest judy_lib )
|
||||
add_test( judyStest judyStest )
|
||||
|
||||
add_executable( judyS2test test/judyS2test.cc )
|
||||
target_link_libraries( judyS2test judy_lib )
|
||||
add_test( judyS2test judyS2test )
|
||||
add_executable( judyS2test test/judyS2test.cc )
|
||||
target_link_libraries( judyS2test judy_lib )
|
||||
add_test( judyS2test judyS2test )
|
||||
|
||||
endif( ENABLE_TESTING )
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -903,8 +903,9 @@ JudySlot * judy_last( Judy * judy, JudySlot next, unsigned int off, unsigned int
|
||||
JudySlot * judy_end( Judy * judy ) {
|
||||
judy->level = 0;
|
||||
return judy_last( judy, *judy->root, 0, 0 );
|
||||
} // judy_nxt: return next entry
|
||||
}
|
||||
|
||||
// judy_nxt: return next entry
|
||||
JudySlot * judy_nxt( Judy * judy ) {
|
||||
JudySlot * table, *inner;
|
||||
int slot, size, cnt;
|
||||
|
||||
@@ -29,14 +29,16 @@ struct judylKVpair {
|
||||
*/
|
||||
template< typename JudyKey, typename JudyValue >
|
||||
class judyLArray {
|
||||
public:
|
||||
typedef judylKVpair< JudyKey, JudyValue > pair;
|
||||
protected:
|
||||
Judy * _judyarray;
|
||||
unsigned int _maxLevels, _depth;
|
||||
JudyValue * _lastSlot;
|
||||
JudyKey _buff[1];
|
||||
bool _success;
|
||||
pair _kv;
|
||||
public:
|
||||
typedef judylKVpair< JudyKey, JudyValue > pair;
|
||||
judyLArray(): _maxLevels( sizeof( JudyKey ) ), _depth( 1 ), _lastSlot( 0 ), _success( true ) {
|
||||
assert( sizeof( JudyKey ) == JUDY_key_size && "JudyKey *must* be the same size as a pointer!" );
|
||||
assert( sizeof( JudyValue ) == JUDY_key_size && "JudyValue *must* be the same size as a pointer!" );
|
||||
@@ -55,9 +57,12 @@ class judyLArray {
|
||||
judy_close( _judyarray );
|
||||
}
|
||||
|
||||
void clear() {
|
||||
void clear( bool deleteContents = false ) {
|
||||
JudyKey key = 0;
|
||||
while( 0 != ( _lastSlot = ( JudyValue * ) judy_strt( _judyarray, ( const unsigned char * ) &key, 0 ) ) ) {
|
||||
if( deleteContents ) {
|
||||
delete *_lastSlot;
|
||||
}
|
||||
judy_del( _judyarray );
|
||||
}
|
||||
}
|
||||
@@ -112,18 +117,17 @@ class judyLArray {
|
||||
}
|
||||
|
||||
/// retrieve the key-value pair for the most recent judy query.
|
||||
inline const pair mostRecentPair() {
|
||||
pair kv;
|
||||
inline const pair & mostRecentPair() {
|
||||
judy_key( _judyarray, ( unsigned char * ) _buff, _depth * JUDY_key_size );
|
||||
if( _lastSlot ) {
|
||||
kv.value = *_lastSlot;
|
||||
_kv.value = *_lastSlot;
|
||||
_success = true;
|
||||
} else {
|
||||
kv.value = ( JudyValue ) 0;
|
||||
_kv.value = ( JudyValue ) 0;
|
||||
_success = false;
|
||||
}
|
||||
kv.key = _buff[0];
|
||||
return kv;
|
||||
_kv.key = _buff[0];
|
||||
return _kv;
|
||||
}
|
||||
|
||||
/// retrieve the first key-value pair in the array
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <ios>
|
||||
|
||||
/// mem values in kb, times in ms (granularity may be higher than 1ms)
|
||||
benchVals getMemAndTime( ) {
|
||||
|
||||
@@ -38,11 +38,6 @@ extern "C" {
|
||||
* depends on getMemAndTime() above - may not work on all platforms.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
template class SC_BASE_EXPORT std::allocator<char>;
|
||||
template class SC_BASE_EXPORT std::basic_string<char, std::char_traits<char>, std::allocator<char> >;
|
||||
#endif
|
||||
|
||||
class SC_BASE_EXPORT benchmark {
|
||||
protected:
|
||||
benchVals initialVals, laterVals;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
#include "sc_mkdir.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* cross-platform mkdir */
|
||||
int sc_mkdir( const char * path ) {
|
||||
#ifdef _WIN32
|
||||
return mkdir( path );
|
||||
#else
|
||||
return mkdir( path, 0777 );
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/* return -1 if error, 0 if created, 1 if dir existed already */
|
||||
int mkDirIfNone( const char * path ) {
|
||||
struct stat s;
|
||||
if( stat( path, &s ) != 0 ) {
|
||||
if( errno == ENOENT ) {
|
||||
return sc_mkdir( path );
|
||||
}
|
||||
} else if( s.st_mode & S_IFDIR ) {
|
||||
return 1;
|
||||
}
|
||||
/* either stat returned an error other than ENOENT, or 'path' exists but isn't a dir */
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef SC_MKDIR
|
||||
#define SC_MKDIR
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
/** cross-platform mkdir() */
|
||||
SC_BASE_EXPORT int sc_mkdir( const char * path );
|
||||
|
||||
/** create a dir 'path' if 'path' doesn't exist
|
||||
* \return -1 if error, 0 if created, 1 if dir existed already
|
||||
* if it returns -1, check errno
|
||||
*/
|
||||
SC_BASE_EXPORT int mkDirIfNone( const char * path );
|
||||
|
||||
#endif /* SC_MKDIR */
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef SC_STRTOULL_H
|
||||
#define SC_STRTOULL_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# define strtoull _strtoui64
|
||||
# define ULLONG_MAX _UI64_MAX
|
||||
#endif
|
||||
|
||||
#endif /* SC_STRTOULL_H */
|
||||
+38
-30
@@ -1,40 +1,48 @@
|
||||
|
||||
set(LIBSTEPDAI_SRCS
|
||||
sdaiApplication_instance_set.cc
|
||||
sdaiBinary.cc
|
||||
sdaiDaObject.cc
|
||||
sdaiEntity_extent.cc
|
||||
sdaiEntity_extent_set.cc
|
||||
sdaiEnum.cc
|
||||
sdaiModel_contents.cc
|
||||
sdaiModel_contents_list.cc
|
||||
sdaiObject.cc
|
||||
sdaiSession_instance.cc
|
||||
sdaiString.cc
|
||||
)
|
||||
sdaiApplication_instance_set.cc
|
||||
sdaiBinary.cc
|
||||
sdaiDaObject.cc
|
||||
sdaiEntity_extent.cc
|
||||
sdaiEntity_extent_set.cc
|
||||
sdaiEnum.cc
|
||||
sdaiModel_contents.cc
|
||||
sdaiModel_contents_list.cc
|
||||
sdaiObject.cc
|
||||
sdaiSession_instance.cc
|
||||
sdaiString.cc
|
||||
)
|
||||
|
||||
SET(SC_CLDAI_HDRS
|
||||
sdaiApplication_instance_set.h
|
||||
sdaiBinary.h
|
||||
sdaiDaObject.h
|
||||
sdaiEntity_extent.h
|
||||
sdaiEntity_extent_set.h
|
||||
sdaiEnum.h
|
||||
sdaiModel_contents.h
|
||||
sdaiModel_contents_list.h
|
||||
sdaiObject.h
|
||||
sdaiSession_instance.h
|
||||
sdaiString.h
|
||||
)
|
||||
sdaiApplication_instance_set.h
|
||||
sdaiBinary.h
|
||||
sdaiDaObject.h
|
||||
sdaiEntity_extent.h
|
||||
sdaiEntity_extent_set.h
|
||||
sdaiEnum.h
|
||||
sdaiModel_contents.h
|
||||
sdaiModel_contents_list.h
|
||||
sdaiObject.h
|
||||
sdaiSession_instance.h
|
||||
sdaiString.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
|
||||
SC_ADDLIB(stepdai "${LIBSTEPDAI_SRCS}" "steputils;base")
|
||||
|
||||
install(FILES ${SC_CLDAI_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cldai)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
+31
-23
@@ -1,33 +1,41 @@
|
||||
|
||||
set(LIBSTEPEDITOR_SRCS
|
||||
STEPfile.cc
|
||||
STEPfile.inline.cc
|
||||
cmdmgr.cc
|
||||
SdaiHeaderSchema.cc
|
||||
SdaiHeaderSchemaAll.cc
|
||||
SdaiHeaderSchemaInit.cc
|
||||
SdaiSchemaInit.cc
|
||||
)
|
||||
STEPfile.cc
|
||||
STEPfile.inline.cc
|
||||
cmdmgr.cc
|
||||
SdaiHeaderSchema.cc
|
||||
SdaiHeaderSchemaAll.cc
|
||||
SdaiHeaderSchemaInit.cc
|
||||
SdaiSchemaInit.cc
|
||||
)
|
||||
|
||||
SET(SC_CLEDITOR_HDRS
|
||||
STEPfile.h
|
||||
cmdmgr.h
|
||||
editordefines.h
|
||||
SdaiHeaderSchema.h
|
||||
SdaiHeaderSchemaClasses.h
|
||||
SdaiSchemaInit.h
|
||||
seeinfodefault.h
|
||||
)
|
||||
STEPfile.h
|
||||
cmdmgr.h
|
||||
editordefines.h
|
||||
SdaiHeaderSchema.h
|
||||
SdaiHeaderSchemaClasses.h
|
||||
SdaiSchemaInit.h
|
||||
seeinfodefault.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/cldai
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/cldai
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
|
||||
SC_ADDLIB(stepeditor "${LIBSTEPEDITOR_SRCS}" "stepcore;stepdai;steputils;base")
|
||||
|
||||
install(FILES ${SC_CLEDITOR_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cleditor)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cleditor)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -1,41 +1,52 @@
|
||||
|
||||
set( clLazyFile_SRCS
|
||||
lazyDataSectionReader.cc
|
||||
lazyFileReader.cc
|
||||
lazyInstMgr.cc
|
||||
p21HeaderSectionReader.cc
|
||||
sectionReader.cc
|
||||
lazyP21DataSectionReader.cc
|
||||
../base/judy/src/judy.c
|
||||
../base/judy/src/judyLArray.h
|
||||
../base/judy/src/judySArray.h
|
||||
)
|
||||
lazyDataSectionReader.cc
|
||||
lazyFileReader.cc
|
||||
lazyInstMgr.cc
|
||||
p21HeaderSectionReader.cc
|
||||
sectionReader.cc
|
||||
lazyP21DataSectionReader.cc
|
||||
../base/judy/src/judy.c
|
||||
../base/judy/src/judyLArray.h
|
||||
../base/judy/src/judySArray.h
|
||||
)
|
||||
|
||||
set( SC_CLLAZYFILE_HDRS
|
||||
headerSectionReader.h
|
||||
lazyFileReader.h
|
||||
lazyP21DataSectionReader.h
|
||||
p21HeaderSectionReader.h
|
||||
lazyDataSectionReader.h
|
||||
lazyInstMgr.h
|
||||
lazyTypes.h
|
||||
sectionReader.h
|
||||
instMgrHelper.h
|
||||
)
|
||||
headerSectionReader.h
|
||||
lazyFileReader.h
|
||||
lazyP21DataSectionReader.h
|
||||
p21HeaderSectionReader.h
|
||||
lazyDataSectionReader.h
|
||||
lazyInstMgr.h
|
||||
lazyTypes.h
|
||||
sectionReader.h
|
||||
instMgrHelper.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/cldai
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/base/judy/src
|
||||
)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/cldai
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/base/judy/src
|
||||
)
|
||||
|
||||
SC_ADDLIB(steplazyfile "${clLazyFile_SRCS};${clLazyFile_HDRS}" "stepcore;stepdai;steputils;base")
|
||||
SC_ADDEXEC(lazy_test "lazy_test.cc" "steplazyfile;stepeditor" )
|
||||
set_target_properties(lazy_test PROPERTIES COMPILE_FLAGS "-DNO_REGISTRY" )
|
||||
if(TARGET lazy_test-static)
|
||||
set_target_properties(lazy_test-static PROPERTIES COMPILE_FLAGS "-DNO_REGISTRY" )
|
||||
endif(TARGET lazy_test-static)
|
||||
|
||||
install(FILES ${SC_CLLAZYFILE_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cllazyfile)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/cllazyfile)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class SC_LAZYFILE_EXPORT headerSectionReader: public sectionReader {
|
||||
return _headerInstances;
|
||||
}
|
||||
|
||||
~headerSectionReader() {
|
||||
virtual ~headerSectionReader() {
|
||||
//FIXME delete each instance?! maybe add to clear, since it iterates over everything already
|
||||
//enum clearHow { rawData, deletePointers }
|
||||
_headerInstances->clear();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* This class is used when creating SDAI_Application_instance's and using a lazyInstMgr. It is returned
|
||||
* by instMgrAdapter. SDAI_Application_instance only uses the GetSTEPentity function.
|
||||
*/
|
||||
class mgrNodeHelper: protected MgrNode {
|
||||
class mgrNodeHelper: public MgrNodeBase {
|
||||
protected:
|
||||
lazyInstMgr * _lim;
|
||||
instanceID _id;
|
||||
@@ -22,13 +22,13 @@ class mgrNodeHelper: protected MgrNode {
|
||||
mgrNodeHelper( lazyInstMgr * lim ) {
|
||||
_lim = lim;
|
||||
_id = 0;
|
||||
prev = next = 0;
|
||||
}
|
||||
inline void setInstance( instanceID id ) {
|
||||
_id = id;
|
||||
}
|
||||
inline SDAI_Application_instance * GetSTEPentity() {
|
||||
// unsigned int c = _lim->countDataSections();
|
||||
return _lim->loadInstance( _id );
|
||||
return _lim->loadInstance( _id, true );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,13 +40,14 @@ class mgrNodeHelper: protected MgrNode {
|
||||
* when an instance is looked up, this uses lazyInstMgr to load it, and then returns a pointer to it.
|
||||
*/
|
||||
|
||||
class instMgrAdapter: public InstMgr {
|
||||
class instMgrAdapter: public InstMgrBase {
|
||||
protected:
|
||||
mgrNodeHelper _mn;
|
||||
public:
|
||||
instMgrAdapter( lazyInstMgr * lim ): InstMgr( 0 ), _mn( lim ) {}
|
||||
instMgrAdapter( lazyInstMgr * lim ): InstMgrBase(), _mn( lim ) {}
|
||||
|
||||
inline mgrNodeHelper * FindFileId( int fileId ) {
|
||||
//TODO check if fileId exists. if not, return null
|
||||
_mn.setInstance( fileId );
|
||||
return &_mn;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "lazyTypes.h"
|
||||
#include "lazyInstMgr.h"
|
||||
#include "Registry.h"
|
||||
#include <SubSuperIterators.h>
|
||||
#include "SdaiSchemaInit.h"
|
||||
#include "instMgrHelper.h"
|
||||
#include "lazyRefs.h"
|
||||
|
||||
lazyInstMgr::lazyInstMgr() {
|
||||
_headerRegistry = new Registry( HeaderSchemaInit );
|
||||
@@ -10,6 +12,7 @@ lazyInstMgr::lazyInstMgr() {
|
||||
_lazyInstanceCount = 0;
|
||||
_loadedInstanceCount = 0;
|
||||
_longestTypeNameLen = 0;
|
||||
_mainRegistry = 0;
|
||||
_errors = new ErrorDescriptor();
|
||||
_ima = new instMgrAdapter( this );
|
||||
}
|
||||
@@ -38,7 +41,7 @@ sectionID lazyInstMgr::registerDataSection( lazyDataSectionReader * sreader ) {
|
||||
|
||||
void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) {
|
||||
_lazyInstanceCount++;
|
||||
assert( inst.loc.begin > 0 && inst.loc.instance > 0 && inst.loc.section >= 0 );
|
||||
assert( inst.loc.begin > 0 && inst.loc.instance > 0 );
|
||||
int len = strlen( inst.name );
|
||||
if( len > _longestTypeNameLen ) {
|
||||
_longestTypeNameLen = len;
|
||||
@@ -46,8 +49,12 @@ void lazyInstMgr::addLazyInstance( namedLazyInstance inst ) {
|
||||
}
|
||||
_instanceTypes->insert( inst.name, inst.loc.instance );
|
||||
/* store 16 bits of section id and 48 of instance offset into one 64-bit int
|
||||
* TODO: check and warn if anything is lost (in calling code?)
|
||||
* does 32bit need anything special?
|
||||
** TODO: check and warn if anything is lost (in calling code?)
|
||||
** does 32bit need anything special?
|
||||
**
|
||||
** create conversion class?
|
||||
** could then initialize conversion object with number of bits
|
||||
** also a good place to check for data loss
|
||||
*/
|
||||
positionAndSection ps = inst.loc.section;
|
||||
ps <<= 48;
|
||||
@@ -85,18 +92,29 @@ unsigned long lazyInstMgr::getNumTypes() const {
|
||||
}
|
||||
|
||||
void lazyInstMgr::openFile( std::string fname ) {
|
||||
_files.push_back( new lazyFileReader( fname, this, _files.size() ) );
|
||||
//don't want to hold a lock for the entire time we're reading the file.
|
||||
//create a place in the vector and remember its location, then free lock
|
||||
///FIXME begin atomic op
|
||||
size_t i = _files.size();
|
||||
_files.push_back( (lazyFileReader * ) 0 );
|
||||
///FIXME end atomic op
|
||||
lazyFileReader * lfr = new lazyFileReader( fname, this, i );
|
||||
_files[i] = lfr;
|
||||
/// TODO resolve inverse attr references
|
||||
//between instances, or eDesc --> inst????
|
||||
}
|
||||
|
||||
SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id ) {
|
||||
SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id, bool reSeek ) {
|
||||
assert( _mainRegistry && "Main registry has not been initialized. Do so with initRegistry() or setRegistry()." );
|
||||
SDAI_Application_instance * inst = 0;
|
||||
std::streampos oldPos;
|
||||
positionAndSection ps;
|
||||
sectionID sid;
|
||||
inst = _instancesLoaded.find( id );
|
||||
SDAI_Application_instance * inst = _instancesLoaded.find( id );
|
||||
if( inst ) {
|
||||
return inst;
|
||||
}
|
||||
instanceStreamPos_t::cvector * cv;
|
||||
if( !inst && 0 != ( cv = _instanceStreamPos.find( id ) ) ) {
|
||||
//FIXME _instanceStreamPos.find( id ) can return nonzero for nonexistent key?!
|
||||
if( 0 != ( cv = _instanceStreamPos.find( id ) ) ) {
|
||||
switch( cv->size() ) {
|
||||
case 0:
|
||||
std::cerr << "Instance #" << id << " not found in any section." << std::endl;
|
||||
@@ -107,7 +125,13 @@ SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id ) {
|
||||
off = ps & 0xFFFFFFFFFFFFULL;
|
||||
sid = ps >> 48;
|
||||
assert( _dataSections.size() > sid );
|
||||
if( reSeek ) {
|
||||
oldPos = _dataSections[sid]->tellg();
|
||||
}
|
||||
inst = _dataSections[sid]->getRealInstance( _mainRegistry, off, id );
|
||||
if( reSeek ) {
|
||||
_dataSections[sid]->seekg( oldPos );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Instance #" << id << " exists in multiple sections. This is not yet supported." << std::endl;
|
||||
@@ -116,6 +140,8 @@ SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id ) {
|
||||
if( ( inst ) && ( inst != & NilSTEPentity ) ) {
|
||||
_instancesLoaded.insert( id, inst );
|
||||
_loadedInstanceCount++;
|
||||
lazyRefs lr( this, inst );
|
||||
lazyRefs::referentInstances_t insts = lr.result();
|
||||
} else {
|
||||
std::cerr << "Error loading instance #" << id << "." << std::endl;
|
||||
}
|
||||
@@ -125,3 +151,33 @@ SDAI_Application_instance * lazyInstMgr::loadInstance( instanceID id ) {
|
||||
return inst;
|
||||
}
|
||||
|
||||
|
||||
instanceSet * lazyInstMgr::instanceDependencies( instanceID id ) {
|
||||
instanceSet * checkedDependencies = new instanceSet();
|
||||
instanceRefs dependencies; //Acts as queue for checking duplicated dependency
|
||||
|
||||
instanceRefs_t * _fwdRefs = getFwdRefs();
|
||||
instanceRefs_t::cvector * _fwdRefsVec = _fwdRefs->find( id );
|
||||
//Initially populating direct dependencies of id into the queue
|
||||
if( _fwdRefsVec != 0 ) {
|
||||
dependencies.insert( dependencies.end(), _fwdRefsVec->begin(), _fwdRefsVec->end() );
|
||||
}
|
||||
|
||||
size_t curPos = 0;
|
||||
while( curPos < dependencies.size() ) {
|
||||
|
||||
bool isNewElement = ( checkedDependencies->insert( dependencies.at( curPos ) ) ).second;
|
||||
if( isNewElement ) {
|
||||
_fwdRefsVec = _fwdRefs->find( dependencies.at( curPos ) );
|
||||
|
||||
if( _fwdRefsVec != 0 ) {
|
||||
dependencies.insert( dependencies.end(), _fwdRefsVec->begin(), _fwdRefsVec->end() );
|
||||
}
|
||||
}
|
||||
|
||||
curPos++;
|
||||
}
|
||||
|
||||
return checkedDependencies;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ class instMgrAdapter;
|
||||
|
||||
class lazyInstMgr {
|
||||
protected:
|
||||
/** map from instance number to instances that it refers to
|
||||
/** multimap from instance number to instances that it refers to
|
||||
* \sa instanceRefs_pair
|
||||
*/
|
||||
instanceRefs_t _fwdInstanceRefs;
|
||||
/** map from instance number to instances that refer to it
|
||||
/** multimap from instance number to instances that refer to it - the majority of these will not be inverse references!
|
||||
* \sa instanceRefs_pair
|
||||
*/
|
||||
instanceRefs_t _revInstanceRefs;
|
||||
@@ -39,11 +39,15 @@ class lazyInstMgr {
|
||||
|
||||
/** map from instance number to instance pointer (loaded instances only)
|
||||
* \sa instancesLoaded_pair
|
||||
*
|
||||
* TODO should be multimap to allow use of instances in multiple data sections?
|
||||
* a unique instance ID (containing sectionID and instanceID) would also work
|
||||
*/
|
||||
instancesLoaded_t _instancesLoaded;
|
||||
|
||||
/** map from instance number to beginning and end positions and the data section
|
||||
* \sa instanceStreamPos_pair
|
||||
*
|
||||
* FIXME to save memory, modify judyL2Array to not use a vector until there are several
|
||||
* instances with the same instanceID. This will help elsewhere as well.
|
||||
*/
|
||||
@@ -65,7 +69,6 @@ class lazyInstMgr {
|
||||
public:
|
||||
lazyInstMgr();
|
||||
~lazyInstMgr();
|
||||
void addSchema( void ( *initFn )() ); //?
|
||||
void openFile( std::string fname );
|
||||
|
||||
void addLazyInstance( namedLazyInstance inst );
|
||||
@@ -80,8 +83,14 @@ class lazyInstMgr {
|
||||
instanceRefs_t * getRevRefs() {
|
||||
return & _revInstanceRefs;
|
||||
}
|
||||
/// returns two iterators delimiting the instances that match `type`
|
||||
instanceTypes_t::cvector * getInstances( std::string type ) { /*const*/
|
||||
/// returns a vector containing the instances that match `type`
|
||||
instanceTypes_t::cvector * getInstances( std::string type, bool caseSensitive = false ) { /*const*/
|
||||
if( !caseSensitive ) {
|
||||
std::string::iterator it = type.begin();
|
||||
for( ; it != type.end(); ++it ) {
|
||||
*it = toupper( *it );
|
||||
}
|
||||
}
|
||||
return _instanceTypes->find( type.c_str() );
|
||||
}
|
||||
/// get the number of instances of a certain type
|
||||
@@ -140,28 +149,62 @@ class lazyInstMgr {
|
||||
unsigned long getNumTypes() const;
|
||||
|
||||
sectionID registerDataSection( lazyDataSectionReader * sreader );
|
||||
fileID registerLazyFile( lazyFileReader * freader );
|
||||
|
||||
ErrorDescriptor * getErrorDesc() {
|
||||
return _errors;
|
||||
}
|
||||
|
||||
SDAI_Application_instance * loadInstance( instanceID id );
|
||||
/** returns a pointer to an instance, loading it if necessary.
|
||||
* \param id the instance number to look for
|
||||
* \param reSeek if true, reset file position to current position when done. only necessary when loading an instance with dependencies; excessive use will cause a performance hit
|
||||
*/
|
||||
SDAI_Application_instance * loadInstance( instanceID id, bool reSeek = false );
|
||||
|
||||
//list all instances that one instance depends on (recursive)
|
||||
instanceSet * instanceDependencies( instanceID id );
|
||||
bool isLoaded( instanceID id ) {
|
||||
_instancesLoaded.find( id );
|
||||
return _instancesLoaded.success();
|
||||
}
|
||||
|
||||
const char * typeFromFile( instanceID id ) {
|
||||
instanceStreamPos_t::cvector * cv;
|
||||
cv = _instanceStreamPos.find( id );
|
||||
if( cv ) {
|
||||
if( cv->size() != 1 ) {
|
||||
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - multiple instances (" << cv->size() << ") with one instanceID (" << id << ") not supported yet." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
positionAndSection ps = cv->at( 0 );
|
||||
//extract p, s, call
|
||||
long int off = ps & 0xFFFFFFFFFFFFULL;
|
||||
sectionID sid = ps >> 48;
|
||||
return _dataSections[sid]->getType( off );
|
||||
}
|
||||
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - instanceID " << id << " not found." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO implement these
|
||||
//list all instances that one instance depends on (recursive)
|
||||
//std::vector<instanceID> instanceDependencies( instanceID id ); //set is faster?
|
||||
|
||||
/* * the opposite of instanceDependencies() - all instances that are *not* dependencies of one particular instance
|
||||
// add another schema to registry
|
||||
//void addSchema( void ( *initFn )() );
|
||||
|
||||
//list all instances that one instance depends on (recursive)
|
||||
//std::vector<instanceID> instanceDependencies( instanceID id ); //set is faster?
|
||||
|
||||
/* * the opposite of instanceDependencies() - all instances that are *not* dependencies of one particular instance
|
||||
same as above, but with list of instances */
|
||||
//std::vector<instanceID> notDependencies(...)
|
||||
//std::vector<instanceID> notDependencies(...)
|
||||
|
||||
//renumber instances so that they are numbered 1..N where N is the total number of instances
|
||||
//void normalizeInstanceIds();
|
||||
//find data that is repeated and eliminate, if possible
|
||||
//void eliminateDuplicates();
|
||||
//tell instMgr to use instances from this section
|
||||
//void useDataSection( sectionID id );
|
||||
//renumber instances so that they are numbered 1..N where N is the total number of instances
|
||||
//void normalizeInstanceIds();
|
||||
|
||||
//find data that is repeated and eliminate, if possible
|
||||
//void eliminateDuplicates();
|
||||
|
||||
//tell instMgr to use instances from this section
|
||||
//void useDataSection( sectionID id );
|
||||
|
||||
// TODO support references from one file to another
|
||||
};
|
||||
|
||||
@@ -11,6 +11,15 @@ lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std
|
||||
while( nl = nextInstance(), ( ( nl.loc.begin > 0 ) && ( nl.name != 0 ) ) ) {
|
||||
parent->getInstMgr()->addLazyInstance( nl );
|
||||
}
|
||||
|
||||
if( sectionReader::_error->severity() <= SEVERITY_WARNING ) {
|
||||
sectionReader::_error->PrintContents( std::cerr );
|
||||
if( sectionReader::_error->severity() <= SEVERITY_INPUT_ERROR ) {
|
||||
_error = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( !_file.good() ) {
|
||||
_error = true;
|
||||
return;
|
||||
@@ -34,6 +43,7 @@ lazyP21DataSectionReader::lazyP21DataSectionReader( lazyFileReader * parent, std
|
||||
}
|
||||
|
||||
// part of readdata1
|
||||
//if this changes, probably need to change sectionReader::getType()
|
||||
const namedLazyInstance lazyP21DataSectionReader::nextInstance() {
|
||||
std::streampos end = -1;
|
||||
namedLazyInstance i;
|
||||
@@ -44,7 +54,6 @@ const namedLazyInstance lazyP21DataSectionReader::nextInstance() {
|
||||
if( ( _file.good() ) && ( i.loc.instance > 0 ) ) {
|
||||
skipWS();
|
||||
i.loc.section = _sectionID;
|
||||
skipWS();
|
||||
i.name = getDelimitedKeyword( ";( /\\" );
|
||||
if( _file.good() ) {
|
||||
end = seekInstanceEnd( & i.refs );
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
#ifndef LAZYREFS_H
|
||||
#define LAZYREFS_H
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "lazyTypes.h"
|
||||
#include "lazyInstMgr.h"
|
||||
#include "ExpDict.h"
|
||||
#include "sdaiApplication_instance.h"
|
||||
#include "SubSuperIterators.h"
|
||||
#include <STEPattribute.h>
|
||||
#include <STEPaggregate.h>
|
||||
|
||||
/*
|
||||
* given inverted attr ia:
|
||||
* attr method value
|
||||
* ----------- -----
|
||||
* ia->Name() isdefinedby
|
||||
* ia->inverted_attr_id_() relatedobjects
|
||||
* ia->inverted_entity_id_() reldefinesbytype
|
||||
*
|
||||
* 1. for the instance in question, find inverse attrs with recursion
|
||||
* 2. look up references to the current instance (_r)
|
||||
* a. for each item in _r, look up its type and add mapping (instanceID -> char* typestring) to _refMap
|
||||
* 3. for each ia,
|
||||
* a. entity name is returned by ia->inverted_entity_id_()
|
||||
* b. add this entity and its children to a list ( edL )
|
||||
* c. compare the type of each item in _refMap with types in edL; for types in both, remember the instance number ( _referentInstances )
|
||||
* d. load each instance in _referentInstances
|
||||
* e. check if the relevant inverted attr of instances loaded from _referentInstances reference the instance in step 1; if not, unload **IF** the instance hadn't been loaded
|
||||
* --> if it was loaded, this implies that it is used elsewhere
|
||||
* f. (optional / TODO ) for performance, cache list edL - it may be useful in the future
|
||||
* -- best to store such that the most recently (frequently?) used lists are retained and others are discarded
|
||||
*/
|
||||
/* ****
|
||||
* ALTERNATE for 2a, 3c:
|
||||
* for each type t in edL, use lim->getInstances( t ) to get a list of instances of that type, Lt
|
||||
* for each instance i in Lt, check if it is in _r
|
||||
* if so, load it
|
||||
* BENEFIT: no need to write lazyInstMgr::getTypeStr() (however, it might be necessary in the future regardless)
|
||||
*/
|
||||
|
||||
//TODO screen out intances that appear to be possible inverse refs but aren't actually
|
||||
// note - doing this well will require major changes, since each inst automatically loads every instance that it references
|
||||
//TODO what about complex instances? scanning each on disk could be a bitch; should the compositional types be scanned during lazy loading?
|
||||
|
||||
//TODO/FIXME in generated code, store ia data in map and eliminate data members that are currently used. modify accessors to use map.
|
||||
class lazyRefs {
|
||||
public:
|
||||
typedef std::set< instanceID > referentInstances_t;
|
||||
protected:
|
||||
typedef std::set< const Inverse_attribute * > iaList_t;
|
||||
typedef judyLArray< instanceID, std::string * > refMap_t;
|
||||
typedef std::set< const EntityDescriptor * > edList_t;
|
||||
iaList_t _iaList;
|
||||
lazyInstMgr * _lim;
|
||||
instanceID _id;
|
||||
refMap_t _refMap;
|
||||
referentInstances_t _referentInstances;
|
||||
SDAI_Application_instance * _inst;
|
||||
|
||||
void checkAnInvAttr( const Inverse_attribute * ia ) {
|
||||
const EntityDescriptor * ed;
|
||||
const Registry * reg = _lim->getMainRegistry();
|
||||
ed = reg->FindEntity( ia->_inverted_entity_id );
|
||||
subtypesIterator subtypeIter( ed );
|
||||
edList_t edL;
|
||||
edL.insert( ed );
|
||||
// 3b - use subtypeIter to add to edL
|
||||
for( ; !subtypeIter.empty(); ++subtypeIter ) {
|
||||
edL.insert( *subtypeIter );
|
||||
}
|
||||
//3c - for each item in both _refMap and edL, add it to _referentInstances
|
||||
potentialReferentInsts( edL );
|
||||
//3d - load each inst
|
||||
iAstruct ias = invAttr( _inst, ia );
|
||||
referentInstances_t::iterator insts = _referentInstances.begin();
|
||||
for( ; insts != _referentInstances.end(); ++insts ) {
|
||||
loadInstIFFreferent( *insts, ias, ia );
|
||||
}
|
||||
//3f - cache edL - TODO
|
||||
}
|
||||
|
||||
void loadInstIFFreferent( instanceID inst, iAstruct ias, const Inverse_attribute * ia ) {
|
||||
bool prevLoaded = _lim->isLoaded( inst );
|
||||
SDAI_Application_instance * rinst = _lim->loadInstance( inst );
|
||||
bool ref = refersToCurrentInst( ia, rinst );
|
||||
if( ref ) {
|
||||
if( ia->inverted_attr_()->IsAggrType() ) {
|
||||
if( !ias.a ) {
|
||||
ias.a = new EntityAggregate;
|
||||
_inst->setInvAttr( ia, ias );
|
||||
assert( invAttr( _inst, ia ).a == ias.a );
|
||||
}
|
||||
EntityAggregate * ea = ias.a;
|
||||
//TODO check if duplicate
|
||||
ea->AddNode( new EntityNode( rinst ) );
|
||||
} else {
|
||||
SDAI_Application_instance * ai = ias.i;
|
||||
if( !ai ) {
|
||||
ias.i = rinst;
|
||||
_inst->setInvAttr( ia, ias );
|
||||
} else if( ai->GetFileId() != inst ) {
|
||||
std::cerr << "ERROR: two instances (" << rinst << ", #" << rinst->GetFileId() << "=" << rinst->getEDesc()->Name();
|
||||
std::cerr << " and " << ai << ", #" << ai->GetFileId() <<"=" << ai->getEDesc()->Name() << ") refer to inst ";
|
||||
std::cerr << _inst->GetFileId() << ", but its inverse attribute is not an aggregation type!" << std::endl;
|
||||
// TODO _error->GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if( !prevLoaded ) {
|
||||
//TODO _lim->unload( inst ); //this should keep the inst loaded for now, but put it in a list of ones that can be unloaded if not accessed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///3e - check if actually inverse ref
|
||||
bool refersToCurrentInst( const Inverse_attribute * ia, SDAI_Application_instance * referrer ) {
|
||||
//find the attr
|
||||
int rindex = attrIndex( referrer, ia->_inverted_attr_id, ia->_inverted_entity_id );
|
||||
STEPattribute sa = referrer->attributes[ rindex ];
|
||||
assert( sa.getADesc()->BaseType() == ENTITY_TYPE );
|
||||
bool found = false;
|
||||
if( sa.getADesc()->IsAggrType() ) {
|
||||
//aggregate - search for current inst id
|
||||
EntityAggregate * aggr = dynamic_cast< EntityAggregate * >( sa.Aggregate());
|
||||
assert( aggr );
|
||||
EntityNode * en = ( EntityNode * ) aggr->GetHead();
|
||||
while( en ) {
|
||||
if( en->node == _inst ) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
en = ( EntityNode * ) en->NextNode();
|
||||
}
|
||||
} else {
|
||||
//single instance
|
||||
assert( sa.getADesc()->NonRefType() == ENTITY_TYPE );
|
||||
if( sa.Entity() == _inst ) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if( !found ) {
|
||||
std::cerr << "inst #" << _inst->FileId() << " not found in #" << referrer->FileId();
|
||||
std::cerr << ", attr #" << rindex << " [contents: ";
|
||||
referrer->STEPwrite( std::cerr );
|
||||
std::cerr << "]" << std::endl;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
int attrIndex( SDAI_Application_instance * inst, const char * name, const char * entity ) {
|
||||
for( int i = 0; i < inst->attributes.list_length(); i++ ) {
|
||||
// std::cout << "attr " << i << " name " << inst->attributes[i].Name() << ", entity " << inst->EntityName() << std::endl;
|
||||
if( ( strcasecmp( name, inst->attributes[i].Name() ) == 0 ) &&
|
||||
( strcasecmp( entity, inst->attributes[i].getADesc()->Owner().Name() ) == 0 ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
iAstruct invAttr( SDAI_Application_instance * inst, const Inverse_attribute * ia /*, iaList_t & iaList */ ) {
|
||||
SDAI_Application_instance::iAMap_t map = inst->getInvAttrs();
|
||||
SDAI_Application_instance::iAMap_t::iterator iai = map.begin();
|
||||
while( iai != map.end() ) {
|
||||
if( iai->first == ia ) {
|
||||
return iai->second;
|
||||
}
|
||||
++iai;
|
||||
}
|
||||
std::cerr << "Error! inverse attr " << ia->Name() << " (" << ia << ") not found in iAMap for entity " << inst->getEDesc()->Name() << std::endl;
|
||||
abort();
|
||||
iAstruct nil;
|
||||
return nil;
|
||||
}
|
||||
|
||||
/** 3c. compare the type of each item in R with types in A
|
||||
* for items that match, remember the instance number (list C)
|
||||
*/
|
||||
void potentialReferentInsts( edList_t & edL ) {
|
||||
refMap_t::pair kv = _refMap.begin();
|
||||
while( kv.value != 0 ) {
|
||||
std::set< const EntityDescriptor * >::iterator edi = edL.begin();
|
||||
for( ; edi != edL.end(); ++edi ) {
|
||||
if( 0 == strcasecmp( kv.value->c_str(), ( *edi )->Name() ) ) {
|
||||
_referentInstances.insert( kv.key );
|
||||
break;
|
||||
}
|
||||
}
|
||||
kv = _refMap.next();
|
||||
}
|
||||
}
|
||||
|
||||
///find any inverse attributes, put in `iaList`
|
||||
/// attrs not necessarily in order!
|
||||
void getInverseAttrs( const EntityDescriptor * ed, iaList_t & iaList ) {
|
||||
iaList.clear();
|
||||
supertypesIterator supersIter( ed );
|
||||
const Inverse_attribute * iAttr;
|
||||
for( ; !supersIter.empty(); ++supersIter ) {
|
||||
//look at attrs of *si
|
||||
InverseAItr iai( &( ( *supersIter )->InverseAttr() ) );
|
||||
while( 0 != ( iAttr = iai.NextInverse_attribute() ) ) {
|
||||
iaList.insert( iAttr );
|
||||
}
|
||||
}
|
||||
// look at our own attrs
|
||||
InverseAItr invAttrIter( &( ed->InverseAttr() ) );
|
||||
while( 0 != ( iAttr = invAttrIter.NextInverse_attribute() ) ) {
|
||||
iaList.insert( iAttr );
|
||||
}
|
||||
}
|
||||
|
||||
// 2. find reverse refs
|
||||
//2a. convert to map where K=instanceID and V=char*
|
||||
// rather than keeping each V in memory or trying to free non-unique ones, look up each type in the Registry and use that pointer
|
||||
bool mapRefsToTypes() {
|
||||
_refMap.clear( true ); // true -> use delete on pointers
|
||||
instanceRefs_t::cvector * refs = _lim->getRevRefs()->find( _id );
|
||||
if( !refs || refs->empty() ) {
|
||||
return false;
|
||||
}
|
||||
instanceRefs_t::cvector::const_iterator it;
|
||||
for( it = refs->begin(); it != refs->end(); ++it ) {
|
||||
const char * type = _lim->typeFromFile( *it );
|
||||
_refMap.insert( *it, new std::string( type ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
lazyRefs( lazyInstMgr * lmgr ): _lim( lmgr ), _id( 0 ) {
|
||||
_iaList.clear();
|
||||
}
|
||||
lazyRefs( lazyInstMgr * lmgr, SDAI_Application_instance * ai ): _lim( lmgr ), _id( 0 ) {
|
||||
_iaList.clear();
|
||||
init( 0, ai );
|
||||
}
|
||||
lazyRefs( lazyInstMgr * lmgr, instanceID iid ): _lim( lmgr ) {
|
||||
_iaList.clear();
|
||||
init( iid, 0 );
|
||||
}
|
||||
|
||||
~lazyRefs() {
|
||||
// delete strings in refMap
|
||||
_refMap.clear( true );
|
||||
}
|
||||
|
||||
/// initialize with the given instance; will use ai if given, else loads instance iid
|
||||
void init( instanceID iid, SDAI_Application_instance * ai = 0 ) {
|
||||
if( iid == 0 && ai == 0 ) {
|
||||
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ << " - both args are null" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if( !ai ) {
|
||||
_inst = _lim->loadInstance( iid );
|
||||
_id = iid;
|
||||
} else {
|
||||
_inst = ai;
|
||||
_id = _inst->GetFileId();
|
||||
}
|
||||
_refMap.clear( true );
|
||||
|
||||
|
||||
// 1. find inverse attrs with recursion
|
||||
getInverseAttrs( ai->getEDesc(), _iaList );
|
||||
|
||||
//2. find reverse refs, map id to type (stop if there are no inverse attrs or no refs)
|
||||
if( _iaList.size() == 0 || !mapRefsToTypes() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
iaList_t::iterator iai = _iaList.begin();
|
||||
for( ; iai != _iaList.end(); ++iai ) {
|
||||
// 3. for each IA, ...
|
||||
checkAnInvAttr( *iai );
|
||||
}
|
||||
}
|
||||
|
||||
referentInstances_t result() {
|
||||
return _referentInstances;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
#endif //LAZYREFS_H
|
||||
@@ -0,0 +1,74 @@
|
||||
for inverse attrs, we have the attr name and the type of the instance
|
||||
|
||||
--load instance, find inverse attr(s)
|
||||
--for each inverse attr:
|
||||
--find all instance types that inherit from the inverted attr's owner (list A)
|
||||
--look up instances that reference the one in question (list B) - use memoization
|
||||
--find instances that match both lists, put in list C
|
||||
--load instances in list C
|
||||
--for list C, check that the relevant attr references the original instance - if not, unload (?)
|
||||
--
|
||||
|
||||
--when done with this inverse attr, cache list A
|
||||
|
||||
|
||||
|
||||
|
||||
EXAMPLE
|
||||
*******
|
||||
|
||||
information model
|
||||
-----------------
|
||||
ENTITY Object;
|
||||
ObjectType : OPTIONAL STRING;
|
||||
INVERSE
|
||||
IsDefinedBy : SET [0:?] OF RelDefinesByType FOR RelatedObjects;
|
||||
END_ENTITY;
|
||||
|
||||
ENTITY RelDefinesByType;
|
||||
RelatedObjects : SET [1:?] OF Object;
|
||||
END_ENTITY;
|
||||
|
||||
ENTITY Window
|
||||
SUBTYPE OF (Object);
|
||||
Description : OPTIONAL string;
|
||||
END_ENTITY;
|
||||
|
||||
data file
|
||||
---------
|
||||
#1=OBJECT('one');
|
||||
#2=RELDEFINESBYTYPE((#1));
|
||||
#3=RELDEFINESBYTYPE((#4));
|
||||
#4=WINDOW('two','blah');
|
||||
|
||||
#1 and #4 have an inverse attr, but this is not visible in the data file
|
||||
#2 and #3 have #1 and #4, respectively, in an aggregate (thus the parenthesis around the instance); in this case, a SET called RelatedObjects
|
||||
RelatedObjects is the inverted attr that the inverse attr IsDefinedBy links to
|
||||
|
||||
looking at the entity descriptor for WINDOW, it is not apparent that there is an inverse attr; its parents must be examined
|
||||
|
||||
|
||||
given inverted attr ia:
|
||||
attr method value
|
||||
----------- -----
|
||||
ia->Name() isdefinedby
|
||||
ia->inverted_attr_id_() relatedobjects
|
||||
ia->inverted_entity_id_() reldefinesbytype
|
||||
|
||||
1. for the instance in question, find inverse attrs with recursion
|
||||
2. for each ia,
|
||||
a. entity name is returned by ia->inverted_entity_id_()
|
||||
b. add this entity and its children to a list (list A)
|
||||
c. look up references to the current instance (list B)
|
||||
d. for each item in B, look up its type; if its type is present in A, remember the instance number (list C)
|
||||
e. load each instance in C
|
||||
f. (optional) check if the relevant inverted attr of instances loaded from list C reference the instance in step 1; if not, unload **IF** the instance hadn't been loaded
|
||||
--> if it was loaded, this implies that it is used elsewhere
|
||||
g. cache list A, since it may be useful in the future
|
||||
-- best to store such that the most recently (frequently?) used lists are retained and others are discarded
|
||||
|
||||
|
||||
NEED TO DO
|
||||
----------
|
||||
make it possible to access inverse attrs without knowing their names
|
||||
probably best to do this much like explicit attrs - creating an array. each element should have a pointer to the inverted attr desc, a pointer to the setter, and a pointer to the getter
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "judyLArray.h"
|
||||
@@ -35,6 +36,8 @@ typedef uint64_t positionAndSection;
|
||||
|
||||
typedef std::vector< instanceID > instanceRefs;
|
||||
|
||||
typedef std::set< instanceID > instanceSet;
|
||||
|
||||
//TODO: create a "unique instance id" from the sectionID and instanceID, and use it everywhere?
|
||||
|
||||
/** This struct contains all the information necessary to locate an instance. It is primarily
|
||||
@@ -42,7 +45,7 @@ typedef std::vector< instanceID > instanceRefs;
|
||||
* situations, so the information should be kept up-to-date.
|
||||
*/
|
||||
typedef struct {
|
||||
long begin;
|
||||
long begin; ///< this is the result of tellg() before reading the instanceID; there may be whitespace or comments, but nothing else.
|
||||
instanceID instance;
|
||||
sectionID section;
|
||||
/* bool modified; */ /* this will be useful when writing instances - if an instance is
|
||||
|
||||
+55
-14
@@ -71,21 +71,60 @@ instanceID printRefs( lazyInstMgr & mgr ) {
|
||||
return id;
|
||||
}
|
||||
|
||||
/// prints dependencies of an instance
|
||||
void printDeps( lazyInstMgr & mgr ) {
|
||||
const int displayInstances = 10;
|
||||
instanceRefs_t * refs = mgr.getFwdRefs();
|
||||
instanceRefs_t::cpair p = refs->end();
|
||||
|
||||
instanceID id = p.key;
|
||||
instanceSet * dependencies = mgr.instanceDependencies( id );
|
||||
|
||||
std::cout << std::endl <<"Dependencies" << std::endl << "==============" << std::endl;
|
||||
instanceSet::const_iterator it( dependencies->begin() ), end( dependencies->end() );
|
||||
|
||||
std::cout << "Example: Instance #" << id << " is recursively dependent on " << dependencies->size() << " instances: ";
|
||||
int i;
|
||||
for(i = 0; it != end && i < displayInstances; it++, i++ ) {
|
||||
std::cout << *it << " ";
|
||||
}
|
||||
|
||||
if( dependencies->size() > displayInstances ) {
|
||||
std::cout << ".... (Displaying only " << displayInstances << " instances) ";
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
delete dependencies;
|
||||
}
|
||||
|
||||
///prints info about a complex instance
|
||||
void dumpComplexInst( STEPcomplex * c, unsigned int depth ) {
|
||||
void dumpComplexInst( STEPcomplex * c ) {
|
||||
int depth = 0;
|
||||
if( c ) {
|
||||
std::cout << "attr list size: " << c->_attr_data_list.size() << ", depth " << depth << std::endl;
|
||||
STEPcomplex_attr_data_list::iterator it;
|
||||
for( it = c->_attr_data_list.begin(); it != c->_attr_data_list.end(); it++ ) {
|
||||
std::cout << "*** Not printing complex instance attribute info - many eDesc pointers are invalid. ***" << std::endl; //FIXME!
|
||||
// std::cout << "attr list size: " << c->_attr_data_list.size() << ", depth " << depth << std::endl;
|
||||
// STEPcomplex_attr_data_list::iterator it;
|
||||
// for( it = c->_attr_data_list.begin(); it != c->_attr_data_list.end(); it++ ) {
|
||||
// std::cout << "*** Not printing complex instance attribute info - many eDesc pointers are invalid. ***" << std::endl; //FIXME!
|
||||
// SDAI_Application_instance * attr = ( SDAI_Application_instance * ) *it;
|
||||
// if( attr->IsComplex() ) {
|
||||
// dumpComplexInst( dynamic_cast<STEPcomplex *>( attr ), depth + 1 );
|
||||
// } else if( attr->eDesc > ( void * ) 0xFF ) { //arbitrary number - invalid ones are usually 0x51
|
||||
// std::cout << "attr " << attr->eDesc->Name() << std::endl;
|
||||
// } else {
|
||||
// std::cout << "attr has eDesc with pointer " << attr->eDesc << std::endl;
|
||||
// }
|
||||
STEPcomplex * complex = c->head;
|
||||
while( complex ) {
|
||||
if( complex->IsComplex() ) {
|
||||
std::cout << "Complex component " << complex->getEDesc()->Name() << " at depth " << depth << " with attr list size ";
|
||||
std::cout << complex->_attr_data_list.size() << std::endl;
|
||||
// dumpComplexInst( complex, depth + 1 );
|
||||
} else {
|
||||
//probably won't ever get here...
|
||||
SDAI_Application_instance * ai = dynamic_cast< SDAI_Application_instance * >( complex );
|
||||
if( ai ) {
|
||||
std::cout << "non-complex component at depth " << depth << ", " << ai->getEDesc()->Name() << std::endl;
|
||||
} else {
|
||||
std::cout << "unknown component at depth " << depth << ": " << complex << std::endl;
|
||||
}
|
||||
}
|
||||
complex = complex->sc;
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,6 +154,7 @@ int main( int argc, char ** argv ) {
|
||||
std::cout << ( float )( scanStats.physMemKB * 1000 ) / instances << " bytes per instance)" << std::endl << std::endl;
|
||||
|
||||
fileInfo( *mgr, 0 );
|
||||
//these are just common types
|
||||
countTypeInstances( *mgr, "CARTESIAN_POINT" );
|
||||
countTypeInstances( *mgr, "POSITIVE_LENGTH_MEASURE" );
|
||||
countTypeInstances( *mgr, "VERTEX_POINT" );
|
||||
@@ -127,6 +167,7 @@ int main( int argc, char ** argv ) {
|
||||
// std::cout << "Total types: " << mgr->getNumTypes() << std::endl;
|
||||
|
||||
instWithRef = printRefs( *mgr );
|
||||
printDeps( *mgr );
|
||||
|
||||
#ifndef NO_REGISTRY
|
||||
if( instWithRef ) {
|
||||
@@ -139,9 +180,9 @@ int main( int argc, char ** argv ) {
|
||||
|
||||
instanceTypes_t::cvector * complexInsts = mgr->getInstances( "" );
|
||||
if( complexInsts && complexInsts->size() > 0 ) {
|
||||
std::cout << "loading lazy instance #" << complexInsts->at( 0 ) << "." << std::endl;
|
||||
std::cout << "loading complex instance #" << complexInsts->at( 0 ) << "." << std::endl;
|
||||
STEPcomplex * c = dynamic_cast<STEPcomplex *>( mgr->loadInstance( complexInsts->at( 0 ) ) );
|
||||
dumpComplexInst( c, 0 );
|
||||
dumpComplexInst( c );
|
||||
std::cout << "Number of instances loaded now: " << mgr->loadedInstanceCount() << std::endl;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "Registry.h"
|
||||
#include "sc_strtoull.h"
|
||||
#include "sdaiApplication_instance.h"
|
||||
#include "read_func.h"
|
||||
#include "SdaiSchemaInit.h"
|
||||
@@ -23,6 +24,7 @@
|
||||
sectionReader::sectionReader( lazyFileReader * parent, std::ifstream & file, std::streampos start, sectionID sid ):
|
||||
_lazyFile( parent ), _file( file ), _sectionStart( start ), _sectionID( sid ) {
|
||||
_fileID = _lazyFile->ID();
|
||||
_error = new ErrorDescriptor();
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +82,7 @@ std::streampos sectionReader::findNormalString( const std::string & str, bool se
|
||||
|
||||
|
||||
//NOTE different behavior than const char * GetKeyword( istream & in, const char * delims, ErrorDescriptor & err ) in read_func.cc
|
||||
// returns pointer to the contents of a static std::string
|
||||
const char * sectionReader::getDelimitedKeyword( const char * delimiters ) {
|
||||
static std::string str;
|
||||
char c;
|
||||
@@ -174,9 +177,8 @@ void sectionReader::locateAllInstances() {
|
||||
}
|
||||
|
||||
instanceID sectionReader::readInstanceNumber() {
|
||||
std::streampos start, end;
|
||||
char c;
|
||||
int digits = 0;
|
||||
size_t digits = 0;
|
||||
instanceID id = 0;
|
||||
|
||||
//find instance number ("# nnnn ="), where ' ' is any whitespace found by isspace()
|
||||
@@ -193,35 +195,67 @@ instanceID sectionReader::readInstanceNumber() {
|
||||
return 0;
|
||||
}
|
||||
skipWS();
|
||||
start = _file.tellg();
|
||||
|
||||
// The largest instance ID yet supported is the maximum value of unsigned long long int
|
||||
assert( std::numeric_limits<instanceID>::max() <= std::numeric_limits<unsigned long long int>::max() );
|
||||
|
||||
size_t instanceIDLength = std::numeric_limits<instanceID>::digits10 + 1;
|
||||
char * buffer = new char( instanceIDLength + 1 ); // +1 for the terminating character
|
||||
|
||||
std::stringstream errorMsg;
|
||||
|
||||
do {
|
||||
c = _file.get();
|
||||
if( isdigit( c ) ) {
|
||||
buffer[ digits ] = c; //copy the charcter into the buffer
|
||||
digits++;
|
||||
|
||||
} else {
|
||||
_file.unget();
|
||||
break;
|
||||
}
|
||||
|
||||
if( digits > instanceIDLength ) {
|
||||
errorMsg << "A very large instance ID of string length greater then " << instanceIDLength << " found. Skipping data section " << _sectionID << ".";
|
||||
|
||||
_error->GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
_error->UserMsg( "A very large instance ID encountered" );
|
||||
_error->DetailMsg( errorMsg.str() );
|
||||
|
||||
delete buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} while( _file.good() );
|
||||
buffer[ digits ] = '\0'; //Append the terminating character
|
||||
skipWS();
|
||||
|
||||
if( _file.good() && ( digits > 0 ) && ( _file.get() == '=' ) ) {
|
||||
end = _file.tellg();
|
||||
_file.seekg( start );
|
||||
_file >> id;
|
||||
_file.seekg( end );
|
||||
id = strtoull( buffer, NULL, 10);
|
||||
if( id == std::numeric_limits<instanceID>::max() ) {
|
||||
//Handling those cases where although the number of digits is equal, but the id value is greater then equal to the maximum allowed value.
|
||||
errorMsg << "A very large instance ID caused an overflow. Skipping data section " << _sectionID << ".";
|
||||
|
||||
_error->GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
_error->UserMsg( "A very large instance ID encountered" );
|
||||
_error->DetailMsg( errorMsg.str() );
|
||||
}
|
||||
|
||||
assert( id > 0 );
|
||||
}
|
||||
delete buffer;
|
||||
return id;
|
||||
}
|
||||
|
||||
//TODO: most of the rest of readdata1, all of readdata2
|
||||
/** load an instance and return a pointer to it.
|
||||
* side effect: recursively loads any instances the specified instance depends upon
|
||||
*/
|
||||
SDAI_Application_instance * sectionReader::getRealInstance( const Registry * reg, long int begin, instanceID instance,
|
||||
const std::string & typeName, const std::string & schName, bool header ) {
|
||||
char c;
|
||||
const char * tName = 0, * sName = 0; //these are necessary since typeName and schName are const
|
||||
std::string comment;
|
||||
Severity sev;
|
||||
Severity sev = SEVERITY_NULL;
|
||||
SDAI_Application_instance * inst = 0;
|
||||
|
||||
tName = typeName.c_str();
|
||||
@@ -274,12 +308,13 @@ SDAI_Application_instance * sectionReader::getRealInstance( const Registry * reg
|
||||
if( !comment.empty() ) {
|
||||
inst->AddP21Comment( comment );
|
||||
}
|
||||
assert( inst->eDesc );
|
||||
assert( inst->getEDesc() );
|
||||
_file.seekg( begin );
|
||||
findNormalString( "(" );
|
||||
_file.unget();
|
||||
//TODO do something with 'sev'
|
||||
sev = inst->STEPread( instance, 0, _lazyFile->getInstMgr()->getAdapter(), _file, sName, true, false );
|
||||
//TODO do something with 'sev'
|
||||
inst->InitIAttrs();
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
@@ -289,8 +324,9 @@ STEPcomplex * sectionReader::CreateSubSuperInstance( const Registry * reg, insta
|
||||
ErrorDescriptor err;
|
||||
std::vector<std::string *> typeNames;
|
||||
_file.get(); //move past the first '('
|
||||
skipWS();
|
||||
while( _file.good() && ( _file.peek() != ')' ) ) {
|
||||
typeNames.push_back( new std::string( getDelimitedKeyword( ";( /\\" ) ) );
|
||||
typeNames.push_back( new std::string( getDelimitedKeyword( ";( /\\\n" ) ) );
|
||||
if( typeNames.back()->empty() ) {
|
||||
delete typeNames.back();
|
||||
typeNames.pop_back();
|
||||
@@ -312,6 +348,9 @@ STEPcomplex * sectionReader::CreateSubSuperInstance( const Registry * reg, insta
|
||||
names[ i ] = typeNames[i]->c_str();
|
||||
}
|
||||
//TODO still need the schema name
|
||||
return new STEPcomplex( ( const_cast<Registry *>( reg ) ), ( const char ** ) names, ( int ) fileid /*, schnm*/ );
|
||||
STEPcomplex * sc = new STEPcomplex( ( const_cast<Registry *>( reg ) ), names, ( int ) fileid /*, schnm*/ );
|
||||
delete[] names;
|
||||
//TODO also delete contents of typeNames!
|
||||
return sc;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,27 @@ class SC_LAZYFILE_EXPORT sectionReader {
|
||||
|
||||
virtual const namedLazyInstance nextInstance() = 0;
|
||||
|
||||
/** returns the type string for an instance, read straight from the file
|
||||
* if this function changes, probably need to change nextInstance() as well
|
||||
* don't check errors - they would have been encountered during the initial file scan, and the file is still open so it can't have been modified */
|
||||
const char * getType( long int offset ) {
|
||||
if( offset <= 0 ) {
|
||||
return 0;
|
||||
}
|
||||
_file.seekg( offset );
|
||||
readInstanceNumber();
|
||||
skipWS();
|
||||
return getDelimitedKeyword( ";( /\\" );
|
||||
}
|
||||
|
||||
instanceID readInstanceNumber();
|
||||
|
||||
void seekg( std::streampos pos ) {
|
||||
_file.seekg( pos );
|
||||
}
|
||||
std::streampos tellg() {
|
||||
return _file.tellg();
|
||||
}
|
||||
};
|
||||
|
||||
#endif //SECTIONREADER_H
|
||||
|
||||
@@ -1,78 +1,88 @@
|
||||
|
||||
set(LIBSTEPCORE_SRCS
|
||||
sdaiApplication_instance.cc
|
||||
STEPcomplex.cc
|
||||
STEPattribute.cc
|
||||
STEPattribute.inline.cc
|
||||
sdai.cc
|
||||
sdaiSelect.cc
|
||||
STEPaggregate.cc
|
||||
STEPundefined.cc
|
||||
STEPattributeList.cc
|
||||
SingleLinkList.cc
|
||||
SingleLinkList.inline.cc
|
||||
Registry.inline.cc
|
||||
ExpDict.cc
|
||||
ExpDict.inline.cc
|
||||
read_func.cc
|
||||
collect.cc
|
||||
complexlist.cc
|
||||
entlist.cc
|
||||
multlist.cc
|
||||
orlist.cc
|
||||
entnode.cc
|
||||
non-ors.cc
|
||||
match-ors.cc
|
||||
trynext.cc
|
||||
print.cc
|
||||
instmgr.cc
|
||||
mgrnode.cc
|
||||
mgrnodearray.cc
|
||||
mgrnodelist.cc
|
||||
dispnode.cc
|
||||
dispnodelist.cc
|
||||
needFunc.cc
|
||||
)
|
||||
sdaiApplication_instance.cc
|
||||
STEPcomplex.cc
|
||||
STEPaggregate.cc
|
||||
STEPattribute.cc
|
||||
STEPattribute.inline.cc
|
||||
STEPattributeList.cc
|
||||
STEPinvAttrList.cc
|
||||
STEPundefined.cc
|
||||
sdai.cc
|
||||
sdaiSelect.cc
|
||||
SingleLinkList.cc
|
||||
SingleLinkList.inline.cc
|
||||
Registry.inline.cc
|
||||
ExpDict.cc
|
||||
ExpDict.inline.cc
|
||||
read_func.cc
|
||||
collect.cc
|
||||
complexlist.cc
|
||||
entlist.cc
|
||||
multlist.cc
|
||||
orlist.cc
|
||||
entnode.cc
|
||||
non-ors.cc
|
||||
match-ors.cc
|
||||
trynext.cc
|
||||
print.cc
|
||||
instmgr.cc
|
||||
mgrnode.cc
|
||||
mgrnodearray.cc
|
||||
mgrnodelist.cc
|
||||
dispnode.cc
|
||||
dispnodelist.cc
|
||||
needFunc.cc
|
||||
)
|
||||
|
||||
SET(SC_CLSTEPCORE_HDRS
|
||||
baseType.h
|
||||
complexSupport.h
|
||||
dictdefs.h
|
||||
ExpDict.h
|
||||
read_func.h
|
||||
Registry.h
|
||||
sdaiApplication_instance.h
|
||||
sdai.h
|
||||
sdaiSelect.h
|
||||
SingleLinkList.h
|
||||
STEPaggregate.h
|
||||
STEPattribute.h
|
||||
STEPattributeList.h
|
||||
STEPcomplex.h
|
||||
STEPundefined.h
|
||||
instmgr.h
|
||||
mgrnode.h
|
||||
mgrnodearray.h
|
||||
mgrnodelist.h
|
||||
dispnode.h
|
||||
dispnodelist.h
|
||||
needFunc.h
|
||||
SubSuperIterators.h
|
||||
)
|
||||
set(SC_CLSTEPCORE_HDRS
|
||||
baseType.h
|
||||
complexSupport.h
|
||||
dictdefs.h
|
||||
ExpDict.h
|
||||
read_func.h
|
||||
Registry.h
|
||||
sdaiApplication_instance.h
|
||||
sdai.h
|
||||
sdaiSelect.h
|
||||
SingleLinkList.h
|
||||
STEPaggregate.h
|
||||
STEPattribute.h
|
||||
STEPattributeList.h
|
||||
STEPinvAttrList.h
|
||||
STEPcomplex.h
|
||||
STEPundefined.h
|
||||
instmgr.h
|
||||
mgrnode.h
|
||||
mgrnodearray.h
|
||||
mgrnodelist.h
|
||||
dispnode.h
|
||||
dispnodelist.h
|
||||
needFunc.h
|
||||
SubSuperIterators.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/cldai
|
||||
${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/cldai
|
||||
${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
)
|
||||
|
||||
SC_ADDLIB(stepcore "${LIBSTEPCORE_SRCS}" "steputils;stepdai;base")
|
||||
|
||||
install(FILES ${SC_CLSTEPCORE_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clstepcore)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clstepcore)
|
||||
|
||||
if(SC_ENABLE_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif(SC_ENABLE_TESTING)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
IF(SC_ENABLE_TESTING)
|
||||
ADD_SUBDIRECTORY( test )
|
||||
ENDIF(SC_ENABLE_TESTING)
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
|
||||
#include <ExpDict.h>
|
||||
#include <STEPaggregate.h>
|
||||
#include <Registry.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include <SubSuperIterators.h>
|
||||
|
||||
Explicit_item_id__set::Explicit_item_id__set( int defaultSize ) {
|
||||
_bufsize = defaultSize;
|
||||
@@ -536,9 +537,9 @@ IntAggregate * create_IntAggregate() {
|
||||
return new IntAggregate;
|
||||
}
|
||||
|
||||
const EntityDescriptor * EntityDescItr::NextEntityDesc() {
|
||||
EntityDescriptor * EntityDescItr::NextEntityDesc_nc() {
|
||||
if( cur ) {
|
||||
const EntityDescriptor * ed = cur->EntityDesc();
|
||||
EntityDescriptor * ed = cur->EntityDesc();
|
||||
cur = ( EntityDescLinkNode * )( cur->NextNode() );
|
||||
return ed;
|
||||
}
|
||||
@@ -554,9 +555,9 @@ const AttrDescriptor * AttrDescItr::NextAttrDesc() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Inverse_attribute * InverseAItr::NextInverse_attribute() {
|
||||
Inverse_attribute * InverseAItr::NextInverse_attribute() {
|
||||
if( cur ) {
|
||||
const Inverse_attribute * ia = cur->Inverse_attr();
|
||||
Inverse_attribute * ia = cur->Inverse_attr();
|
||||
cur = ( Inverse_attributeLinkNode * )( cur->NextNode() );
|
||||
return ia;
|
||||
}
|
||||
@@ -811,6 +812,47 @@ EntityDescriptor::~EntityDescriptor() {
|
||||
delete _uniqueness_rules;
|
||||
}
|
||||
|
||||
// initialize one inverse attr; used in InitIAttrs, below
|
||||
void initIAttr( Inverse_attribute * ia, Registry & reg, const char * schNm, const char * name ) {
|
||||
const AttrDescriptor * ad;
|
||||
const char * aid = ia->inverted_attr_id_();
|
||||
const char * eid = ia->inverted_entity_id_();
|
||||
const EntityDescriptor * e = reg.FindEntity( eid, schNm );
|
||||
AttrDescItr adl( e->ExplicitAttr() );
|
||||
while( 0 != ( ad = adl.NextAttrDesc() ) ) {
|
||||
if( !strcmp( aid, ad->Name() ) ) {
|
||||
ia->inverted_attr_( ad );
|
||||
return;
|
||||
}
|
||||
}
|
||||
supertypesIterator sit(e);
|
||||
for( ; !sit.empty(); ++sit ) {
|
||||
AttrDescItr adi( sit.current()->ExplicitAttr() );
|
||||
while( 0 != ( ad = adi.NextAttrDesc() ) ) {
|
||||
if( !strcmp( aid, ad->Name() ) ) {
|
||||
ia->inverted_attr_( ad );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cerr << "Inverse attr " << ia->Name() << " for " << name << ": cannot find AttrDescriptor " << aid << " for entity " << eid << "." << std::endl;
|
||||
//FIXME should we abort? or is there a sensible recovery path?
|
||||
abort();
|
||||
}
|
||||
|
||||
/** initialize inverse attrs
|
||||
* call once per eDesc (once per EXPRESS entity type)
|
||||
* must be called _after_ init_Sdai* functions for any ia->inverted_entity_id_'s
|
||||
*
|
||||
*/
|
||||
void EntityDescriptor::InitIAttrs( Registry & reg, const char * schNm ) {
|
||||
InverseAItr iai( &( InverseAttr() ) );
|
||||
Inverse_attribute * ia;
|
||||
while( 0 != ( ia = iai.NextInverse_attribute() ) ) {
|
||||
initIAttr( ia, reg, schNm, _name );
|
||||
}
|
||||
}
|
||||
|
||||
const char * EntityDescriptor::GenerateExpress( std::string & buf ) const {
|
||||
std::string sstr;
|
||||
int count;
|
||||
@@ -878,7 +920,7 @@ const char * EntityDescriptor::GenerateExpress( std::string & buf ) const {
|
||||
}
|
||||
/////////
|
||||
|
||||
InverseAItr iai( _inverseAttr );
|
||||
InverseAItr iai( &_inverseAttr );
|
||||
|
||||
iai.ResetItr();
|
||||
const Inverse_attribute * ia = iai.NextInverse_attribute();
|
||||
|
||||
+98
-45
@@ -172,7 +172,11 @@ class SC_CORE_EXPORT EntityDescItr {
|
||||
cur = ( EntityDescLinkNode * )( edl.GetHead() );
|
||||
}
|
||||
|
||||
const EntityDescriptor * NextEntityDesc();
|
||||
inline const EntityDescriptor * NextEntityDesc() {
|
||||
return NextEntityDesc_nc();
|
||||
}
|
||||
EntityDescriptor * NextEntityDesc_nc();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -664,6 +668,7 @@ class SC_CORE_EXPORT Schema : public Dictionary_instance {
|
||||
protected:
|
||||
const char * _name;
|
||||
EntityDescriptorList _entList; // list of entities in the schema
|
||||
EntityDescriptorList _entsWithInverseAttrs;
|
||||
TypeDescriptorList _typeList; // list of types in the schema
|
||||
TypeDescriptorList _unnamed_typeList; // list of unnamed types in the schema (for cleanup)
|
||||
Interface_spec _interface; // list of USE and REF interfaces (SDAI)
|
||||
@@ -729,15 +734,43 @@ class SC_CORE_EXPORT Schema : public Dictionary_instance {
|
||||
EntityDescLinkNode * AddEntity( EntityDescriptor * ed ) {
|
||||
return _entList.AddNode( ed );
|
||||
}
|
||||
/// must be called in addition to AddEntity()
|
||||
EntityDescLinkNode * AddEntityWInverse( EntityDescriptor * ed ) {
|
||||
return _entsWithInverseAttrs.AddNode( ed );
|
||||
}
|
||||
|
||||
TypeDescLinkNode * AddType( TypeDescriptor * td ) {
|
||||
return _typeList.AddNode( td );
|
||||
}
|
||||
|
||||
TypeDescLinkNode * AddUnnamedType( TypeDescriptor * td ) {
|
||||
return _unnamed_typeList.AddNode( td );
|
||||
}
|
||||
|
||||
const EntityDescriptorList * Entities() const {
|
||||
return & _entList;
|
||||
}
|
||||
const EntityDescriptorList * EntsWInverse() const {
|
||||
return & _entsWithInverseAttrs;
|
||||
}
|
||||
const TypeDescriptorList * Types() const {
|
||||
return & _typeList;
|
||||
}
|
||||
const TypeDescriptorList * UnnamedTypes() const {
|
||||
return & _unnamed_typeList;
|
||||
}
|
||||
EntityDescriptorList * Entities() {
|
||||
return & _entList;
|
||||
}
|
||||
EntityDescriptorList * EntsWInverse() {
|
||||
return & _entsWithInverseAttrs;
|
||||
}
|
||||
TypeDescriptorList * Types() {
|
||||
return & _typeList;
|
||||
}
|
||||
TypeDescriptorList * UnnamedTypes() {
|
||||
return & _unnamed_typeList;
|
||||
}
|
||||
|
||||
// the whole schema
|
||||
void GenerateExpress( ostream & out ) const;
|
||||
|
||||
@@ -811,7 +844,7 @@ class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode {
|
||||
Inverse_attributeLinkNode();
|
||||
virtual ~Inverse_attributeLinkNode();
|
||||
|
||||
const Inverse_attribute * Inverse_attr() const {
|
||||
Inverse_attribute * Inverse_attr() const {
|
||||
return _invAttr;
|
||||
}
|
||||
void Inverse_attr( Inverse_attribute * ia ) {
|
||||
@@ -822,30 +855,32 @@ class SC_CORE_EXPORT Inverse_attributeLinkNode : public SingleLinkNode {
|
||||
class SC_CORE_EXPORT Inverse_attributeList : public SingleLinkList {
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
Inverse_attributeList();
|
||||
virtual ~Inverse_attributeList();
|
||||
|
||||
virtual SingleLinkNode * NewNode() {
|
||||
return new Inverse_attributeLinkNode;
|
||||
}
|
||||
public:
|
||||
Inverse_attributeList();
|
||||
virtual ~Inverse_attributeList();
|
||||
Inverse_attributeLinkNode * AddNode( Inverse_attribute * ia );
|
||||
};
|
||||
|
||||
class SC_CORE_EXPORT InverseAItr {
|
||||
protected:
|
||||
const Inverse_attributeList & ial;
|
||||
const Inverse_attributeList * ial;
|
||||
const Inverse_attributeLinkNode * cur;
|
||||
|
||||
public:
|
||||
InverseAItr( const Inverse_attributeList & iaList );
|
||||
InverseAItr( const Inverse_attributeList * iaList );
|
||||
virtual ~InverseAItr();
|
||||
|
||||
void ResetItr() {
|
||||
cur = ( Inverse_attributeLinkNode * )( ial.GetHead() );
|
||||
void ResetItr( const Inverse_attributeList * iaList = 0 ) {
|
||||
if( iaList ) {
|
||||
ial = iaList;
|
||||
}
|
||||
cur = ( Inverse_attributeLinkNode * )( ial->GetHead() );
|
||||
}
|
||||
|
||||
const Inverse_attribute * NextInverse_attribute();
|
||||
Inverse_attribute * NextInverse_attribute();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -889,34 +924,44 @@ class SC_CORE_EXPORT AttrDescriptor {
|
||||
_name = n;
|
||||
}
|
||||
|
||||
// BaseType() is the underlying type of this attribute.
|
||||
// NonRefType() is the first non REFERENCE_TYPE type
|
||||
// e.g. Given attributes of each of the following types
|
||||
// TYPE count = INTEGER;
|
||||
// TYPE ref_count = count;
|
||||
// TYPE count_set = SET OF ref_count;
|
||||
// BaseType() will return INTEGER_TYPE for an attr of each type.
|
||||
// BaseTypeDescriptor() returns the TypeDescriptor for Integer
|
||||
// NonRefType() will return INTEGER_TYPE for the first two. For an
|
||||
// attribute of type count_set NonRefType() would return
|
||||
// AGGREGATE_TYPE
|
||||
// NonRefTypeDescriptor() returns the TypeDescriptor for Integer
|
||||
// for the first two and a TypeDescriptor for an
|
||||
// aggregate for the last.
|
||||
|
||||
/** BaseType() is the underlying type of this attribute.
|
||||
* NonRefType() is the first non REFERENCE_TYPE type
|
||||
* e.g. Given attributes of each of the following types
|
||||
* TYPE count = INTEGER;
|
||||
* TYPE ref_count = count;
|
||||
* TYPE count_set = SET OF ref_count;
|
||||
* BaseType() will return INTEGER_TYPE for an attr of each type.
|
||||
* BaseTypeDescriptor() returns the TypeDescriptor for Integer
|
||||
* NonRefType() will return INTEGER_TYPE for the first two. For an
|
||||
* attribute of type count_set NonRefType() would return
|
||||
* AGGREGATE_TYPE
|
||||
* NonRefTypeDescriptor() returns the TypeDescriptor for Integer
|
||||
* for the first two and a TypeDescriptor for an
|
||||
* aggregate for the last.
|
||||
*
|
||||
* \sa NonRefType()
|
||||
* \sa NonRefTypeDescriptor()
|
||||
*/
|
||||
///@{
|
||||
PrimitiveType BaseType() const;
|
||||
const TypeDescriptor * BaseTypeDescriptor() const;
|
||||
///@}
|
||||
|
||||
// the first PrimitiveType that is not REFERENCE_TYPE (the first
|
||||
// TypeDescriptor *_referentType that does not have REFERENCE_TYPE
|
||||
// for it's fundamentalType variable). This would return the same
|
||||
// as BaseType() for fundamental types. An aggregate type
|
||||
// would return AGGREGATE_TYPE then you could find out the type of
|
||||
// an element by calling AggrElemType(). Select types
|
||||
// would work the same?
|
||||
|
||||
/**
|
||||
* the first PrimitiveType that is not REFERENCE_TYPE (the first
|
||||
* TypeDescriptor *_referentType that does not have REFERENCE_TYPE
|
||||
* for it's fundamentalType variable). This would return the same
|
||||
* as BaseType() for fundamental types. An aggregate type
|
||||
* would return AGGREGATE_TYPE then you could find out the type of
|
||||
* an element by calling AggrElemType(). Select types
|
||||
* would work the same?
|
||||
*
|
||||
* \sa BaseType()
|
||||
*/
|
||||
///@{
|
||||
PrimitiveType NonRefType() const;
|
||||
const TypeDescriptor * NonRefTypeDescriptor() const;
|
||||
///@}
|
||||
|
||||
int IsAggrType() const;
|
||||
PrimitiveType AggrElemType() const;
|
||||
@@ -1063,7 +1108,7 @@ class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor {
|
||||
const char * _inverted_attr_id;
|
||||
const char * _inverted_entity_id;
|
||||
protected:
|
||||
AttrDescriptor * _inverted_attr; // not implemented
|
||||
const AttrDescriptor * _inverted_attr; // not implemented (?!) (perhaps this means "not used"?)
|
||||
public:
|
||||
|
||||
Inverse_attribute(
|
||||
@@ -1098,22 +1143,23 @@ class SC_CORE_EXPORT Inverse_attribute : public AttrDescriptor {
|
||||
_inverted_entity_id = iei;
|
||||
}
|
||||
|
||||
/// FIXME not implemented
|
||||
class AttrDescriptor * inverted_attr_() {
|
||||
/// FIXME not implemented (?!) (perhaps this means "not set"?)
|
||||
//set _inverted_attr in an extra init step in generated code? any other way to ensure pointers are valid?
|
||||
const class AttrDescriptor * inverted_attr_() const {
|
||||
return _inverted_attr;
|
||||
}
|
||||
|
||||
void inverted_attr_( AttrDescriptor * ia ) {
|
||||
void inverted_attr_( const AttrDescriptor * ia ) {
|
||||
_inverted_attr = ia;
|
||||
}
|
||||
|
||||
// below are obsolete (and not implemented anyway)
|
||||
class AttrDescriptor * InverseAttribute() {
|
||||
return _inverted_attr;
|
||||
}
|
||||
void InverseOf( AttrDescriptor * invAttr ) {
|
||||
_inverted_attr = invAttr;
|
||||
}
|
||||
// class AttrDescriptor * InverseAttribute() {
|
||||
// return _inverted_attr;
|
||||
// }
|
||||
// void InverseOf( AttrDescriptor * invAttr ) {
|
||||
// _inverted_attr = invAttr;
|
||||
// }
|
||||
};
|
||||
|
||||
/** \class SchRename
|
||||
@@ -1464,9 +1510,14 @@ class SC_CORE_EXPORT EnumTypeDescriptor : public TypeDescriptor {
|
||||
* will be building the same thing but using the new schema info.
|
||||
* nodes (i.e. EntityDesc nodes) for each entity.
|
||||
*/
|
||||
|
||||
class Registry;
|
||||
|
||||
class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor {
|
||||
|
||||
protected:
|
||||
//used in InitIAttrs so we don't have to #include registry.h
|
||||
|
||||
SDAI_LOGICAL _abstractEntity;
|
||||
SDAI_LOGICAL _extMapping;
|
||||
// does external mapping have to be used to create an instance of
|
||||
@@ -1493,6 +1544,8 @@ class SC_CORE_EXPORT EntityDescriptor : public TypeDescriptor {
|
||||
|
||||
virtual ~EntityDescriptor();
|
||||
|
||||
void InitIAttrs( Registry & reg, const char * schNm );
|
||||
|
||||
const char * GenerateExpress( std::string & buf ) const;
|
||||
|
||||
const char * QualifiedName( std::string & s ) const;
|
||||
|
||||
@@ -162,9 +162,9 @@ Inverse_attributeLinkNode * Inverse_attributeList::AddNode( Inverse_attribute *
|
||||
return node;
|
||||
}
|
||||
|
||||
InverseAItr::InverseAItr( const Inverse_attributeList & iaList )
|
||||
InverseAItr::InverseAItr( const Inverse_attributeList * iaList )
|
||||
: ial( iaList ) {
|
||||
cur = ( Inverse_attributeLinkNode * )( ial.GetHead() );
|
||||
cur = ( Inverse_attributeLinkNode * )( ial->GetHead() );
|
||||
}
|
||||
|
||||
InverseAItr::~InverseAItr() {
|
||||
|
||||
@@ -324,7 +324,7 @@ SDAI_Application_instance * Registry::ObjCreate( const char * nm, const char * s
|
||||
se->Error().severity( SEVERITY_WARNING );
|
||||
se->Error().UserMsg( "ENTITY requires external mapping" );
|
||||
}
|
||||
se->eDesc = entd;
|
||||
se->setEDesc( entd );
|
||||
return se;
|
||||
} else {
|
||||
return ENTITY_NULL;
|
||||
|
||||
@@ -58,7 +58,7 @@ STEPaggregate & STEPaggregate::ShallowCopy( const STEPaggregate & a ) {
|
||||
|
||||
/// do not require exchange file format
|
||||
Severity STEPaggregate::AggrValidLevel( const char * value, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int optional, char * tokenList, int addFileId,
|
||||
int clearError ) {
|
||||
std::string buf;
|
||||
@@ -78,7 +78,7 @@ Severity STEPaggregate::AggrValidLevel( const char * value, ErrorDescriptor * er
|
||||
|
||||
/// require exchange file format
|
||||
Severity STEPaggregate::AggrValidLevel( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int optional, char * tokenList, int addFileId,
|
||||
int clearError ) {
|
||||
std::string buf;
|
||||
@@ -97,7 +97,7 @@ Severity STEPaggregate::AggrValidLevel( istream & in, ErrorDescriptor * err,
|
||||
/// if exchangeFileFormat == 1 then paren delims are required.
|
||||
|
||||
Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int addFileId, int assignVal, int exchangeFileFormat,
|
||||
const char * ) {
|
||||
(void) insts; //not used in ReadValue() for this class
|
||||
@@ -203,7 +203,7 @@ Severity STEPaggregate::ReadValue( istream & in, ErrorDescriptor * err,
|
||||
}
|
||||
|
||||
Severity STEPaggregate::StrToVal( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int addFileId ) {
|
||||
istringstream in( ( char * )s );
|
||||
return ReadValue( in, err, elem_type, insts, addFileId, 1, 0 );
|
||||
@@ -212,7 +212,7 @@ Severity STEPaggregate::StrToVal( const char * s, ErrorDescriptor * err,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Severity STEPaggregate::STEPread( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int addFileId, const char * currSch ) {
|
||||
return ReadValue( in, err, elem_type, insts, addFileId, 1, 1, currSch );
|
||||
}
|
||||
@@ -476,7 +476,7 @@ EntityAggregate::~EntityAggregate() {
|
||||
|
||||
/// if exchangeFileFormat == 1 then delims are required.
|
||||
Severity EntityAggregate::ReadValue( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int addFileId, int assignVal,
|
||||
int exchangeFileFormat, const char * ) {
|
||||
ErrorDescriptor errdesc;
|
||||
@@ -618,7 +618,7 @@ SingleLinkNode * EntityNode::NewNode() {
|
||||
|
||||
Severity EntityNode::StrToVal( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId ) {
|
||||
InstMgrBase * insts, int addFileId ) {
|
||||
SDAI_Application_instance * se = ReadEntityRef( s, err, ",)", insts,
|
||||
addFileId );
|
||||
if( se != S_ENTITY_NULL ) {
|
||||
@@ -639,20 +639,20 @@ Severity EntityNode::StrToVal( const char * s, ErrorDescriptor * err,
|
||||
|
||||
Severity EntityNode::StrToVal( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId ) {
|
||||
InstMgrBase * insts, int addFileId ) {
|
||||
return STEPread( in, err, elem_type, insts, addFileId );
|
||||
}
|
||||
|
||||
Severity EntityNode::STEPread( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId ) {
|
||||
InstMgrBase * insts, int addFileId ) {
|
||||
istringstream in( ( char * )s );
|
||||
return STEPread( in, err, elem_type, insts, addFileId );
|
||||
}
|
||||
|
||||
Severity EntityNode::STEPread( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId ) {
|
||||
InstMgrBase * insts, int addFileId ) {
|
||||
SDAI_Application_instance * se = ReadEntityRef( in, err, ",)", insts,
|
||||
addFileId );
|
||||
if( se != S_ENTITY_NULL ) {
|
||||
@@ -714,7 +714,7 @@ SelectAggregate::~SelectAggregate() {
|
||||
|
||||
/// if exchangeFileFormat == 1 then delims are required.
|
||||
Severity SelectAggregate::ReadValue( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int addFileId, int assignVal,
|
||||
int exchangeFileFormat, const char * currSch ) {
|
||||
ErrorDescriptor errdesc;
|
||||
@@ -858,7 +858,7 @@ SingleLinkNode * SelectNode::NewNode() {
|
||||
|
||||
Severity SelectNode::StrToVal( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId ) {
|
||||
InstMgrBase * insts, int addFileId ) {
|
||||
(void) elem_type; //unused
|
||||
(void) addFileId; //unused
|
||||
istringstream in( ( char * )s );
|
||||
@@ -870,20 +870,20 @@ Severity SelectNode::StrToVal( const char * s, ErrorDescriptor * err,
|
||||
|
||||
Severity SelectNode::StrToVal( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId, const char * currSch ) {
|
||||
InstMgrBase * insts, int addFileId, const char * currSch ) {
|
||||
return STEPread( in, err, elem_type, insts, addFileId, currSch );
|
||||
}
|
||||
|
||||
Severity SelectNode::STEPread( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId ) {
|
||||
InstMgrBase * insts, int addFileId ) {
|
||||
istringstream in( ( char * )s );
|
||||
return STEPread( in, err, elem_type, insts, addFileId );
|
||||
}
|
||||
|
||||
Severity SelectNode::STEPread( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId, const char * currSch ) {
|
||||
InstMgrBase * insts, int addFileId, const char * currSch ) {
|
||||
(void) elem_type; //unused
|
||||
if( !node ) {
|
||||
cerr << "Internal error: " << __FILE__ << ": " << __LINE__ << "\n"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* and is not subject to copyright.
|
||||
*/
|
||||
|
||||
class InstMgr;
|
||||
class InstMgrBase;
|
||||
class STEPaggregate;
|
||||
class TypeDescriptor;
|
||||
|
||||
@@ -42,7 +42,7 @@ class SC_CORE_EXPORT STEPaggregate : public SingleLinkList {
|
||||
|
||||
virtual Severity ReadValue( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0,
|
||||
InstMgrBase * insts, int addFileId = 0,
|
||||
int assignVal = 1, int ExchangeFileFormat = 1,
|
||||
const char * currSch = 0 );
|
||||
public:
|
||||
@@ -52,22 +52,22 @@ class SC_CORE_EXPORT STEPaggregate : public SingleLinkList {
|
||||
}
|
||||
|
||||
virtual Severity AggrValidLevel( const char * value, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int optional, char * tokenList, int addFileId = 0,
|
||||
int clearError = 0 );
|
||||
|
||||
virtual Severity AggrValidLevel( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type, InstMgr * insts,
|
||||
const TypeDescriptor * elem_type, InstMgrBase * insts,
|
||||
int optional, char * tokenList, int addFileId = 0,
|
||||
int clearError = 0 );
|
||||
|
||||
// INPUT
|
||||
virtual Severity StrToVal( const char * s, ErrorDescriptor * err = 0,
|
||||
const TypeDescriptor * elem_type = 0,
|
||||
InstMgr * insts = 0, int addFileId = 0 );
|
||||
InstMgrBase * insts = 0, int addFileId = 0 );
|
||||
virtual Severity STEPread( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type = 0,
|
||||
InstMgr * insts = 0, int addFileId = 0,
|
||||
InstMgrBase * insts = 0, int addFileId = 0,
|
||||
const char * currSch = 0 );
|
||||
// OUTPUT
|
||||
virtual const char * asStr( std::string & s ) const;
|
||||
@@ -88,6 +88,7 @@ class SC_CORE_EXPORT STEPaggregate : public SingleLinkList {
|
||||
** \class GenericAggregate
|
||||
** This class supports LIST OF:
|
||||
** SELECT_TYPE, BINARY_TYPE, GENERIC_TYPE, ENUM_TYPE, UNKNOWN_TYPE type
|
||||
** FIXME this class, as well as SelectAggregate, for SELECTs?!
|
||||
******************************************************************/
|
||||
class SC_CORE_EXPORT GenericAggregate : public STEPaggregate {
|
||||
public:
|
||||
@@ -97,9 +98,10 @@ class SC_CORE_EXPORT GenericAggregate : public STEPaggregate {
|
||||
GenericAggregate();
|
||||
virtual ~GenericAggregate();
|
||||
};
|
||||
typedef GenericAggregate * GenericAggregateH;
|
||||
typedef GenericAggregate * GenericAggregate_ptr;
|
||||
typedef GenericAggregate_ptr GenericAggregate_var;
|
||||
typedef GenericAggregate * GenericAggregateH;
|
||||
typedef GenericAggregate * GenericAggregate_ptr;
|
||||
typedef const GenericAggregate * GenericAggregate_ptr_c;
|
||||
typedef GenericAggregate_ptr GenericAggregate_var;
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
@@ -109,7 +111,7 @@ class SC_CORE_EXPORT EntityAggregate : public STEPaggregate {
|
||||
public:
|
||||
virtual Severity ReadValue( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0,
|
||||
InstMgrBase * insts, int addFileId = 0,
|
||||
int assignVal = 1, int ExchangeFileFormat = 1,
|
||||
const char * currSch = 0 );
|
||||
|
||||
@@ -119,9 +121,10 @@ class SC_CORE_EXPORT EntityAggregate : public STEPaggregate {
|
||||
EntityAggregate();
|
||||
virtual ~EntityAggregate();
|
||||
};
|
||||
typedef EntityAggregate * EntityAggregateH;
|
||||
typedef EntityAggregate * EntityAggregate_ptr;
|
||||
typedef EntityAggregate_ptr EntityAggregate_var;
|
||||
typedef EntityAggregate * EntityAggregateH;
|
||||
typedef EntityAggregate * EntityAggregate_ptr;
|
||||
typedef const EntityAggregate * EntityAggregate_ptr_c;
|
||||
typedef EntityAggregate_ptr EntityAggregate_var;
|
||||
|
||||
/****************************************************************//**
|
||||
** \class SelectAggregate
|
||||
@@ -131,7 +134,7 @@ class SC_CORE_EXPORT SelectAggregate : public STEPaggregate {
|
||||
public:
|
||||
virtual Severity ReadValue( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0,
|
||||
InstMgrBase * insts, int addFileId = 0,
|
||||
int assignVal = 1, int ExchangeFileFormat = 1,
|
||||
const char * currSch = 0 );
|
||||
|
||||
@@ -141,9 +144,10 @@ class SC_CORE_EXPORT SelectAggregate : public STEPaggregate {
|
||||
SelectAggregate();
|
||||
virtual ~SelectAggregate();
|
||||
};
|
||||
typedef SelectAggregate * SelectAggregateH;
|
||||
typedef SelectAggregate * SelectAggregate_ptr;
|
||||
typedef SelectAggregate_ptr SelectAggregate_var;
|
||||
typedef SelectAggregate * SelectAggregateH;
|
||||
typedef SelectAggregate * SelectAggregate_ptr;
|
||||
typedef const SelectAggregate * SelectAggregate_ptr_c;
|
||||
typedef SelectAggregate_ptr SelectAggregate_var;
|
||||
|
||||
/****************************************************************//**
|
||||
** \class StringAggregate
|
||||
@@ -157,9 +161,10 @@ class SC_CORE_EXPORT StringAggregate : public STEPaggregate {
|
||||
StringAggregate();
|
||||
virtual ~StringAggregate();
|
||||
};
|
||||
typedef StringAggregate * StringAggregateH;
|
||||
typedef StringAggregate * StringAggregate_ptr;
|
||||
typedef StringAggregate_ptr StringAggregate_var;
|
||||
typedef StringAggregate * StringAggregateH;
|
||||
typedef StringAggregate * StringAggregate_ptr;
|
||||
typedef const StringAggregate * StringAggregate_ptr_c;
|
||||
typedef StringAggregate_ptr StringAggregate_var;
|
||||
|
||||
|
||||
/****************************************************************//**
|
||||
@@ -174,9 +179,10 @@ class SC_CORE_EXPORT BinaryAggregate : public STEPaggregate {
|
||||
BinaryAggregate();
|
||||
virtual ~BinaryAggregate();
|
||||
};
|
||||
typedef BinaryAggregate * BinaryAggregateH;
|
||||
typedef BinaryAggregate * BinaryAggregate_ptr;
|
||||
typedef BinaryAggregate_ptr BinaryAggregate_var;
|
||||
typedef BinaryAggregate * BinaryAggregateH;
|
||||
typedef BinaryAggregate * BinaryAggregate_ptr;
|
||||
typedef const BinaryAggregate * BinaryAggregate_ptr_c;
|
||||
typedef BinaryAggregate_ptr BinaryAggregate_var;
|
||||
|
||||
/**************************************************************//**
|
||||
** \class EnumAggregate
|
||||
@@ -190,9 +196,10 @@ class SC_CORE_EXPORT EnumAggregate : public STEPaggregate {
|
||||
EnumAggregate();
|
||||
virtual ~EnumAggregate();
|
||||
};
|
||||
typedef EnumAggregate * EnumAggregateH;
|
||||
typedef EnumAggregate * EnumAggregate_ptr;
|
||||
typedef EnumAggregate_ptr EnumAggregate_var;
|
||||
typedef EnumAggregate * EnumAggregateH;
|
||||
typedef EnumAggregate * EnumAggregate_ptr;
|
||||
typedef const EnumAggregate * EnumAggregate_ptr_c;
|
||||
typedef EnumAggregate_ptr EnumAggregate_var;
|
||||
|
||||
class SC_CORE_EXPORT LOGICALS : public EnumAggregate {
|
||||
public:
|
||||
@@ -201,9 +208,10 @@ class SC_CORE_EXPORT LOGICALS : public EnumAggregate {
|
||||
LOGICALS();
|
||||
virtual ~LOGICALS();
|
||||
};
|
||||
typedef LOGICALS * LogicalsH;
|
||||
typedef LOGICALS * LOGICALS_ptr;
|
||||
typedef LOGICALS_ptr LOGICALS_var;
|
||||
typedef LOGICALS * LogicalsH;
|
||||
typedef LOGICALS * LOGICALS_ptr;
|
||||
typedef const LOGICALS * LOGICALS_ptr_c;
|
||||
typedef LOGICALS_ptr LOGICALS_var;
|
||||
SC_CORE_EXPORT LOGICALS * create_LOGICALS();
|
||||
|
||||
|
||||
@@ -215,8 +223,9 @@ class SC_CORE_EXPORT BOOLEANS : public EnumAggregate {
|
||||
virtual ~BOOLEANS();
|
||||
};
|
||||
|
||||
typedef BOOLEANS * BOOLEANS_ptr;
|
||||
typedef BOOLEANS_ptr BOOLEANS_var;
|
||||
typedef BOOLEANS * BOOLEANS_ptr;
|
||||
typedef const BOOLEANS * BOOLEANS_ptr_c;
|
||||
typedef BOOLEANS_ptr BOOLEANS_var;
|
||||
|
||||
SC_CORE_EXPORT BOOLEANS * create_BOOLEANS();
|
||||
|
||||
@@ -229,9 +238,10 @@ class SC_CORE_EXPORT RealAggregate : public STEPaggregate {
|
||||
RealAggregate();
|
||||
virtual ~RealAggregate();
|
||||
};
|
||||
typedef RealAggregate * RealAggregateH;
|
||||
typedef RealAggregate * RealAggregate_ptr;
|
||||
typedef RealAggregate_ptr RealAggregate_var;
|
||||
typedef RealAggregate * RealAggregateH;
|
||||
typedef RealAggregate * RealAggregate_ptr;
|
||||
typedef const RealAggregate * RealAggregate_ptr_c;
|
||||
typedef RealAggregate_ptr RealAggregate_var;
|
||||
|
||||
class SC_CORE_EXPORT IntAggregate : public STEPaggregate {
|
||||
|
||||
@@ -242,9 +252,10 @@ class SC_CORE_EXPORT IntAggregate : public STEPaggregate {
|
||||
IntAggregate();
|
||||
virtual ~IntAggregate();
|
||||
};
|
||||
typedef IntAggregate * IntAggregateH;
|
||||
typedef IntAggregate * IntAggregate_ptr;
|
||||
typedef IntAggregate_ptr IntAggregate_var;
|
||||
typedef IntAggregate * IntAggregateH;
|
||||
typedef IntAggregate * IntAggregate_ptr;
|
||||
typedef const IntAggregate * IntAggregate_ptr_c;
|
||||
typedef IntAggregate_ptr IntAggregate_var;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -311,17 +322,17 @@ class SC_CORE_EXPORT EntityNode : public STEPnode {
|
||||
// INPUT
|
||||
virtual Severity StrToVal( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0 );
|
||||
InstMgrBase * insts, int addFileId = 0 );
|
||||
virtual Severity StrToVal( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0 );
|
||||
InstMgrBase * insts, int addFileId = 0 );
|
||||
|
||||
virtual Severity STEPread( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0 );
|
||||
InstMgrBase * insts, int addFileId = 0 );
|
||||
virtual Severity STEPread( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0 );
|
||||
InstMgrBase * insts, int addFileId = 0 );
|
||||
// OUTPUT
|
||||
virtual const char * asStr( std::string & s );
|
||||
virtual const char * STEPwrite( std::string & s, const char * = 0 );
|
||||
@@ -370,18 +381,18 @@ class SC_CORE_EXPORT SelectNode : public STEPnode {
|
||||
// INPUT
|
||||
virtual Severity StrToVal( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0 );
|
||||
InstMgrBase * insts, int addFileId = 0 );
|
||||
virtual Severity StrToVal( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0,
|
||||
InstMgrBase * insts, int addFileId = 0,
|
||||
const char * currSch = 0 );
|
||||
|
||||
virtual Severity STEPread( const char * s, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0 );
|
||||
InstMgrBase * insts, int addFileId = 0 );
|
||||
virtual Severity STEPread( istream & in, ErrorDescriptor * err,
|
||||
const TypeDescriptor * elem_type,
|
||||
InstMgr * insts, int addFileId = 0,
|
||||
InstMgrBase * insts, int addFileId = 0,
|
||||
const char * currSch = 0 );
|
||||
// OUTPUT
|
||||
virtual const char * asStr( std::string & s );
|
||||
|
||||
@@ -46,7 +46,7 @@ const int Real_Num_Precision = REAL_NUM_PRECISION;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// the value of the attribute is assigned from the supplied string
|
||||
Severity STEPattribute::StrToVal( const char * s, InstMgr * instances, int addFileId ) {
|
||||
Severity STEPattribute::StrToVal( const char * s, InstMgrBase * instances, int addFileId ) {
|
||||
if( _redefAttr ) {
|
||||
return _redefAttr->StrToVal( s, instances, addFileId );
|
||||
}
|
||||
@@ -194,7 +194,7 @@ Severity STEPattribute::StrToVal( const char * s, InstMgr * instances, int addFi
|
||||
** value >= SEVERITY_WARNING means program can continue parsing input,
|
||||
** value <= SEVERITY_INPUT_ERROR is fatal read error
|
||||
******************************************************************/
|
||||
Severity STEPattribute::STEPread( istream & in, InstMgr * instances, int addFileId,
|
||||
Severity STEPattribute::STEPread( istream & in, InstMgrBase * instances, int addFileId,
|
||||
const char * currSch, bool strict ) {
|
||||
|
||||
// The attribute has been redefined by the attribute pointed
|
||||
@@ -750,22 +750,18 @@ Severity STEPattribute::set_null() {
|
||||
|
||||
case REFERENCE_TYPE:
|
||||
case GENERIC_TYPE:
|
||||
cerr << "Internal error: " << __FILE__ << __LINE__
|
||||
<< "\n" << _POC_ "\n";
|
||||
cerr << "Internal error: " << __FILE__ << ":" << __LINE__ << "\n" << _POC_ "\n";
|
||||
return SEVERITY_BUG;
|
||||
|
||||
case UNKNOWN_TYPE:
|
||||
default: {
|
||||
default:
|
||||
ptr.u -> set_null();
|
||||
char errStr[BUFSIZ];
|
||||
errStr[0] = '\0';
|
||||
sprintf( errStr, " Warning: attribute '%s : %s : %d' - %s.\n",
|
||||
Name(), TypeName(), Type(),
|
||||
"Don't know how to make attribute NULL" );
|
||||
_error.AppendToDetailMsg( errStr );
|
||||
std::stringstream err;
|
||||
err << " Warning: attribute '" << Name() << " : " << TypeName() << " : ";
|
||||
err << Type() << "' - " << "Don't know how to make attribute NULL" << std::endl;
|
||||
_error.AppendToDetailMsg( err.str() );
|
||||
_error.GreaterSeverity( SEVERITY_WARNING );
|
||||
return SEVERITY_WARNING;
|
||||
}
|
||||
}
|
||||
if( Nullable() ) {
|
||||
return SEVERITY_NULL;
|
||||
@@ -1052,6 +1048,14 @@ bool operator == ( const STEPattribute & a1, const STEPattribute & a2 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** evaluate the equality of two attributes
|
||||
* ignores _error and refCount, since those are ancillary
|
||||
* \return true if not equal
|
||||
*/
|
||||
bool operator != ( const STEPattribute & a1, const STEPattribute & a2 ) {
|
||||
return !( a1 == a2 );
|
||||
}
|
||||
|
||||
/// return true if the attr descriptor is identical
|
||||
bool sameADesc( const STEPattribute & a1, const STEPattribute & a2 ) {
|
||||
return a1.aDesc == a2.aDesc;
|
||||
@@ -1065,7 +1069,7 @@ bool sameADesc( const STEPattribute & a1, const STEPattribute & a2 ) {
|
||||
* *note* for string values - (attrValue = 0) => string value does not exist,
|
||||
* attrValue exists it is valid.
|
||||
******************************************************************/
|
||||
Severity STEPattribute::ValidLevel( const char * attrValue, ErrorDescriptor * error, InstMgr * im, bool clearError ) {
|
||||
Severity STEPattribute::ValidLevel( const char * attrValue, ErrorDescriptor * error, InstMgrBase * im, bool clearError ) {
|
||||
if( clearError ) {
|
||||
ClearErrorMsg();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
typedef double real;
|
||||
|
||||
class InstMgr;
|
||||
class InstMgrBase;
|
||||
class SDAI_Application_instance;
|
||||
class STEPaggregate;
|
||||
class SCLundefined;
|
||||
@@ -42,10 +42,10 @@ class EntityDescriptor;
|
||||
extern SC_CORE_EXPORT int SetErrOnNull( const char * attrValue, ErrorDescriptor * error );
|
||||
|
||||
extern SC_CORE_EXPORT SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList,
|
||||
InstMgr * instances, int addFileId );
|
||||
InstMgrBase * instances, int addFileId );
|
||||
|
||||
extern SC_CORE_EXPORT SDAI_Application_instance * ReadEntityRef( const char * s, ErrorDescriptor * err, const char * tokenList,
|
||||
InstMgr * instances, int addFileId );
|
||||
InstMgrBase * instances, int addFileId );
|
||||
|
||||
extern SC_CORE_EXPORT Severity EntityValidLevel( SDAI_Application_instance * se,
|
||||
const TypeDescriptor * ed, ///< entity type that entity se needs to match. (this must be an EntityDescriptor)
|
||||
@@ -55,13 +55,13 @@ extern SC_CORE_EXPORT Severity EntityValidLevel( const char * attrValue, ///< st
|
||||
const TypeDescriptor * ed, /**< entity type that entity in attrValue (if it exists) needs
|
||||
* to match. (this must be an EntityDescriptor)
|
||||
*/
|
||||
ErrorDescriptor * err, InstMgr * im, int clearError );
|
||||
ErrorDescriptor * err, InstMgrBase * im, int clearError );
|
||||
|
||||
////////////////////
|
||||
////////////////////
|
||||
|
||||
extern SC_CORE_EXPORT SDAI_Application_instance * STEPread_reference( const char * s, ErrorDescriptor * err,
|
||||
InstMgr * instances, int addFileId );
|
||||
InstMgrBase * instances, int addFileId );
|
||||
////////////////////
|
||||
|
||||
extern SC_CORE_EXPORT int QuoteInString( istream & in );
|
||||
@@ -132,9 +132,9 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
|
||||
///////////// Read, Write, Assign attr value
|
||||
|
||||
Severity StrToVal( const char * s, InstMgr * instances = 0,
|
||||
Severity StrToVal( const char * s, InstMgrBase * instances = 0,
|
||||
int addFileId = 0 );
|
||||
Severity STEPread( istream & in = cin, InstMgr * instances = 0,
|
||||
Severity STEPread( istream & in = cin, InstMgrBase * instances = 0,
|
||||
int addFileId = 0, const char * currSch = NULL, bool strict = true );
|
||||
|
||||
/// return the attr value as a string
|
||||
@@ -146,19 +146,7 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
|
||||
Severity set_null();
|
||||
|
||||
/** \fn Integer()
|
||||
* \fn Real()
|
||||
* \fn Number()
|
||||
* \fn String()
|
||||
* \fn Binary()
|
||||
* \fn Entity()
|
||||
* \fn Aggregate()
|
||||
* \fn Enum()
|
||||
* \fn Logical()
|
||||
* \fn Boolean()
|
||||
* \fn Select()
|
||||
* \fn Undefined()
|
||||
*
|
||||
/**
|
||||
* These functions verify that the attribute contains the requested type and
|
||||
* returns a pointer. The pointer is null if the requested type does not match.
|
||||
*
|
||||
@@ -166,6 +154,7 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
* \sa NonRefType()
|
||||
* \sa is_null()
|
||||
*/
|
||||
///@{
|
||||
SDAI_Integer * Integer();
|
||||
SDAI_Real * Real();
|
||||
SDAI_Real * Number();
|
||||
@@ -178,6 +167,7 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
SDAI_BOOLEAN * Boolean();
|
||||
SDAI_Select * Select();
|
||||
SCLundefined * Undefined();
|
||||
///@}
|
||||
|
||||
/// allows direct access to the union containing attr data (dangerous!)
|
||||
attrUnion * Raw() {
|
||||
@@ -232,7 +222,7 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
_error.ClearErrorMsg();
|
||||
}
|
||||
|
||||
Severity ValidLevel( const char* attrValue, ErrorDescriptor* error, InstMgr* im, bool clearError = true );
|
||||
Severity ValidLevel( const char* attrValue, ErrorDescriptor* error, InstMgrBase * im, bool clearError = true );
|
||||
|
||||
////////////////// Constructors
|
||||
|
||||
@@ -262,13 +252,11 @@ class SC_CORE_EXPORT STEPattribute {
|
||||
STEPattribute( const class AttrDescriptor & d, SCLundefined * p );
|
||||
|
||||
/// return true if attr types and values match
|
||||
friend bool operator == ( const STEPattribute & a1, const STEPattribute & a2 );
|
||||
friend bool operator != ( const STEPattribute & a1, const STEPattribute & a2 ) {
|
||||
return !( a1 == a2 );
|
||||
}
|
||||
SC_CORE_EXPORT friend bool operator == ( const STEPattribute & a1, const STEPattribute & a2 );
|
||||
SC_CORE_EXPORT friend bool operator != ( const STEPattribute & a1, const STEPattribute & a2 );
|
||||
|
||||
/// return true if aDesc's match (behavior of old operator==)
|
||||
friend bool sameADesc ( const STEPattribute & a1, const STEPattribute & a2 );
|
||||
SC_CORE_EXPORT friend bool sameADesc ( const STEPattribute & a1, const STEPattribute & a2 );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,13 +12,13 @@ ReadStdKeyword( istream & in, std::string & buf, int skipInitWS );
|
||||
|
||||
|
||||
STEPcomplex::STEPcomplex( Registry * registry, int fileid )
|
||||
: SDAI_Application_instance( fileid, 1 ), sc( 0 ), _registry( registry ), visited( 0 ) {
|
||||
: SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) {
|
||||
head = this;
|
||||
}
|
||||
|
||||
STEPcomplex::STEPcomplex( Registry * registry, const std::string ** names,
|
||||
int fileid, const char * schnm )
|
||||
: SDAI_Application_instance( fileid, 1 ), sc( 0 ), _registry( registry ), visited( 0 ) {
|
||||
: SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) {
|
||||
char * nms[BUFSIZ];
|
||||
int j, k;
|
||||
|
||||
@@ -38,7 +38,7 @@ STEPcomplex::STEPcomplex( Registry * registry, const std::string ** names,
|
||||
|
||||
STEPcomplex::STEPcomplex( Registry * registry, const char ** names, int fileid,
|
||||
const char * schnm )
|
||||
: SDAI_Application_instance( fileid, 1 ), sc( 0 ), _registry( registry ), visited( 0 ) {
|
||||
: SDAI_Application_instance( fileid, true ), sc( 0 ), _registry( registry ), visited( 0 ) {
|
||||
|
||||
head = this;
|
||||
Initialize( names, schnm );
|
||||
@@ -204,17 +204,14 @@ void STEPcomplex::AssignDerives() {
|
||||
}
|
||||
}
|
||||
|
||||
/** \fn STEPcomplex::AddEntityPart
|
||||
** this function should only be called for the head entity
|
||||
** in the list of entity parts.
|
||||
*/
|
||||
/** this function should only be called for the head entity in the list of entity parts. */
|
||||
void STEPcomplex::AddEntityPart( const char * name ) {
|
||||
STEPcomplex * scomplex;
|
||||
|
||||
if( name ) {
|
||||
scomplex = new STEPcomplex( _registry, STEPfile_id );
|
||||
scomplex->BuildAttrs( name );
|
||||
if( scomplex->eDesc ) {
|
||||
scomplex->InitIAttrs();
|
||||
scomplex->head = this;
|
||||
AppendEntity( scomplex );
|
||||
} else {
|
||||
@@ -231,9 +228,10 @@ STEPcomplex * STEPcomplex::EntityPart( const char * name, const char * currSch )
|
||||
if( scomp->eDesc->CurrName( name, currSch ) ) {
|
||||
return scomp;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
cout << "Bug in STEPcomplex::EntityPart(): entity part has "
|
||||
<< "no EntityDescriptor\n";
|
||||
}
|
||||
scomp = scomp->sc;
|
||||
}
|
||||
return 0;
|
||||
@@ -258,7 +256,7 @@ const EntityDescriptor * STEPcomplex::IsA( const EntityDescriptor * ed ) const {
|
||||
}
|
||||
}
|
||||
|
||||
Severity STEPcomplex::ValidLevel( ErrorDescriptor * error, InstMgr * im,
|
||||
Severity STEPcomplex::ValidLevel( ErrorDescriptor * error, InstMgrBase * im,
|
||||
int clearError ) {
|
||||
(void) error; //unused
|
||||
(void) im;
|
||||
@@ -276,7 +274,7 @@ void STEPcomplex::AppendEntity( STEPcomplex * stepc ) {
|
||||
}
|
||||
|
||||
// READ
|
||||
Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgr * instance_set,
|
||||
Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * instance_set,
|
||||
istream & in, const char * currSch, bool /*useTechCor*/, bool /*strict*/ ) {
|
||||
char c;
|
||||
std::string typeNm;
|
||||
@@ -303,8 +301,7 @@ Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgr * instance_
|
||||
in >> ws;
|
||||
c = in.peek();
|
||||
if( c != '(' ) {
|
||||
_error.AppendToDetailMsg(
|
||||
"Missing open paren before entity attr values.\n" );
|
||||
_error.AppendToDetailMsg( "Missing open paren before entity attr values.\n" );
|
||||
cout << "ERROR: missing open paren\n";
|
||||
_error.GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
STEPread_error( c, 0, in, currSch );
|
||||
@@ -312,15 +309,12 @@ Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgr * instance_
|
||||
}
|
||||
|
||||
stepc = EntityPart( typeNm.c_str(), currSch );
|
||||
if( stepc )
|
||||
stepc->SDAI_Application_instance::STEPread( id, addFileId,
|
||||
instance_set, in,
|
||||
currSch );
|
||||
else {
|
||||
cout << "ERROR: complex entity part \"" << typeNm
|
||||
<< "\" does not exist.\n";
|
||||
_error.AppendToDetailMsg(
|
||||
"Complex entity part of instance does not exist.\n" );
|
||||
if( stepc ) {
|
||||
//WARNING need to seek to the correct position when this is done... how?
|
||||
stepc->SDAI_Application_instance::STEPread( id, addFileId, instance_set, in, currSch );
|
||||
} else {
|
||||
cout << "ERROR: complex entity part \"" << typeNm << "\" does not exist." << endl;;
|
||||
_error.AppendToDetailMsg( "Complex entity part of instance does not exist.\n" );
|
||||
_error.GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
STEPread_error( c, 0, in, currSch );
|
||||
return _error.severity();
|
||||
@@ -328,12 +322,16 @@ Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgr * instance_
|
||||
in >> ws;
|
||||
c = in.peek();
|
||||
}
|
||||
if( c != ')' )
|
||||
cout <<
|
||||
"ERROR: missing ending paren for complex entity instance.\n";
|
||||
else {
|
||||
if( c != ')' ) {
|
||||
cout << "ERROR: missing ending paren for complex entity instance." << endl;
|
||||
} else {
|
||||
in.get( c ); // read the closing paren
|
||||
}
|
||||
} else {
|
||||
_error.AppendToDetailMsg( "Complex instances must begin with '('. Found '" );
|
||||
_error.AppendToDetailMsg( c );
|
||||
_error.AppendToDetailMsg( "' instead.\n" );
|
||||
_error.GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
}
|
||||
return _error.severity();
|
||||
}
|
||||
@@ -341,7 +339,7 @@ Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgr * instance_
|
||||
//FIXME delete this?
|
||||
#ifdef buildwhileread
|
||||
// READ
|
||||
Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgr * instance_set,
|
||||
Severity STEPcomplex::STEPread( int id, int addFileId, class InstMgrBase * instance_set,
|
||||
istream & in, const char * currSch ) {
|
||||
ClearError( 1 );
|
||||
STEPfile_id = id;
|
||||
|
||||
@@ -13,13 +13,28 @@
|
||||
typedef std::list<void *> STEPcomplex_attr_data_list;
|
||||
typedef std::list<void *>::iterator STEPcomplex_attr_data;
|
||||
|
||||
/** TODO add a method to ed to create iAttr structure
|
||||
* either call same method in all parents, or add their iAttrs in some other way
|
||||
* does not need to be ordered
|
||||
*
|
||||
* simply move iAttrs into eDesc? don't recall whether that data can be safely shared amongst multiple instances or not
|
||||
* if it can't be shared, we'd need to enforce copy-on-write somehow - perhaps making iAttrs protected with a getter
|
||||
* that requires an instance as an arg - i.e. inst->eDesc->iAttrSetup(inst)
|
||||
*
|
||||
* what about inheritance? should each eDesc include all iattrs, or assemble the list as necessary at runtime?
|
||||
* eDesc should assemble a complete list on demand at runtime...
|
||||
*
|
||||
* How to initialize iAttrs for SC's? BuildIAttrs( eDesc )
|
||||
*/
|
||||
|
||||
|
||||
class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance {
|
||||
public: //TODO should this _really_ be public?!
|
||||
STEPcomplex * sc;
|
||||
STEPcomplex * head;
|
||||
Registry * _registry;
|
||||
int visited; ///< used when reading (or as you wish?)
|
||||
STEPcomplex_attr_data_list _attr_data_list;
|
||||
STEPcomplex_attr_data_list _attr_data_list; //< what is this for?
|
||||
public:
|
||||
STEPcomplex( Registry * registry, int fileid );
|
||||
STEPcomplex( Registry * registry, const std::string ** names, int fileid,
|
||||
@@ -34,11 +49,11 @@ class SC_CORE_EXPORT STEPcomplex : public SDAI_Application_instance {
|
||||
|
||||
virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const;
|
||||
|
||||
virtual Severity ValidLevel( ErrorDescriptor * error, InstMgr * im,
|
||||
virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im,
|
||||
int clearError = 1 );
|
||||
// READ
|
||||
virtual Severity STEPread( int id, int addFileId,
|
||||
class InstMgr * instance_set,
|
||||
class InstMgrBase * instance_set,
|
||||
istream & in = cin, const char * currSch = NULL,
|
||||
bool useTechCor = true, bool strict = true );
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
|
||||
/** \file STEPinvAttrList.cc
|
||||
* derived from STEPattributeList.cc
|
||||
*/
|
||||
|
||||
#include <STEPinvAttrList.h>
|
||||
#include <ExpDict.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
invAttrListNodeI::invAttrListNodeI(Inverse_attribute* a, setterI_t s, getterI_t g): invAttrListNode(a), set( s ), get( g ) {}
|
||||
invAttrListNodeA::invAttrListNodeA(Inverse_attribute* a, setterA_t s, getterA_t g): invAttrListNode(a), set( s ), get( g ) {}
|
||||
|
||||
invAttrListNodeI::~invAttrListNodeI() {}
|
||||
invAttrListNodeA::~invAttrListNodeA() {}
|
||||
|
||||
STEPinvAttrList::STEPinvAttrList() {}
|
||||
STEPinvAttrList::~STEPinvAttrList() {}
|
||||
|
||||
invAttrListNode * STEPinvAttrList::operator []( int n ) {
|
||||
int x = 0;
|
||||
invAttrListNode * a = ( invAttrListNode * )head;
|
||||
int cnt = EntryCount();
|
||||
if( n < cnt ) {
|
||||
while( a && ( x < n ) ) {
|
||||
a = ( invAttrListNode * )( a->next );
|
||||
x++;
|
||||
}
|
||||
}
|
||||
if( !a ) {
|
||||
cerr << "\nERROR in STEP Core library: " << __FILE__ << ":"
|
||||
<< __LINE__ << "\n" << _POC_ << "\n\n";
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
int STEPinvAttrList::list_length() {
|
||||
return EntryCount();
|
||||
}
|
||||
|
||||
void STEPinvAttrList::push( Inverse_attribute * a, setterA_t s, getterA_t g ) {
|
||||
invAttrListNode * an = ( invAttrListNode * )head;
|
||||
|
||||
// if the attribute already exists in the list, don't push it
|
||||
while( an ) {
|
||||
if( a == ( an -> attr ) ) {
|
||||
return;
|
||||
}
|
||||
an = ( invAttrListNode * )( an->next );
|
||||
}
|
||||
invAttrListNode * ialn = (invAttrListNode *) new invAttrListNodeA( a, s, g );
|
||||
AppendNode( ialn );
|
||||
}
|
||||
|
||||
void STEPinvAttrList::push( Inverse_attribute * a, setterI_t s, getterI_t g ) {
|
||||
invAttrListNode * an = ( invAttrListNode * )head;
|
||||
|
||||
// if the attribute already exists in the list, don't push it
|
||||
while( an ) {
|
||||
if( a == ( an -> attr ) ) {
|
||||
return;
|
||||
}
|
||||
an = ( invAttrListNode * )( an->next );
|
||||
}
|
||||
invAttrListNode * ialn = (invAttrListNode *) new invAttrListNodeI( a, s, g );
|
||||
AppendNode( ialn );
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
#ifndef _STEPinvAttrList_h
|
||||
#define _STEPinvAttrList_h 1
|
||||
|
||||
/// FIXME remove these classes? not sure there's a use for them now...
|
||||
|
||||
/** \file STEPinvAttrList.h
|
||||
* derived from STEPattributeList.h
|
||||
*
|
||||
* Similar to Inverse_attributeList, but this list also contains pointers to the setter and getter.
|
||||
*
|
||||
* \sa Inverse_attributeList
|
||||
*/
|
||||
|
||||
class Inverse_attribute;
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <SingleLinkList.h>
|
||||
|
||||
class STEPinvAttrList;
|
||||
class EntityAggregate;
|
||||
class SDAI_Application_instance;
|
||||
|
||||
/** setterI_t, getterI_t: for inverse attrs that only allow a single (Instance) reference
|
||||
* setterA_t, getterA_t: for inverse attrs that allow multiple (Aggregate) refs
|
||||
* @{
|
||||
*/
|
||||
typedef void ( *setterI_t )( SDAI_Application_instance *, const SDAI_Application_instance * );
|
||||
typedef SDAI_Application_instance * ( *getterI_t )( const SDAI_Application_instance * );
|
||||
typedef void ( *setterA_t )( SDAI_Application_instance *, const EntityAggregate * );
|
||||
typedef EntityAggregate * ( *getterA_t )( const SDAI_Application_instance * );
|
||||
/** @} */
|
||||
|
||||
/** invAttrListNode: base class + 2 derived classes, one for single instances and one for aggregates
|
||||
* @{
|
||||
*/
|
||||
class SC_CORE_EXPORT invAttrListNode : public SingleLinkNode {
|
||||
friend class STEPinvAttrList;
|
||||
protected:
|
||||
invAttrListNode( Inverse_attribute * a ) : attr( a ) {};
|
||||
Inverse_attribute * attr;
|
||||
public:
|
||||
Inverse_attribute * inverseADesc() {
|
||||
return attr;
|
||||
}
|
||||
virtual bool isAggregate() = 0;
|
||||
};
|
||||
|
||||
class SC_CORE_EXPORT invAttrListNodeI : public invAttrListNode {
|
||||
friend class STEPinvAttrList;
|
||||
protected:
|
||||
setterI_t set;
|
||||
getterI_t get;
|
||||
public:
|
||||
invAttrListNodeI( Inverse_attribute * a, setterI_t s, getterI_t g );
|
||||
virtual ~invAttrListNodeI();
|
||||
setterI_t setter() {
|
||||
return set;
|
||||
}
|
||||
getterI_t getter() {
|
||||
return get;
|
||||
}
|
||||
virtual bool isAggregate() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class SC_CORE_EXPORT invAttrListNodeA : public invAttrListNode {
|
||||
friend class STEPinvAttrList;
|
||||
protected:
|
||||
setterA_t set;
|
||||
getterA_t get;
|
||||
public:
|
||||
invAttrListNodeA( Inverse_attribute * a, setterA_t s, getterA_t g );
|
||||
virtual ~invAttrListNodeA();
|
||||
setterA_t setter() {
|
||||
return set;
|
||||
}
|
||||
getterA_t getter() {
|
||||
return get;
|
||||
}
|
||||
virtual bool isAggregate() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/// Similar to Inverse_attributeList, but this list also contains pointers to the setter and getter.
|
||||
class SC_CORE_EXPORT STEPinvAttrList : public SingleLinkList {
|
||||
public:
|
||||
STEPinvAttrList();
|
||||
virtual ~STEPinvAttrList();
|
||||
invAttrListNode * operator []( int n );
|
||||
int list_length();
|
||||
void push( Inverse_attribute * a, setterA_t s, getterA_t g );
|
||||
void push( Inverse_attribute * a, setterI_t s, getterI_t g );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
+13
-26
@@ -49,7 +49,7 @@ InstMgr::PrintSortedFileIds() {
|
||||
InstMgr::InstMgr( int ownsInstances )
|
||||
: maxFileId( -1 ), _ownsInstances( ownsInstances ) {
|
||||
master = new MgrNodeArray();
|
||||
sortedMaster = new MgrNodeArraySorted();
|
||||
sortedMaster = new std::map<int, MgrNode *>;
|
||||
}
|
||||
|
||||
InstMgr::~InstMgr() {
|
||||
@@ -58,7 +58,8 @@ InstMgr::~InstMgr() {
|
||||
} else {
|
||||
master->ClearEntries();
|
||||
}
|
||||
sortedMaster->ClearEntries();
|
||||
sortedMaster->clear();
|
||||
std::map<int, MgrNode *>::iterator iter;
|
||||
|
||||
delete master;
|
||||
delete sortedMaster;
|
||||
@@ -68,13 +69,13 @@ InstMgr::~InstMgr() {
|
||||
|
||||
void InstMgr::ClearInstances() {
|
||||
master->ClearEntries();
|
||||
sortedMaster->ClearEntries();
|
||||
sortedMaster->clear();
|
||||
maxFileId = -1;
|
||||
}
|
||||
|
||||
void InstMgr::DeleteInstances() {
|
||||
master->DeleteEntries();
|
||||
sortedMaster->ClearEntries();
|
||||
sortedMaster->clear();
|
||||
maxFileId = -1;
|
||||
}
|
||||
|
||||
@@ -164,12 +165,10 @@ InstMgr::VerifyInstances( ErrorDescriptor & err ) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MgrNode * InstMgr::FindFileId( int fileId ) {
|
||||
int index = sortedMaster->MgrNodeIndex( fileId );
|
||||
if( index >= 0 ) {
|
||||
return ( MgrNode * )( *sortedMaster )[index];
|
||||
} else {
|
||||
return ( MgrNode * )0;
|
||||
}
|
||||
std::map<int, MgrNode *>::iterator it;
|
||||
it=sortedMaster->find(fileId);
|
||||
if (it == sortedMaster->end()) return ( MgrNode * )0;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -182,13 +181,6 @@ int InstMgr::GetIndex( MgrNode * mn ) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int InstMgr::GetIndex( SDAI_Application_instance * se ) {
|
||||
int fileId = se->StepFileId();
|
||||
return sortedMaster->MgrNodeIndex( fileId );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int InstMgr::VerifyEntity( int fileId, const char * expectedType ) {
|
||||
MgrNode * mn = FindFileId( fileId );
|
||||
if( mn ) {
|
||||
@@ -210,7 +202,6 @@ MgrNode * InstMgr::Append( SDAI_Application_instance * se, stateEnum listState )
|
||||
if( debug_level > 3 ) {
|
||||
cout << "#" << se->StepFileId() << " append node to InstMgr" << endl;
|
||||
}
|
||||
|
||||
MgrNode * mn = 0;
|
||||
|
||||
if( se->StepFileId() == 0 ) { // no id assigned
|
||||
@@ -240,8 +231,8 @@ MgrNode * InstMgr::Append( SDAI_Application_instance * se, stateEnum listState )
|
||||
cout << "append to InstMgr **ERROR ** node #" << se->StepFileId() <<
|
||||
" doesn't have state information" << endl;
|
||||
master->Append( mn );
|
||||
sortedMaster->Insert( mn );
|
||||
//PrintSortedFileIds();
|
||||
(*sortedMaster)[mn->GetFileId()] = mn;
|
||||
//PrintSortedFileIds();
|
||||
return mn;
|
||||
}
|
||||
|
||||
@@ -251,15 +242,11 @@ void InstMgr::Delete( MgrNode * node ) {
|
||||
// delete the node from its current state list
|
||||
node->Remove();
|
||||
|
||||
int index;
|
||||
|
||||
// get the index of the node in the sorted master array
|
||||
index = sortedMaster->MgrNodeIndex( node->GetFileId() );
|
||||
// remove the node from the sorted master array
|
||||
sortedMaster->Remove( index );
|
||||
sortedMaster->erase( node->GetFileId() );
|
||||
|
||||
// get the index into the master array by ptr arithmetic
|
||||
index = node->ArrayIndex();
|
||||
int index = node->ArrayIndex();
|
||||
master->Remove( index );
|
||||
|
||||
delete node;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
// IT IS VERY IMPORTANT THAT THE ORDER OF THE FOLLOWING INCLUDE FILES
|
||||
// BE PRESERVED
|
||||
|
||||
@@ -37,7 +39,13 @@
|
||||
|
||||
#include <mgrnodearray.h>
|
||||
|
||||
class SC_CORE_EXPORT InstMgr {
|
||||
class SC_CORE_EXPORT InstMgrBase {
|
||||
public:
|
||||
virtual MgrNodeBase * FindFileId( int fileId ) = 0;
|
||||
virtual ~InstMgrBase() {};
|
||||
};
|
||||
|
||||
class SC_CORE_EXPORT InstMgr : public InstMgrBase {
|
||||
protected:
|
||||
int maxFileId;
|
||||
int _ownsInstances; // if true will delete instances inside destructor
|
||||
@@ -45,7 +53,7 @@ class SC_CORE_EXPORT InstMgr {
|
||||
MgrNodeArray * master; // master array of all MgrNodes made up of
|
||||
// complete, incomplete, new, delete MgrNodes lists
|
||||
// this corresponds to the display list object by index
|
||||
MgrNodeArraySorted * sortedMaster; // master array sorted by fileId
|
||||
std::map<int, MgrNode *> *sortedMaster; // master array sorted by fileId
|
||||
// StateList *master; // this will be an sorted array of ptrs to MgrNodes
|
||||
|
||||
public:
|
||||
|
||||
@@ -29,13 +29,21 @@ class DisplayNode;
|
||||
|
||||
class InstMgr;
|
||||
|
||||
class SC_CORE_EXPORT MgrNodeBase : public GenericNode {
|
||||
public:
|
||||
virtual inline SDAI_Application_instance * GetSTEPentity() {
|
||||
abort();
|
||||
};
|
||||
virtual ~MgrNodeBase() {};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// class MgrNode
|
||||
// If you delete this object, it deletes the SDAI_Application_instance it represents,
|
||||
// the DisplayNode, and removes itself from any list it is in.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SC_CORE_EXPORT MgrNode : public GenericNode {
|
||||
class SC_CORE_EXPORT MgrNode : public MgrNodeBase {
|
||||
friend class GenNodeList;
|
||||
friend class MgrNodeList;
|
||||
friend class InstMgr;
|
||||
|
||||
@@ -38,9 +38,10 @@ typedef std::string Express_id;
|
||||
class TypeDescriptor;
|
||||
class EntityDescriptor;
|
||||
class SelectTypeDescriptor;
|
||||
class InstMgr;
|
||||
class InstMgrBase;
|
||||
|
||||
#include "STEPattributeList.h"
|
||||
#include "STEPinvAttrList.h"
|
||||
|
||||
class STEPattributeList;
|
||||
class STEPattribute;
|
||||
@@ -226,7 +227,7 @@ typedef SDAI_Application_instance * STEPentityH;
|
||||
|
||||
extern SC_CORE_EXPORT SDAI_Application_instance *
|
||||
ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList,
|
||||
InstMgr * instances, int addFileId );
|
||||
InstMgrBase * instances, int addFileId );
|
||||
|
||||
#define SdaiInteger SDAI_Integer
|
||||
#define SdaiReal SDAI_Real
|
||||
|
||||
@@ -10,13 +10,16 @@
|
||||
* and is not subject to copyright.
|
||||
*/
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <sdai.h>
|
||||
#include <instmgr.h>
|
||||
#include <STEPcomplex.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <read_func.h> //for ReadTokenSeparator, used when comments are inside entities
|
||||
|
||||
#include "sdaiApplication_instance.h"
|
||||
#include "superInvAttrIter.h"
|
||||
|
||||
SDAI_Application_instance NilSTEPentity;
|
||||
|
||||
/**************************************************************//**
|
||||
@@ -32,22 +35,22 @@ SDAI_Application_instance NilSTEPentity;
|
||||
|
||||
SDAI_Application_instance::SDAI_Application_instance()
|
||||
: _cur( 0 ),
|
||||
eDesc( NULL ),
|
||||
_complex( false ),
|
||||
STEPfile_id( 0 ),
|
||||
p21Comment( std::string( "" ) ),
|
||||
eDesc( NULL ),
|
||||
headMiEntity( 0 ),
|
||||
nextMiEntity( 0 ),
|
||||
_complex( 0 ) {
|
||||
nextMiEntity( 0 ) {
|
||||
}
|
||||
|
||||
SDAI_Application_instance::SDAI_Application_instance( int fileid, int complex )
|
||||
: _cur( 0 ),
|
||||
eDesc( NULL ),
|
||||
_complex( complex ),
|
||||
STEPfile_id( fileid ),
|
||||
p21Comment( std::string( "" ) ),
|
||||
eDesc( NULL ),
|
||||
headMiEntity( 0 ),
|
||||
nextMiEntity( 0 ),
|
||||
_complex( complex ) {
|
||||
nextMiEntity( 0 ) {
|
||||
}
|
||||
|
||||
SDAI_Application_instance::~SDAI_Application_instance() {
|
||||
@@ -70,6 +73,27 @@ SDAI_Application_instance::~SDAI_Application_instance() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// initialize inverse attrs
|
||||
/// eDesc->InitIAttrs() must have been called previously
|
||||
/// call once per instance (*not* once per class)
|
||||
void SDAI_Application_instance::InitIAttrs() {
|
||||
assert( eDesc && "eDesc must be set; please report this bug." );
|
||||
InverseAItr iai( &( eDesc->InverseAttr() ) );
|
||||
const Inverse_attribute * ia;
|
||||
iAstruct s;
|
||||
memset( &s, 0, sizeof s );
|
||||
while( 0 != ( ia = iai.NextInverse_attribute() ) ) {
|
||||
iAMap.insert( iAMap_t::value_type( ia, s ) );
|
||||
}
|
||||
superInvAttrIter siai( eDesc );
|
||||
while( !siai.empty() ) {
|
||||
ia = siai.next();
|
||||
assert( ia && "Null inverse attr!" );
|
||||
iAMap.insert( iAMap_t::value_type( ia, s ) );
|
||||
}
|
||||
}
|
||||
|
||||
SDAI_Application_instance * SDAI_Application_instance::Replicate() {
|
||||
char errStr[BUFSIZ];
|
||||
if( IsComplex() ) {
|
||||
@@ -251,7 +275,7 @@ const EntityDescriptor * SDAI_Application_instance::IsA( const EntityDescriptor
|
||||
/**
|
||||
* Checks the validity of the current attribute values for the entity
|
||||
*/
|
||||
Severity SDAI_Application_instance::ValidLevel( ErrorDescriptor * error, InstMgr * im,
|
||||
Severity SDAI_Application_instance::ValidLevel( ErrorDescriptor * error, InstMgrBase * im,
|
||||
int clearError ) {
|
||||
ErrorDescriptor err;
|
||||
if( clearError ) {
|
||||
@@ -477,7 +501,7 @@ void SDAI_Application_instance::STEPread_error( char c, int i, istream & in, con
|
||||
** Status:
|
||||
******************************************************************/
|
||||
Severity SDAI_Application_instance::STEPread( int id, int idIncr,
|
||||
InstMgr * instance_set, istream & in,
|
||||
InstMgrBase * instance_set, istream & in,
|
||||
const char * currSch, bool useTechCor, bool strict ) {
|
||||
STEPfile_id = id;
|
||||
char c = '\0';
|
||||
@@ -631,7 +655,7 @@ Severity SDAI_Application_instance::STEPread( int id, int idIncr,
|
||||
|
||||
/// read an entity reference and return a pointer to the SDAI_Application_instance
|
||||
SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err, const char * tokenList,
|
||||
InstMgr * instances, int addFileId ) {
|
||||
InstMgrBase * instances, int addFileId ) {
|
||||
char c;
|
||||
char errStr[BUFSIZ];
|
||||
errStr[0] = '\0';
|
||||
@@ -640,8 +664,7 @@ SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err,
|
||||
in >> c;
|
||||
switch( c ) {
|
||||
case '@':
|
||||
err->AppendToDetailMsg(
|
||||
"Use of @ instead of # to identify entity.\n" );
|
||||
err->AppendToDetailMsg( "Use of @ instead of # to identify entity.\n" );
|
||||
err->GreaterSeverity( SEVERITY_WARNING );
|
||||
// no break statement here on purpose
|
||||
case '#': {
|
||||
@@ -675,7 +698,7 @@ SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err,
|
||||
// lookup which object has id as its instance id
|
||||
SDAI_Application_instance * inst;
|
||||
/* If there is a ManagerNode it should have a SDAI_Application_instance */
|
||||
MgrNode * mn = 0;
|
||||
MgrNodeBase * mn = 0;
|
||||
mn = instances->FindFileId( id );
|
||||
if( mn ) {
|
||||
inst = mn->GetSTEPentity() ;
|
||||
@@ -715,7 +738,7 @@ SDAI_Application_instance * ReadEntityRef( istream & in, ErrorDescriptor * err,
|
||||
|
||||
/// read an entity reference and return a pointer to the SDAI_Application_instance
|
||||
SDAI_Application_instance * ReadEntityRef( const char * s, ErrorDescriptor * err, const char * tokenList,
|
||||
InstMgr * instances, int addFileId ) {
|
||||
InstMgrBase * instances, int addFileId ) {
|
||||
istringstream in( ( char * )s );
|
||||
return ReadEntityRef( in, err, tokenList, instances, addFileId );
|
||||
}
|
||||
@@ -736,7 +759,7 @@ Severity EntityValidLevel( SDAI_Application_instance * se,
|
||||
"missing or invalid EntityDescriptor\n" );
|
||||
err->AppendToUserMsg( messageBuf );
|
||||
err->AppendToDetailMsg( messageBuf );
|
||||
cerr << "Internal error: " << __FILE__ << __LINE__
|
||||
cerr << "Internal error: " << __FILE__ << ":" << __LINE__
|
||||
<< "\n" << _POC_ "\n";
|
||||
return SEVERITY_BUG;
|
||||
}
|
||||
@@ -747,7 +770,7 @@ Severity EntityValidLevel( SDAI_Application_instance * se,
|
||||
"for SDAI_Application_instance argument." );
|
||||
err->AppendToUserMsg( messageBuf );
|
||||
err->AppendToDetailMsg( messageBuf );
|
||||
cerr << "Internal error: " << __FILE__ << __LINE__
|
||||
cerr << "Internal error: " << __FILE__ << ":" << __LINE__
|
||||
<< "\n" << _POC_ "\n";
|
||||
return SEVERITY_BUG;
|
||||
}
|
||||
@@ -755,9 +778,9 @@ Severity EntityValidLevel( SDAI_Application_instance * se,
|
||||
// DAVE: Can an entity be used in an Express TYPE so that this
|
||||
// EntityDescriptor would have type REFERENCE_TYPE -- it looks like NO
|
||||
|
||||
else if( se->eDesc ) {
|
||||
else if( se->getEDesc() ) {
|
||||
// is se a descendant of ed?
|
||||
if( se->eDesc->IsA( ed ) ) {
|
||||
if( se->getEDesc()->IsA( ed ) ) {
|
||||
return SEVERITY_NULL;
|
||||
} else {
|
||||
if( se->IsComplex() ) {
|
||||
@@ -822,7 +845,7 @@ Severity EntityValidLevel( const char * attrValue, // string contain entity ref
|
||||
// attrValue (if it exists) needs
|
||||
// to match. (this must be an
|
||||
// EntityDescriptor)
|
||||
ErrorDescriptor * err, InstMgr * im, int clearError ) {
|
||||
ErrorDescriptor * err, InstMgrBase * im, int clearError ) {
|
||||
char tmp [BUFSIZ];
|
||||
tmp[0] = '\0';
|
||||
char messageBuf [BUFSIZ];
|
||||
@@ -834,7 +857,7 @@ Severity EntityValidLevel( const char * attrValue, // string contain entity ref
|
||||
}
|
||||
|
||||
int fileId;
|
||||
MgrNode * mn = 0;
|
||||
MgrNodeBase * mn = 0;
|
||||
|
||||
// fmtstr1 contains "#%d %ns" where n is BUFSIZ-1
|
||||
fmtstr1 << " #%d %" << BUFSIZ - 1 << "s ";
|
||||
@@ -896,9 +919,40 @@ STEPattribute * SDAI_Application_instance::NextAttribute() {
|
||||
return 0;
|
||||
}
|
||||
return &attributes [_cur - 1];
|
||||
|
||||
}
|
||||
|
||||
int SDAI_Application_instance::AttributeCount() {
|
||||
return attributes.list_length();
|
||||
}
|
||||
|
||||
const iAstruct SDAI_Application_instance::getInvAttr( const Inverse_attribute * const ia ) const {
|
||||
iAstruct ias;
|
||||
memset( &ias, 0, sizeof ias );
|
||||
iAMap_t::const_iterator it = iAMap.find( ia );
|
||||
if( it != iAMap.end() ) {
|
||||
ias = (*it).second;
|
||||
}
|
||||
return ias;
|
||||
}
|
||||
|
||||
const SDAI_Application_instance::iAMap_t::value_type SDAI_Application_instance::getInvAttr( const char * name ) const {
|
||||
iAMap_t::const_iterator it = iAMap.begin();
|
||||
for( ; it != iAMap.end(); ++it ) {
|
||||
if( 0 == strcmp( it->first->Name(), name) ) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
iAstruct z;
|
||||
memset( &z, 0, sizeof z );
|
||||
iAMap_t::value_type nil( NULL, z );
|
||||
return nil;
|
||||
}
|
||||
|
||||
void SDAI_Application_instance::setInvAttr( const Inverse_attribute * const ia, const iAstruct ias ) {
|
||||
iAMap_t::iterator it = iAMap.find(ia);
|
||||
if( it != iAMap.end() ) {
|
||||
it->second = ias;
|
||||
} else {
|
||||
iAMap.insert( iAMap_t::value_type( ia, ias ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,21 +13,39 @@
|
||||
*/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// SDAI_Application_instance used to be STEPentity
|
||||
//class STEPinvAttrList;
|
||||
class EntityAggregate;
|
||||
class Inverse_attribute;
|
||||
typedef struct {
|
||||
// bool aggregate;
|
||||
union {
|
||||
EntityAggregate * a;
|
||||
SDAI_Application_instance * i;
|
||||
};
|
||||
} iAstruct;
|
||||
|
||||
/** @class
|
||||
* this used to be STEPentity
|
||||
*/
|
||||
class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI {
|
||||
private:
|
||||
int _cur; // provides a built-in way of accessing attributes in order.
|
||||
|
||||
public:
|
||||
typedef std::map< const Inverse_attribute * const, iAstruct> iAMap_t;
|
||||
protected:
|
||||
const EntityDescriptor * eDesc;
|
||||
iAMap_t iAMap;
|
||||
bool _complex;
|
||||
|
||||
public: //TODO make these private?
|
||||
STEPattributeList attributes;
|
||||
int STEPfile_id;
|
||||
int STEPfile_id; //TODO are neg values ever used (signalling)? if not, make unsigned?
|
||||
ErrorDescriptor _error;
|
||||
std::string p21Comment;
|
||||
// registry additions
|
||||
const EntityDescriptor * eDesc;
|
||||
|
||||
/**
|
||||
** head entity for multiple inheritance. If it is null then this
|
||||
@@ -40,18 +58,23 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI {
|
||||
/// these form a chain of other entity parents for multiple inheritance
|
||||
SDAI_Application_instance * nextMiEntity;
|
||||
|
||||
protected:
|
||||
int _complex;
|
||||
|
||||
public:
|
||||
SDAI_Application_instance();
|
||||
SDAI_Application_instance( int fileid, int complex = 0 );
|
||||
virtual ~SDAI_Application_instance();
|
||||
|
||||
int IsComplex() const {
|
||||
bool IsComplex() const {
|
||||
return _complex;
|
||||
}
|
||||
/// initialize inverse attribute list
|
||||
void InitIAttrs();
|
||||
|
||||
void setEDesc( const EntityDescriptor * const ed ) {
|
||||
eDesc = ed;
|
||||
}
|
||||
const EntityDescriptor * getEDesc() const {
|
||||
return eDesc;
|
||||
}
|
||||
void StepFileId( int fid ) {
|
||||
STEPfile_id = fid;
|
||||
}
|
||||
@@ -74,7 +97,7 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI {
|
||||
|
||||
virtual const EntityDescriptor * IsA( const EntityDescriptor * ) const;
|
||||
|
||||
virtual Severity ValidLevel( ErrorDescriptor * error, InstMgr * im,
|
||||
virtual Severity ValidLevel( ErrorDescriptor * error, InstMgrBase * im,
|
||||
int clearError = 1 );
|
||||
ErrorDescriptor & Error() {
|
||||
return _error;
|
||||
@@ -92,27 +115,34 @@ class SC_CORE_EXPORT SDAI_Application_instance : public SDAI_DAObject_SDAI {
|
||||
void ResetAttributes() {
|
||||
_cur = 0;
|
||||
}
|
||||
// ACCESS inverse attributes
|
||||
const iAstruct getInvAttr( const Inverse_attribute * const ia ) const;
|
||||
const iAMap_t::value_type getInvAttr( const char * name ) const;
|
||||
void setInvAttr( const Inverse_attribute * const ia, const iAstruct ias );
|
||||
const iAMap_t & getInvAttrs() const {
|
||||
return iAMap;
|
||||
}
|
||||
|
||||
// READ
|
||||
virtual Severity STEPread( int id, int addFileId,
|
||||
class InstMgr * instance_set,
|
||||
istream & in = cin, const char * currSch = NULL,
|
||||
class InstMgrBase * instance_set,
|
||||
std::istream & in = std::cin, const char * currSch = NULL,
|
||||
bool useTechCor = true, bool strict = true );
|
||||
virtual void STEPread_error( char c, int i, std::istream& in, const char * schnm );
|
||||
|
||||
// WRITE
|
||||
virtual void STEPwrite( ostream & out = cout, const char * currSch = NULL,
|
||||
virtual void STEPwrite( std::ostream & out = std::cout, const char * currSch = NULL,
|
||||
int writeComments = 1 );
|
||||
virtual const char * STEPwrite( std::string & buf, const char * currSch = NULL );
|
||||
|
||||
void WriteValuePairs( ostream & out, const char * currSch = NULL,
|
||||
void WriteValuePairs( std::ostream & out, const char * currSch = NULL,
|
||||
int writeComments = 1, int mixedCase = 1 );
|
||||
|
||||
void STEPwrite_reference( ostream & out = cout );
|
||||
void STEPwrite_reference( std::ostream & out = std::cout );
|
||||
const char * STEPwrite_reference( std::string & buf );
|
||||
|
||||
void beginSTEPwrite( ostream & out = cout ); ///< writes out the SCOPE section
|
||||
void endSTEPwrite( ostream & out = cout );
|
||||
void beginSTEPwrite( std::ostream & out = std::cout ); ///< writes out the SCOPE section
|
||||
void endSTEPwrite( std::ostream & out = std::cout );
|
||||
|
||||
// MULTIPLE INHERITANCE
|
||||
int MultipleInheritance() {
|
||||
|
||||
@@ -33,9 +33,29 @@ SDAI_Select::SDAI_Select( const SelectTypeDescriptor * s,
|
||||
#endif
|
||||
}
|
||||
|
||||
SDAI_Select::SDAI_Select( const SDAI_Select & other ) {
|
||||
underlying_type = other.underlying_type;
|
||||
base_type = other.base_type;
|
||||
_type = other._type;
|
||||
#ifdef SC_LOGGING
|
||||
*logStream << "Exiting SDAI_Select constructor." << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
SDAI_Select::~SDAI_Select() {
|
||||
}
|
||||
|
||||
SDAI_Select & SDAI_Select::operator=( const SDAI_Select & other ) {
|
||||
if( &other != this ) {
|
||||
_error = other._error;
|
||||
_type = other._type;
|
||||
base_type = other.base_type;
|
||||
underlying_type = other.underlying_type;
|
||||
val = other.val;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Severity SDAI_Select::severity() const {
|
||||
return _error.severity();
|
||||
}
|
||||
@@ -135,7 +155,7 @@ void SDAI_Select::nullify() {
|
||||
}
|
||||
|
||||
Severity SDAI_Select::SelectValidLevel( const char * attrValue, ErrorDescriptor * err,
|
||||
InstMgr * im ) {
|
||||
InstMgrBase * im ) {
|
||||
SDAI_Select * tmp = NewSelect();
|
||||
Severity s = SEVERITY_NULL;
|
||||
|
||||
@@ -146,7 +166,7 @@ Severity SDAI_Select::SelectValidLevel( const char * attrValue, ErrorDescriptor
|
||||
}
|
||||
|
||||
Severity SDAI_Select::StrToVal( const char * Val, const char * selectType,
|
||||
ErrorDescriptor * err, InstMgr * instances ) {
|
||||
ErrorDescriptor * err, InstMgrBase * instances ) {
|
||||
severity( SEVERITY_NULL );
|
||||
if( SetUnderlyingType( CanBe( selectType ) ) )
|
||||
|
||||
@@ -208,7 +228,7 @@ Severity SDAI_Select::StrToVal( const char * Val, const char * selectType,
|
||||
* This function does the following:
|
||||
*/
|
||||
Severity SDAI_Select::STEPread( istream & in, ErrorDescriptor * err,
|
||||
InstMgr * instances, const char * utype,
|
||||
InstMgrBase * instances, const char * utype,
|
||||
int addFileId, const char * currSch ) {
|
||||
char c = '\0';
|
||||
std::string tmp;
|
||||
|
||||
@@ -52,6 +52,7 @@ class SC_CORE_EXPORT SDAI_Select {
|
||||
// constructors
|
||||
SDAI_Select( const SelectTypeDescriptor * s = 0,
|
||||
const TypeDescriptor * td = 0 );
|
||||
SDAI_Select( const SDAI_Select & other );
|
||||
virtual ~SDAI_Select();
|
||||
|
||||
// from SDAI binding
|
||||
@@ -61,7 +62,7 @@ class SC_CORE_EXPORT SDAI_Select {
|
||||
void nullify();
|
||||
|
||||
Severity SelectValidLevel( const char * attrValue, ErrorDescriptor * err,
|
||||
InstMgr * im );
|
||||
InstMgrBase * im );
|
||||
|
||||
// reading and writing
|
||||
const char * STEPwrite( std::string & s, const char * currSch = 0 ) const;
|
||||
@@ -75,22 +76,24 @@ class SC_CORE_EXPORT SDAI_Select {
|
||||
|
||||
|
||||
Severity StrToVal( const char * val, const char * selectType,
|
||||
ErrorDescriptor * err, InstMgr * instances = 0 );
|
||||
ErrorDescriptor * err, InstMgrBase * instances = 0 );
|
||||
virtual Severity StrToVal_content( const char *,
|
||||
InstMgr * instances = 0 ) = 0;
|
||||
InstMgrBase * instances = 0 ) = 0;
|
||||
|
||||
Severity STEPread( istream & in, ErrorDescriptor * err,
|
||||
InstMgr * instances = 0, const char * utype = 0,
|
||||
InstMgrBase * instances = 0, const char * utype = 0,
|
||||
int addFileId = 0, const char * = NULL );
|
||||
|
||||
// abstract function
|
||||
virtual Severity STEPread_content( istream & in = cin,
|
||||
InstMgr * instances = 0,
|
||||
InstMgrBase * instances = 0,
|
||||
const char * utype = 0,
|
||||
int addFileId = 0,
|
||||
const char * currSch = 0 ) = 0;
|
||||
|
||||
virtual SDAI_Select & operator =( const SDAI_Select & ) = 0;
|
||||
//windows complains if operator= is pure virtual, perhaps because the impl is not in the lib with the definition
|
||||
//linux has a regression if the pure virtual operator= is commented out
|
||||
virtual SDAI_Select & operator =( const SDAI_Select & other );
|
||||
|
||||
int set_null();
|
||||
int is_null();
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef SUPERINVATTRITER_H
|
||||
#define SUPERINVATTRITER_H
|
||||
|
||||
#include "SubSuperIterators.h"
|
||||
#include "ExpDict.h"
|
||||
|
||||
/**
|
||||
* this class implements an iterator for inverse attributes in an EntityDescriptor's supertypes
|
||||
* makes use of supertypesIterator and InverseAItr
|
||||
*
|
||||
* TODO verify that this iterates correctly!
|
||||
*/
|
||||
class superInvAttrIter {
|
||||
protected:
|
||||
supertypesIterator sit;
|
||||
InverseAItr * invIter;
|
||||
const Inverse_attribute * nextInv;
|
||||
bool isempty; ///< if true, don't try to access invIter - it is not initialized
|
||||
public:
|
||||
/// WARNING this will not iterate over the ia's in the first ed, only in its supertypes! change that?
|
||||
superInvAttrIter( const EntityDescriptor * ed ): sit( ed ), invIter(0), nextInv( 0 ), isempty( false ) {
|
||||
reset();
|
||||
}
|
||||
void reset( const EntityDescriptor * ed = 0 ) {
|
||||
sit.reset( ed );
|
||||
if( invIter ) {
|
||||
delete invIter;
|
||||
invIter = 0;
|
||||
}
|
||||
if( sit.empty() ) {
|
||||
isempty = true;
|
||||
} else {
|
||||
invIter = new InverseAItr( &( sit.current()->InverseAttr() ) );
|
||||
nextInv = invIter->NextInverse_attribute();
|
||||
if( !nextInv ) {
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
~superInvAttrIter() {
|
||||
if( invIter ) {
|
||||
delete invIter;
|
||||
invIter = 0;
|
||||
}
|
||||
}
|
||||
const EntityDescriptor * currentEDesc() {
|
||||
if( isempty ) {
|
||||
return NULL;
|
||||
}
|
||||
return sit.current();
|
||||
}
|
||||
bool empty() {
|
||||
if( isempty ) {
|
||||
return true;
|
||||
}
|
||||
return ( !sit.hasNext() && !nextInv );
|
||||
}
|
||||
const Inverse_attribute * next() {
|
||||
if( isempty ) {
|
||||
return NULL;
|
||||
}
|
||||
const Inverse_attribute * ia = nextInv;
|
||||
/* if we're on the last inverse attr for the current super, go to the next super
|
||||
* keep going until we find an ia or run out of supers */
|
||||
while( ( 0 == ( nextInv = invIter->NextInverse_attribute() ) ) && sit.hasNext() ) {
|
||||
invIter->ResetItr( &( sit.next()->InverseAttr() ) );
|
||||
}
|
||||
return ia;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //SUPERINVATTRITER_H
|
||||
@@ -1,22 +1,33 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
#c++ tests for clstepcore
|
||||
|
||||
INCLUDE_DIRECTORIES( ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${SC_SOURCE_DIR}/src/clutils
|
||||
${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/base )
|
||||
include_directories(
|
||||
${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
)
|
||||
|
||||
function(add_stepcore_test name libs)
|
||||
SC_ADDEXEC( tst_${name} test_${name}.cc "${libs}" "TESTABLE" )
|
||||
add_test( NAME build_cpp_${name}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target tst_${name}
|
||||
--config $<CONFIGURATION> )
|
||||
add_test( NAME test_${name}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND $<TARGET_FILE:tst_${name}> )
|
||||
set_tests_properties( build_cpp_${name} PROPERTIES LABELS cpp_unit_stepcore DEPENDS stepcore )
|
||||
set_tests_properties( test_${name} PROPERTIES LABELS cpp_unit_stepcore DEPENDS build_cpp_${name} )
|
||||
SC_ADDEXEC(tst_${name} test_${name}.cc "${libs}" "TESTABLE")
|
||||
add_test(NAME build_cpp_${name}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} --build .
|
||||
--target tst_${name}
|
||||
--config $<CONFIGURATION>)
|
||||
add_test(NAME test_${name}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND $<TARGET_FILE:tst_${name}>)
|
||||
set_tests_properties(build_cpp_${name} PROPERTIES LABELS cpp_unit_stepcore DEPENDS stepcore)
|
||||
set_tests_properties(test_${name} PROPERTIES LABELS cpp_unit_stepcore DEPENDS build_cpp_${name})
|
||||
endfunction(add_stepcore_test name libs)
|
||||
|
||||
add_stepcore_test( "SupertypesIterator" "stepcore;steputils;stepeditor;stepdai;base" ) #all these libs are necessary?
|
||||
add_stepcore_test( "operators_STEPattribute" "stepcore;steputils;stepeditor;stepdai;base" )
|
||||
add_stepcore_test("SupertypesIterator" "stepcore;steputils;stepeditor;stepdai;base") #all these libs are necessary?
|
||||
add_stepcore_test("operators_STEPattribute" "stepcore;steputils;stepeditor;stepdai;base")
|
||||
add_stepcore_test("operators_SDAI_Select" "stepcore;steputils;stepeditor;stepdai;base")
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/** \file test_operators_SDAI_Select.cc
|
||||
* tests for SDAI_Select operators
|
||||
* currently only implements a test for operator=
|
||||
* TODO implement others
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "ExpDict.h"
|
||||
#include "baseType.h"
|
||||
#include "sdaiSelect.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class TestSdaiSelect: public SDAI_Select {
|
||||
public:
|
||||
TestSdaiSelect( SelectTypeDescriptor * s, TypeDescriptor * t, BASE_TYPE b, SDAI_String v, ErrorDescriptor e ):
|
||||
SDAI_Select( s, t ) {
|
||||
base_type = b;
|
||||
val = v;
|
||||
_error = e;
|
||||
}
|
||||
TestSdaiSelect(): SDAI_Select() {}
|
||||
TestSdaiSelect & operator=( const TestSdaiSelect & other ) {
|
||||
SDAI_Select::operator=( other );
|
||||
return *this;
|
||||
}
|
||||
SDAI_Select& operator=( const SDAI_Select& other ) {
|
||||
SDAI_Select::operator=( other );
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// \return true for match
|
||||
bool compare( SelectTypeDescriptor * s, TypeDescriptor * t, BASE_TYPE b, SDAI_String * v, ErrorDescriptor * e ) {
|
||||
bool pass = _type == s;
|
||||
pass &= underlying_type == t;
|
||||
pass &= base_type == b;
|
||||
pass &= val == v->c_str();
|
||||
pass &= ( _error.severity() == e->severity() ) && ( _error.debug_level() == e->debug_level() );
|
||||
return pass;
|
||||
}
|
||||
|
||||
// dummy implementations of pure virtual funcs
|
||||
const TypeDescriptor* AssignEntity( SDAI_Application_instance * /*i*/ ) { return (TypeDescriptor *)0; }
|
||||
SDAI_Select* NewSelect(){ return (SDAI_Select *)0; }
|
||||
BASE_TYPE ValueType() const { return sdaiBOOLEAN; }
|
||||
void STEPwrite_content( std::ostream& /*o*/, const char* /*a*/ ) const {}
|
||||
Severity StrToVal_content( const char* /*a*/, InstMgrBase* /*m*/ ) { return SEVERITY_NULL; }
|
||||
Severity STEPread_content(std::istream& i, InstMgrBase* m, const char* c, int n, const char* d) {
|
||||
(void)i; (void)m; (void)c; (void)n; (void)d; return SEVERITY_NULL;
|
||||
}
|
||||
};
|
||||
|
||||
/// \return true for success
|
||||
bool testOperatorEq() {
|
||||
Schema * sch = 0;
|
||||
SelectTypeDescriptor s( 5, "a", sdaiBOOLEAN, sch, "b" );
|
||||
TypeDescriptor t;
|
||||
BASE_TYPE b = sdaiAGGR;
|
||||
SDAI_String v( "test string" );
|
||||
ErrorDescriptor e( SEVERITY_MAX, 99 );
|
||||
TestSdaiSelect s1( &s, &t, b, v, e );
|
||||
TestSdaiSelect s2;
|
||||
|
||||
s2 = s1;
|
||||
if( s2.compare( &s, &t, b, &v, &e ) ) {
|
||||
return true;
|
||||
} else {
|
||||
cerr << __FILE__ << ":" << __LINE__ << " - error: test for SDAI_Select::operator= failed" << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int main( int /*argc*/, char ** /*argv*/ ) {
|
||||
bool pass = true;
|
||||
pass &= testOperatorEq();
|
||||
//TODO test other operators
|
||||
cerr << "FIXME this test is incomplete!" << endl;
|
||||
if( pass ) {
|
||||
exit( EXIT_SUCCESS );
|
||||
} else {
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
+33
-25
@@ -1,35 +1,43 @@
|
||||
|
||||
set(LIBSTEPUTILS_SRCS
|
||||
Str.cc
|
||||
dirobj.cc
|
||||
gennode.cc
|
||||
gennodelist.cc
|
||||
gennodearray.cc
|
||||
sc_hash.cc
|
||||
errordesc.cc
|
||||
)
|
||||
Str.cc
|
||||
dirobj.cc
|
||||
gennode.cc
|
||||
gennodelist.cc
|
||||
gennodearray.cc
|
||||
sc_hash.cc
|
||||
errordesc.cc
|
||||
)
|
||||
|
||||
SET(SC_CLUTILS_HDRS
|
||||
dirobj.h
|
||||
errordesc.h
|
||||
gennodearray.h
|
||||
gennode.h
|
||||
gennodelist.h
|
||||
sc_hash.h
|
||||
Str.h
|
||||
)
|
||||
set(SC_CLUTILS_HDRS
|
||||
dirobj.h
|
||||
errordesc.h
|
||||
gennodearray.h
|
||||
gennode.h
|
||||
gennodelist.h
|
||||
sc_hash.h
|
||||
Str.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_BINARY_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_BINARY_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
SC_ADDLIB(steputils "${LIBSTEPUTILS_SRCS}" "base")
|
||||
|
||||
IF(MINGW OR MSVC OR BORLAND)
|
||||
TARGET_LINK_LIBRARIES(steputils shlwapi.lib)
|
||||
ENDIF()
|
||||
if(MINGW OR MSVC OR BORLAND)
|
||||
target_link_libraries(steputils shlwapi.lib)
|
||||
endif()
|
||||
|
||||
install(FILES ${SC_CLUTILS_HDRS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clutils)
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/stepcode/clutils)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user